[{"id":19590,"web_url":"https://patchwork.libcamera.org/comment/19590/","msgid":"<20210910004947.GD4137293@pyrite.rasen.tech>","date":"2021-09-10T00:49:47","subject":"Re: [libcamera-devel] [PATCH v3] android: jpeg: Split and pass the\n\tthumbnail planes to encoder","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Umang,\n\nOn Thu, Sep 09, 2021 at 09:18:57PM +0530, Umang Jain wrote:\n> After multi-planar support was introduced for jpeg encoding as well,\n> EncoderLibJpeg::encode() expects a vector of planes as the source of\n> framebuffer to be encoded. Currently, we are passing a contiguous buffer\n> which is treated as only one plane (instead of two, as thumbnail is NV12).\n> \n> Hence, split the thumbnail data into respective planes according to NV12.\n> This fixes a crash in encoding of thumbnails.\n> \n> Fixes: 894ca69f6043(\"android: jpeg: Support multi-planar buffers\")\n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n> Changes 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(-)\n> \n> diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\n> index 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> -- \n> 2.31.0\n>","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 C584BBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Sep 2021 00:49:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3A56F6916E;\n\tFri, 10 Sep 2021 02:49:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 229DC60503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Sep 2021 02:49:55 +0200 (CEST)","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 B92BF883;\n\tFri, 10 Sep 2021 02:49:53 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VffxB1qv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631234994;\n\tbh=tpOj+izzBFByM8SJ/F/Gk8P30tjLqmUfGvB/7uAsAw8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VffxB1qvSDfK+YE8W9tNvsBD/OUWTitbI6u0y8/f1G+/jVk38JWiq6JiKgXpRjARh\n\t7my4G3x+CJk5yWCdLQhisFxwGqODzTuWHnvOcPUvebgQeFYUCl7W154tBcIgzWQO8T\n\ts75R0VXxWgWmbYgwLmpLzTUkqcOo9Xg/Nq9ggCqY=","Date":"Fri, 10 Sep 2021 09:49:47 +0900","From":"paul.elder@ideasonboard.com","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<20210910004947.GD4137293@pyrite.rasen.tech>","References":"<20210909154857.299746-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210909154857.299746-1-umang.jain@ideasonboard.com>","Subject":"Re: [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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19591,"web_url":"https://patchwork.libcamera.org/comment/19591/","msgid":"<YTrZ2mqB6TXR8hwG@pendragon.ideasonboard.com>","date":"2021-09-10T04:06:50","subject":"Re: [libcamera-devel] [PATCH v3] android: jpeg: Split and pass the\n\tthumbnail planes to encoder","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nOn Thu, Sep 09, 2021 at 09:18:57PM +0530, Umang Jain wrote:\n> After multi-planar support was introduced for jpeg encoding as well,\n> EncoderLibJpeg::encode() expects a vector of planes as the source of\n> framebuffer to be encoded. Currently, we are passing a contiguous buffer\n> which is treated as only one plane (instead of two, as thumbnail is NV12).\n> \n> Hence, split the thumbnail data into respective planes according to NV12.\n> This fixes a crash in encoding of thumbnails.\n> \n> Fixes: 894ca69f6043(\"android: jpeg: Support multi-planar buffers\")\n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n> Changes 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(-)\n> \n> diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\n> index 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\nThese should be yPlaneSize and uvPlaneSize.\n\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>","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 6A9C7BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Sep 2021 04:07:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9FE636916E;\n\tFri, 10 Sep 2021 06:07:14 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BB0C960249\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Sep 2021 06:07:12 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 36EE3883;\n\tFri, 10 Sep 2021 06:07:12 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"jWN4HF46\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631246832;\n\tbh=DIS50jZRk6m0SK9jwtdBjTAHWbxyV8BBfhYELh9xNDU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=jWN4HF46Ol+Jid5lPWc9cu7/Saj+0AIUDraAIS5EdnBVcVKDiErhc0KDII6D0HNuA\n\tF3JTwOR2lLcf87nTyVrZb7nmEQLKcDhs+G1TO2gUKqaOy7cYU+I1txFx3IsztNkCtc\n\tCJnSNisWe7KGzsUhTFqX3d1y88xFLRIaA5krN9ZM=","Date":"Fri, 10 Sep 2021 07:06:50 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YTrZ2mqB6TXR8hwG@pendragon.ideasonboard.com>","References":"<20210909154857.299746-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210909154857.299746-1-umang.jain@ideasonboard.com>","Subject":"Re: [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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19592,"web_url":"https://patchwork.libcamera.org/comment/19592/","msgid":"<843c8f9a-351e-bbb8-1d95-80f69436cf91@ideasonboard.com>","date":"2021-09-10T04:15:46","subject":"Re: [libcamera-devel] [PATCH v3] android: jpeg: Split and pass the\n\tthumbnail planes to encoder","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 9/10/21 9:36 AM, Laurent Pinchart wrote:\n> Hi Umang,\n>\n> On Thu, Sep 09, 2021 at 09:18:57PM +0530, Umang Jain wrote:\n>> After multi-planar support was introduced for jpeg encoding as well,\n>> EncoderLibJpeg::encode() expects a vector of planes as the source of\n>> framebuffer to be encoded. Currently, we are passing a contiguous buffer\n>> which is treated as only one plane (instead of two, as thumbnail is NV12).\n>>\n>> Hence, split the thumbnail data into respective planes according to NV12.\n>> This fixes a crash in encoding of thumbnails.\n>>\n>> Fixes: 894ca69f6043(\"android: jpeg: Support multi-planar buffers\")\n>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n>> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n>> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n>> ---\n>> Changes 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(-)\n>>\n>> diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\n>> index 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> These should be yPlaneSize and uvPlaneSize.\n\n\noh yeah :-/\n\nI had pushed the patch last night though. Fixup on top?\n\n>\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>>","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 63A02BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Sep 2021 04:15:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C6F6A6916E;\n\tFri, 10 Sep 2021 06:15:52 +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 73C6560249\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Sep 2021 06:15:51 +0200 (CEST)","from [192.168.1.104] (unknown [103.251.226.149])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9000B883;\n\tFri, 10 Sep 2021 06:15:50 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"uZ7+AqYd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631247351;\n\tbh=CyoMpg7bhSjIXL9WkaaM9nva/pJw/rhtIB2gjN3GCpU=;\n\th=Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=uZ7+AqYdlNIxBeg9kmqsNWXtQOENRd6nAxrlnGI9DxTgm7EaYQmUuy2EXhOEimRZn\n\t4Qx4Wv7BtouFuaZVR2s3oxoD8cqKQGVG1VfgL+O40apQ/KT36TrY0tfKSCTU/ZY67/\n\t/f/rsa/y5JP9VYUX3O6/N+9uSRLogksPvQvs6c6M=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20210909154857.299746-1-umang.jain@ideasonboard.com>\n\t<YTrZ2mqB6TXR8hwG@pendragon.ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<843c8f9a-351e-bbb8-1d95-80f69436cf91@ideasonboard.com>","Date":"Fri, 10 Sep 2021 09:45:46 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<YTrZ2mqB6TXR8hwG@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19593,"web_url":"https://patchwork.libcamera.org/comment/19593/","msgid":"<YTrduyPXxeJ8PMnD@pendragon.ideasonboard.com>","date":"2021-09-10T04:23:23","subject":"Re: [libcamera-devel] [PATCH v3] android: jpeg: Split and pass the\n\tthumbnail planes to encoder","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nOn Fri, Sep 10, 2021 at 09:45:46AM +0530, Umang Jain wrote:\n> On 9/10/21 9:36 AM, Laurent Pinchart wrote:\n> > On Thu, Sep 09, 2021 at 09:18:57PM +0530, Umang Jain wrote:\n> >> After multi-planar support was introduced for jpeg encoding as well,\n> >> EncoderLibJpeg::encode() expects a vector of planes as the source of\n> >> framebuffer to be encoded. Currently, we are passing a contiguous buffer\n> >> which is treated as only one plane (instead of two, as thumbnail is NV12).\n> >>\n> >> Hence, split the thumbnail data into respective planes according to NV12.\n> >> This fixes a crash in encoding of thumbnails.\n> >>\n> >> Fixes: 894ca69f6043(\"android: jpeg: Support multi-planar buffers\")\n> >> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> >> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> >> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> >> ---\n> >> Changes 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(-)\n> >>\n> >> diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\n> >> index 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> > These should be yPlaneSize and uvPlaneSize.\n> \n> oh yeah :-/\n> \n> I had pushed the patch last night though. Fixup on top?\n\nIf you don't mind :-)\n\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> >>","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 4BE4EBDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Sep 2021 04:23:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CBDA66916E;\n\tFri, 10 Sep 2021 06:23:47 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 59EDD60249\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Sep 2021 06:23:46 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D203C883;\n\tFri, 10 Sep 2021 06:23:45 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"YusaORJM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631247826;\n\tbh=n/+kDi4MuVIQd4/wBdyLQIa8ToChq9QXCjw1RBsUYL4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=YusaORJMsjv0BUgrNOHg6OZ4E2bsIL2UV3ltkWMgQGLosPmQUpetfqqky6EfbvdDd\n\tG9VTcBKGKG44b7GMVgxcdnEC1T+/W8f2+4RrUGhGvaMGu3PSrWyPWu3A1Zfstdmqhs\n\tIrPj/Q+vlRVG/ecI3ui9cigocC/zPpgHPOMsJaa0=","Date":"Fri, 10 Sep 2021 07:23:23 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YTrduyPXxeJ8PMnD@pendragon.ideasonboard.com>","References":"<20210909154857.299746-1-umang.jain@ideasonboard.com>\n\t<YTrZ2mqB6TXR8hwG@pendragon.ideasonboard.com>\n\t<843c8f9a-351e-bbb8-1d95-80f69436cf91@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<843c8f9a-351e-bbb8-1d95-80f69436cf91@ideasonboard.com>","Subject":"Re: [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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]