{"id":11062,"url":"https://patchwork.libcamera.org/api/patches/11062/?format=json","web_url":"https://patchwork.libcamera.org/patch/11062/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210129151154.1051163-3-naush@raspberrypi.com>","date":"2021-01-29T15:11:50","name":"[libcamera-devel,v5,2/6] pipeline: raspberrypi: Set the ISP Output1 to 1/4 resolution if unused","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"43e21a829e8fbd01dc3ce56e29f2a893336f9d8c","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11062/mbox/","series":[{"id":1627,"url":"https://patchwork.libcamera.org/api/series/1627/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1627","date":"2021-01-29T15:11:48","name":"Raspberry Pi: Colour denoise","version":5,"mbox":"https://patchwork.libcamera.org/series/1627/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11062/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11062/checks/","tags":{},"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 5B9BEBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 29 Jan 2021 15:12:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D97A8683B0;\n\tFri, 29 Jan 2021 16:12:03 +0100 (CET)","from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E8FE6683A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Jan 2021 16:12:01 +0100 (CET)","by mail-wm1-x32a.google.com with SMTP id m2so7109626wmm.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Jan 2021 07:12:01 -0800 (PST)","from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tf13sm6517461wmf.1.2021.01.29.07.11.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 29 Jan 2021 07:12:00 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"mUBgC9J1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=dsPixlnJZhJd5BDuTN2uW6MwnaS4GEG/CSXQPrFQY2E=;\n\tb=mUBgC9J1eoomV72THSQAx7Aa+tNpLMdD1w0xwnIWANFHB4p3jv5x2AkZOJpc5ZrJW2\n\tM6gvckjDYEtL2EgOb89IJOoOs7IUXxoHMmFrHoMh3oANvmPc6puZU+FYd3/c1epTm9CS\n\tOEcuhaVsy46Rq7a+KjH9IcjHuOZ/Amin4qXdCPPrTq01sZDYLUM9CS61YXoBut1di8qW\n\tXVtH+LUVbvDWLhrDRBE9yKXlR+SVhpyw0P3wJ9TWUWrAh1BXrHGxl3r3WvQjh2gE1A6u\n\t+DCaeWha3wzYjXZFkIMalkpH+WIiZiAvbyNFRTisgTbDMd2gnK4USa0ASX/+oGoZvxB8\n\tnEEA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=dsPixlnJZhJd5BDuTN2uW6MwnaS4GEG/CSXQPrFQY2E=;\n\tb=Nl67LfL7X3XOQC0VtKE0EmGQEkBEhAESxyMDpN2HEZ1G8bPAIBeFwY3WuHPZMANBvi\n\t1+bM3911Z/rXh8Qy97hOjbURNsGpPuxcL7QBxITlxrrvWbEL8ZKitIeBVS2FsNF+GsDO\n\tmlNmh8rBMhOO57RVH4JLrAl4od4cZOKwrAUEpilkjETsOJFivCk7v8JoN+lKGxQ4tNRD\n\t0w+vyXNdWJz+gXXtU3NzV4N0dqnLqDJyQuTZ9iE37ppOTG6GmbFA/dlAnf090i9yECEL\n\tNLnAyhyGBzym/rcaRcqV97HI2DP3LREHDJ/B9GQ8FMvlDY/SbBVqqkJ1JEpGuUA+3ENb\n\t2Pow==","X-Gm-Message-State":"AOAM530/g5PGt7jLbhBB5+bzIHUYOdyA/Ox7hiKwJCX28N/10+yHmTnR\n\tqF2shNrSiJuo9DJMLO2wMvpCoNT4VlnXG70i","X-Google-Smtp-Source":"ABdhPJxOSLoiUsuLL1kPthJNnVczqY+ARZsUUSogNwdhC7vj6mGnAkFg4N4A7jPi8S/By5Kros3JTg==","X-Received":"by 2002:a1c:8157:: with SMTP id c84mr4361518wmd.24.1611933121101;\n\tFri, 29 Jan 2021 07:12:01 -0800 (PST)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 29 Jan 2021 15:11:50 +0000","Message-Id":"<20210129151154.1051163-3-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20210129151154.1051163-1-naush@raspberrypi.com>","References":"<20210129151154.1051163-1-naush@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v5 2/6] pipeline: raspberrypi: Set the ISP\n\tOutput1 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>","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>"},"content":"In preparation for fast colour denoise, set the low resolution ISP\noutput stream (Output1) to a 1/4 resolution of the application requested\nstream (Output0). This only happens if the application has not requested\nan additional YUV or RGB stream.\n\nWe also constrain this 1/4 resolution to at most 1200 pixels in the\nlargest dimension to avoid being too taxing on memory usage and system\nbandwidth.\n\nAlso switch the default StreamRole::VideoRecording to YUV420 to allow\nfast colour denoise to run.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 35 ++++++++++++++++++-\n 1 file changed, 34 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex d9895c779725..fe4c75f09925 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -496,7 +496,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n \n \t\tcase StreamRole::VideoRecording:\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@@ -608,6 +608,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@@ -632,6 +633,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t\tformat.size = cfg.size;\n \t\tformat.fourcc = fourcc;\n \n+\t\tLOG(RPI, Info) << \"Setting \" << stream->name() << \" to a resolution of \"\n+\t\t\t       << format.toString();\n+\n \t\tret = stream->dev()->setFormat(&format);\n \t\tif (ret)\n \t\t\treturn -EINVAL;\n@@ -645,6 +649,35 @@ 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+\tif (!output1Set) {\n+\t\tV4L2DeviceFormat output1Format = format;\n+\t\tconstexpr unsigned int maxDimensions = 1200;\n+\t\tconst Size limit = Size(maxDimensions, maxDimensions).boundedToAspectRatio(format.size);\n+\n+\t\toutput1Format.size = (format.size / 2).boundedTo(limit).alignedDownTo(2, 2);\n+\n+\t\tLOG(RPI, Info) << \"Setting ISP Output1 (internal) to a resolution of \"\n+\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. */\n","prefixes":["libcamera-devel","v5","2/6"]}