From patchwork Mon Sep 7 07:16:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9509 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 245A2BDB1C for ; Mon, 7 Sep 2020 07:16:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E46E362BDF; Mon, 7 Sep 2020 09:16:17 +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="RTzFUwuj"; dkim-atps=neutral Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A64262B76 for ; Mon, 7 Sep 2020 09:16:15 +0200 (CEST) Received: by mail-wm1-x342.google.com with SMTP id x23so3375833wmi.3 for ; Mon, 07 Sep 2020 00:16:15 -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=NxN5BIHNXBiSe01AANUlWSLW1QWfFBaoWgYdFWkMoL4=; b=RTzFUwujm9BzOaFk5OLgQ6bRc5FSDm1VfUPz94ePjHCz3IHZ7wJUUFmcqsRmdRbeF5 pqi4kJzEEYIleELp7dv36+QwMuNXvxVevb+O+jv5zFNaI7q3Dz8/fyETquICkf7D/2v9 5TSpk8M34wUYy2Z60bNpFIaPzvMj/6pUz7rdGi7klae2/qcw6xlU6Ex05iZD2kr8+EgS pQEvXZMBATMcs4w6ual20bFebsIS1RGHhWP877pS7Z4mxhvEypBcMHXYQ8rFE5AlAqss CGfyDvz84hvbFRj3vsFUWLrI6l0IXcxoRBPB700jwE0PDG428GQGxVy4+mXdRCrGaZn9 LD/g== 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=NxN5BIHNXBiSe01AANUlWSLW1QWfFBaoWgYdFWkMoL4=; b=MC2GJEfPdWc3YgkqxmNCXxgPEukEAZL0WFuwOIrH5kz1HcAga3K63ripGvmKmH3D6N 1dCIOEuP5SggpRPWDNfu6Q2L+SHX8OdXRnfpvHPN0uDbcgowxzbDEnslizgTGX3c/RCY uWhw8MhSZSzGMNN8u8D9B3UR7jMmX+zRkv57htl+vGshsbwXEhPQuds/XnW0YUzWWQ+t uv5/KbGt4fWtLknFmq6AkQouFEF+wJC4PmgXObJeiJl9RF5o9txcdGJ3TMMY/cvAbo84 8nQcerdbshtdawg1xKCdXsp6D7A+Cl6fhvv41p+8VC3JRjxcR5eG4JU+KvbKhaUYhdWG yLrg== X-Gm-Message-State: AOAM532KyYdrAUVZqoHVzwh21u9r5xbNcBY/QUPUuX0JCo7liuADitYQ 9TqkcaGkIeNNfuf6GjvGckVdaKFqf0ZktQ== X-Google-Smtp-Source: ABdhPJypRFkz/Qr3dzEF7y46KZLDpmoo3yhuMKpwTCka+Sskhnlp3AdpUvbc0rDrMRTD+mNFdIfLAg== X-Received: by 2002:a1c:302:: with SMTP id 2mr18884498wmd.134.1599462975033; Mon, 07 Sep 2020 00:16:15 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id b2sm25543636wmh.47.2020.09.07.00.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2020 00:16:14 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 7 Sep 2020 08:16:03 +0100 Message-Id: <20200907071604.8355-9-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200907071604.8355-1-david.plowman@raspberrypi.com> References: <20200907071604.8355-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 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++) {