[v5,5/6] ipa: simple: Report contrast in metadata
diff mbox series

Message ID 20250326124856.75709-6-mzamazal@redhat.com
State Superseded
Headers show
Series
  • ipa: simple: Introduce metadata reporting
Related show

Commit Message

Milan Zamazal March 26, 2025, 12:48 p.m. UTC
Provide the requested contrast value, if any, in the metadata to add to
the completed requests.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 src/ipa/simple/algorithms/lut.cpp | 15 ++++++++++++++-
 src/ipa/simple/algorithms/lut.h   |  5 +++++
 src/ipa/simple/ipa_context.h      |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

Comments

Kieran Bingham March 26, 2025, 9:29 p.m. UTC | #1
Quoting Milan Zamazal (2025-03-26 12:48:54)
> Provide the requested contrast value, if any, in the metadata to add to
> the completed requests.
> 
> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/ipa/simple/algorithms/lut.cpp | 15 ++++++++++++++-
>  src/ipa/simple/algorithms/lut.h   |  5 +++++
>  src/ipa/simple/ipa_context.h      |  1 +
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp
> index a06cdeba..e8638f27 100644
> --- a/src/ipa/simple/algorithms/lut.cpp
> +++ b/src/ipa/simple/algorithms/lut.cpp
> @@ -87,9 +87,11 @@ int16_t Lut::ccmValue(unsigned int i, float ccm) const
>  
>  void Lut::prepare(IPAContext &context,
>                   [[maybe_unused]] const uint32_t frame,
> -                 [[maybe_unused]] IPAFrameContext &frameContext,
> +                 IPAFrameContext &frameContext,
>                   DebayerParams *params)
>  {
> +       frameContext.contrast = context.activeState.knobs.contrast;
> +
>         /*
>          * Update the gamma table if needed. This means if black level changes
>          * and since the black level gets updated only if a lower value is
> @@ -139,6 +141,17 @@ void Lut::prepare(IPAContext &context,
>         }
>  }
>  
> +void Lut::process([[maybe_unused]] IPAContext &context,
> +                 [[maybe_unused]] const uint32_t frame,
> +                 [[maybe_unused]] IPAFrameContext &frameContext,
> +                 [[maybe_unused]] const SwIspStats *stats,
> +                 ControlList &metadata)
> +{
> +       const auto &contrast = frameContext.contrast;
> +       if (contrast)
> +               metadata.set(controls::Contrast, contrast.value());
> +}
> +
>  REGISTER_IPA_ALGORITHM(Lut, "Lut")
>  
>  } /* namespace ipa::soft::algorithms */
> diff --git a/src/ipa/simple/algorithms/lut.h b/src/ipa/simple/algorithms/lut.h
> index 77324800..ba8b9021 100644
> --- a/src/ipa/simple/algorithms/lut.h
> +++ b/src/ipa/simple/algorithms/lut.h
> @@ -30,6 +30,11 @@ public:
>                      const uint32_t frame,
>                      IPAFrameContext &frameContext,
>                      DebayerParams *params) override;
> +       void process(IPAContext &context,
> +                    const uint32_t frame,
> +                    IPAFrameContext &frameContext,
> +                    const SwIspStats *stats,
> +                    ControlList &metadata) override;
>  
>  private:
>         void updateGammaTable(IPAContext &context);
> diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h
> index bfac835b..10d539f5 100644
> --- a/src/ipa/simple/ipa_context.h
> +++ b/src/ipa/simple/ipa_context.h
> @@ -74,6 +74,7 @@ struct IPAFrameContext : public FrameContext {
>                 double red;
>                 double blue;
>         } gains;
> +       std::optional<double> contrast;
>  };
>  
>  struct IPAContext {
> -- 
> 2.49.0
>
Laurent Pinchart March 26, 2025, 11:30 p.m. UTC | #2
Hi Milan,

Thank you for the patch.

On Wed, Mar 26, 2025 at 01:48:54PM +0100, Milan Zamazal wrote:
> Provide the requested contrast value, if any, in the metadata to add to
> the completed requests.
> 
> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/ipa/simple/algorithms/lut.cpp | 15 ++++++++++++++-
>  src/ipa/simple/algorithms/lut.h   |  5 +++++
>  src/ipa/simple/ipa_context.h      |  1 +
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp
> index a06cdeba..e8638f27 100644
> --- a/src/ipa/simple/algorithms/lut.cpp
> +++ b/src/ipa/simple/algorithms/lut.cpp
> @@ -87,9 +87,11 @@ int16_t Lut::ccmValue(unsigned int i, float ccm) const
>  
>  void Lut::prepare(IPAContext &context,
>  		  [[maybe_unused]] const uint32_t frame,
> -		  [[maybe_unused]] IPAFrameContext &frameContext,
> +		  IPAFrameContext &frameContext,
>  		  DebayerParams *params)
>  {
> +	frameContext.contrast = context.activeState.knobs.contrast;
> +
>  	/*
>  	 * Update the gamma table if needed. This means if black level changes
>  	 * and since the black level gets updated only if a lower value is
> @@ -139,6 +141,17 @@ void Lut::prepare(IPAContext &context,
>  	}
>  }
>  
> +void Lut::process([[maybe_unused]] IPAContext &context,
> +		  [[maybe_unused]] const uint32_t frame,
> +		  [[maybe_unused]] IPAFrameContext &frameContext,
> +		  [[maybe_unused]] const SwIspStats *stats,
> +		  ControlList &metadata)
> +{
> +	const auto &contrast = frameContext.contrast;
> +	if (contrast)
> +		metadata.set(controls::Contrast, contrast.value());
> +}
> +
>  REGISTER_IPA_ALGORITHM(Lut, "Lut")
>  
>  } /* namespace ipa::soft::algorithms */
> diff --git a/src/ipa/simple/algorithms/lut.h b/src/ipa/simple/algorithms/lut.h
> index 77324800..ba8b9021 100644
> --- a/src/ipa/simple/algorithms/lut.h
> +++ b/src/ipa/simple/algorithms/lut.h
> @@ -30,6 +30,11 @@ public:
>  		     const uint32_t frame,
>  		     IPAFrameContext &frameContext,
>  		     DebayerParams *params) override;
> +	void process(IPAContext &context,
> +		     const uint32_t frame,
> +		     IPAFrameContext &frameContext,
> +		     const SwIspStats *stats,
> +		     ControlList &metadata) override;
>  
>  private:
>  	void updateGammaTable(IPAContext &context);
> diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h
> index bfac835b..10d539f5 100644
> --- a/src/ipa/simple/ipa_context.h
> +++ b/src/ipa/simple/ipa_context.h
> @@ -74,6 +74,7 @@ struct IPAFrameContext : public FrameContext {
>  		double red;
>  		double blue;
>  	} gains;
> +	std::optional<double> contrast;
>  };
>  
>  struct IPAContext {

Patch
diff mbox series

diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp
index a06cdeba..e8638f27 100644
--- a/src/ipa/simple/algorithms/lut.cpp
+++ b/src/ipa/simple/algorithms/lut.cpp
@@ -87,9 +87,11 @@  int16_t Lut::ccmValue(unsigned int i, float ccm) const
 
 void Lut::prepare(IPAContext &context,
 		  [[maybe_unused]] const uint32_t frame,
-		  [[maybe_unused]] IPAFrameContext &frameContext,
+		  IPAFrameContext &frameContext,
 		  DebayerParams *params)
 {
+	frameContext.contrast = context.activeState.knobs.contrast;
+
 	/*
 	 * Update the gamma table if needed. This means if black level changes
 	 * and since the black level gets updated only if a lower value is
@@ -139,6 +141,17 @@  void Lut::prepare(IPAContext &context,
 	}
 }
 
+void Lut::process([[maybe_unused]] IPAContext &context,
+		  [[maybe_unused]] const uint32_t frame,
+		  [[maybe_unused]] IPAFrameContext &frameContext,
+		  [[maybe_unused]] const SwIspStats *stats,
+		  ControlList &metadata)
+{
+	const auto &contrast = frameContext.contrast;
+	if (contrast)
+		metadata.set(controls::Contrast, contrast.value());
+}
+
 REGISTER_IPA_ALGORITHM(Lut, "Lut")
 
 } /* namespace ipa::soft::algorithms */
diff --git a/src/ipa/simple/algorithms/lut.h b/src/ipa/simple/algorithms/lut.h
index 77324800..ba8b9021 100644
--- a/src/ipa/simple/algorithms/lut.h
+++ b/src/ipa/simple/algorithms/lut.h
@@ -30,6 +30,11 @@  public:
 		     const uint32_t frame,
 		     IPAFrameContext &frameContext,
 		     DebayerParams *params) override;
+	void process(IPAContext &context,
+		     const uint32_t frame,
+		     IPAFrameContext &frameContext,
+		     const SwIspStats *stats,
+		     ControlList &metadata) override;
 
 private:
 	void updateGammaTable(IPAContext &context);
diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h
index bfac835b..10d539f5 100644
--- a/src/ipa/simple/ipa_context.h
+++ b/src/ipa/simple/ipa_context.h
@@ -74,6 +74,7 @@  struct IPAFrameContext : public FrameContext {
 		double red;
 		double blue;
 	} gains;
+	std::optional<double> contrast;
 };
 
 struct IPAContext {