[1/1] libipa: Allow disabling algorithms via the tuning file
diff mbox series

Message ID 20250429124806.138056-2-isaac.scott@ideasonboard.com
State New
Headers show
Series
  • Allow algorithms to be disabled via the tuning file
Related show

Commit Message

Isaac Scott April 29, 2025, 12:48 p.m. UTC
Allows the user to add "disabled" as a parameter in their tuning file,
which lets them test disabling algorithms without having to delete them.

Usage example:

version: 1
algorithms:
  - Agc:
      disabled:
      AeMeteringMode:
        MeteringCentreWeighted: [ 0, 0, 0, 0, 0, 0, 6, 8, 6, 0, 0, 8, 16, 8, 0, 0, 6, 8, 6, 0, 0, 0, 0, 0, 0 ]
        MeteringSpot: [ 0, 0, 0, 0, 0, 0, 2, 4, 2, 0, 0, 4, 16, 4, 0, 0, 2, 4, 2, 0, 0, 0, 0, 0, 0 ]
        MeteringMatrix: [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
      AeExposureMode:

This example will disable the Agc algorithm.

Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com>
---
 src/ipa/libipa/module.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Stefan Klug April 30, 2025, 9:36 a.m. UTC | #1
Hi Isaac,

Thank you for the patch. 

On Tue, Apr 29, 2025 at 01:48:06PM +0100, Isaac Scott wrote:
> Allows the user to add "disabled" as a parameter in their tuning file,
> which lets them test disabling algorithms without having to delete them.

I think such a property would be useful. Ideally I'd like to toggle that
at runtime also, but that is for later.

One suggestion though: Can we call the property "enabled" with a boolean
value?

Best regards,
Stefan

> 
> Usage example:
> 
> version: 1
> algorithms:
>   - Agc:
>       disabled:
>       AeMeteringMode:
>         MeteringCentreWeighted: [ 0, 0, 0, 0, 0, 0, 6, 8, 6, 0, 0, 8, 16, 8, 0, 0, 6, 8, 6, 0, 0, 0, 0, 0, 0 ]
>         MeteringSpot: [ 0, 0, 0, 0, 0, 0, 2, 4, 2, 0, 0, 4, 16, 4, 0, 0, 2, 4, 2, 0, 0, 0, 0, 0, 0 ]
>         MeteringMatrix: [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
>       AeExposureMode:
> 
> This example will disable the Agc algorithm.
> 
> Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com>
> ---
>  src/ipa/libipa/module.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h
> index 0fb51916..86cc382b 100644
> --- a/src/ipa/libipa/module.h
> +++ b/src/ipa/libipa/module.h
> @@ -74,6 +74,13 @@ private:
>  	int createAlgorithm(Context &context, const YamlObject &data)
>  	{
>  		const auto &[name, algoData] = *data.asDict().begin();
> +		if (algoData.contains("disabled")) {
> +			LOG(IPAModuleAlgo, Debug)
> +				<< "Algorithm " << name << " is disabled"
> +				<< " in the tuning file!";
> +			/* If we return an error code, the IPA does not work */
> +			return 0;
> +		}
>  		std::unique_ptr<Algorithm<Module>> algo = createAlgorithm(name);
>  		if (!algo) {
>  			LOG(IPAModuleAlgo, Error)
> -- 
> 2.43.0
>
Paul Elder May 12, 2025, 11:55 p.m. UTC | #2
Quoting Stefan Klug (2025-04-30 11:36:00)
> Hi Isaac,
> 
> Thank you for the patch. 
> 
> On Tue, Apr 29, 2025 at 01:48:06PM +0100, Isaac Scott wrote:
> > Allows the user to add "disabled" as a parameter in their tuning file,
> > which lets them test disabling algorithms without having to delete them.
> 
> I think such a property would be useful. Ideally I'd like to toggle that
> at runtime also, but that is for later.
> 
> One suggestion though: Can we call the property "enabled" with a boolean
> value?

I think I'm in this camp too. Even though the default is "existence of the algo
in the tuning file = enabled", I think "enabled: false" is nicer than an empty
"disabled:" entry.

Paul

> 
> Best regards,
> Stefan
> 
> > 
> > Usage example:
> > 
> > version: 1
> > algorithms:
> >   - Agc:
> >       disabled:
> >       AeMeteringMode:
> >         MeteringCentreWeighted: [ 0, 0, 0, 0, 0, 0, 6, 8, 6, 0, 0, 8, 16, 8, 0, 0, 6, 8, 6, 0, 0, 0, 0, 0, 0 ]
> >         MeteringSpot: [ 0, 0, 0, 0, 0, 0, 2, 4, 2, 0, 0, 4, 16, 4, 0, 0, 2, 4, 2, 0, 0, 0, 0, 0, 0 ]
> >         MeteringMatrix: [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
> >       AeExposureMode:
> > 
> > This example will disable the Agc algorithm.
> > 
> > Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com>
> > ---
> >  src/ipa/libipa/module.h | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h
> > index 0fb51916..86cc382b 100644
> > --- a/src/ipa/libipa/module.h
> > +++ b/src/ipa/libipa/module.h
> > @@ -74,6 +74,13 @@ private:
> >       int createAlgorithm(Context &context, const YamlObject &data)
> >       {
> >               const auto &[name, algoData] = *data.asDict().begin();
> > +             if (algoData.contains("disabled")) {
> > +                     LOG(IPAModuleAlgo, Debug)
> > +                             << "Algorithm " << name << " is disabled"
> > +                             << " in the tuning file!";
> > +                     /* If we return an error code, the IPA does not work */
> > +                     return 0;
> > +             }
> >               std::unique_ptr<Algorithm<Module>> algo = createAlgorithm(name);
> >               if (!algo) {
> >                       LOG(IPAModuleAlgo, Error)
> > -- 
> > 2.43.0
> >

Patch
diff mbox series

diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h
index 0fb51916..86cc382b 100644
--- a/src/ipa/libipa/module.h
+++ b/src/ipa/libipa/module.h
@@ -74,6 +74,13 @@  private:
 	int createAlgorithm(Context &context, const YamlObject &data)
 	{
 		const auto &[name, algoData] = *data.asDict().begin();
+		if (algoData.contains("disabled")) {
+			LOG(IPAModuleAlgo, Debug)
+				<< "Algorithm " << name << " is disabled"
+				<< " in the tuning file!";
+			/* If we return an error code, the IPA does not work */
+			return 0;
+		}
 		std::unique_ptr<Algorithm<Module>> algo = createAlgorithm(name);
 		if (!algo) {
 			LOG(IPAModuleAlgo, Error)