{"id":13767,"url":"https://patchwork.libcamera.org/api/patches/13767/?format=json","web_url":"https://patchwork.libcamera.org/patch/13767/","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":"<20210908094949.111140-1-umang.jain@ideasonboard.com>","date":"2021-09-08T09:49:49","name":"[libcamera-devel,v2] android: jpeg: Split and pass the thumbnail planes to encoder","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c51405e4ec9719745e6f92ababa31f3bcb21d750","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/13767/mbox/","series":[{"id":2498,"url":"https://patchwork.libcamera.org/api/series/2498/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2498","date":"2021-09-08T09:49:49","name":"[libcamera-devel,v2] android: jpeg: Split and pass the thumbnail planes to encoder","version":2,"mbox":"https://patchwork.libcamera.org/series/2498/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13767/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13767/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 6A73FBDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Sep 2021 09:50:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ED7D760250;\n\tWed,  8 Sep 2021 11:50: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 8D4106024D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Sep 2021 11:50:05 +0200 (CEST)","from perceval.ideasonboard.com (unknown [103.251.226.149])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 835E8993;\n\tWed,  8 Sep 2021 11:50:04 +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=\"vUzPOoHu\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631094605;\n\tbh=kK3M4LSliyIJmB4VszDM4Ghu31VvnQvxCLt2AV3Zf68=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=vUzPOoHugUqb0j87ln0euLLzi6tAupGKRgE+bhargKICHfkrgd3ir5zbWKC2R32Y/\n\tR4mmah7flUBGtQcvadqNw4M2+9V+QHXyn/bPmyA7SMsR3R6U8cXd1fhTPr3GWb/AfJ\n\tChlWJbM2IEskhb6G4wNawwFcKSwJNXc6RlCykqwU=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  8 Sep 2021 15:19:49 +0530","Message-Id":"<20210908094949.111140-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 v2] 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>\n---\nChanges in v2: \n- Fix basic split logic error.\n- Add Jacopo's suggestion as a \\todo since it's a superior method to fix\n  this.\n---\n src/android/jpeg/post_processor_jpeg.cpp | 18 ++++++++++++++----\n 1 file changed, 14 insertions(+), 4 deletions(-)","diff":"diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex 68d74842..1bf507a4 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -66,13 +66,23 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,\n \tint ret = thumbnailEncoder_.configure(thCfg);\n \n \tif (!rawThumbnail.empty() && !ret) {\n+\t\tthumbnail->resize(rawThumbnail.size());\n+\n \t\t/*\n-\t\t * \\todo Avoid value-initialization of all elements of the\n-\t\t * vector.\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\tthumbnail->resize(rawThumbnail.size());\n+\t\tstd::vector<Span<uint8_t>> thumbnailPlanes;\n+\t\tunsigned int thumbnailSize = targetSize.height * targetSize.width;\n+\t\tthumbnailPlanes.push_back({ rawThumbnail.data(), thumbnailSize });\n+\t\tthumbnailPlanes.push_back({ rawThumbnail.data() + thumbnailSize,\n+\t\t\t\t\t    thumbnailSize / 2 });\n \n-\t\tint jpeg_size = thumbnailEncoder_.encode({ rawThumbnail },\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","v2"]}