Patch Detail
Show a patch.
GET /api/1.1/patches/13728/?format=api
{ "id": 13728, "url": "https://patchwork.libcamera.org/api/1.1/patches/13728/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13728/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20210907154606.11350-1-laurent.pinchart@ideasonboard.com>", "date": "2021-09-07T15:46:06", "name": "[libcamera-devel,v3.1,20/30] android: jpeg: Support multi-planar buffers", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "d36ffc8fd72649c888b9d073a8d999a806b8a69c", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13728/mbox/", "series": [ { "id": 2491, "url": "https://patchwork.libcamera.org/api/1.1/series/2491/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2491", "date": "2021-09-07T15:44:41", "name": null, "version": 1, "mbox": "https://patchwork.libcamera.org/series/2491/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13728/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13728/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 E15ADBE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 7 Sep 2021 15:46:29 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B15A16916C;\n\tTue, 7 Sep 2021 17:46:29 +0200 (CEST)", "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 8E69460251\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 7 Sep 2021 17:46:28 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3013924F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 7 Sep 2021 17:46:28 +0200 (CEST)" ], "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=\"aGrOsGj6\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631029588;\n\tbh=HRSUvzVUzrrhgJyZd4eTtvJJ2KJab/rLeRs0TwHwUf8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=aGrOsGj6PwlpByGwiBOLeuR9QCBXup/ik7dIzoAloUL8cZS3PCVRX9pm3arn0qRFe\n\tEQKEO7saP8Pwgl+p5eromh7P/xCh1SObfaCnARaG5oC7Jf38VnE5obfHjennc42nVs\n\tAmwpaC8ioMOsCSQFNZOBOPhBLR0sB7Y7+kYMZS8g=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 7 Sep 2021 18:46:06 +0300", "Message-Id": "<20210907154606.11350-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.32.0", "In-Reply-To": "<20210906225636.14683-20-laurent.pinchart@ideasonboard.com>", "References": "<20210906225636.14683-20-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3.1 20/30] android: jpeg: Support\n\tmulti-planar buffers", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The JPEG post-processor uses MappedFrameBuffer to access pixel data, but\nonly uses data from the first plane. Pass the vector of planes to the\nencode() function to correctly handle multi-planar formats (currently\nlimited to NV12).\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nAcked-by: Umang Jain <umang.jain@ideasonboard.com>\nTested-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nChanges since v3:\n\n- Add assertions to check the number of planes\n---\n src/android/jpeg/encoder_libjpeg.cpp | 19 +++++++++++--------\n src/android/jpeg/encoder_libjpeg.h | 8 +++++---\n src/android/jpeg/post_processor_jpeg.cpp | 2 +-\n src/android/jpeg/thumbnailer.cpp | 5 +++--\n 4 files changed, 20 insertions(+), 14 deletions(-)", "diff": "diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp\nindex 807a0949a8fc..21a3b33dd92c 100644\n--- a/src/android/jpeg/encoder_libjpeg.cpp\n+++ b/src/android/jpeg/encoder_libjpeg.cpp\n@@ -103,9 +103,9 @@ int EncoderLibJpeg::configure(const StreamConfiguration &cfg)\n \treturn 0;\n }\n \n-void EncoderLibJpeg::compressRGB(Span<const uint8_t> frame)\n+void EncoderLibJpeg::compressRGB(const std::vector<Span<uint8_t>> &planes)\n {\n-\tunsigned char *src = const_cast<unsigned char *>(frame.data());\n+\tunsigned char *src = const_cast<unsigned char *>(planes[0].data());\n \t/* \\todo Stride information should come from buffer configuration. */\n \tunsigned int stride = pixelFormatInfo_->stride(compress_.image_width, 0);\n \n@@ -121,7 +121,7 @@ void EncoderLibJpeg::compressRGB(Span<const uint8_t> frame)\n * Compress the incoming buffer from a supported NV format.\n * This naively unpacks the semi-planar NV12 to a YUV888 format for libjpeg.\n */\n-void EncoderLibJpeg::compressNV(Span<const uint8_t> frame)\n+void EncoderLibJpeg::compressNV(const std::vector<Span<uint8_t>> &planes)\n {\n \tuint8_t tmprowbuf[compress_.image_width * 3];\n \n@@ -143,8 +143,8 @@ void EncoderLibJpeg::compressNV(Span<const uint8_t> frame)\n \tunsigned int cb_pos = nvSwap_ ? 1 : 0;\n \tunsigned int cr_pos = nvSwap_ ? 0 : 1;\n \n-\tconst unsigned char *src = frame.data();\n-\tconst unsigned char *src_c = src + y_stride * compress_.image_height;\n+\tconst unsigned char *src = planes[0].data();\n+\tconst unsigned char *src_c = planes[1].data();\n \n \tJSAMPROW row_pointer[1];\n \trow_pointer[0] = &tmprowbuf[0];\n@@ -188,11 +188,12 @@ int EncoderLibJpeg::encode(const FrameBuffer &source, Span<uint8_t> dest,\n \t\treturn frame.error();\n \t}\n \n-\treturn encode(frame.planes()[0], dest, exifData, quality);\n+\treturn encode(frame.planes(), dest, exifData, quality);\n }\n \n-int EncoderLibJpeg::encode(Span<const uint8_t> src, Span<uint8_t> dest,\n-\t\t\t Span<const uint8_t> exifData, unsigned int quality)\n+int EncoderLibJpeg::encode(const std::vector<Span<uint8_t>> &src,\n+\t\t\t Span<uint8_t> dest, Span<const uint8_t> exifData,\n+\t\t\t unsigned int quality)\n {\n \tunsigned char *destination = dest.data();\n \tunsigned long size = dest.size();\n@@ -220,6 +221,8 @@ int EncoderLibJpeg::encode(Span<const uint8_t> src, Span<uint8_t> dest,\n \tLOG(JPEG, Debug) << \"JPEG Encode Starting:\" << compress_.image_width\n \t\t\t << \"x\" << compress_.image_height;\n \n+\tASSERT(src.size() == pixelFormatInfo_->numPlanes());\n+\n \tif (nv_)\n \t\tcompressNV(src);\n \telse\ndiff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h\nindex 61fbd1a69278..45ffbd7fae5d 100644\n--- a/src/android/jpeg/encoder_libjpeg.h\n+++ b/src/android/jpeg/encoder_libjpeg.h\n@@ -9,6 +9,8 @@\n \n #include \"encoder.h\"\n \n+#include <vector>\n+\n #include \"libcamera/internal/formats.h\"\n \n #include <jpeglib.h>\n@@ -24,14 +26,14 @@ public:\n \t\t libcamera::Span<uint8_t> destination,\n \t\t libcamera::Span<const uint8_t> exifData,\n \t\t unsigned int quality) override;\n-\tint encode(libcamera::Span<const uint8_t> source,\n+\tint encode(const std::vector<libcamera::Span<uint8_t>> &planes,\n \t\t libcamera::Span<uint8_t> destination,\n \t\t libcamera::Span<const uint8_t> exifData,\n \t\t unsigned int quality);\n \n private:\n-\tvoid compressRGB(libcamera::Span<const uint8_t> frame);\n-\tvoid compressNV(libcamera::Span<const uint8_t> frame);\n+\tvoid compressRGB(const std::vector<libcamera::Span<uint8_t>> &planes);\n+\tvoid compressNV(const std::vector<libcamera::Span<uint8_t>> &planes);\n \n \tstruct jpeg_compress_struct compress_;\n \tstruct jpeg_error_mgr jerr_;\ndiff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex 3160a784419c..68d74842925d 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -72,7 +72,7 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,\n \t\t */\n \t\tthumbnail->resize(rawThumbnail.size());\n \n-\t\tint jpeg_size = thumbnailEncoder_.encode(rawThumbnail,\n+\t\tint jpeg_size = thumbnailEncoder_.encode({ rawThumbnail },\n \t\t\t\t\t\t\t *thumbnail, {}, quality);\n \t\tthumbnail->resize(jpeg_size);\n \ndiff --git a/src/android/jpeg/thumbnailer.cpp b/src/android/jpeg/thumbnailer.cpp\nindex 043c7b33f06a..1fab80724f3c 100644\n--- a/src/android/jpeg/thumbnailer.cpp\n+++ b/src/android/jpeg/thumbnailer.cpp\n@@ -59,11 +59,12 @@ void Thumbnailer::createThumbnail(const FrameBuffer &source,\n \tconst unsigned int tw = targetSize.width;\n \tconst unsigned int th = targetSize.height;\n \n+\tASSERT(frame.planes().size() == 2);\n \tASSERT(tw % 2 == 0 && th % 2 == 0);\n \n \t/* Image scaling block implementing nearest-neighbour algorithm. */\n-\tunsigned char *src = static_cast<unsigned char *>(frame.planes()[0].data());\n-\tunsigned char *srcC = src + sh * sw;\n+\tunsigned char *src = frame.planes()[0].data();\n+\tunsigned char *srcC = frame.planes()[1].data();\n \tunsigned char *srcCb, *srcCr;\n \tunsigned char *dstY, *srcY;\n \n", "prefixes": [ "libcamera-devel", "v3.1", "20/30" ] }