summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/alsc.cpp
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2020-09-07 08:16:03 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2020-09-29 11:43:07 +0100
commit94b667b43f735fa27d2ded854d112048e5b2dc0d (patch)
treeb04e14d6340620a350db2a7e03c7d38e05c3f3fc /src/ipa/raspberrypi/controller/rpi/alsc.cpp
parent5c32a0daf5c3ce59491b043bd2e3efd1f7a7d224 (diff)
libcamera: ipa: raspberrypi: ALSC: Handle user transform
Update ALSC (Auto Lens Shading Correction) to handle correctly the user transform now passed in the camera mode. The user transform is applied directly in the sensor so the image statistics already incorporate it, and the adaptive algorithm is entirely agnostic towards it, so all we have to do is flip the calibrated tables to match. (These tables will have been calibrated without the user transform.) Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/alsc.cpp')
-rw-r--r--src/ipa/raspberrypi/controller/rpi/alsc.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp
index 0d0e0b0c..f610de25 100644
--- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp
@@ -184,7 +184,10 @@ void Alsc::waitForAysncThread()
static bool compare_modes(CameraMode const &cm0, CameraMode const &cm1)
{
- // Return true if the modes crop from the sensor significantly differently.
+ // Return true if the modes crop from the sensor significantly differently,
+ // or if the user transform has changed.
+ if (cm0.transform != cm1.transform)
+ return true;
int left_diff = abs(cm0.crop_x - cm1.crop_x);
int top_diff = abs(cm0.crop_y - cm1.crop_y);
int right_diff = fabs(cm0.crop_x + cm0.scale_x * cm0.width -
@@ -428,6 +431,10 @@ void resample_cal_table(double const cal_table_in[XY],
xf[i] = x - x_lo[i];
x_hi[i] = std::min(x_lo[i] + 1, X - 1);
x_lo[i] = std::max(x_lo[i], 0);
+ if (!!(camera_mode.transform & libcamera::Transform::HFlip)) {
+ x_lo[i] = X - 1 - x_lo[i];
+ x_hi[i] = X - 1 - x_hi[i];
+ }
}
// Now march over the output table generating the new values.
double scale_y = camera_mode.sensor_height /
@@ -440,6 +447,10 @@ void resample_cal_table(double const cal_table_in[XY],
double yf = y - y_lo;
int y_hi = std::min(y_lo + 1, Y - 1);
y_lo = std::max(y_lo, 0);
+ if (!!(camera_mode.transform & libcamera::Transform::VFlip)) {
+ y_lo = Y - 1 - y_lo;
+ y_hi = Y - 1 - y_hi;
+ }
double const *row_above = cal_table_in + X * y_lo;
double const *row_below = cal_table_in + X * y_hi;
for (int i = 0; i < X; i++) {