ipa: rkisp1: cproc: Store per-frame information in frame context
Rework the algorithm's usage of the active state, to store the value of controls for the last queued request in the queueRequest() function, and store a copy of the values in the corresponding frame context. The latter is used in the prepare() function to populate the ISP parameters with values corresponding to the right frame. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
128f22bce5
commit
cb08adffe2
3 changed files with 56 additions and 24 deletions
|
@ -38,55 +38,66 @@ LOG_DEFINE_CATEGORY(RkISP1CProc)
|
||||||
*/
|
*/
|
||||||
void ColorProcessing::queueRequest(IPAContext &context,
|
void ColorProcessing::queueRequest(IPAContext &context,
|
||||||
[[maybe_unused]] const uint32_t frame,
|
[[maybe_unused]] const uint32_t frame,
|
||||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
const ControlList &controls)
|
const ControlList &controls)
|
||||||
{
|
{
|
||||||
auto &cproc = context.activeState.cproc;
|
auto &cproc = context.activeState.cproc;
|
||||||
|
bool update = false;
|
||||||
|
|
||||||
const auto &brightness = controls.get(controls::Brightness);
|
const auto &brightness = controls.get(controls::Brightness);
|
||||||
if (brightness) {
|
if (brightness) {
|
||||||
cproc.brightness = std::clamp<int>(std::lround(*brightness * 128), -128, 127);
|
int value = std::clamp<int>(std::lround(*brightness * 128), -128, 127);
|
||||||
cproc.updateParams = true;
|
if (cproc.brightness != value) {
|
||||||
|
cproc.brightness = value;
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
|
||||||
LOG(RkISP1CProc, Debug) << "Set brightness to " << *brightness;
|
LOG(RkISP1CProc, Debug) << "Set brightness to " << value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &contrast = controls.get(controls::Contrast);
|
const auto &contrast = controls.get(controls::Contrast);
|
||||||
if (contrast) {
|
if (contrast) {
|
||||||
cproc.contrast = std::clamp<int>(std::lround(*contrast * 128), 0, 255);
|
int value = std::clamp<int>(std::lround(*contrast * 128), 0, 255);
|
||||||
cproc.updateParams = true;
|
if (cproc.contrast != value) {
|
||||||
|
cproc.contrast = value;
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
|
||||||
LOG(RkISP1CProc, Debug) << "Set contrast to " << *contrast;
|
LOG(RkISP1CProc, Debug) << "Set contrast to " << value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto saturation = controls.get(controls::Saturation);
|
const auto saturation = controls.get(controls::Saturation);
|
||||||
if (saturation) {
|
if (saturation) {
|
||||||
cproc.saturation = std::clamp<int>(std::lround(*saturation * 128), 0, 255);
|
int value = std::clamp<int>(std::lround(*saturation * 128), 0, 255);
|
||||||
cproc.updateParams = true;
|
if (cproc.saturation != value) {
|
||||||
|
cproc.saturation = value;
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
|
||||||
LOG(RkISP1CProc, Debug) << "Set saturation to " << *saturation;
|
LOG(RkISP1CProc, Debug) << "Set saturation to " << value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frameContext.cproc.brightness = cproc.brightness;
|
||||||
|
frameContext.cproc.contrast = cproc.contrast;
|
||||||
|
frameContext.cproc.saturation = cproc.saturation;
|
||||||
|
frameContext.cproc.update = update;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||||
*/
|
*/
|
||||||
void ColorProcessing::prepare(IPAContext &context,
|
void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,
|
||||||
[[maybe_unused]] const uint32_t frame,
|
[[maybe_unused]] const uint32_t frame,
|
||||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params)
|
rkisp1_params_cfg *params)
|
||||||
{
|
{
|
||||||
auto &cproc = context.activeState.cproc;
|
|
||||||
|
|
||||||
/* Check if the algorithm configuration has been updated. */
|
/* Check if the algorithm configuration has been updated. */
|
||||||
if (!cproc.updateParams)
|
if (!frameContext.cproc.update)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cproc.updateParams = false;
|
params->others.cproc_config.brightness = frameContext.cproc.brightness;
|
||||||
|
params->others.cproc_config.contrast = frameContext.cproc.contrast;
|
||||||
params->others.cproc_config.brightness = cproc.brightness;
|
params->others.cproc_config.sat = frameContext.cproc.saturation;
|
||||||
params->others.cproc_config.contrast = cproc.contrast;
|
|
||||||
params->others.cproc_config.sat = cproc.saturation;
|
|
||||||
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_CPROC;
|
params->module_en_update |= RKISP1_CIF_ISP_MODULE_CPROC;
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_CPROC;
|
params->module_ens |= RKISP1_CIF_ISP_MODULE_CPROC;
|
||||||
|
|
|
@ -160,9 +160,6 @@ namespace libcamera::ipa::rkisp1 {
|
||||||
*
|
*
|
||||||
* \var IPAActiveState::cproc.saturation
|
* \var IPAActiveState::cproc.saturation
|
||||||
* \brief Saturation level
|
* \brief Saturation level
|
||||||
*
|
|
||||||
* \var IPAActiveState::cproc.updateParams
|
|
||||||
* \brief Indicates if ISP parameters need to be updated
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,6 +233,24 @@ namespace libcamera::ipa::rkisp1 {
|
||||||
* \brief Whether the Auto White Balance algorithm is enabled
|
* \brief Whether the Auto White Balance algorithm is enabled
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \var IPAFrameContext::cproc
|
||||||
|
* \brief Color Processing parameters for this frame
|
||||||
|
*
|
||||||
|
* \struct IPAFrameContext::cproc.brightness
|
||||||
|
* \brief Brightness level
|
||||||
|
*
|
||||||
|
* \var IPAFrameContext::cproc.contrast
|
||||||
|
* \brief Contrast level
|
||||||
|
*
|
||||||
|
* \var IPAFrameContext::cproc.saturation
|
||||||
|
* \brief Saturation level
|
||||||
|
*
|
||||||
|
* \var IPAFrameContext::cproc.update
|
||||||
|
* \brief Indicates if the color processing parameters have been updated
|
||||||
|
* compared to the previous frame
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \var IPAFrameContext::sensor
|
* \var IPAFrameContext::sensor
|
||||||
* \brief Sensor configuration that used been used for this frame
|
* \brief Sensor configuration that used been used for this frame
|
||||||
|
|
|
@ -75,7 +75,6 @@ struct IPAActiveState {
|
||||||
int8_t brightness;
|
int8_t brightness;
|
||||||
uint8_t contrast;
|
uint8_t contrast;
|
||||||
uint8_t saturation;
|
uint8_t saturation;
|
||||||
bool updateParams;
|
|
||||||
} cproc;
|
} cproc;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -107,6 +106,13 @@ struct IPAFrameContext : public FrameContext {
|
||||||
bool autoEnabled;
|
bool autoEnabled;
|
||||||
} awb;
|
} awb;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int8_t brightness;
|
||||||
|
uint8_t contrast;
|
||||||
|
uint8_t saturation;
|
||||||
|
bool update;
|
||||||
|
} cproc;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint32_t exposure;
|
uint32_t exposure;
|
||||||
double gain;
|
double gain;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue