ipa: rkisp1: Implement LensShadingCorrectionEnable control
Implement the LensShadingCorrectionEnable control for rkisp1. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Tested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
@@ -233,7 +233,7 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame,
|
||||
*strengthConfig = strengthConfig_;
|
||||
|
||||
const auto &awb = context.configuration.awb;
|
||||
const auto &lsc = context.configuration.lsc;
|
||||
const auto &lsc = context.activeState.lsc;
|
||||
|
||||
auto &mode = config->gain.mode;
|
||||
|
||||
|
||||
@@ -416,6 +416,9 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
context.ctrlMap[&controls::LensShadingCorrectionEnable] =
|
||||
ControlInfo(false, true, true);
|
||||
|
||||
shadingDescriptors_ = std::move(lscData);
|
||||
|
||||
return 0;
|
||||
@@ -460,7 +463,7 @@ int LensShadingCorrection::configure(IPAContext &context,
|
||||
|
||||
sets_.setData(std::move(shadingData));
|
||||
|
||||
context.configuration.lsc.enabled = true;
|
||||
context.activeState.lsc.enabled = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -481,6 +484,29 @@ void LensShadingCorrection::copyTable(rkisp1_cif_isp_lsc_config &config,
|
||||
std::copy(set.b.begin(), set.b.end(), &config.b_data_tbl[0][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* \copydoc libcamera::ipa::Algorithm::queueRequest
|
||||
*/
|
||||
void LensShadingCorrection::queueRequest(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
const ControlList &controls)
|
||||
{
|
||||
auto &lsc = context.activeState.lsc;
|
||||
|
||||
const auto &lscEnable = controls.get(controls::LensShadingCorrectionEnable);
|
||||
if (lscEnable && *lscEnable != lsc.enabled) {
|
||||
lsc.enabled = *lscEnable;
|
||||
|
||||
LOG(RkISP1Lsc, Debug)
|
||||
<< (lsc.enabled ? "Enabling" : "Disabling") << " Lsc";
|
||||
|
||||
frameContext.lsc.update = true;
|
||||
}
|
||||
|
||||
frameContext.lsc.enabled = lsc.enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
@@ -492,18 +518,28 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,
|
||||
uint32_t ct = frameContext.awb.temperatureK;
|
||||
unsigned int quantizedCt = quantize(ct, kColourTemperatureQuantization);
|
||||
|
||||
/*
|
||||
* Add a threshold so that oscillations around a quantization step don't
|
||||
* lead to constant changes.
|
||||
*/
|
||||
if (utils::abs_diff(ct, lastAppliedCt_) < kColourTemperatureQuantization / 2)
|
||||
return;
|
||||
/* Check if we can skip the update. */
|
||||
if (!frameContext.lsc.update) {
|
||||
if (!frameContext.lsc.enabled)
|
||||
return;
|
||||
|
||||
if (quantizedCt == lastAppliedQuantizedCt_)
|
||||
return;
|
||||
/*
|
||||
* Add a threshold so that oscillations around a quantization
|
||||
* step don't lead to constant changes.
|
||||
*/
|
||||
if (utils::abs_diff(ct, lastAppliedCt_) < kColourTemperatureQuantization / 2)
|
||||
return;
|
||||
|
||||
if (quantizedCt == lastAppliedQuantizedCt_)
|
||||
return;
|
||||
}
|
||||
|
||||
auto config = params->block<BlockType::Lsc>();
|
||||
config.setEnabled(true);
|
||||
config.setEnabled(frameContext.lsc.enabled);
|
||||
|
||||
if (!frameContext.lsc.enabled)
|
||||
return;
|
||||
|
||||
setParameters(*config);
|
||||
|
||||
const Components &set = sets_.getInterpolated(quantizedCt);
|
||||
@@ -517,6 +553,18 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,
|
||||
<< quantizedCt;
|
||||
}
|
||||
|
||||
/**
|
||||
* \copydoc libcamera::ipa::Algorithm::process
|
||||
*/
|
||||
void LensShadingCorrection::process([[maybe_unused]] IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
[[maybe_unused]] const rkisp1_stat_buffer *stats,
|
||||
ControlList &metadata)
|
||||
{
|
||||
metadata.set(controls::LensShadingCorrectionEnable, frameContext.lsc.enabled);
|
||||
}
|
||||
|
||||
REGISTER_IPA_ALGORITHM(LensShadingCorrection, "LensShadingCorrection")
|
||||
|
||||
} /* namespace ipa::rkisp1::algorithms */
|
||||
|
||||
@@ -26,9 +26,16 @@ public:
|
||||
|
||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||
int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;
|
||||
void queueRequest(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
const ControlList &controls) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
RkISP1Params *params) override;
|
||||
void process(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
const rkisp1_stat_buffer *stats,
|
||||
ControlList &metadata) override;
|
||||
|
||||
struct Components {
|
||||
std::vector<uint16_t> r;
|
||||
|
||||
@@ -55,10 +55,6 @@ struct IPASessionConfiguration {
|
||||
bool supported;
|
||||
} compress;
|
||||
|
||||
struct {
|
||||
bool enabled;
|
||||
} lsc;
|
||||
|
||||
struct {
|
||||
utils::Duration minExposureTime;
|
||||
utils::Duration maxExposureTime;
|
||||
@@ -143,6 +139,10 @@ struct IPAActiveState {
|
||||
double gain;
|
||||
double strength;
|
||||
} wdr;
|
||||
|
||||
struct {
|
||||
bool enabled;
|
||||
} lsc;
|
||||
};
|
||||
|
||||
struct IPAFrameContext : public FrameContext {
|
||||
@@ -218,6 +218,11 @@ struct IPAFrameContext : public FrameContext {
|
||||
double strength;
|
||||
double gain;
|
||||
} wdr;
|
||||
|
||||
struct {
|
||||
bool enabled;
|
||||
bool update;
|
||||
} lsc;
|
||||
};
|
||||
|
||||
struct IPAContext {
|
||||
|
||||
Reference in New Issue
Block a user