ipa: rkisp1: cproc: Convert to use Quantized types
Convert the Brightness, Contrast and Saturation helper functions to a Quantizer type to support maintaining the data. While modifying the include blocks of the ipa_context.h, also fix the include style for libipa components. Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -39,16 +39,6 @@ constexpr float kDefaultBrightness = 0.0f;
|
||||
constexpr float kDefaultContrast = 1.0f;
|
||||
constexpr float kDefaultSaturation = 1.0f;
|
||||
|
||||
int convertBrightness(const float v)
|
||||
{
|
||||
return std::clamp<int>(std::lround(v * 128), -128, 127);
|
||||
}
|
||||
|
||||
int convertContrastOrSaturation(const float v)
|
||||
{
|
||||
return std::clamp<int>(std::lround(v * 128), 0, 255);
|
||||
}
|
||||
|
||||
} /* namespace */
|
||||
|
||||
/**
|
||||
@@ -74,9 +64,9 @@ int ColorProcessing::configure(IPAContext &context,
|
||||
{
|
||||
auto &cproc = context.activeState.cproc;
|
||||
|
||||
cproc.brightness = convertBrightness(kDefaultBrightness);
|
||||
cproc.contrast = convertContrastOrSaturation(kDefaultContrast);
|
||||
cproc.saturation = convertContrastOrSaturation(kDefaultSaturation);
|
||||
cproc.brightness = BrightnessQ(kDefaultBrightness);
|
||||
cproc.contrast = ContrastQ(kDefaultContrast);
|
||||
cproc.saturation = SaturationQ(kDefaultSaturation);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -97,7 +87,7 @@ void ColorProcessing::queueRequest(IPAContext &context,
|
||||
|
||||
const auto &brightness = controls.get(controls::Brightness);
|
||||
if (brightness) {
|
||||
int value = convertBrightness(*brightness);
|
||||
BrightnessQ value = *brightness;
|
||||
if (cproc.brightness != value) {
|
||||
cproc.brightness = value;
|
||||
update = true;
|
||||
@@ -108,7 +98,7 @@ void ColorProcessing::queueRequest(IPAContext &context,
|
||||
|
||||
const auto &contrast = controls.get(controls::Contrast);
|
||||
if (contrast) {
|
||||
int value = convertContrastOrSaturation(*contrast);
|
||||
ContrastQ value = *contrast;
|
||||
if (cproc.contrast != value) {
|
||||
cproc.contrast = value;
|
||||
update = true;
|
||||
@@ -119,7 +109,7 @@ void ColorProcessing::queueRequest(IPAContext &context,
|
||||
|
||||
const auto saturation = controls.get(controls::Saturation);
|
||||
if (saturation) {
|
||||
int value = convertContrastOrSaturation(*saturation);
|
||||
SaturationQ value = *saturation;
|
||||
if (cproc.saturation != value) {
|
||||
cproc.saturation = value;
|
||||
update = true;
|
||||
@@ -148,9 +138,9 @@ void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,
|
||||
|
||||
auto config = params->block<BlockType::Cproc>();
|
||||
config.setEnabled(true);
|
||||
config->brightness = frameContext.cproc.brightness;
|
||||
config->contrast = frameContext.cproc.contrast;
|
||||
config->sat = frameContext.cproc.saturation;
|
||||
config->brightness = frameContext.cproc.brightness.quantized();
|
||||
config->contrast = frameContext.cproc.contrast.quantized();
|
||||
config->sat = frameContext.cproc.saturation.quantized();
|
||||
}
|
||||
|
||||
REGISTER_IPA_ALGORITHM(ColorProcessing, "ColorProcessing")
|
||||
|
||||
@@ -24,14 +24,20 @@
|
||||
#include "libcamera/internal/matrix.h"
|
||||
#include "libcamera/internal/vector.h"
|
||||
|
||||
#include <libipa/camera_sensor_helper.h>
|
||||
#include <libipa/fc_queue.h>
|
||||
#include "libipa/agc_mean_luminance.h"
|
||||
#include "libipa/camera_sensor_helper.h"
|
||||
#include "libipa/fc_queue.h"
|
||||
#include "libipa/fixedpoint.h"
|
||||
|
||||
namespace libcamera {
|
||||
|
||||
namespace ipa::rkisp1 {
|
||||
|
||||
/* Fixed point types used by CPROC */
|
||||
using BrightnessQ = Q<1, 7>;
|
||||
using ContrastQ = UQ<1, 7>;
|
||||
using SaturationQ = UQ<1, 7>;
|
||||
|
||||
struct IPAHwSettings {
|
||||
unsigned int numAeCells;
|
||||
unsigned int numHistogramBins;
|
||||
@@ -111,9 +117,9 @@ struct IPAActiveState {
|
||||
} ccm;
|
||||
|
||||
struct {
|
||||
int8_t brightness;
|
||||
uint8_t contrast;
|
||||
uint8_t saturation;
|
||||
BrightnessQ brightness;
|
||||
ContrastQ contrast;
|
||||
SaturationQ saturation;
|
||||
} cproc;
|
||||
|
||||
struct {
|
||||
@@ -173,9 +179,10 @@ struct IPAFrameContext : public FrameContext {
|
||||
} awb;
|
||||
|
||||
struct {
|
||||
int8_t brightness;
|
||||
uint8_t contrast;
|
||||
uint8_t saturation;
|
||||
BrightnessQ brightness;
|
||||
ContrastQ contrast;
|
||||
SaturationQ saturation;
|
||||
|
||||
bool update;
|
||||
} cproc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user