From patchwork Fri Feb 26 13:29:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11402 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 4175EBD80C for ; Fri, 26 Feb 2021 13:29:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0F19C68A82; Fri, 26 Feb 2021 14:29:23 +0100 (CET) Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE92468A76 for ; Fri, 26 Feb 2021 14:29:16 +0100 (CET) Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id B22A7200005 for ; Fri, 26 Feb 2021 13:29:16 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Feb 2021 14:29:29 +0100 Message-Id: <20210226132932.165484-10-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210226132932.165484-1-jacopo@jmondi.org> References: <20210226132932.165484-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 09/12] android: jpeg: Use maxJpegBufferSize() for compatibility 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" Platforms that do not provide a memory backend implementation should keep using the maxJpegBufferSize() value to calculate the location where to place the JPEG blob id, as the android_generic backend returns the allocated buffer size as calculated using lseek which is larger than the maximum JPEG frame size, which is where the framework expects the JPEG blob to be placed. Signed-off-by: Jacopo Mondi --- src/android/jpeg/post_processor_jpeg.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index d6eeb962e81d..e7f66d66698c 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -185,9 +185,17 @@ int PostProcessorJpeg::process(const FrameBuffer &source, } /* Fill in the JPEG blob header. */ - uint8_t *resultPtr = destination->plane(0) + - destination->planeSize(0) - - sizeof(struct camera3_jpeg_blob); + /* + * \todo For backward compatibility reasons with the android_generic + * memory backend, continue using the maxJpegBufferSize in case the + * computed buffer size is larger. This can be dropped once all + * supported platforms will have a working memory backend that + * returns the correct buffer size. + */ + size_t blobSize = std::min(cameraDevice_->maxJpegBufferSize(), + destination->planeSize(0)); + uint8_t *resultPtr = destination->plane(0) + blobSize + - sizeof(struct camera3_jpeg_blob); auto *blob = reinterpret_cast(resultPtr); blob->jpeg_blob_id = CAMERA3_JPEG_BLOB_ID; blob->jpeg_size = jpeg_size;