From patchwork Fri Aug 21 15:56:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9353 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 290AABE173 for ; Fri, 21 Aug 2020 15:57:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E7B70620AD; Fri, 21 Aug 2020 17:57:10 +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="Am6TeCs3"; dkim-atps=neutral Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E3C562704 for ; Fri, 21 Aug 2020 17:57:07 +0200 (CEST) Received: by mail-wr1-x441.google.com with SMTP id f7so2432408wrw.1 for ; Fri, 21 Aug 2020 08:57:07 -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=CCMHN5/Ef9RcmUox9fxFCH7C4LVbiHbauYbkuYeFGYA=; b=Am6TeCs3+SEtS0qivg5ERPIfHQmpMAMJ6YKML21JitppBk6bT2dZP87e1oJyPp8dZ5 UNc7QOT5fpUjQuixXiFH0IGt6N2ymCtCOdcYR8qz1rc7m15IKyYXjbDWTKS/I6vLInzu xONi6RJTwcLnKjW0XQiz65du670PJyhs9gugVihqlLneshzKpWcw5sd7f6uadfdOHGKp 0vclNPQyUY6Q5tggzgCefpHAS8ObYJ6KvRqLBMYin/+AbO4pXOK7DVGuFMcxlLoffF3b O9R5/PmRsK7O5lkAHCzDNmHhTXhnp3ZWmJR8D6yCvwetWMaCPpMuLGHRNFa1ByTZRZp8 63GA== 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=CCMHN5/Ef9RcmUox9fxFCH7C4LVbiHbauYbkuYeFGYA=; b=XBCDbB6gBUjLNR7B5i6SGecD3p1fLFElybMKbkFN4UkYEApV8snNlOeWaXvylmAMBG uAQHca4yA0y6huLmmL7TzwMK5aX77oV+OXKNQA19S96qQPxiscdC43jz9n6sOIsbPvx6 t6PrfzhwhEXNH2QEnMZt6WiX5UWDQSsgUOlGzD26eLoib2i6lBCTeIvekzRdp43LI48i gJ8WLoXyYxYXCZfIXBPRFp3yWFBzktSGF+j0grNDtvXFs4PNuzrH7G9GCFeAp+8NWsmG ATN55rzgspX/f+IhYjvAl0rXhPbitsr2XBTd3DhobcTSmLSIbEvHsOQSmhptniNJK5Mv yZlQ== X-Gm-Message-State: AOAM531W5cinqef29otDbn1fcYAQ6Ivy/ORLI4BW0NnKLc3sT3NYiqtN 59rQqfzot7Cx4MklRGMSdauLCvNoSu6Vcg== X-Google-Smtp-Source: ABdhPJwaKFw8Gyc41gG8l8+BsGim/mx9GAqd1MFocns88emCOnv08ghE2Du6oPOCbPGCaXGWJ7r7Dg== X-Received: by 2002:a5d:4ccb:: with SMTP id c11mr3253864wrt.159.1598025426242; Fri, 21 Aug 2020 08:57:06 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id l11sm5627385wme.11.2020.08.21.08.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 08:57:05 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 21 Aug 2020 16:56:41 +0100 Message-Id: <20200821155641.11839-6-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200821155641.11839-1-david.plowman@raspberrypi.com> References: <20200821155641.11839-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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.) 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 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++) {