libcamera: ipa: simple: Move contrast settings to adjust.cpp
Let's move the contrast settings from lut.cpp to adjust.cpp, where they belong, similarly to saturation. Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Robert Mader <robert.mader@collabora.com> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
d92f5f5402
commit
e8e2bd39f9
@@ -23,6 +23,7 @@ LOG_DEFINE_CATEGORY(IPASoftAdjust)
|
||||
|
||||
int Adjust::init(IPAContext &context, [[maybe_unused]] const YamlObject &tuningData)
|
||||
{
|
||||
context.ctrlMap[&controls::Contrast] = ControlInfo(0.0f, 2.0f, 1.0f);
|
||||
if (context.ccmEnabled)
|
||||
context.ctrlMap[&controls::Saturation] = ControlInfo(0.0f, 2.0f, 1.0f);
|
||||
return 0;
|
||||
@@ -31,6 +32,7 @@ int Adjust::init(IPAContext &context, [[maybe_unused]] const YamlObject &tuningD
|
||||
int Adjust::configure(IPAContext &context,
|
||||
[[maybe_unused]] const IPAConfigInfo &configInfo)
|
||||
{
|
||||
context.activeState.knobs.contrast = std::optional<double>();
|
||||
context.activeState.knobs.saturation = std::optional<double>();
|
||||
|
||||
return 0;
|
||||
@@ -41,6 +43,12 @@ void Adjust::queueRequest(typename Module::Context &context,
|
||||
[[maybe_unused]] typename Module::FrameContext &frameContext,
|
||||
const ControlList &controls)
|
||||
{
|
||||
const auto &contrast = controls.get(controls::Contrast);
|
||||
if (contrast.has_value()) {
|
||||
context.activeState.knobs.contrast = contrast;
|
||||
LOG(IPASoftAdjust, Debug) << "Setting contrast to " << contrast.value();
|
||||
}
|
||||
|
||||
const auto &saturation = controls.get(controls::Saturation);
|
||||
if (saturation.has_value()) {
|
||||
context.activeState.knobs.saturation = saturation;
|
||||
@@ -75,6 +83,8 @@ void Adjust::prepare(IPAContext &context,
|
||||
IPAFrameContext &frameContext,
|
||||
[[maybe_unused]] DebayerParams *params)
|
||||
{
|
||||
frameContext.contrast = context.activeState.knobs.contrast;
|
||||
|
||||
if (!context.ccmEnabled)
|
||||
return;
|
||||
|
||||
@@ -95,6 +105,10 @@ void Adjust::process([[maybe_unused]] IPAContext &context,
|
||||
[[maybe_unused]] const SwIspStats *stats,
|
||||
ControlList &metadata)
|
||||
{
|
||||
const auto &contrast = frameContext.contrast;
|
||||
if (contrast)
|
||||
metadata.set(controls::Contrast, contrast.value());
|
||||
|
||||
const auto &saturation = frameContext.saturation;
|
||||
metadata.set(controls::Saturation, saturation.value_or(1.0));
|
||||
}
|
||||
|
||||
@@ -24,36 +24,16 @@ LOG_DEFINE_CATEGORY(IPASoftLut)
|
||||
|
||||
namespace ipa::soft::algorithms {
|
||||
|
||||
int Lut::init(IPAContext &context,
|
||||
[[maybe_unused]] const YamlObject &tuningData)
|
||||
{
|
||||
context.ctrlMap[&controls::Contrast] = ControlInfo(0.0f, 2.0f, 1.0f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Lut::configure(IPAContext &context,
|
||||
[[maybe_unused]] const IPAConfigInfo &configInfo)
|
||||
{
|
||||
/* Gamma value is fixed */
|
||||
context.configuration.gamma = 1.0 / 2.2;
|
||||
context.activeState.knobs.contrast = std::optional<double>();
|
||||
updateGammaTable(context);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Lut::queueRequest(typename Module::Context &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] typename Module::FrameContext &frameContext,
|
||||
const ControlList &controls)
|
||||
{
|
||||
const auto &contrast = controls.get(controls::Contrast);
|
||||
if (contrast.has_value()) {
|
||||
context.activeState.knobs.contrast = contrast;
|
||||
LOG(IPASoftLut, Debug) << "Setting contrast to " << contrast.value();
|
||||
}
|
||||
}
|
||||
|
||||
void Lut::updateGammaTable(IPAContext &context)
|
||||
{
|
||||
const auto blackLevel = context.activeState.blc.level;
|
||||
@@ -96,11 +76,9 @@ int16_t Lut::matrixValue(unsigned int i, float ccm) const
|
||||
|
||||
void Lut::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
DebayerParams *params)
|
||||
{
|
||||
frameContext.contrast = context.activeState.knobs.contrast;
|
||||
|
||||
/*
|
||||
* Update the gamma table if needed. This means if black level changes
|
||||
* and since the black level gets updated only if a lower value is
|
||||
@@ -157,17 +135,6 @@ void Lut::prepare(IPAContext &context,
|
||||
params->contrastExp = context.activeState.gamma.contrastExp;
|
||||
}
|
||||
|
||||
void Lut::process([[maybe_unused]] IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
[[maybe_unused]] const SwIspStats *stats,
|
||||
ControlList &metadata)
|
||||
{
|
||||
const auto &contrast = frameContext.contrast;
|
||||
if (contrast)
|
||||
metadata.set(controls::Contrast, contrast.value());
|
||||
}
|
||||
|
||||
REGISTER_IPA_ALGORITHM(Lut, "Lut")
|
||||
|
||||
} /* namespace ipa::soft::algorithms */
|
||||
|
||||
@@ -19,22 +19,11 @@ public:
|
||||
Lut() = default;
|
||||
~Lut() = default;
|
||||
|
||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
|
||||
void queueRequest(typename Module::Context &context,
|
||||
const uint32_t frame,
|
||||
typename Module::FrameContext &frameContext,
|
||||
const ControlList &controls)
|
||||
override;
|
||||
void prepare(IPAContext &context,
|
||||
const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
DebayerParams *params) override;
|
||||
void process(IPAContext &context,
|
||||
const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
const SwIspStats *stats,
|
||||
ControlList &metadata) override;
|
||||
|
||||
private:
|
||||
void updateGammaTable(IPAContext &context);
|
||||
|
||||
Reference in New Issue
Block a user