{"id":11147,"url":"https://patchwork.libcamera.org/api/patches/11147/?format=json","web_url":"https://patchwork.libcamera.org/patch/11147/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210204150820.38427-1-jacopo@jmondi.org>","date":"2021-02-04T15:08:20","name":"[libcamera-devel,v2] android: camera_device: Generate JPEG thumbnail sizes","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"d494068d3a55d70f3a91ae762f0fd6bccc185bcb","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11147/mbox/","series":[{"id":1653,"url":"https://patchwork.libcamera.org/api/series/1653/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1653","date":"2021-02-04T15:08:20","name":"[libcamera-devel,v2] android: camera_device: Generate JPEG thumbnail sizes","version":2,"mbox":"https://patchwork.libcamera.org/series/1653/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11147/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11147/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 34EDBBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Feb 2021 15:08:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A5A5A61433;\n\tThu,  4 Feb 2021 16:08:05 +0100 (CET)","from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 762146141A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Feb 2021 16:08:04 +0100 (CET)","from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 0096A100005;\n\tThu,  4 Feb 2021 15:08:03 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  4 Feb 2021 16:08:20 +0100","Message-Id":"<20210204150820.38427-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.30.0","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2] android: camera_device: Generate JPEG\n\tthumbnail sizes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The list of the available thumbnail sizes is generated from the\nlist of available JPEG resolution, one for each aspect ratio.\n\nThis change fixes the CTS test\nandroid.hardware.cts.CameraTest#testJpegThumbnailSize\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 39 ++++++++++++++++++++++++++++++-----\n 1 file changed, 34 insertions(+), 5 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex df5e295656d7..cdb28f1f2d28 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -871,12 +871,41 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \t\t\t\t  &availableControlModes, 1);\n \n \t/* JPEG static metadata. */\n-\tstd::vector<int32_t> availableThumbnailSizes = {\n-\t\t0, 0,\n-\t};\n+\n+\t/*\n+\t * Create the list of supported thumbnail sizes by inspecting the\n+\t * available JPEG resolutions collected in streamConfigurations_ and\n+\t * generate one entry for each aspect ratio.\n+\t *\n+\t * The JPEG thumbnailer can freely scale, so pick an arbitrary\n+\t * (160, 160) size as designated thumbnail size.\n+\t */\n+\tconstexpr Size maxJpegThumbnail(160, 160);\n+\tstd::vector<Size> thumbnailSizes;\n+\tthumbnailSizes.push_back({ 0, 0 });\n+\tfor (const auto &entry : streamConfigurations_) {\n+\t\tif (entry.androidFormat != HAL_PIXEL_FORMAT_BLOB)\n+\t\t\tcontinue;\n+\n+\t\tSize thumbnailSize = maxJpegThumbnail\n+\t\t\t\t     .boundedToAspectRatio({ entry.resolution.width,\n+\t\t\t\t\t\t\t     entry.resolution.height });\n+\t\tthumbnailSizes.push_back(thumbnailSize);\n+\t}\n+\n+\tstd::sort(thumbnailSizes.begin(), thumbnailSizes.end());\n+\tauto last = std::unique(thumbnailSizes.begin(), thumbnailSizes.end());\n+\tthumbnailSizes.erase(last, thumbnailSizes.end());\n+\n+\t/* Transform sizes in to a list of integers that can be consumed. */\n+\tstd::vector<int32_t> thumbnailEntries;\n+\tthumbnailEntries.reserve(thumbnailSizes.size() * 2);\n+\tfor (const auto &size : thumbnailSizes) {\n+\t\tthumbnailEntries.push_back(size.width);\n+\t\tthumbnailEntries.push_back(size.height);\n+\t}\n \tstaticMetadata_->addEntry(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,\n-\t\t\t\t  availableThumbnailSizes.data(),\n-\t\t\t\t  availableThumbnailSizes.size());\n+\t\t\t\t  thumbnailEntries.data(), thumbnailEntries.size());\n \n \t/*\n \t * \\todo Calculate the maximum JPEG buffer size by asking the encoder\n","prefixes":["libcamera-devel","v2"]}