[{"id":15069,"web_url":"https://patchwork.libcamera.org/comment/15069/","msgid":"<YCHYLzSn7KPdcJ6x@pendragon.ideasonboard.com>","date":"2021-02-09T00:32:47","subject":"Re: [libcamera-devel] [PATCH v6 2/6] pipeline: raspberrypi: Set the\n\tISP Output1 to 1/4 resolution if unused","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Mon, Feb 08, 2021 at 03:07:34PM +0000, Naushir Patuck wrote:\n> In preparation for fast colour denoise, set the low resolution ISP\n> output stream (Output1) to a 1/4 resolution of the application requested\n> stream (Output0). This only happens if the application has not requested\n> an additional YUV or RGB stream.\n> \n> We also constrain this 1/4 resolution to at most 1200 pixels in the\n> largest dimension to avoid being too taxing on memory usage and system\n> bandwidth.\n> \n> Also switch the default StreamRole::VideoRecording to YUV420 to allow\n> fast colour denoise to run.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nA single SoB line is enough ;-)\n\n> ---\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 46 ++++++++++++++++++-\n>  1 file changed, 45 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 183a690dbca1..7ecb080f62d3 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -494,8 +494,16 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::VideoRecording:\n> +\t\t\t/*\n> +\t\t\t * The colour denoise algorithm require the analysis\n\ns/require/requires/\n\nI'll fix when applying.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t\t * image, produced by the second ISP output, to be in\n> +\t\t\t * YUV420 format. Select this format as the default, to\n> +\t\t\t * maximize chances that it will be picked by\n> +\t\t\t * applications and enable usage of the colour denoise\n> +\t\t\t * algorithm.\n> +\t\t\t */\n>  \t\t\tfmts = data->isp_[Isp::Output0].dev()->formats();\n> -\t\t\tpixelFormat = formats::NV12;\n> +\t\t\tpixelFormat = formats::YUV420;\n>  \t\t\tsize = { 1920, 1080 };\n>  \t\t\tbufferCount = 4;\n>  \t\t\toutCount++;\n> @@ -607,6 +615,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>  \t * StreamConfiguration appropriately.\n>  \t */\n>  \tV4L2DeviceFormat format;\n> +\tbool output1Set = false;\n>  \tfor (unsigned i = 0; i < config->size(); i++) {\n>  \t\tStreamConfiguration &cfg = config->at(i);\n>  \n> @@ -631,6 +640,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>  \t\tformat.size = cfg.size;\n>  \t\tformat.fourcc = fourcc;\n>  \n> +\t\tLOG(RPI, Debug) << \"Setting \" << stream->name() << \" to \"\n> +\t\t\t\t<< format.toString();\n> +\n>  \t\tret = stream->dev()->setFormat(&format);\n>  \t\tif (ret)\n>  \t\t\treturn -EINVAL;\n> @@ -644,6 +656,38 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>  \n>  \t\tcfg.setStream(stream);\n>  \t\tstream->setExternal(true);\n> +\n> +\t\tif (i != maxIndex)\n> +\t\t\toutput1Set = true;\n> +\t}\n> +\n> +\t/*\n> +\t * If ISP::Output1 stream has not been requested by the application, we\n> +\t * set it up for internal use now. This second stream will be used for\n> +\t * fast colour denoise, and must be a quarter resolution of the ISP::Output0\n> +\t * stream. However, also limit the maximum size to 1200 pixels in the\n> +\t * larger dimension, just to avoid being wasteful with buffer allocations\n> +\t * and memory bandwidth.\n> +\t *\n> +\t * \\todo If Output 1 format is not YUV420, Output 1 ought to be disabled as\n> +\t * colour denoise will not run.\n> +\t */\n> +\tif (!output1Set) {\n> +\t\tV4L2DeviceFormat output1Format = format;\n> +\t\tconstexpr Size maxDimensions(1200, 1200);\n> +\t\tconst Size limit = maxDimensions.boundedToAspectRatio(format.size);\n> +\n> +\t\toutput1Format.size = (format.size / 2).boundedTo(limit).alignedDownTo(2, 2);\n> +\n> +\t\tLOG(RPI, Debug) << \"Setting ISP Output1 (internal) to \"\n> +\t\t\t\t<< output1Format.toString();\n> +\n> +\t\tret = data->isp_[Isp::Output1].dev()->setFormat(&output1Format);\n> +\t\tif (ret) {\n> +\t\t\tLOG(RPI, Error) << \"Failed to set format on ISP Output1: \"\n> +\t\t\t\t\t<< ret;\n> +\t\t\treturn -EINVAL;\n> +\t\t}\n>  \t}\n>  \n>  \t/* ISP statistics output format. */","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 3F1A2BD162\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Feb 2021 00:33:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C0E456148F;\n\tTue,  9 Feb 2021 01:33:12 +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 A379C602FF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Feb 2021 01:33:11 +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 259FA583;\n\tTue,  9 Feb 2021 01:33:11 +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=\"VGQgUStr\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1612830791;\n\tbh=MQlS/cpqD4Nx9HUM7uOHyRhsJo2kpr9tIixXilH8lPQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VGQgUStrIxP7CfC05GFbBKQCL0rwS7EyiG/1B1UJ8n42LP2nJIq92TMDQBOAUGToq\n\t2JGpsYRO8Ib18Vxeur20IeR+FgvPw4j2P+PVs/IIiDO4oPPxPH5KB79H5GqPL3BFjk\n\to+kO4x+IiubLypxKN5Wq1meekjEtQG6XE03rUHCk=","Date":"Tue, 9 Feb 2021 02:32:47 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YCHYLzSn7KPdcJ6x@pendragon.ideasonboard.com>","References":"<20210208150738.2293520-1-naush@raspberrypi.com>\n\t<20210208150738.2293520-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210208150738.2293520-3-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v6 2/6] pipeline: raspberrypi: Set the\n\tISP Output1 to 1/4 resolution if unused","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","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>"}}]