From patchwork Fri Sep 4 10:30:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9498 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 DA152BF6D3 for ; Fri, 4 Sep 2020 10:30:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A07ED62B68; Fri, 4 Sep 2020 12:30:55 +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="PCm4yE49"; dkim-atps=neutral Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A409D62B2F for ; Fri, 4 Sep 2020 12:30:53 +0200 (CEST) Received: by mail-wm1-x343.google.com with SMTP id a9so5597610wmm.2 for ; Fri, 04 Sep 2020 03:30:53 -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=PCm4yE49avK96QxjHNgOl3Of6MfscXKBm5hxXYBNrb94cF2TqGe0VosyKPVW2AzVe2 oHipLzahpvEOAA9HYqGHga6SS6may31mnR8zbm8hY2lBk9Zt18rd/L/4UhnkSQWY6WwR ypZl6R2nihtUnWtLEPDdD1aYaxUIX3LvroB8QwkwYqKMHoIHY1+w4aWm/5VwMgTaBskr TuDvjQJKQlY/PfNL7jvUugBu2vRdOlwJsjhRBWP+jgj8U2iIoUEIKG+REvN9MB9ItRUJ fKQkZUZd/grty00bQc5jDBR3oI/oFbFlj7Oy7uWl735NnLbWuMRZHst/N7cyr88MXDnj /P1A== 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=jBljvPhufSnIbBk8MId++EXrJBLiZWiRucOTDBOGym/5rfSWXcUYcNfLYvTxiEq+Vl G123vPm2QrKBgi9tZE/CrTl4LKaNOcLGRGXNgTLz62bkZYKRDc9cX4vfM6Pa97JM4eO/ 8MnKxb1E5rqxyItO0Bg0dxkG4fl4g2MAAbn3KE5tO34FAFi5HIV92ax77Z6QU5mCae6K F9M2ENKg6EeiN2LZ3cERgIdq97uS5enTP0t8AMk/BXIrEeCLlE6CuDXxZ3/936idIP5g wtWEIkB5EZJ21cbMlYSnNOfschzUPWI5uLQOvsC31JijCW3O+1etFKwJ7eTifiN8goPh b+xg== X-Gm-Message-State: AOAM533h5gCHeDlWe/J07XY2VmUvbD//bPgG6DT3UwzH6RlbQB9y0QW/ FlHcbdsnJdirZadSsU2xSKt69Se80huJzw== X-Google-Smtp-Source: ABdhPJyS/eS/xyBTZIJ2l7mLvrfjsEICcdfqR4QzL42D7pGHa3lkvui0cWMbARoVIN7K1toaE+gX0g== X-Received: by 2002:a7b:c958:: with SMTP id i24mr7234760wml.50.1599215453141; Fri, 04 Sep 2020 03:30:53 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id q4sm10294542wru.65.2020.09.04.03.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 03:30:52 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 4 Sep 2020 11:30:42 +0100 Message-Id: <20200904103042.1593-9-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200904103042.1593-1-david.plowman@raspberrypi.com> References: <20200904103042.1593-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v7 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++) {