From patchwork Fri Aug 28 14:41: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: 9422 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 D40D9BF019 for ; Fri, 28 Aug 2020 14:41:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A1F176291C; Fri, 28 Aug 2020 16:41:25 +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="VwwNvkMQ"; dkim-atps=neutral Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 11254628F3 for ; Fri, 28 Aug 2020 16:41:23 +0200 (CEST) Received: by mail-wm1-x341.google.com with SMTP id t14so1132007wmi.3 for ; Fri, 28 Aug 2020 07:41:23 -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=VwwNvkMQdERJJyklkxtJ7tfuiRdOWY3LTtCGpXMr27vSDGXgVFV1+VijMM4HdnpDGS E5/Wuukod1gHpJ3k/lyw3T430EHhwoAAik9upH9rzG8lSPPSQ0mceaxhm65WyaKpGHaj 4DWkuGqgP89BsnQszxD1GB19+yV//dsklca1VcUGOCIDAgYP+V+iuuvAjIl9S4zSWM6g VAgd32cfqD2RtKsLbCWqiEXaspZZ/w+Yum4jeGS6h7fc9JNw46tVyOYVa++ODeP8UFu/ 7j+3OOS2inQUUYn3MIYgPJcQckZi1MwbHJPIs/4hjFXK4adLXyMXccmaiQfvoa+llIg5 d5iw== 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=YR5Rdbyb/DLIW6z6TCZSKSJklznHOC2WJwoHAJtNkE6saXWkN1C4QgoVdJsbm/D3AG mTRefH2xI2zI3gyKtgGxLGkjXUPkaQPtgS4hAsJ1mhG4KXrG/vez3K8i5H1+lsG7vrGP l7n+i8PekIIqVE30E7DDiHD8Y4oEO+K24GwL0g10GoIuVilk6ZHj27UyIzZwkTHSF7ZA pABrP94Gp0VzD/u0DejwXifFHdStaj9pg6ePjP880wrLxj6uPeAHLpDGDsm1VmVY5EpN ZVgm0Qq87oSkc0CeQkMKxQ3W4fWJmNUDm8Ty8bUjOiZaSmDb3aY8acSdD6hEiVOXKZFP 0a/g== X-Gm-Message-State: AOAM531+J8jynYVD9bI/kPx3L8pO1Gakrc4TOX3vE0aVKyNzTi95bmVt 3PIiYWo1SGZ59h7b542FCRf1Deo3CJil9A== X-Google-Smtp-Source: ABdhPJybbLoH3jpI5AH+zFSEaAQfwcLRkTxnnWNumnDYx4FwqQ0TCg4kOb6/uWqL54Ivs46wuWDGzg== X-Received: by 2002:a7b:c2aa:: with SMTP id c10mr1924450wmk.86.1598625682532; Fri, 28 Aug 2020 07:41:22 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id s12sm2493724wmj.26.2020.08.28.07.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 07:41:21 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 28 Aug 2020 15:41:10 +0100 Message-Id: <20200828144110.17303-8-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200828144110.17303-1-david.plowman@raspberrypi.com> References: <20200828144110.17303-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 7/7] 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 --- 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++) {