From patchwork Wed Sep 8 06:23:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13757 X-Patchwork-Delegate: umang.jain@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9A7C4BDB1D for ; Wed, 8 Sep 2021 06:23:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CCD866916E; Wed, 8 Sep 2021 08:23:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RU8S8ZVR"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C33896024C for ; Wed, 8 Sep 2021 08:23:27 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [IPv6:2409:4041:2d98:b4ea:c869:beee:1b25:d212]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A5DE6DD; Wed, 8 Sep 2021 08:23:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1631082207; bh=QAt10spV6YKYvsasj6ZcZcZka7N96YvarHbTaqAyNnI=; h=From:To:Cc:Subject:Date:From; b=RU8S8ZVRQslXf99rF30M47sSh6pdYjCYUW9pfhSmm8HooHgWkmfJ6blphLGkp9ybF W89slgoP9ZhtvLRX6p4Vq3AkyQ/FT39D9nk0vK2NS30ARznsUbGSiuNV1D79LiGw8k N9b4TOuOCrhRf1jvazOE/TUDk9WVPx2Kv5y30bdA= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Sep 2021 11:53:16 +0530 Message-Id: <20210908062316.49466-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] android: jpeg: Pass the thumbnail planes correctly to encoder X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" After multi-planar support was introduced for jpeg encoding as well, EncoderLibJpeg::encode() expects a vector of planes as the source of framebuffer to be encoded. Currently, this is broken for thumbnail encoding as the thumbnail generated is directly passed as a single plane. Hence, piece the thumbnail data as planes if the parent Framebuffer is multi-planar. This fixes the encoding of the corresponding thumbnail. Fixes: 894ca69f6043("android: jpeg: Support multi-planar buffers") Signed-off-by: Umang Jain --- src/android/jpeg/post_processor_jpeg.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 68d74842..d896581f 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -66,13 +66,18 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source, int ret = thumbnailEncoder_.configure(thCfg); if (!rawThumbnail.empty() && !ret) { - /* - * \todo Avoid value-initialization of all elements of the - * vector. - */ - thumbnail->resize(rawThumbnail.size()); + std::vector> thumbnailPlanes; + for (int i = 0; i < source.planes().size(); i++) { + unsigned int thumbnailSize = + targetSize.height * targetSize.width; + Span plane{ + rawThumbnail.data() + (i * thumbnailSize), + thumbnailSize + }; + thumbnailPlanes.push_back(plane); + } - int jpeg_size = thumbnailEncoder_.encode({ rawThumbnail }, + int jpeg_size = thumbnailEncoder_.encode(thumbnailPlanes, *thumbnail, {}, quality); thumbnail->resize(jpeg_size);