[{"id":12096,"web_url":"https://patchwork.libcamera.org/comment/12096/","msgid":"<20200823020128.GF25161@pendragon.ideasonboard.com>","date":"2020-08-23T02:01:28","subject":"Re: [libcamera-devel] [PATCH v3 5/5] libcamera: ipa: raspberrypi:\n\tALSC: Handle user transform","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Fri, Aug 21, 2020 at 04:56:41PM +0100, David Plowman wrote:\n> Update ALSC (Auto Lens Shading Correction) to handle correctly the\n> user transform now passed in the camera mode.\n> \n> The user transform is applied directly in the sensor so the image\n> statistics already incorporate it, and the adaptive algorithm is\n> entirely agnostic towards it, so all we have to do is flip the\n> calibrated tables to match. (These tables will have been calibrated\n> without the user transform.)\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/ipa/raspberrypi/controller/rpi/alsc.cpp | 13 ++++++++++++-\n>  1 file changed, 12 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n> index 9df713a..fdeda21 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n> @@ -184,7 +184,10 @@ void Alsc::waitForAysncThread()\n>  \n>  static bool compare_modes(CameraMode const &cm0, CameraMode const &cm1)\n>  {\n> -\t// Return true if the modes crop from the sensor significantly differently.\n> +\t// Return true if the modes crop from the sensor significantly differently,\n> +\t// or if the user transform has changed.\n> +\tif (cm0.transform != cm1.transform)\n> +\t\treturn true;\n>  \tint left_diff = abs(cm0.crop_x - cm1.crop_x);\n>  \tint top_diff = abs(cm0.crop_y - cm1.crop_y);\n>  \tint right_diff = fabs(cm0.crop_x + cm0.scale_x * cm0.width -\n> @@ -429,6 +432,10 @@ void resample_cal_table(double const cal_table_in[XY],\n>  \t\txf[i] = x - x_lo[i];\n>  \t\tx_hi[i] = std::min(x_lo[i] + 1, X - 1);\n>  \t\tx_lo[i] = std::max(x_lo[i], 0);\n> +\t\tif (!!(camera_mode.transform & libcamera::Transform::HFlip)) {\n> +\t\t\tx_lo[i] = X - 1 - x_lo[i];\n> +\t\t\tx_hi[i] = X - 1 - x_hi[i];\n> +\t\t}\n>  \t}\n>  \t// Now march over the output table generating the new values.\n>  \tdouble scale_y = camera_mode.sensor_height /\n> @@ -441,6 +448,10 @@ void resample_cal_table(double const cal_table_in[XY],\n>  \t\tdouble yf = y - y_lo;\n>  \t\tint y_hi = std::min(y_lo + 1, Y - 1);\n>  \t\ty_lo = std::max(y_lo, 0);\n> +\t\tif (!!(camera_mode.transform & libcamera::Transform::VFlip)) {\n> +\t\t\ty_lo = Y - 1 - y_lo;\n> +\t\t\ty_hi = Y - 1 - y_hi;\n> +\t\t}\n>  \t\tdouble const *row_above = cal_table_in + X * y_lo;\n>  \t\tdouble const *row_below = cal_table_in + X * y_hi;\n>  \t\tfor (int i = 0; i < X; i++) {","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1F3B0BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 23 Aug 2020 02:01:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B4C8A626DB;\n\tSun, 23 Aug 2020 04:01:48 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6915360383\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 23 Aug 2020 04:01:47 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ECF60279;\n\tSun, 23 Aug 2020 04:01:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"XzPK2Syk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1598148107;\n\tbh=edJDchIQWOJ+Zerl2xmIXnIkDNnB6dtbeSKpWE5P55E=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=XzPK2SykQgT2Zb3aJ1s3vRX25ok9IzkXvBWp1xRULiexAYmtsq7pg/A2v60PW8K/5\n\tgrBw1dMpayqDWmyJSBjljeqfYDkG+hqMljBnaEECXuknzqDxTFSGRGjnRgmksQrPhz\n\tEOhoFMzhoHOPsQmgU13rzp0z5+A2NyG4RsJINgnA=","Date":"Sun, 23 Aug 2020 05:01:28 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<20200823020128.GF25161@pendragon.ideasonboard.com>","References":"<20200821155641.11839-1-david.plowman@raspberrypi.com>\n\t<20200821155641.11839-6-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200821155641.11839-6-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v3 5/5] libcamera: ipa: raspberrypi:\n\tALSC: Handle user transform","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]