<div dir="ltr"><div dir="ltr">Hi David,<div><br></div><div>Thank you for your review feedback.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 20 Jan 2021 at 09:53, David Plowman <<a href="mailto:david.plowman@raspberrypi.com">david.plowman@raspberrypi.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Naush<br>
<br>
Thanks for this patch. Just one small tidiness thing...<br>
<br>
On Wed, 20 Jan 2021 at 08:34, Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>> wrote:<br>
><br>
> In preparation for fast colour denoise, set the low resolution ISP<br>
> output stream (Output1) to a 1/4 resolution of the application requested<br>
> stream (Output0). This only happens if the application has not requested<br>
> an additional YUV or RGB stream.<br>
><br>
> We also constrain this 1/4 resolution to at most 1200 pixels in the<br>
> largest dimension to avoid being too taxing on memory usage and system<br>
> bandwidth.<br>
><br>
> Also switch the default StreamRole::VideoRecording to YUV420 to allow<br>
> fast colour denoise to run.<br>
><br>
> Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br>
> ---<br>
>  .../pipeline/raspberrypi/raspberrypi.cpp      | 42 ++++++++++++++++++-<br>
>  1 file changed, 41 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
> index e03bcb036f9f..282c4ba75d89 100644<br>
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
> @@ -496,7 +496,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,<br>
><br>
>                 case StreamRole::VideoRecording:<br>
>                         fmts = data->isp_[Isp::Output0].dev()->formats();<br>
> -                       pixelFormat = formats::NV12;<br>
> +                       pixelFormat = formats::YUV420;<br>
>                         size = { 1920, 1080 };<br>
>                         bufferCount = 4;<br>
>                         outCount++;<br>
> @@ -608,6 +608,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)<br>
>          * StreamConfiguration appropriately.<br>
>          */<br>
>         V4L2DeviceFormat format;<br>
> +       bool output1Set = false;<br>
>         for (unsigned i = 0; i < config->size(); i++) {<br>
>                 StreamConfiguration &cfg = config->at(i);<br>
><br>
> @@ -632,6 +633,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)<br>
>                 format.size = cfg.size;<br>
>                 format.fourcc = fourcc;<br>
><br>
> +               LOG(RPI, Info) << "Setting " << stream->name() << " to a resolution of "<br>
> +                              << format.toString();<br>
> +<br>
>                 ret = stream->dev()->setFormat(&format);<br>
>                 if (ret)<br>
>                         return -EINVAL;<br>
> @@ -645,6 +649,42 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)<br>
><br>
>                 cfg.setStream(stream);<br>
>                 stream->setExternal(true);<br>
> +<br>
> +               if (i != maxIndex)<br>
> +                       output1Set = true;<br>
> +       }<br>
> +<br>
> +       /*<br>
> +        * If ISP::Output1 stream has not been requested by the application, we<br>
> +        * set it up for internal use now. This second stream will be used for<br>
> +        * fast colour denoise, and must be a quarter resolution of the ISP::Output0<br>
> +        * stream. However, also limit the maximum size to 1200 pixels in the<br>
> +        * larger dimension, just to avoid being wasteful with buffer allocations<br>
> +        * and memory bandwidth.<br>
> +        */<br>
> +       if (!output1Set) {<br>
> +               V4L2DeviceFormat output1Format = format;<br>
> +               constexpr unsigned int maxDimensions = 1200;<br>
> +<br>
> +               output1Format.size = format.size / 2;<br>
> +               if (output1Format.size.width > maxDimensions) {<br>
> +                       output1Format.size.height = maxDimensions * output1Format.size.height /<br>
> +                                                   output1Format.size.width;<br>
> +                       output1Format.size.height &= ~1;<br>
> +                       output1Format.size.width = maxDimensions;<br>
> +               } else if (output1Format.size.height > maxDimensions) {<br>
> +                       output1Format.size.width = maxDimensions * output1Format.size.width /<br>
> +                                                  output1Format.size.height;<br>
> +                       output1Format.size.width &= ~1;<br>
> +                       output1Format.size.height = maxDimensions;<br>
> +               }<br>
<br>
I wonder if we can tidy this up with those new(ish) Size methods?<br>
Maybe along the lines of<br>
<br>
const Size maxSize = Size(maxDimensions ,<br>
maxDimensions).boundedToAspectRatio(format.size);<br>
output1Format.size = (format.size / 2).boundedTo(maxSize).alignedDownTo(2, 2);<br></blockquote><div><br></div><div>Ooh, that is much nicer!  Have to admit, I didn't much explore the Size class to see if this could be done.</div><div>I will make the suggested change on the next revision.</div><div><br></div><div>Regards,</div><div>Naush</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks!<br>
David<br>
<br>
> +<br>
> +               LOG(RPI, Info) << "Setting ISP Output 1 (internal) to a resolution of "<br>
> +                              << output1Format.toString();<br>
> +<br>
> +               ret = data->isp_[Isp::Output1].dev()->setFormat(&output1Format);<br>
> +               if (ret)<br>
> +                       return -EINVAL;<br>
>         }<br>
><br>
>         /* ISP statistics output format. */<br>
> --<br>
> 2.25.1<br>
><br>
> _______________________________________________<br>
> libcamera-devel mailing list<br>
> <a href="mailto:libcamera-devel@lists.libcamera.org" target="_blank">libcamera-devel@lists.libcamera.org</a><br>
> <a href="https://lists.libcamera.org/listinfo/libcamera-devel" rel="noreferrer" target="_blank">https://lists.libcamera.org/listinfo/libcamera-devel</a><br>
</blockquote></div></div>