[{"id":15423,"web_url":"https://patchwork.libcamera.org/comment/15423/","msgid":"<YD5UgCV1ParkzjGH@pendragon.ideasonboard.com>","date":"2021-03-02T15:06:40","subject":"Re: [libcamera-devel] [PATCH v4 08/11] android: camera_buffer: Add\n\tmethod to get the JPEG blob size","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tue, Mar 02, 2021 at 03:18:41PM +0100, Jacopo Mondi wrote:\n> To maintain compatibility with platforms that do not provide a memory\n> backend implementation add a method to be return the size of the buffer\n> used for JPEG encoding capped to a maximum size.\n> \n> Platforms that implement a memory backend will always calculate the\n> correct buffer size.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/android/camera_buffer.h              |  2 ++\n>  src/android/mm/generic_camera_buffer.cpp | 14 ++++++++++++++\n>  2 files changed, 16 insertions(+)\n> \n> diff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h\n> index 2311cdaf96b2..784fbd50e50b 100644\n> --- a/src/android/camera_buffer.h\n> +++ b/src/android/camera_buffer.h\n> @@ -26,6 +26,8 @@ public:\n>  \n>  \tlibcamera::Span<const uint8_t> plane(unsigned int plane) const;\n>  \tlibcamera::Span<uint8_t> plane(unsigned int plane);\n> +\n> +\tsize_t jpegBufferSize(size_t maxJpegBufferSize) const;\n>  };\n>  \n>  #endif /* __ANDROID_CAMERA_BUFFER_H__ */\n> diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp\n> index 45a83c351266..98e63dfa0577 100644\n> --- a/src/android/mm/generic_camera_buffer.cpp\n> +++ b/src/android/mm/generic_camera_buffer.cpp\n> @@ -27,6 +27,8 @@ public:\n>  \tunsigned int numPlanes() const;\n>  \n>  \tSpan<uint8_t> plane(unsigned int plane);\n> +\n> +\tsize_t jpegBufferSize(size_t maxJpegBufferSize) const;\n>  };\n>  \n>  CameraBuffer::Private::Private(CameraBuffer *cameraBuffer,\n> @@ -77,6 +79,12 @@ Span<uint8_t> CameraBuffer::Private::plane(unsigned int plane)\n>  \treturn maps_[plane];\n>  }\n>  \n> +size_t CameraBuffer::Private::jpegBufferSize(size_t maxJpegBufferSize) const\n> +{\n> +\treturn std::min<unsigned int>(maps_[0].size(),\n> +\t\t\t\t      maxJpegBufferSize);\n> +}\n> +\n>  CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags)\n>  \t: Extensible(new Private(this, camera3Buffer, flags))\n>  {\n> @@ -109,3 +117,9 @@ Span<uint8_t> CameraBuffer::plane(unsigned int plane)\n>  \tPrivate *const d = LIBCAMERA_D_PTR();\n>  \treturn d->plane(plane);\n>  }\n> +\n> +size_t CameraBuffer::jpegBufferSize(size_t maxJpegBufferSize) const\n> +{\n> +\tconst Private *const d = LIBCAMERA_D_PTR();\n> +\treturn d->jpegBufferSize(maxJpegBufferSize);\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 C43BEBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Mar 2021 15:07:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 92C9968A93;\n\tTue,  2 Mar 2021 16:07:10 +0100 (CET)","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 C67C968A7E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Mar 2021 16:07:08 +0100 (CET)","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 4BCF245D;\n\tTue,  2 Mar 2021 16:07:08 +0100 (CET)"],"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=\"GKdIVkVh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1614697628;\n\tbh=l12ml8CxD7g9sM7b386hMEZMJfcYGx7+9co9wySgYmg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=GKdIVkVhCPkVxOMuY5OqC2WtJ0jdvAYqxQ7XZahKqqM6Cegn3HXYg2jx/02AJaoY1\n\tBANZDbF0uvYYEpxOh/68jV0ybIoQaTVBs6xNbT7H6oRXajNwOFhLQKlw3q8u0gyblm\n\t8fpnDyccTKrVNV9TfGMXU4aVLRoib4t60mgk3YrQ=","Date":"Tue, 2 Mar 2021 17:06:40 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YD5UgCV1ParkzjGH@pendragon.ideasonboard.com>","References":"<20210302141844.126634-1-jacopo@jmondi.org>\n\t<20210302141844.126634-9-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210302141844.126634-9-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v4 08/11] android: camera_buffer: Add\n\tmethod to get the JPEG blob size","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":"Han-lin Chen <hanlinchen@chromium.org>,\n\tlibcamera-devel@lists.libcamera.org, Daniel Hung-yu Wu <hywu@google.com>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]