[libcamera-devel,1/2] controls: Add controls for tonemapping
diff mbox series

Message ID 20211221052854.2690659-2-paul.elder@ideasonboard.com
State New
Delegated to: Paul Elder
Headers show
Series
  • android: Tonemapping
Related show

Commit Message

Paul Elder Dec. 21, 2021, 5:28 a.m. UTC
Add controls related to tonemapping:
- TonemapMode: set and report the source of the tonemap curve
- TonemapGamma: the gamma value for tonemap curve gamma mode
- TonemapPresetCurve: the preset tonemap curve for tonemap curve preset
  mode
- TonemapCurve: the tonemap curve for custom (contrast) curve mode, also
  used to report the TonemapCurve that was used, regardless of the mode
- TonemapCurveSize: the number of data points of TonemapCurve

These are based on android's tonemapping controls.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/libcamera/control_ids.yaml | 100 +++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)

Patch
diff mbox series

diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
index 3236da1d..411200a8 100644
--- a/src/libcamera/control_ids.yaml
+++ b/src/libcamera/control_ids.yaml
@@ -697,6 +697,106 @@  controls:
         For a monochrome camera, all four color channels must have the same
         values.
 
+  - TonemapMode:
+      type: int32_t
+      description: |
+        High-level global contrast/gamma/tonemapping control. This control,
+        TonemapCurve, and TonemapCurveSize are the minimum required controls
+        for tonemapping support.
+      enum:
+        - name: TonemapModeContrastCurve
+          value: 0
+          description: |
+            Use the tonemapping curve specified in TonemapCurve.
+            All color enhancement and tonemapping must be disabled, except
+            for applying the tonemapping curve specified by TonemapCurve.
+        - name: TonemapModeFast
+          value: 1
+          description: |
+            Advanced gamma mapping and color enhancement may be applied,
+            without reducing frame rate compared to raw sensor output. The
+            camera will use its own tonemap curve, and report it in TonemapCurve.
+        - name: TonemapModeHighQuality
+          value: 2
+          description: |
+            High-quality gamma mapping and color enhancement will be
+            applied, at the cost of possibly reduced frame rate compared to
+            raw sensor output. The camera will use its own tonemap curve, and
+            report it in TonemapCurve.
+        - name: TonemapModeGammaValue
+          value: 3
+          description: |
+            Use the gamma value specified in TonemapGamma to perform
+            tonemapping. All color enhancement and tonemapping shall be
+            disabled, except for applying the tonemapping curve specified
+            by TonemapGamma.
+
+            If this mode is supported, then the TonemapGamma control must be
+            supported as well.
+        - name: TonemapModePresetCurve
+          value: 4
+          description: |
+            Use the present tonemapping curve specified in
+            TonemapPresetCurve to perform tonemapping. All color
+            enhancement and tonemapping must be disabled, except for
+            applying the tonemapping curve specified by TonemapPresetCurve.
+
+            If this mode is supported, then the TonemapPresetCurve control must
+            be supported as well.
+
+  - TonemapGamma:
+      type: float
+      description: |
+        Tonemapping curve to use when TonemapMode is TonemapModeGammaValue.
+        The tonemap curve will be defined by the following formula, OUT =
+        pow(IN, 1.0 / gamma) where IN and OUT is the input pixel value
+        scaled to range [0.0, 1.0], pow is the power function and gamma is
+        the gamma value specified by this key. The same curve will be
+        applied to all color channels. The camera device may clip the input
+        gamma value to its supported range. The actual applied value will
+        be returned in result metadata. The valid range of gamma values
+        varies on different devices, but values within [1.0, 5.0] are
+        guaranteed not to be clipped.
+
+  - TonemapPresetCurve:
+      type: int32_t
+      description: |
+        Tonemapping curve to use when TonemapMode is TonemapModePresetCurve.
+      enum:
+        - name: TonemapPresetCurveSRGB
+          value: 0
+          description: Tonemapping curve is defined by sRGB
+        - name: TonemapPresetCurveREC709
+          value: 1
+          description: Tonemapping curve is defined by ITU-R BT.709
+
+  - TonemapCurve:
+      type: float
+      description: |
+        Three arrays of [ [in, out], [in, out], ... ] format to describe a
+        tonemapping curve to be applied when TonemapMode is set to
+        TonemapModeContrastCurve. The first array is the tonemapping curve for
+        red, second for green, and third for blue. When returned in metadata,
+        this control will hold the tonemap curve used by the camera. Since the
+        actual pixel ranges of both input and output may change depending on
+        the camera, the values are specified by normalized floating point
+        numbers, in the range [0.0, 1.0].
+
+        The number of pairs N, representing the number of data points on the
+        tonemapping curve, shall be specified in TonemapCurveSize.
+
+        This control, TonemapCurveSize, and TonemapMode are the minimum required
+        controls for tonemapping support.
+      size: [3xNx2]
+
+  - TonemapCurveSize:
+      type: int32_t
+      description: |
+        The number of data points on the tonemapping curve specified or
+        reported in TonemapCurve. This control, TonemapCurve, and TonemapMode
+        are the minimum required controls for tonemapping support.
+
+
   # ----------------------------------------------------------------------------
   # Draft controls section