[{"id":12530,"web_url":"https://patchwork.libcamera.org/comment/12530/","msgid":"<20200915223902.GF3998@pendragon.ideasonboard.com>","date":"2020-09-15T22:39:02","subject":"Re: [libcamera-devel] [PATCH v4 02/10] android: camera_device:\n\tGenerate JPEG sizes","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 Sat, Sep 12, 2020 at 12:11:21PM +0200, Jacopo Mondi wrote:\n> When producing the list of image resolutions to claim as supported by the\n> camera HAL, the JPEG stream was assumed to be 'always valid' as, at the\n> time, there was no JPEG support in place at all.\n> \n> With the introduction of support for JPEG compression, reporting\n> non-valid sizes as supported obviously causes troubles.\n> \n> In order to avoid reporting non-supported resolutions as supported,\n> produce the list of available JPEG sizes by using the ones supported\n> by the YCbCr_420_888 format, from which the JPEG stream is encoded.\n> \n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/android/camera_device.cpp | 40 ++++++++++++++++++++++-------------\n>  1 file changed, 25 insertions(+), 15 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index ebebdac38e28..3be2dac28f9c 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -369,17 +369,21 @@ int CameraDevice::initializeStreamConfigurations()\n>  \t\tconst std::vector<PixelFormat> &libcameraFormats =\n>  \t\t\tcamera3Format.libcameraFormats;\n>  \n> +\t\t/*\n> +\t\t * JPEG is always supported, either produced directly by the\n> +\t\t * camera, or encoded in the HAL.\n> +\t\t */\n> +\t\tif (androidFormat == HAL_PIXEL_FORMAT_BLOB) {\n> +\t\t\tformatsMap_[androidFormat] = formats::MJPEG;\n> +\t\t\tcontinue;\n> +\t\t}\n> +\n>  \t\t/*\n>  \t\t * Test the libcamera formats that can produce images\n>  \t\t * compatible with the format defined by Android.\n>  \t\t */\n>  \t\tPixelFormat mappedFormat;\n>  \t\tfor (const PixelFormat &pixelFormat : libcameraFormats) {\n> -\t\t\t/* \\todo Fixed mapping for JPEG. */\n> -\t\t\tif (androidFormat == HAL_PIXEL_FORMAT_BLOB) {\n> -\t\t\t\tmappedFormat = formats::MJPEG;\n> -\t\t\t\tbreak;\n> -\t\t\t}\n>  \n>  \t\t\t/*\n>  \t\t\t * The stream configuration size can be adjusted,\n> @@ -422,19 +426,25 @@ int CameraDevice::initializeStreamConfigurations()\n>  \t\t\tcfg.size = res;\n>  \n>  \t\t\tCameraConfiguration::Status status = cameraConfig->validate();\n> -\t\t\t/*\n> -\t\t\t * Unconditionally report we can produce JPEG.\n> -\t\t\t *\n> -\t\t\t * \\todo The JPEG stream will be implemented as an\n> -\t\t\t * HAL-only stream, but some cameras can produce it\n> -\t\t\t * directly. As of now, claim support for JPEG without\n> -\t\t\t * inspecting where the JPEG stream is produced.\n> -\t\t\t */\n> -\t\t\tif (androidFormat != HAL_PIXEL_FORMAT_BLOB &&\n> -\t\t\t    status != CameraConfiguration::Valid)\n> +\t\t\tif (status != CameraConfiguration::Valid)\n>  \t\t\t\tcontinue;\n>  \n>  \t\t\tstreamConfigurations_.push_back({ res, androidFormat });\n> +\n> +\t\t\t/*\n> +\t\t\t * If the format is HAL_PIXEL_FORMAT_YCbCr_420_888\n> +\t\t\t * from which JPEG is produced, add an entry for\n> +\t\t\t * the JPEG stream.\n> +\t\t\t *\n> +\t\t\t * \\todo Wire the JPEG encoder to query the supported\n> +\t\t\t * sizes provided a list of formats it can encode.\n> +\t\t\t *\n> +\t\t\t * \\todo Support JPEG streams produced by the Camera\n> +\t\t\t * natively.\n> +\t\t\t */\n> +\t\t\tif (androidFormat == HAL_PIXEL_FORMAT_YCbCr_420_888)\n> +\t\t\t\tstreamConfigurations_.push_back(\n> +\t\t\t\t\t{ res, HAL_PIXEL_FORMAT_BLOB });\n>  \t\t}\n>  \t}\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 DAA47C3B5B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Sep 2020 22:39:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 523B662E13;\n\tWed, 16 Sep 2020 00:39:34 +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 320C662C8C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 16 Sep 2020 00:39:32 +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 8FD45FD8;\n\tWed, 16 Sep 2020 00:39:31 +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=\"Cd471oKS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1600209571;\n\tbh=IRx7ng6+E7WmAWdPNw6dIXzwQy+ryg6ocI3ZrFxxxOA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Cd471oKSh41NkM/oK965Fnb7CIU8F1EWmT5TpkuyUgGx7ayOgN3eqmPHlCZJOVjcX\n\to95z48tEu7Sfi87rIqps20cNZFgtQSFFkA+otQp/dq0hG8rB7H327ub1ie1z3mzTP8\n\t9i4rLSWK/cyy5BWpP2R/kuaRFHNNwBYeUm6M+9Rc=","Date":"Wed, 16 Sep 2020 01:39:02 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200915223902.GF3998@pendragon.ideasonboard.com>","References":"<20200912101129.12625-1-jacopo@jmondi.org>\n\t<20200912101129.12625-3-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200912101129.12625-3-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v4 02/10] android: camera_device:\n\tGenerate JPEG sizes","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":"hanlinchen@chromium.org, libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]