[v3,13/19] ipa: rkisp1: Switch histogram to RGB combined mode
diff mbox series

Message ID 20250815102945.1602071-14-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • Implement WDR algorithm
Related show

Commit Message

Stefan Klug Aug. 15, 2025, 10:29 a.m. UTC
The Y mode of the histogram gets captured at the ISP output, before the
output formatter.  This has the side effect that the first and the last
bins are empty in case of limited YUV range.  Another side effect is
that gamma and GWDR processing is included in the histogram which makes
algorithm development very difficult. In RGB mode the histogram is taken
after xtalk (CCM) and is therefore independent of gamma and WDR. The
limited range issue also does not apply. In the ISP reference it is
however stated that "it is not possible to calculate a luminance or
grayscale histogram from an RGB histogram since the position information
is lost during its generation".

During testing the RGB histogram provided good data and better
algorithmic stability at a possible (but not measured) inaccuracy.

Another option would be to pass the color space information into the IPA
and strip the histogram accordingly. For ease of implementation switch to
the RGB mode.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

---

Changes in v3:
- Added block comment inside the code
---
 src/ipa/rkisp1/algorithms/agc.cpp | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Kieran Bingham Aug. 15, 2025, 11:50 a.m. UTC | #1
Quoting Stefan Klug (2025-08-15 11:29:33)
> The Y mode of the histogram gets captured at the ISP output, before the
> output formatter.  This has the side effect that the first and the last
> bins are empty in case of limited YUV range.  Another side effect is
> that gamma and GWDR processing is included in the histogram which makes
> algorithm development very difficult. In RGB mode the histogram is taken
> after xtalk (CCM) and is therefore independent of gamma and WDR. The
> limited range issue also does not apply. In the ISP reference it is
> however stated that "it is not possible to calculate a luminance or
> grayscale histogram from an RGB histogram since the position information
> is lost during its generation".
> 
> During testing the RGB histogram provided good data and better
> algorithmic stability at a possible (but not measured) inaccuracy.
> 
> Another option would be to pass the color space information into the IPA
> and strip the histogram accordingly. For ease of implementation switch to
> the RGB mode.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> ---
> 
> Changes in v3:
> - Added block comment inside the code

Thanks


> ---
>  src/ipa/rkisp1/algorithms/agc.cpp | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
> index d34c041f9fe1..ba617a4e6e0c 100644
> --- a/src/ipa/rkisp1/algorithms/agc.cpp
> +++ b/src/ipa/rkisp1/algorithms/agc.cpp
> @@ -396,7 +396,24 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,
>         hstConfig.setEnabled(true);
>  
>         hstConfig->meas_window = context.configuration.agc.measureWindow;
> -       hstConfig->mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM;
> +       /**

Should this be a doxygen block ** ? Will it get rendered into the
internal doxygen docs for Rkisp1 IPA when we build it ?

> +         * The Y mode of the histogram gets captured at the ISP output, before

Tiny nit: whitespace error at the *

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

> +        * the output formatter.  This has the side effect that the first and
> +        * the last bins are empty in case of limited YUV range.  Another side
> +        * effect is that gamma and GWDR processing is included in the histogram
> +        * which makes algorithm development very difficult. In RGB mode the
> +        * histogram is taken after xtalk (CCM) and is therefore independent of
> +        * gamma and WDR. The limited range issue also does not apply. In the
> +        * ISP reference it is however stated that "it is not possible to
> +        * calculate a luminance or grayscale histogram from an RGB histogram
> +        * since the position information is lost during its generation".
> +        *
> +        * During testing the RGB histogram provided good data and better
> +        * algorithmic stability at a possible (but not measured) inaccuracy.
> +        *
> +        * \todo For a proper fix support for HIST64 is needed.
> +        */
> +       hstConfig->mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED;
>  
>         Span<uint8_t> weights{
>                 hstConfig->hist_weight,
> -- 
> 2.48.1
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index d34c041f9fe1..ba617a4e6e0c 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -396,7 +396,24 @@  void Agc::prepare(IPAContext &context, const uint32_t frame,
 	hstConfig.setEnabled(true);
 
 	hstConfig->meas_window = context.configuration.agc.measureWindow;
-	hstConfig->mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM;
+	/**
+         * The Y mode of the histogram gets captured at the ISP output, before
+	 * the output formatter.  This has the side effect that the first and
+	 * the last bins are empty in case of limited YUV range.  Another side
+	 * effect is that gamma and GWDR processing is included in the histogram
+	 * which makes algorithm development very difficult. In RGB mode the
+	 * histogram is taken after xtalk (CCM) and is therefore independent of
+	 * gamma and WDR. The limited range issue also does not apply. In the
+	 * ISP reference it is however stated that "it is not possible to
+	 * calculate a luminance or grayscale histogram from an RGB histogram
+	 * since the position information is lost during its generation".
+	 *
+	 * During testing the RGB histogram provided good data and better
+	 * algorithmic stability at a possible (but not measured) inaccuracy.
+	 *
+	 * \todo For a proper fix support for HIST64 is needed.
+	 */
+	hstConfig->mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED;
 
 	Span<uint8_t> weights{
 		hstConfig->hist_weight,