[v2,00/16] Implement WDR algorithm
mbox series

Message ID 20250808141315.413839-1-stefan.klug@ideasonboard.com
Headers show
Series
  • Implement WDR algorithm
Related show

Message

Stefan Klug Aug. 8, 2025, 2:12 p.m. UTC
Hi all,

This series implements a global tone mapping algorithm for rkisp1.  The
details of the algorithms are explained in patch 15/16, so I won't
repeat them here.

v1 of the series was here:
https://patchwork.libcamera.org/project/libcamera/list/?series=5122

Compared to v1 of the series there were quite some changes. The old
series contained mitigation for exposure quantization using the AWB
gains. During my work on HDR stitching support it got clear that we need
to use the compression curve from the companding block of the imx8mp.
That curve can serve as a way better gain than the AWB gains, so I added
a compression algorithm (patches 1-2) which then is used for the
quantization correction.  The quantization correction was generalized to
support exposure and gain quantization effects (patches 3-9). Patch 10
spilled over from the WDR preparation series and now has a (possibly)
better commit message.  The rest is the actual WDR implementation that
was mostly there in v1. I fixed a few bugs and included changes from
review (thanks Paul). The details are in the individual patches.

Best regards,
Stefan

Stefan Klug (16):
  ipa: rkisp1: Add basic compression algorithm
  tuning: rksip1: Add a static Compress entry
  libipa: camera_sensor_helper: Add quantizeGain() function
  libipa: exposure_mode_helper: Take exposure/gain quantization into
    account
  libipa: exposure_mode_helper: Remove double calculation of
    lastStageGain
  libipa: exposure_mode_helper: Remove unnecessary clamp calls
  libipa: agc_mean_luminance: Configure the exposure mode helpers
  libipa: exposure_mode_helper: Calculate quantization gain in
    splitExposure()
  ipa: rkisp1: agc: Add correction for exposure quantization
  pipeline: rkisp1: Add error log when parameter queuing fails
  include: linux: Partially update linux headers from
    v6.16-rc1-310-gd968e50b5c26
  libcamera: Add PID controller class
  ipa: rkisp1: Switch histogram to RGB combined mode
  pipeline: rkisp1: Query kernel for available params blocks
  ipa: rkisp1: Add WDR algorithm
  tuning: rksip1: Add a static WideDynamicRange entry

 include/libcamera/internal/meson.build      |   1 +
 include/libcamera/internal/pid_controller.h |  46 ++
 include/libcamera/ipa/rkisp1.mojom          |   2 +-
 include/linux/rkisp1-config.h               | 108 ++++-
 include/linux/v4l2-controls.h               |  17 +-
 src/ipa/ipu3/algorithms/agc.cpp             |   4 +-
 src/ipa/libipa/agc_mean_luminance.cpp       |  22 +-
 src/ipa/libipa/agc_mean_luminance.h         |   3 +-
 src/ipa/libipa/camera_sensor_helper.cpp     |  23 +
 src/ipa/libipa/camera_sensor_helper.h       |   1 +
 src/ipa/libipa/exposure_mode_helper.cpp     | 103 ++--
 src/ipa/libipa/exposure_mode_helper.h       |  12 +-
 src/ipa/rkisp1/algorithms/agc.cpp           |  35 +-
 src/ipa/rkisp1/algorithms/compress.cpp      | 100 ++++
 src/ipa/rkisp1/algorithms/compress.h        |  33 ++
 src/ipa/rkisp1/algorithms/meson.build       |   2 +
 src/ipa/rkisp1/algorithms/wdr.cpp           | 510 ++++++++++++++++++++
 src/ipa/rkisp1/algorithms/wdr.h             |  64 +++
 src/ipa/rkisp1/ipa_context.h                |  23 +
 src/ipa/rkisp1/params.cpp                   |   1 +
 src/ipa/rkisp1/params.h                     |   2 +
 src/ipa/rkisp1/rkisp1.cpp                   |  20 +-
 src/libcamera/control_ids_debug.yaml        |   7 +-
 src/libcamera/control_ids_draft.yaml        |  70 +++
 src/libcamera/meson.build                   |   1 +
 src/libcamera/pid_controller.cpp            | 172 +++++++
 src/libcamera/pipeline/rkisp1/rkisp1.cpp    |  38 +-
 utils/tuning/rkisp1.py                      |   9 +-
 28 files changed, 1364 insertions(+), 65 deletions(-)
 create mode 100644 include/libcamera/internal/pid_controller.h
 create mode 100644 src/ipa/rkisp1/algorithms/compress.cpp
 create mode 100644 src/ipa/rkisp1/algorithms/compress.h
 create mode 100644 src/ipa/rkisp1/algorithms/wdr.cpp
 create mode 100644 src/ipa/rkisp1/algorithms/wdr.h
 create mode 100644 src/libcamera/pid_controller.cpp

Comments

Stefan Klug Aug. 8, 2025, 2:41 p.m. UTC | #1
Oops, CI just told me that I broke pipelines (rpi, c55) that I don't
usually build :-)

