From patchwork Sat Aug 29 11:54:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9434 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 650E8BF019 for ; Sat, 29 Aug 2020 11:54:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2DE1662949; Sat, 29 Aug 2020 13:54:45 +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="Uc2eS+Zh"; dkim-atps=neutral Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 94D466293D for ; Sat, 29 Aug 2020 13:54:41 +0200 (CEST) Received: by mail-wr1-x443.google.com with SMTP id w5so1545533wrp.8 for ; Sat, 29 Aug 2020 04:54:41 -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=Uc2eS+ZhSzmHaCXNo5noUxlX+hYu0qMKw7cPflvDH2sRPBhFGcLi4334Qxt6ChNE9y GRxJZaS4dXnpUMSxlvD999iQOOqaVEUUo2H1Qk3bdFX/MJKiu5ryQ4el1Y13xJ7CrIt9 /K0iiG5XI0ryZt2tloDpE/oN8Wq1n36XjZxcSA2OuH/ytQSoo2os1OgKnzTeitOWZVJC E5dMAGFcF6x56wSvwGupqeA9qpL+duP5jK2tyx5Uh9G+Q04u6LkwrARl0COxjXpUYC5n KB7Iiw5+xWgYoRbHZdF5KAT7h8tMQUBeg0Mza7Wt6xkH3KPXdDMcbldh+psEL/5syqVq slNA== 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=jB3DmbFU8UsIBICoDo7XnJYCZsDn1dU/Cu0YC6pMH9Yg7+IXw3glbwn4wUmKXC7DQT rq2XBQY6GUc0hEf4SiKYkD1W1md8AnTchhjmiZtDJ0RLJ7Hqlpc1JP3zjYt+NUyatFp+ UGj+bvrjTfyBYmsO7lD7XEJsTMgV5PX/AmWIHl+KpzSM17e0jY/15/JgL957Mk3q/Dqe J/mRm1DCzBFglU5yQgNuXEiWH9sXIOqYI1dgYO+8hInZsZ1F3YIkF/XVqF4BPkD06T5y tMQ4VQahJWYS9AnSHr/PmMDHlgaY0Jy+KHdDCnY06RS8dO2nqstFbus9tsOnJlF5Lcit ZvZg== X-Gm-Message-State: AOAM531Rm48ojDH5eSDjrrh4RxMgCCU8SD0oFRYJmGGrmUpFPFBLv743 s+fyz8vT2H+qo0pDggJGp19qRV9n5pOQiA== X-Google-Smtp-Source: ABdhPJwKKElD/Gy7KFniGN8PUW+FAbFYeS8r+8DWQv4tO4pzn+3SZ3bxgSt8kdGNUx2p4+bQGjDpWQ== X-Received: by 2002:adf:a48d:: with SMTP id g13mr3227683wrb.212.1598702081052; Sat, 29 Aug 2020 04:54:41 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id v16sm3071523wmj.14.2020.08.29.04.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Aug 2020 04:54:40 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Sat, 29 Aug 2020 12:54:29 +0100 Message-Id: <20200829115429.30010-9-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200829115429.30010-1-david.plowman@raspberrypi.com> References: <20200829115429.30010-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 --- 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++) {