<div dir="ltr"><div dir="ltr">Hi Laurent,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 26 Jan 2021 at 22:54, Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.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">On Wed, Jan 27, 2021 at 12:47:06AM +0200, Laurent Pinchart wrote:<br>
> Hi Naush,<br>
> <br>
> Thank you for the patch.<br>
> <br>
> On Tue, Jan 26, 2021 at 04:24:11PM +0000, Naushir Patuck wrote:<br>
> > This denoise algorithm class will be used to pass in the user requested<br>
> > denoise operating mode to the controller. The existing Denoise<br>
> > controller will derive from this new DenoiseAlgorithm class.<br>
> > <br>
> > Add a denoise mode field in the denoise status metadata object for the<br>
> > IPA to use when configuring the ISP.<br>
> > <br>
> > Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br>
> > Reviewed-by: David Plowman <<a href="mailto:david.plowman@raspberrypi.com" target="_blank">david.plowman@raspberrypi.com</a>><br>
> > Reviewed-by: Kieran Bingham <<a href="mailto:kieran.bingham@ideasonboard.com" target="_blank">kieran.bingham@ideasonboard.com</a>><br>
> > ---<br>
> > .../controller/denoise_algorithm.hpp | 23 +++++++++++++++++++<br>
> > .../raspberrypi/controller/denoise_status.h | 1 +<br>
> > src/ipa/raspberrypi/controller/rpi/sdn.cpp | 11 +++++++--<br>
> > src/ipa/raspberrypi/controller/rpi/sdn.hpp | 5 +++-<br>
> > 4 files changed, 37 insertions(+), 3 deletions(-)<br>
> > create mode 100644 src/ipa/raspberrypi/controller/denoise_algorithm.hpp<br>
> > <br>
> > diff --git a/src/ipa/raspberrypi/controller/denoise_algorithm.hpp b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp<br>
> > new file mode 100644<br>
> > index 000000000000..df1f35cc9e5f<br>
> > --- /dev/null<br>
> > +++ b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp<br>
> > @@ -0,0 +1,23 @@<br>
> > +/* SPDX-License-Identifier: BSD-2-Clause */<br>
> > +/*<br>
> > + * Copyright (C) 2021, Raspberry Pi (Trading) Limited<br>
> > + *<br>
> > + * denoise.hpp - Denoise control algorithm interface<br>
> > + */<br>
> > +#pragma once<br>
> > +<br>
> > +#include "algorithm.hpp"<br>
> > +<br>
> > +namespace RPiController {<br>
> > +<br>
> > +enum DenoiseMode { Off, ColourOff, ColourFast, ColourHighQuality };<br>
> <br>
> Should we consider using enum class here ? Adding an unqualified 'Off'<br>
> identifier to the namespace seems quite prone to namespace clashes.<br></blockquote><div><br></div><div>Yes, you are right. My first implementation did have this as an enum class. I opted to change because we have to cast out to an int later on. But I do prefer enum class, so I will revert back.</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>
> (Additionally we usually split enums with one entry per line, but the<br>
> RPi IPA doesn't use the same coding style, so it's up to you.)<br>
<br>
Another question, what's the difference between ColourFast and<br>
ColourHighQuality ? How fast is fast, or how slow is high quality ?<br></blockquote><div><br></div><div>High quality denoise is just what it says on the tin. It analyses and filters the output image. However, this is slow in processing due to the complex filtering operations, and really only wants to be used for a stills image capture. Throughput numbers are based on clock speed, but typically you would be talking about a factor of 10 slower than the typical pixel processing rate.</div><div><br></div><div>Fast colour denoise analyses a 1/4 resolution image and filters out the full resolution output image. This gives us the faster throughput we need when running viewfinder or video recording. Additionally, the filtering is less complex than the high quality mode, so is faster yet. Again, t<span style="font-family:Arial,Helvetica,sans-serif">hroughput numbers are based on clock speed, but you would only see a typical under 2x slowdown over the typical pixel processing rate.</span></div><div></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>
> > +<br>
> > +class DenoiseAlgorithm : public Algorithm<br>
> > +{<br>
> > +public:<br>
> > + DenoiseAlgorithm(Controller *controller) : Algorithm(controller) {}<br>
> > + // A Denoise algorithm must provide the following:<br>
> > + virtual void SetMode(DenoiseMode mode) = 0;<br>
> > +};<br>
> > +<br>
> > +} // namespace RPiController<br>
> > diff --git a/src/ipa/raspberrypi/controller/denoise_status.h b/src/ipa/raspberrypi/controller/denoise_status.h<br>
> > index 06d7cfb91ae8..6064cc2c192e 100644<br>
> > --- a/src/ipa/raspberrypi/controller/denoise_status.h<br>
> > +++ b/src/ipa/raspberrypi/controller/denoise_status.h<br>
> > @@ -16,6 +16,7 @@ struct DenoiseStatus {<br>
> > double noise_constant;<br>
> > double noise_slope;<br>
> > double strength;<br>
> > + unsigned int mode;<br>
> <br>
> Should this be of type DenoiseMode ?<br></blockquote><div><br></div><div>This is meant to be a C interoparable header file. But perhaps that does not matter so much, I will have to discuss this with David. <span style="font-family:Arial,Helvetica,sans-serif">If I switch to enum class for </span><span style="font-family:Arial,Helvetica,sans-serif">DenoiseMode (as above), this will have to remain integer based, or is there an alternative?</span></div><div><br></div><div>Regards,</div><div>Naush</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>
> > };<br>
> > <br>
> > #ifdef __cplusplus<br>
> > diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp<br>
> > index d8c1521a6633..ecc7845eda4c 100644<br>
> > --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp<br>
> > +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp<br>
> > @@ -1,6 +1,6 @@<br>
> > /* SPDX-License-Identifier: BSD-2-Clause */<br>
> > /*<br>
> > - * Copyright (C) 2019, Raspberry Pi (Trading) Limited<br>
> > + * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited<br>
> > *<br>
> > * sdn.cpp - SDN (spatial denoise) control algorithm<br>
> > */<br>
> > @@ -18,7 +18,7 @@ using namespace RPiController;<br>
> > #define NAME "rpi.sdn"<br>
> > <br>
> > Sdn::Sdn(Controller *controller)<br>
> > - : Algorithm(controller)<br>
> > + : DenoiseAlgorithm(controller), mode_(DenoiseMode::ColourOff)<br>
> > {<br>
> > }<br>
> > <br>
> > @@ -48,6 +48,7 @@ void Sdn::Prepare(Metadata *image_metadata)<br>
> > status.noise_constant = noise_status.noise_constant * deviation_;<br>
> > status.noise_slope = noise_status.noise_slope * deviation_;<br>
> > status.strength = strength_;<br>
> > + status.mode = mode_;<br>
> > image_metadata->Set("denoise.status", status);<br>
> > RPI_LOG("Sdn: programmed constant " << status.noise_constant<br>
> > << " slope " << status.noise_slope<br>
> > @@ -55,6 +56,12 @@ void Sdn::Prepare(Metadata *image_metadata)<br>
> > << status.strength);<br>
> > }<br>
> > <br>
> > +void Sdn::SetMode(DenoiseMode mode)<br>
> > +{<br>
> > + // We only distinguish between off and all other modes.<br>
> > + mode_ = mode;<br>
> > +}<br>
> > +<br>
> > // Register algorithm with the system.<br>
> > static Algorithm *Create(Controller *controller)<br>
> > {<br>
> > diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.hpp b/src/ipa/raspberrypi/controller/rpi/sdn.hpp<br>
> > index 486c000d7b77..2371ce04163f 100644<br>
> > --- a/src/ipa/raspberrypi/controller/rpi/sdn.hpp<br>
> > +++ b/src/ipa/raspberrypi/controller/rpi/sdn.hpp<br>
> > @@ -7,12 +7,13 @@<br>
> > #pragma once<br>
> > <br>
> > #include "../algorithm.hpp"<br>
> > +#include "../denoise_algorithm.hpp"<br>
> > <br>
> > namespace RPiController {<br>
> > <br>
> > // Algorithm to calculate correct spatial denoise (SDN) settings.<br>
> > <br>
> > -class Sdn : public Algorithm<br>
> > +class Sdn : public DenoiseAlgorithm<br>
> > {<br>
> > public:<br>
> > Sdn(Controller *controller = NULL);<br>
> > @@ -20,10 +21,12 @@ public:<br>
> > void Read(boost::property_tree::ptree const ¶ms) override;<br>
> > void Initialise() override;<br>
> > void Prepare(Metadata *image_metadata) override;<br>
> > + void SetMode(DenoiseMode mode) override;<br>
> > <br>
> > private:<br>
> > double deviation_;<br>
> > double strength_;<br>
> > + DenoiseMode mode_;<br>
> > };<br>
> > <br>
> > } // namespace RPiController<br>
<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
</blockquote></div></div>