ipa: raspberrypi: Replace Raspberry Pi debug with libcamera debug

This commit deals with all the "small" algorithms (that is, not
Agc/Awb/Alsc). A few unnecessary debug messages have also been
removed.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
David Plowman 2021-01-25 18:48:57 +00:00 committed by Laurent Pinchart
parent eb605eab5b
commit d97b1bcd2a
9 changed files with 97 additions and 45 deletions

View file

@ -6,12 +6,17 @@
*/
#include <stdint.h>
#include "libcamera/internal/log.h"
#include "../contrast_status.h"
#include "../histogram.hpp"
#include "contrast.hpp"
using namespace RPiController;
using namespace libcamera;
LOG_DEFINE_CATEGORY(RPiContrast)
// This is a very simple control algorithm which simply retrieves the results of
// AGC and AWB via their "status" metadata, and applies digital gain to the
@ -97,11 +102,13 @@ Pwl compute_stretch_curve(Histogram const &histogram,
double hist_lo = histogram.Quantile(config.lo_histogram) *
(65536 / NUM_HISTOGRAM_BINS);
double level_lo = config.lo_level * 65536;
RPI_LOG("Move histogram point " << hist_lo << " to " << level_lo);
LOG(RPiContrast, Debug)
<< "Move histogram point " << hist_lo << " to " << level_lo;
hist_lo = std::max(
level_lo,
std::min(65535.0, std::min(hist_lo, level_lo + config.lo_max)));
RPI_LOG("Final values " << hist_lo << " -> " << level_lo);
LOG(RPiContrast, Debug)
<< "Final values " << hist_lo << " -> " << level_lo;
enhance.Append(hist_lo, level_lo);
// Keep the mid-point (median) in the same place, though, to limit the
// apparent amount of global brightness shift.
@ -113,11 +120,13 @@ Pwl compute_stretch_curve(Histogram const &histogram,
double hist_hi = histogram.Quantile(config.hi_histogram) *
(65536 / NUM_HISTOGRAM_BINS);
double level_hi = config.hi_level * 65536;
RPI_LOG("Move histogram point " << hist_hi << " to " << level_hi);
LOG(RPiContrast, Debug)
<< "Move histogram point " << hist_hi << " to " << level_hi;
hist_hi = std::min(
level_hi,
std::max(0.0, std::max(hist_hi, level_hi - config.hi_max)));
RPI_LOG("Final values " << hist_hi << " -> " << level_hi);
LOG(RPiContrast, Debug)
<< "Final values " << hist_hi << " -> " << level_hi;
enhance.Append(hist_hi, level_hi);
enhance.Append(65535, 65535);
return enhance;
@ -127,7 +136,8 @@ Pwl apply_manual_contrast(Pwl const &gamma_curve, double brightness,
double contrast)
{
Pwl new_gamma_curve;
RPI_LOG("Manual brightness " << brightness << " contrast " << contrast);
LOG(RPiContrast, Debug)
<< "Manual brightness " << brightness << " contrast " << contrast;
gamma_curve.Map([&](double x, double y) {
new_gamma_curve.Append(
x, std::max(0.0, std::min(65535.0,