From patchwork Fri Oct 6 13:19:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19119 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 D8305C32C0 for ; Fri, 6 Oct 2023 13:20:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9E6F062994; Fri, 6 Oct 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1696598420; bh=Vco4sOLhS+b8qbdF80LzDvfty2cxrcwq99X42VGxOE0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=abAfZhUJxO6C3WfQKbBYk/XZ5cU39Ws2ZR+Y9CVYo8npoPM/TVsMnYBUYL26hYbrU BtWbUntgp5CRFGTZaCCaSs56KBCzC5mS6TMUcpY1gG+lvz2LowDHTwY/6caiZYsvxC c7kXjQ33UFTGRNXYMHYaVIJgWtnEW3U/3GZTAnD3aqMXrbN13RQCRn6JYLhVJBcBR3 95HLNi7GWrkX//RtLJZ671lvGOYnLVWYpeqpjLFgx11hbI3UKbFYdb/XP69RLFvIwP 0nr2yv56S0tPMLs1g1EbenWQJirzgwTXkvFME5h/Yx09LAD/JZlj2OA6u+VaDyFyT2 tXrpq+w9HHDVQ== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 941BA6298A for ; Fri, 6 Oct 2023 15:20:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="rdlX829k"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-32157c8e4c7so2047865f8f.1 for ; Fri, 06 Oct 2023 06:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1696598417; x=1697203217; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GJZWIHSvD4qhUhRVpGxrtaU/At69rVVeRUf6Y6dNodU=; b=rdlX829kPcBQKVVmxNdCSloTET14aGe77VD9/TkW5I6CnFjNXcriAG3tOwGjcMuBwC wOXsQkuKaIuecPmbz2cy8jcrm05EEOI3D4F8QVdpR7TbmhCwz9tsLyE7SNPyNJDZYxH7 tiqkBeN26fRWTeouq4lPAz510HEaomYx+F0ppzM6HhiviiLApDk0rJf3I2xYBjN/xR/v o6nFwkKg83Ll7z/VJzIL9bBKzQkPq8GQCqFb7dn+MF7iS7m37NyU2KWXQB7G/l32O0tf MYfaWVP+3R/lemh89ABAdszoHruVkZMxRl5wPAztQ240Xilqf3JJX4f4ipS63eL9QNz6 A0Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598417; x=1697203217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GJZWIHSvD4qhUhRVpGxrtaU/At69rVVeRUf6Y6dNodU=; b=JURVQz+07G4jSnGcROmtSgw+9R+ZgkcLjCWivxOvrNXLOfNCrrJ5pkKx77+yGjUZdc /hINJXQxvOHrjoqpZq+mLGhJ44Rfe1J84nlhGH7zooNxD7DUgH4jAOEAvAQYyUgFl7BR stoL24Ckmav+6FwzqDnr2CnVzQRsYG1IxzCqq0mI35WzfYom8TudyWzfNYrdEDpnkpp8 R7GwwfXm673uP4OdIGEHwkDRTCmQDnJo/hLrPamMDuRVav/0Zkj3pwWt+9hgyZWCZt7k lJ9ZCP/BpBdRGSYrJT7E7tcdr2NdHqQFD2d9K8X/Cjx1/oVze+6Ep+4kIcGzclrVXsfb e81g== X-Gm-Message-State: AOJu0Ywu0fFLjTkGITgeYzh+LcXVjks9wX6tA/bIgK6g8Mhobb3GdqG3 nrR1gj3bv5l6h3R5KHcJOh5tONUjbl7EW6oIYoX3HQ== X-Google-Smtp-Source: AGHT+IHuVD8O8dg/2yTcHuH6ma3WVIm+YILPJwsPqhbZV81f1nMWbYi/ggRJxuRUd17w9BezZsSgLA== X-Received: by 2002:a05:6000:1112:b0:321:6005:8979 with SMTP id z18-20020a056000111200b0032160058979mr7240126wrw.17.1696598416905; Fri, 06 Oct 2023 06:20:16 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id m8-20020a056000180800b00321773bb933sm1639478wrh.77.2023.10.06.06.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:20:16 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Oct 2023 14:19:57 +0100 Message-Id: <20231006132000.23504-18-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231006132000.23504-1-naush@raspberrypi.com> References: <20231006132000.23504-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 17/20] ipa: rpi: contrast: Allow adaptive contrast enhancement to be disabled 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: David Plowman The enableCe() function enables or disables adaptive contrast enhancement and the restoreCe() function sets it back to its normal state (which is what was read from the tuning file). In future, algorithms like HDR might want to take over tonemapping functions, so any dynamic behaviour here would upset them. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- src/ipa/rpi/controller/contrast_algorithm.h | 2 ++ src/ipa/rpi/controller/rpi/contrast.cpp | 13 ++++++++++++- src/ipa/rpi/controller/rpi/contrast.h | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ipa/rpi/controller/contrast_algorithm.h b/src/ipa/rpi/controller/contrast_algorithm.h index ce17a4f949b9..895b36b0a80f 100644 --- a/src/ipa/rpi/controller/contrast_algorithm.h +++ b/src/ipa/rpi/controller/contrast_algorithm.h @@ -17,6 +17,8 @@ public: /* A contrast algorithm must provide the following: */ virtual void setBrightness(double brightness) = 0; virtual void setContrast(double contrast) = 0; + virtual void enableCe(bool enable) = 0; + virtual void restoreCe() = 0; }; } /* namespace RPiController */ diff --git a/src/ipa/rpi/controller/rpi/contrast.cpp b/src/ipa/rpi/controller/rpi/contrast.cpp index bee1eadd3657..4e038a021d8a 100644 --- a/src/ipa/rpi/controller/rpi/contrast.cpp +++ b/src/ipa/rpi/controller/rpi/contrast.cpp @@ -42,6 +42,7 @@ int Contrast::read(const libcamera::YamlObject ¶ms) { // enable adaptive enhancement by default config_.ceEnable = params["ce_enable"].get(1); + ceEnable_ = config_.ceEnable; // the point near the bottom of the histogram to move config_.loHistogram = params["lo_histogram"].get(0.01); // where in the range to try and move it to @@ -65,6 +66,16 @@ void Contrast::setContrast(double contrast) contrast_ = contrast; } +void Contrast::enableCe(bool enable) +{ + ceEnable_ = enable; +} + +void Contrast::restoreCe() +{ + ceEnable_ = config_.ceEnable; +} + void Contrast::initialise() { /* @@ -150,7 +161,7 @@ void Contrast::process(StatisticsPtr &stats, * histogram down, and possibly push the end up. */ Pwl gammaCurve = config_.gammaCurve; - if (config_.ceEnable) { + if (ceEnable_) { if (config_.loMax != 0 || config_.hiMax != 0) gammaCurve = computeStretchCurve(histogram, config_).compose(gammaCurve); /* diff --git a/src/ipa/rpi/controller/rpi/contrast.h b/src/ipa/rpi/controller/rpi/contrast.h index 9c81277a0450..59aa70dceeb9 100644 --- a/src/ipa/rpi/controller/rpi/contrast.h +++ b/src/ipa/rpi/controller/rpi/contrast.h @@ -37,6 +37,8 @@ public: int read(const libcamera::YamlObject ¶ms) override; void setBrightness(double brightness) override; void setContrast(double contrast) override; + void enableCe(bool enable) override; + void restoreCe() override; void initialise() override; void prepare(Metadata *imageMetadata) override; void process(StatisticsPtr &stats, Metadata *imageMetadata) override; @@ -46,6 +48,7 @@ private: double brightness_; double contrast_; ContrastStatus status_; + double ceEnable_; }; } /* namespace RPiController */