{"id":11145,"url":"https://patchwork.libcamera.org/api/patches/11145/?format=json","web_url":"https://patchwork.libcamera.org/patch/11145/","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":"<20210204143503.33498-1-jacopo@jmondi.org>","date":"2021-02-04T14:35:03","name":"[libcamera-devel] android: camera_device: Generate JPEG thumbnail sizes","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"247aff3791b555ffb750935df39e9afb4215a673","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/11145/mbox/","series":[{"id":1651,"url":"https://patchwork.libcamera.org/api/series/1651/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1651","date":"2021-02-04T14:35:03","name":"[libcamera-devel] android: camera_device: Generate JPEG thumbnail sizes","version":1,"mbox":"https://patchwork.libcamera.org/series/1651/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11145/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11145/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 151A1BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Feb 2021 14:34:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A44876141A;\n\tThu,  4 Feb 2021 15:34:47 +0100 (CET)","from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 98B5A60305\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Feb 2021 15:34:46 +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 relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 44A0E4000C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Feb 2021 14:34:46 +0000 (UTC)"],"X-Originating-IP":"93.61.96.190","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  4 Feb 2021 15:35:03 +0100","Message-Id":"<20210204143503.33498-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.30.0","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH] 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\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..0b699c957990 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 tumbnail 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, 120) size as designated thumbnail size.\n+\t */\n+\tconstexpr Size maxJpegThumbnail(160, 120);\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 it in 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"]}