I'll fix these for v3. This version is imho still fine for review.

Best regards,
Stefan

Quoting Stefan Klug (2025-08-08 16:12:38)
> Hi all,
> 
> This series implements a global tone mapping algorithm for rkisp1.  The
> details of the algorithms are explained in patch 15/16, so I won't
> repeat them here.
> 
> v1 of the series was here:
> https://patchwork.libcamera.org/project/libcamera/list/?series=5122
> 
> Compared to v1 of the series there were quite some changes. The old
> series contained mitigation for exposure quantization using the AWB
> gains. During my work on HDR stitching support it got clear that we need
> to use the compression curve from the companding block of the imx8mp.
> That curve can serve as a way better gain than the AWB gains, so I added
> a compression algorithm (patches 1-2) which then is used for the
> quantization correction.  The quantization correction was generalized to
> support exposure and gain quantization effects (patches 3-9). Patch 10
> spilled over from the WDR preparation series and now has a (possibly)
> better commit message.  The rest is the actual WDR implementation that
> was mostly there in v1. I fixed a few bugs and included changes from
> review (thanks Paul). The details are in the individual patches.
> 
> Best regards,
> Stefan
> 
> Stefan Klug (16):
>   ipa: rkisp1: Add basic compression algorithm
>   tuning: rksip1: Add a static Compress entry
>   libipa: camera_sensor_helper: Add quantizeGain() function
>   libipa: exposure_mode_helper: Take exposure/gain quantization into
>     account
>   libipa: exposure_mode_helper: Remove double calculation of
>     lastStageGain
>   libipa: exposure_mode_helper: Remove unnecessary clamp calls
>   libipa: agc_mean_luminance: Configure the exposure mode helpers
>   libipa: exposure_mode_helper: Calculate quantization gain in
>     splitExposure()
>   ipa: rkisp1: agc: Add correction for exposure quantization
>   pipeline: rkisp1: Add error log when parameter queuing fails
>   include: linux: Partially update linux headers from
>     v6.16-rc1-310-gd968e50b5c26
>   libcamera: Add PID controller class
>   ipa: rkisp1: Switch histogram to RGB combined mode
>   pipeline: rkisp1: Query kernel for available params blocks
>   ipa: rkisp1: Add WDR algorithm
>   tuning: rksip1: Add a static WideDynamicRange entry
> 
>  include/libcamera/internal/meson.build      |   1 +
>  include/libcamera/internal/pid_controller.h |  46 ++
>  include/libcamera/ipa/rkisp1.mojom          |   2 +-
>  include/linux/rkisp1-config.h               | 108 ++++-
>  include/linux/v4l2-controls.h               |  17 +-
>  src/ipa/ipu3/algorithms/agc.cpp             |   4 +-
>  src/ipa/libipa/agc_mean_luminance.cpp       |  22 +-
>  src/ipa/libipa/agc_mean_luminance.h         |   3 +-
>  src/ipa/libipa/camera_sensor_helper.cpp     |  23 +
>  src/ipa/libipa/camera_sensor_helper.h       |   1 +
>  src/ipa/libipa/exposure_mode_helper.cpp     | 103 ++--
>  src/ipa/libipa/exposure_mode_helper.h       |  12 +-
>  src/ipa/rkisp1/algorithms/agc.cpp           |  35 +-
>  src/ipa/rkisp1/algorithms/compress.cpp      | 100 ++++
>  src/ipa/rkisp1/algorithms/compress.h        |  33 ++
>  src/ipa/rkisp1/algorithms/meson.build       |   2 +
>  src/ipa/rkisp1/algorithms/wdr.cpp           | 510 ++++++++++++++++++++
>  src/ipa/rkisp1/algorithms/wdr.h             |  64 +++
>  src/ipa/rkisp1/ipa_context.h                |  23 +
>  src/ipa/rkisp1/params.cpp                   |   1 +
>  src/ipa/rkisp1/params.h                     |   2 +
>  src/ipa/rkisp1/rkisp1.cpp                   |  20 +-
>  src/libcamera/control_ids_debug.yaml        |   7 +-
>  src/libcamera/control_ids_draft.yaml        |  70 +++
>  src/libcamera/meson.build                   |   1 +
>  src/libcamera/pid_controller.cpp            | 172 +++++++
>  src/libcamera/pipeline/rkisp1/rkisp1.cpp    |  38 +-
>  utils/tuning/rkisp1.py                      |   9 +-
>  28 files changed, 1364 insertions(+), 65 deletions(-)
>  create mode 100644 include/libcamera/internal/pid_controller.h
>  create mode 100644 src/ipa/rkisp1/algorithms/compress.cpp
>  create mode 100644 src/ipa/rkisp1/algorithms/compress.h
>  create mode 100644 src/ipa/rkisp1/algorithms/wdr.cpp
>  create mode 100644 src/ipa/rkisp1/algorithms/wdr.h
>  create mode 100644 src/libcamera/pid_controller.cpp
> 
> -- 
> 2.48.1
>