[{"id":27960,"web_url":"https://patchwork.libcamera.org/comment/27960/","msgid":"<mlj6bfy6b4brdkhuyo2ebp3jvo2keolvm2narsntw5sru5vpzs@jom7fsuikpcd>","date":"2023-10-12T10:52:52","subject":"Re: [libcamera-devel] [PATCH 17/20] ipa: rpi: contrast: Allow\n\tadaptive contrast enhancement to be disabled","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Naush\n\nOn Fri, Oct 06, 2023 at 02:19:57PM +0100, Naushir Patuck via libcamera-devel wrote:\n> From: David Plowman <david.plowman@raspberrypi.com>\n>\n> The enableCe() function enables or disables adaptive contrast\n> enhancement and the restoreCe() function sets it back to its normal\n> state (which is what was read from the tuning file).\n>\n> In future, algorithms like HDR might want to take over tonemapping\n> functions, so any dynamic behaviour here would upset them.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n> ---\n>  src/ipa/rpi/controller/contrast_algorithm.h |  2 ++\n>  src/ipa/rpi/controller/rpi/contrast.cpp     | 13 ++++++++++++-\n>  src/ipa/rpi/controller/rpi/contrast.h       |  3 +++\n>  3 files changed, 17 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/ipa/rpi/controller/contrast_algorithm.h b/src/ipa/rpi/controller/contrast_algorithm.h\n> index ce17a4f949b9..895b36b0a80f 100644\n> --- a/src/ipa/rpi/controller/contrast_algorithm.h\n> +++ b/src/ipa/rpi/controller/contrast_algorithm.h\n> @@ -17,6 +17,8 @@ public:\n>  \t/* A contrast algorithm must provide the following: */\n>  \tvirtual void setBrightness(double brightness) = 0;\n>  \tvirtual void setContrast(double contrast) = 0;\n> +\tvirtual void enableCe(bool enable) = 0;\n> +\tvirtual void restoreCe() = 0;\n>  };\n>\n>  } /* namespace RPiController */\n> diff --git a/src/ipa/rpi/controller/rpi/contrast.cpp b/src/ipa/rpi/controller/rpi/contrast.cpp\n> index bee1eadd3657..4e038a021d8a 100644\n> --- a/src/ipa/rpi/controller/rpi/contrast.cpp\n> +++ b/src/ipa/rpi/controller/rpi/contrast.cpp\n> @@ -42,6 +42,7 @@ int Contrast::read(const libcamera::YamlObject &params)\n>  {\n>  \t// enable adaptive enhancement by default\n>  \tconfig_.ceEnable = params[\"ce_enable\"].get<int>(1);\n> +\tceEnable_ = config_.ceEnable;\n>  \t// the point near the bottom of the histogram to move\n>  \tconfig_.loHistogram = params[\"lo_histogram\"].get<double>(0.01);\n>  \t// where in the range to try and move it to\n> @@ -65,6 +66,16 @@ void Contrast::setContrast(double contrast)\n>  \tcontrast_ = contrast;\n>  }\n>\n> +void Contrast::enableCe(bool enable)\n> +{\n> +\tceEnable_ = enable;\n> +}\n> +\n> +void Contrast::restoreCe()\n> +{\n> +\tceEnable_ = config_.ceEnable;\n> +}\n> +\n>  void Contrast::initialise()\n>  {\n>  \t/*\n> @@ -150,7 +161,7 @@ void Contrast::process(StatisticsPtr &stats,\n>  \t * histogram down, and possibly push the end up.\n>  \t */\n>  \tPwl gammaCurve = config_.gammaCurve;\n> -\tif (config_.ceEnable) {\n> +\tif (ceEnable_) {\n>  \t\tif (config_.loMax != 0 || config_.hiMax != 0)\n>  \t\t\tgammaCurve = computeStretchCurve(histogram, config_).compose(gammaCurve);\n>  \t\t/*\n> diff --git a/src/ipa/rpi/controller/rpi/contrast.h b/src/ipa/rpi/controller/rpi/contrast.h\n> index 9c81277a0450..59aa70dceeb9 100644\n> --- a/src/ipa/rpi/controller/rpi/contrast.h\n> +++ b/src/ipa/rpi/controller/rpi/contrast.h\n> @@ -37,6 +37,8 @@ public:\n>  \tint read(const libcamera::YamlObject &params) override;\n>  \tvoid setBrightness(double brightness) override;\n>  \tvoid setContrast(double contrast) override;\n> +\tvoid enableCe(bool enable) override;\n> +\tvoid restoreCe() override;\n>  \tvoid initialise() override;\n>  \tvoid prepare(Metadata *imageMetadata) override;\n>  \tvoid process(StatisticsPtr &stats, Metadata *imageMetadata) override;\n> @@ -46,6 +48,7 @@ private:\n>  \tdouble brightness_;\n>  \tdouble contrast_;\n>  \tContrastStatus status_;\n> +\tdouble ceEnable_;\n>  };\n>\n>  } /* namespace RPiController */\n> --\n> 2.34.1\n>","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 E1BBAC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 Oct 2023 10:52:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1F0ED62980;\n\tThu, 12 Oct 2023 12:52:57 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E568F6296D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Oct 2023 12:52:55 +0200 (CEST)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A52F37FC;\n\tThu, 12 Oct 2023 12:52:52 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697107977;\n\tbh=kQyZjT1ye/wz78xXtiaF3U53buZNPCpiMJy/mJei7yA=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Wr44ec8Dyg6GbDgqNKlAd6biExNQDc6zaGp4fL8jqIidEvQL/cEsItobKQHPXhcSq\n\tLAtLJYkGyPJYf7OHE+p50yEEtfcZJFjJk8aUZ2BcXadDvLB1m4R7YVL/OMnOl+uxuw\n\tfhjktBtKesChyA9iq+7TYDIgc7GCJ++BIGgijWP+afrWmTYFMANAYHbpdxhrzM7VCJ\n\toLmY24GJuZ9xB9PdNI97cXLbf2goqjY3eH32YisNw+upUFOVow2BspYR0iTZ0Dgtq5\n\tW4IzigzB2nuBl3MiS4WPgAOLFve8u1yxECVWrmZMTydqkPPCBi3pTnxNI/ckRTGqHE\n\tVB4h2Lhewfr7Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1697107972;\n\tbh=kQyZjT1ye/wz78xXtiaF3U53buZNPCpiMJy/mJei7yA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AduBR4H5DIvXAGnRoQ7HU581yqvOgFZXSB0+9mPvAKK3+p1NAWJ/vZIS9KiynTc2h\n\tAnBMwyzj9VLUMW1xeLMcO1Ylw/G/Vc38vCFeZ50Gn5B2I0qsYstNH34XG/KS3WOuc9\n\t4Q+FH+EgU+WU6AWOGL8NexQIxbsQ3z3IjnOZPI9Y="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"AduBR4H5\"; dkim-atps=neutral","Date":"Thu, 12 Oct 2023 12:52:52 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<mlj6bfy6b4brdkhuyo2ebp3jvo2keolvm2narsntw5sru5vpzs@jom7fsuikpcd>","References":"<20231006132000.23504-1-naush@raspberrypi.com>\n\t<20231006132000.23504-18-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20231006132000.23504-18-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 17/20] ipa: rpi: contrast: Allow\n\tadaptive contrast enhancement to be disabled","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]