From patchwork Thu Jun 13 08:33:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20286 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 A9D87C3237 for ; Thu, 13 Jun 2024 08:36:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4534F65491; Thu, 13 Jun 2024 10:36:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WW5ubFTa"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ADEFB6548B for ; Thu, 13 Jun 2024 10:36:40 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:3fed:9d83:54f9:6b93]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CBDF7BEB; Thu, 13 Jun 2024 10:36:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718267786; bh=eqfNOwYbtBMJh2BtlKNYOagP2VNXb1FXXBVyLCo7Q+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WW5ubFTa7oAkKkW5tiKQLJSK9XjRZ/PMcQhy3PPA/NS3p/8K/t0VOWvix7fzw5b/H 7SLEQX+Sk8ZsuFqBZNTACjFKP7xp0bnypKUuhb83v7gNoLPD2sVC8wrvev3jOd3T9R NJcXJcNCYTNGC240B7uzaQ6sr8jB3CyIofcndNZ8= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 2/3] ipa: rkisp1: cproc: Merge identical functions Date: Thu, 13 Jun 2024 10:33:19 +0200 Message-ID: <20240613083533.855791-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613083533.855791-1-stefan.klug@ideasonboard.com> References: <20240613083533.855791-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 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" convertContrast() and convertSaturation() are equal. Merge them into one. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/rkisp1/algorithms/cproc.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp index 955298093fda..9f400a52dd96 100644 --- a/src/ipa/rkisp1/algorithms/cproc.cpp +++ b/src/ipa/rkisp1/algorithms/cproc.cpp @@ -44,12 +44,7 @@ int convertBrightness(const float v) return std::clamp(std::lround(v * 128), -128, 127); } -int convertContrast(const float v) -{ - return std::clamp(std::lround(v * 128), 0, 255); -} - -int convertSaturation(const float v) +int convertContrastOrSaturation(const float v) { return std::clamp(std::lround(v * 128), 0, 255); } @@ -80,8 +75,8 @@ int ColorProcessing::configure([[maybe_unused]] IPAContext &context, auto &cproc = context.activeState.cproc; cproc.brightness = convertBrightness(kDefaultBrightness); - cproc.contrast = convertContrast(kDefaultContrast); - cproc.saturation = convertSaturation(kDefaultSaturation); + cproc.contrast = convertContrastOrSaturation(kDefaultContrast); + cproc.saturation = convertContrastOrSaturation(kDefaultSaturation); return 0; } @@ -113,7 +108,7 @@ void ColorProcessing::queueRequest(IPAContext &context, const auto &contrast = controls.get(controls::Contrast); if (contrast) { - int value = convertContrast(*contrast); + int value = convertContrastOrSaturation(*contrast); if (cproc.contrast != value) { cproc.contrast = value; update = true; @@ -124,7 +119,7 @@ void ColorProcessing::queueRequest(IPAContext &context, const auto saturation = controls.get(controls::Saturation); if (saturation) { - int value = convertSaturation(*saturation); + int value = convertContrastOrSaturation(*saturation); if (cproc.saturation != value) { cproc.saturation = value; update = true;