From patchwork Thu Aug 6 16:36:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9268 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 88DD2BD86F for ; Thu, 6 Aug 2020 16:36:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 55DE960BF7; Thu, 6 Aug 2020 18:36:58 +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="bwVCpo/u"; dkim-atps=neutral Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F5E860E00 for ; Thu, 6 Aug 2020 18:36:54 +0200 (CEST) Received: by mail-wm1-x32a.google.com with SMTP id x5so9417498wmi.2 for ; Thu, 06 Aug 2020 09:36:54 -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=pU4KCuTRMlbv0WdNJxhxE+59YkBpPb4btW7ceGvrAzo=; b=bwVCpo/ufljfPzwWZkOTeEfkDx9yaF/MKF9JfNKTZNryzOSilp6lZnhfl7uR8Cmn/J K6Tma8W6KufP4WMf08s95C6y0UFzmSnXgOv34Jcj9vSj8lGcHmOYKLukB2Bwygz+448l rKUioAFGJdsj4TtH1Z+WiXz/UNAhqpGSC7w9D+bLBJGl52vCdemhA/ttEvM38diH/gon r63xM9Lr9AXRKQ8gEJuygBDFn2TVu0V4wR7THNicLGgZ4xD43SCTG4uUauSAi6nEWMPV KjuJKIyZRMLBMdFmRwq7DH2QXLYkHYdZB7M5+vlW3uue/5KhVwjlBjVmu6uuyrvo+DIe y7aA== 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=pU4KCuTRMlbv0WdNJxhxE+59YkBpPb4btW7ceGvrAzo=; b=UF65Kd3bW9z8MSrLCTEuOX57P/XG9OfCisvzugshLNH/MK3zh5h1KGglntqol0ACzy RGSd6QltXFpUYHwGYVzrQqlj/V+ClJnjA9Fd9sCXsWl4JFrFkIkbQsOyXmkDaFFhPf40 NE+YAnS2X2Ns0rGEUurGaUov+Y4Imx0A7nXtZNnUW9yLTDHdCdXkdP/U8CW1iUawRL2+ K+vPb5JAMVaxF9UKBQQC4KOuN8YvOjkBBAvAF4SMmYkPhFUOrzAZK00/QonP+JZrUcDh bbcRP8Un8YWmcyfq0iDVb0vBxyKMhkHeXOWkqLcKGSgsNcSG0wFFMZ1ZlCQexu3XY1jB Q4GQ== X-Gm-Message-State: AOAM530BmECTZa4YoeEq5TyYeyTcVEdfOIZo7edcXjQeXhzMGfUHTXIv RS5TflVCi1D8Ptj83kMOnSHB7rUXqlYvpQ== X-Google-Smtp-Source: ABdhPJw0YLKejQph28OHGMu0hmW3YSmetRLmv6vBkdAIWXqJN4r1Y7RJwVd+i2lDrasTRJRFNviIFQ== X-Received: by 2002:a1c:678b:: with SMTP id b133mr9523240wmc.117.1596731813922; Thu, 06 Aug 2020 09:36:53 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id e5sm7405076wrc.37.2020.08.06.09.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 09:36:53 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 6 Aug 2020 17:36:39 +0100 Message-Id: <20200806163639.12971-6-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200806163639.12971-1-david.plowman@raspberrypi.com> References: <20200806163639.12971-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/5] 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.) --- 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++) {