{"id":13797,"url":"https://patchwork.libcamera.org/api/patches/13797/?format=json","web_url":"https://patchwork.libcamera.org/patch/13797/","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":"<20210909154857.299746-1-umang.jain@ideasonboard.com>","date":"2021-09-09T15:48:57","name":"[libcamera-devel,v3] android: jpeg: Split and pass the thumbnail planes to encoder","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"a34f3255460e3523cfc4f266ba0945311ee5067a","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/13797/mbox/","series":[{"id":2512,"url":"https://patchwork.libcamera.org/api/series/2512/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2512","date":"2021-09-09T15:48:57","name":"[libcamera-devel,v3] android: jpeg: Split and pass the thumbnail planes to encoder","version":3,"mbox":"https://patchwork.libcamera.org/series/2512/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13797/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13797/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 900C1BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Sep 2021 15:49:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1B4EC6916E;\n\tThu,  9 Sep 2021 17:49:06 +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 707286916B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Sep 2021 17:49:05 +0200 (CEST)","from perceval.ideasonboard.com (unknown [103.251.226.149])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 06C47883;\n\tThu,  9 Sep 2021 17:49:03 +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=\"sOuEuMgb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631202545;\n\tbh=IYNwI6wr3BwqkY0qGL8P70AfXu+6MlsevgJF6M9LA8E=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=sOuEuMgbsuc9WJPO4VxHJzajhnyfUa4bw+jjBmjx41xE9si25+pI6aDWPm/7jRwML\n\tfEe5kSGMsMexMEvp/cQVowYagpFnYeAaHv4YbufveRV1oGkR4Zv+4SoUbleFqUIxiW\n\tBPnt91gaFlh6Y8aKLasQDRC8FIwe7nnoN4jZR0vk=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  9 Sep 2021 21:18:57 +0530","Message-Id":"<20210909154857.299746-1-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3] android: jpeg: Split and pass the\n\tthumbnail planes to encoder","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":"After multi-planar support was introduced for jpeg encoding as well,\nEncoderLibJpeg::encode() expects a vector of planes as the source of\nframebuffer to be encoded. Currently, we are passing a contiguous buffer\nwhich is treated as only one plane (instead of two, as thumbnail is NV12).\n\nHence, split the thumbnail data into respective planes according to NV12.\nThis fixes a crash in encoding of thumbnails.\n\nFixes: 894ca69f6043(\"android: jpeg: Support multi-planar buffers\")\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges in v3:\n- Use planeSize() helpers recently introduced for readability.\n---\n src/android/jpeg/post_processor_jpeg.cpp | 17 ++++++++++++++++-\n 1 file changed, 16 insertions(+), 1 deletion(-)","diff":"diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex 68d74842..ef2d98cc 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -72,7 +72,22 @@ 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\t/*\n+\t\t * Split planes manually as the encoder expects a vector of\n+\t\t * planes.\n+\t\t *\n+\t\t * \\todo Pass a vector of planes directly to\n+\t\t * Thumbnailer::createThumbnailer above and remove the manual\n+\t\t * planes split from here.\n+\t\t */\n+\t\tstd::vector<Span<uint8_t>> thumbnailPlanes;\n+\t\tconst PixelFormatInfo &formatNV12 = PixelFormatInfo::info(formats::NV12);\n+\t\tsize_t YPlaneSize = formatNV12.planeSize(targetSize, 0);\n+\t\tsize_t UVPlaneSize = formatNV12.planeSize(targetSize, 1);\n+\t\tthumbnailPlanes.push_back({ rawThumbnail.data(), YPlaneSize });\n+\t\tthumbnailPlanes.push_back({ rawThumbnail.data() + YPlaneSize, UVPlaneSize });\n+\n+\t\tint jpeg_size = thumbnailEncoder_.encode(thumbnailPlanes,\n \t\t\t\t\t\t\t *thumbnail, {}, quality);\n \t\tthumbnail->resize(jpeg_size);\n \n","prefixes":["libcamera-devel","v3"]}