Patch Detail
Show a patch.
GET /api/patches/10971/?format=api
{ "id": 10971, "url": "https://patchwork.libcamera.org/api/patches/10971/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10971/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210123051704.188117-7-paul.elder@ideasonboard.com>", "date": "2021-01-23T05:17:02", "name": "[libcamera-devel,v3,6/8] android: jpeg: Configure thumbnailer based on request metadata", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9792560a6a669401d2a056c1178ead0fd7622522", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": { "id": 17, "url": "https://patchwork.libcamera.org/api/users/17/?format=api", "username": "epaul", "first_name": "Paul", "last_name": "Elder", "email": "paul.elder@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/10971/mbox/", "series": [ { "id": 1601, "url": "https://patchwork.libcamera.org/api/series/1601/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1601", "date": "2021-01-23T05:16:56", "name": "Fill in android result metadata and EXIF tabs", "version": 3, "mbox": "https://patchwork.libcamera.org/series/1601/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10971/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10971/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 55176C0F2B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 23 Jan 2021 05:17:29 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1F6F968277;\n\tSat, 23 Jan 2021 06:17:29 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 89AF66030D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Jan 2021 06:17:27 +0100 (CET)", "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 17123813;\n\tSat, 23 Jan 2021 06:17:25 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"lmlnKElu\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1611379047;\n\tbh=q9Uu+V7CSqF7jZM5ayXtIdkotoiQdam0sPajR8Q9J74=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=lmlnKEluCNdi9lsCLplQgGKFrrpN1adom8aN+E5VJCgeIxNZeoiflngoUcecevdbr\n\tjsnTXZ0drxIeXwzdQXMlLIpN76WVL+6uKVOniBUmW+Wf9mFzZX/Z4WMBOuTrodtp+1\n\twnX1fV59a0oCk4J/dSbJQN1e689ONrNaBYSzk+Ks=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 23 Jan 2021 14:17:02 +0900", "Message-Id": "<20210123051704.188117-7-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20210123051704.188117-1-paul.elder@ideasonboard.com>", "References": "<20210123051704.188117-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v3 6/8] android: jpeg: Configure\n\tthumbnailer based on request metadata", "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": "Configure the thumbnailer based on the thumbnail parameters given by the\nandroid request metadata. Only the thumbnail encoder needs to be\nconfigured, and since it is only used at post-processing time, move the\nconfiguration out of the post-processor constructor and into the\nprocessing step.\n\nAlso set the following android result metadata tags:\n- ANDROID_JPEG_THUMBNAIL_SIZE\n- ANDROID_JPEG_THUMBNAIL_QUALITY\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nNew in v3\n- split from \"android: Set result metadata and EXIF fields based on\n request\"\n---\n src/android/jpeg/post_processor_jpeg.cpp | 40 +++++++++++++++++-------\n src/android/jpeg/post_processor_jpeg.h | 1 +\n src/android/jpeg/thumbnailer.cpp | 25 ++-------------\n src/android/jpeg/thumbnailer.h | 4 +--\n 4 files changed, 34 insertions(+), 36 deletions(-)", "diff": "diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex b325a06a..e5e42d39 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -41,12 +41,6 @@ int PostProcessorJpeg::configure(const StreamConfiguration &inCfg,\n \tstreamSize_ = outCfg.size;\n \n \tthumbnailer_.configure(inCfg.size, inCfg.pixelFormat);\n-\tStreamConfiguration thCfg = inCfg;\n-\tthCfg.size = thumbnailer_.size();\n-\tif (thumbnailEncoder_.configure(thCfg) != 0) {\n-\t\tLOG(JPEG, Error) << \"Failed to configure thumbnail encoder\";\n-\t\treturn -EINVAL;\n-\t}\n \n \tencoder_ = std::make_unique<EncoderLibJpeg>();\n \n@@ -54,14 +48,20 @@ int PostProcessorJpeg::configure(const StreamConfiguration &inCfg,\n }\n \n void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,\n+\t\t\t\t\t const Size &targetSize,\n \t\t\t\t\t std::vector<unsigned char> *thumbnail)\n {\n \t/* Stores the raw scaled-down thumbnail bytes. */\n \tstd::vector<unsigned char> rawThumbnail;\n \n-\tthumbnailer_.createThumbnail(source, &rawThumbnail);\n+\tthumbnailer_.createThumbnail(source, targetSize, &rawThumbnail);\n+\n+\tStreamConfiguration thCfg;\n+\tthCfg.size = targetSize;\n+\tthCfg.pixelFormat = thumbnailer_.pixelFormat();\n+\tint ret = thumbnailEncoder_.configure(thCfg);\n \n-\tif (!rawThumbnail.empty()) {\n+\tif (!rawThumbnail.empty() && !ret) {\n \t\t/*\n \t\t * \\todo Avoid value-initialization of all elements of the\n \t\t * vector.\n@@ -125,10 +125,26 @@ int PostProcessorJpeg::process(const FrameBuffer &source,\n \t\t\t\t\t entry.data.i64, 1);\n \t}\n \n-\tstd::vector<unsigned char> thumbnail;\n-\tgenerateThumbnail(source, &thumbnail);\n-\tif (!thumbnail.empty())\n-\t\texif.setThumbnail(thumbnail, Exif::Compression::JPEG);\n+\tret = requestMetadata.getEntry(ANDROID_JPEG_THUMBNAIL_SIZE, &entry);\n+\tif (ret) {\n+\t\tconst int32_t *data = entry.data.i32;\n+\t\tSize thumbnailSize = { static_cast<uint32_t>(data[0]),\n+\t\t\t\t static_cast<uint32_t>(data[1]) };\n+\n+\t\tif (thumbnailSize != Size(0, 0)) {\n+\t\t\tstd::vector<unsigned char> thumbnail;\n+\t\t\tgenerateThumbnail(source, thumbnailSize, &thumbnail);\n+\t\t\tif (!thumbnail.empty())\n+\t\t\t\texif.setThumbnail(thumbnail, Exif::Compression::JPEG);\n+\t\t}\n+\n+\t\tresultMetadata->addEntry(ANDROID_JPEG_THUMBNAIL_SIZE, data, 2);\n+\n+\t\t/* \\todo Use this quality as a parameter to the encoder */\n+\t\tret = requestMetadata.getEntry(ANDROID_JPEG_THUMBNAIL_QUALITY, &entry);\n+\t\tif (ret)\n+\t\t\tresultMetadata->addEntry(ANDROID_JPEG_THUMBNAIL_QUALITY, entry.data.u8, 1);\n+\t}\n \n \tret = requestMetadata.getEntry(ANDROID_JPEG_GPS_COORDINATES, &entry);\n \tif (ret) {\ndiff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h\nindex d721d1b9..660b79b4 100644\n--- a/src/android/jpeg/post_processor_jpeg.h\n+++ b/src/android/jpeg/post_processor_jpeg.h\n@@ -31,6 +31,7 @@ public:\n \n private:\n \tvoid generateThumbnail(const libcamera::FrameBuffer &source,\n+\t\t\t const libcamera::Size &targetSize,\n \t\t\t std::vector<unsigned char> *thumbnail);\n \n \tCameraDevice *const cameraDevice_;\ndiff --git a/src/android/jpeg/thumbnailer.cpp b/src/android/jpeg/thumbnailer.cpp\nindex 5374538a..f709d343 100644\n--- a/src/android/jpeg/thumbnailer.cpp\n+++ b/src/android/jpeg/thumbnailer.cpp\n@@ -32,30 +32,11 @@ void Thumbnailer::configure(const Size &sourceSize, PixelFormat pixelFormat)\n \t\treturn;\n \t}\n \n-\ttargetSize_ = computeThumbnailSize();\n-\n \tvalid_ = true;\n }\n \n-/*\n- * The Exif specification recommends the width of the thumbnail to be a\n- * multiple of 16 (section 4.8.1). Hence, compute the corresponding height\n- * keeping the aspect ratio same as of the source.\n- */\n-Size Thumbnailer::computeThumbnailSize() const\n-{\n-\tunsigned int targetHeight;\n-\tconstexpr unsigned int kTargetWidth = 160;\n-\n-\ttargetHeight = kTargetWidth * sourceSize_.height / sourceSize_.width;\n-\n-\tif (targetHeight & 1)\n-\t\ttargetHeight++;\n-\n-\treturn Size(kTargetWidth, targetHeight);\n-}\n-\n void Thumbnailer::createThumbnail(const FrameBuffer &source,\n+\t\t\t\t const Size &targetSize,\n \t\t\t\t std::vector<unsigned char> *destination)\n {\n \tMappedFrameBuffer frame(&source, PROT_READ);\n@@ -73,8 +54,8 @@ void Thumbnailer::createThumbnail(const FrameBuffer &source,\n \n \tconst unsigned int sw = sourceSize_.width;\n \tconst unsigned int sh = sourceSize_.height;\n-\tconst unsigned int tw = targetSize_.width;\n-\tconst unsigned int th = targetSize_.height;\n+\tconst unsigned int tw = targetSize.width;\n+\tconst unsigned int th = targetSize.height;\n \n \tASSERT(tw % 2 == 0 && th % 2 == 0);\n \ndiff --git a/src/android/jpeg/thumbnailer.h b/src/android/jpeg/thumbnailer.h\nindex 98f11833..bbd9832d 100644\n--- a/src/android/jpeg/thumbnailer.h\n+++ b/src/android/jpeg/thumbnailer.h\n@@ -20,15 +20,15 @@ public:\n \tvoid configure(const libcamera::Size &sourceSize,\n \t\t libcamera::PixelFormat pixelFormat);\n \tvoid createThumbnail(const libcamera::FrameBuffer &source,\n+\t\t\t const libcamera::Size &targetSize,\n \t\t\t std::vector<unsigned char> *dest);\n-\tconst libcamera::Size &size() const { return targetSize_; }\n+\tconst libcamera::PixelFormat &pixelFormat() const { return pixelFormat_; }\n \n private:\n \tlibcamera::Size computeThumbnailSize() const;\n \n \tlibcamera::PixelFormat pixelFormat_;\n \tlibcamera::Size sourceSize_;\n-\tlibcamera::Size targetSize_;\n \n \tbool valid_;\n };\n", "prefixes": [ "libcamera-devel", "v3", "6/8" ] }