diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2021-08-04 14:29:04 +0100 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2021-08-05 08:53:59 +0100 |
commit | e5e0ce6573ac91a76954eeaf89cd309a48fd333d (patch) | |
tree | be140b60881e297947da87c282edd31e9ee16b3f /src/ipa/ipu3/algorithms/contrast.cpp | |
parent | 9f1c38e2609cd8689aab901402188cd223c223b5 (diff) |
ipa: ipu3: Introduce a modular contrast algorithmipu3/modules
Implement a new modular framework for algorithms with a common context
structure that is passed to each algorithm through a common API.
The initial algorithm is chosen to configure the gamma contrast curve
which replicates the implementation from AWB for simplicity.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/ipu3/algorithms/contrast.cpp')
-rw-r--r-- | src/ipa/ipu3/algorithms/contrast.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/ipa/ipu3/algorithms/contrast.cpp b/src/ipa/ipu3/algorithms/contrast.cpp new file mode 100644 index 00000000..890dc3ff --- /dev/null +++ b/src/ipa/ipu3/algorithms/contrast.cpp @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Ideas On Board + * + * constrast.cpp - IPU3 Contrast and Gamma control + */ + +#include "contrast.h" + +#include <cmath> + +#include <libcamera/base/log.h> + +namespace libcamera { + +namespace ipa::ipu3::algorithms { + +LOG_DEFINE_CATEGORY(IPU3Contrast) + +Contrast::Contrast() + : gamma_(1.0) +{ +} + +void Contrast::initialise(IPAContext &context) +{ + ipu3_uapi_params ¶ms = context.params; + + /* Limit the gamma effect for now */ + gamma_ = 1.1; + + /* Plot the gamma curve into the look up table */ + for (uint32_t i = 0; i < 256; i++) { + double j = i / 255.0; + double gamma = std::pow(j, 1.0 / gamma_); + + /* The maximum value 255 is represented on 13 bits in the IPU3 */ + params.acc_param.gamma.gc_lut.lut[i] = gamma * 8191; + } + + LOG(IPU3Contrast, Info) << "Processed Gamma Curve"; +} + +} /* namespace ipa::ipu3::algorithms */ + +} /* namespace libcamera */ |