[libcamera-devel] [PATCH v3 5/5] libcamera: ipa: raspberrypi: ALSC: Handle user transform
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sun Aug 23 04:01:28 CEST 2020
Hi David,
Thank you for the patch.
On Fri, Aug 21, 2020 at 04:56:41PM +0100, David Plowman wrote:
> 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 at raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> src/ipa/raspberrypi/controller/rpi/alsc.cpp | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp
> index 9df713a..fdeda21 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 -
> @@ -429,6 +432,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 /
> @@ -441,6 +448,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++) {
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list