From patchwork Fri Oct 13 07:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19141 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 228B7C32C1 for ; Fri, 13 Oct 2023 07:49:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B8931629AA; Fri, 13 Oct 2023 09:49:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697183348; bh=BVzzOqrgaQi3OOBwyfJcTJA7cdtOwtsPIxk8KKuR/zU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jayeQbMFPbkAKFDiAbgsUluec8SNoTzDkw15xqb9jiwHy+l3KW4TfQtkTvfIM0iWX 4eSHrNZtAzyWPSAj+SEq4TDTmVV3I/OHIWZj31wfF0WdCXdCx/m23rkyv6nEXG0Cvd a8mfUe0p+KNgNjzza3t+DO9TB5R6YKnoRx75FMluXLjQ8ptGrGS5KdCq+EagP37ILD Zw91onrteMm39O47JbOvChaeGvYjfXg9J4bCky9u9ahNWwN5i8AhNUSZ/NNrEn4Ukg slRYa63/rCWm8rC7ZvtsxCMMD5eedgjLSs6SxUQ56PrCIwGBtBnsllG/+/SveHgBSV 4iwyF1vpiJIsg== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 48D45629A2 for ; Fri, 13 Oct 2023 09:48:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="lze3JkQ9"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-405361bb9f7so19232215e9.2 for ; Fri, 13 Oct 2023 00:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697183338; x=1697788138; 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=1blZHZTcVda6hrHqBicD9uRzvwISRZzuZpzkStU5tQo=; b=lze3JkQ9veRQ2GFQhjUgjG5bmygMwvpmfPIF7JZtun3JITObjL8Y3Fu2EyZnHul5b6 DxmlLZ2Ian3DjveymmEueMqVFYJYyZPJsS2ReKom87htHkAu1X6x4oyCZrqjQJHRmsZI hFJ8md3kT1M4ktl1A/h/xFbpknGdcnj4tILwNdoLq+neo9Yimb+LANwTJ411mmy7gT8O shGUQNMBGcUpwbap9GbzvwJRQ/RnZ/TSFDQbWctlMWTsiVwc1u93zdZ4GoYCPHKaQ8K4 YDYD2pWzaR5Kdwi72GvZUWMREx2bQ1cT5ShgIa5oMXuZS/0/UuySDEZ17WqYSNv96ekb 9BXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697183338; x=1697788138; 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=1blZHZTcVda6hrHqBicD9uRzvwISRZzuZpzkStU5tQo=; b=soDjX5OS2wAkYq0e4ldzc//6P8q6LX52AYHac6ZxahZ1lDa7kX7pcXtgPC/TcVwviH 1k9h2VKY0kXrIjhfwvb8nV3I92z3uVFc/DtLW3IeqABdpB+7q+sJsuIFznW1O5BZMxQR jc1FnFq+q87tGtGzN3Uq5BsabZcpod7LlQCLBSJAHNLORgGkV3sXlMhzZlSmQa/FqADx uJ4Ye/77Naa/G/NLW4arATOXIigjT3TzaFNnixzQ0pfTDzYDRXFFWMYSV8bIoLGd7AAW c6ZmErI3LlPnFNJWS1U0eBwKw4XqbIEeqALnOekIIx6bLX7C9EIbOc63Kv9INpcHgEDd Yh6Q== X-Gm-Message-State: AOJu0YyBQbifFG+p2thldhRKBvYYJE+NtkUomXdkZR8WN8l2k+sA0iTp 2f+1LMkoVOnzNHMkr7vaqm2o+UALKM0k860xrtpzpg== X-Google-Smtp-Source: AGHT+IHM+LJfWfg+jjk/jtUZvVjq8/xJs4dS03UyHWIOjejYOnjU1kfyNM7K9NqkMcwfVUnx9YpHWA== X-Received: by 2002:a7b:cb8b:0:b0:3fb:e189:3532 with SMTP id m11-20020a7bcb8b000000b003fbe1893532mr22844142wmi.20.1697183338702; Fri, 13 Oct 2023 00:48:58 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id m16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 00:48:58 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 13 Oct 2023 08:48:38 +0100 Message-Id: <20231013074841.16972-18-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013074841.16972-1-naush@raspberrypi.com> References: <20231013074841.16972-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 Cc: Jacopo Mondi 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 */