From patchwork Wed Sep 2 10:44:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9451 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 197C0BF019 for ; Wed, 2 Sep 2020 10:44:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D656C629D3; Wed, 2 Sep 2020 12:44:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ZwvaOowv"; dkim-atps=neutral Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C5F9B629AB for ; Wed, 2 Sep 2020 12:44:22 +0200 (CEST) Received: by mail-wr1-x444.google.com with SMTP id a17so4700181wrn.6 for ; Wed, 02 Sep 2020 03:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yqzzfDnOwH0Awzrjn/UOHYIemK1WmVNHkZJX33QDD+s=; b=ZwvaOowveWeD+SW6jS8jSoKJMigRiGrFJbRl5+53y8GVEBRjqCwazzM+yGhN+ao9l3 T+PFgOBLl5VpOLCIgd6hZfQApFoWCouqdQIeedP72r/4vwNwZfgMSMvqu3tO/LAHrg11 GLhJxiannlpUaNqgE3msAAUkDT1Kyk8Ncw29E7MJAAseFTzx1DpCqk4c3enDvbrd7LiN K93xx0HEp2cx9tzoFptnyeIkdoWefd3DwJ/HKaM7RRR0jAYcsEg4i07KSK40a75fAgNC u3EB4ojezGSO8s2myQM3+U61HCMp+caoSyZlgYm2RNhOISZ8yjfSELrpEpu5limXnfwf lmQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yqzzfDnOwH0Awzrjn/UOHYIemK1WmVNHkZJX33QDD+s=; b=AnYbihtSOaXrE6NEDEgkrkFqO1Xg3+Y8vtdAnkhfwhFmHHwDIRmyX4BQGyVws22WAj AhcElsInN45RPpOPXvzMtOvbrxdxTgoAf8zTsg3xzf8sBrPt/fDkfNJATzWc1A5bEoKG 6/irsq6reU4KhfZrkbjcZWNHpfWf2Bc4AC1raqtZ9354wcTwWWZeoZKbpkaHoZBFjnTQ PKDkN76qqmehhStrhF0FtWoi7S583FCG2JHbtAlKzCypvOgCyjnQZNF4XVpa9KpF2nmn iSuEIsaEZLlh8BZRfWW7/K+yKGRiRm5hX7TIg1v8MMfd1j7SANe/WRRrBON27zHpq6F8 5SbA== X-Gm-Message-State: AOAM530IaTkpfjMucfXfE0jknFJottRgZ/3FIMtPSmihwo4GFxDZAODA 0O1HHQScqES/mno7GnQJmR6H8tgmjAfpVg== X-Google-Smtp-Source: ABdhPJyS7lxt3LkKx6YKNLxxyydHJAPRPF+BTbO67IL1ApYB+ytEBN304gLik05wTL9oFyt45mMyLA== X-Received: by 2002:a5d:5106:: with SMTP id s6mr7036332wrt.166.1599043462076; Wed, 02 Sep 2020 03:44:22 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id m3sm5583062wmb.26.2020.09.02.03.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 03:44:21 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 2 Sep 2020 11:44:10 +0100 Message-Id: <20200902104410.7569-9-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200902104410.7569-1-david.plowman@raspberrypi.com> References: <20200902104410.7569-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 8/8] libcamera: ipa: raspberrypi: ALSC: Handle user transform X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- 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 0d0e0b0..f610de2 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++) {