[RFC,0/2] Add BitDepthValue for simplified bit depth conversion
mbox series

Message ID 20241127144655.1074720-1-isaac.scott@ideasonboard.com
Headers show
Series
  • Add BitDepthValue for simplified bit depth conversion
Related show

Message

Isaac Scott Nov. 27, 2024, 2:46 p.m. UTC
Following recent changes to black-level support, it can be unclear how we
define the type used to represent it. There are many instances within
the codebase where bitshifting is used inline to convert values from one
bit depth to another, or values have been converted manually from values
listed in datasheets.

This series implements a new BitDepthValue type that makes it explicit
what bit depth a value is intended to be. It also allows for the
abstraction of the process of converting values from one bit depth to
another, and allows users to assign values of one bit depth to another
without having to bitshift, improving readability and reducing
guesswork. It also avoids the possibility of human error that could
come into play when converting values to different bit depths manually,
and makes it easier to store black-level values in the form that better
matches the datasheets.

The camera_sensor_helper classes have been converted to use
BitDepthValue, and unit tests are included to verify the functionality
of the changes, as well as show how they can be used.

I have not included the Doxygen files yet, these will be handled if this
is an acceptable approach.


Isaac Scott (2):
  libcamera: bitdepth: Add BitDepth implementation
  libcamera: bitdepth: Adapt camera_sensor_helper to use BitDepth

 src/ipa/libipa/bitdepth.h               |  86 +++++++++++++++++++
 src/ipa/libipa/camera_sensor_helper.cpp |  18 ++--
 src/ipa/libipa/camera_sensor_helper.h   |   5 +-
 src/ipa/simple/algorithms/awb.cpp       |   3 +-
 src/ipa/simple/algorithms/blc.cpp       |  10 ++-
 src/ipa/simple/ipa_context.h            |   5 +-
 src/ipa/simple/soft_simple.cpp          |   5 +-
 test/ipa/libipa/bitdepth.cpp            | 107 ++++++++++++++++++++++++
 8 files changed, 218 insertions(+), 21 deletions(-)
 create mode 100644 src/ipa/libipa/bitdepth.h
 create mode 100644 test/ipa/libipa/bitdepth.cpp