From patchwork Wed Nov 27 14:46:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaac Scott X-Patchwork-Id: 22124 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 00853C3200 for ; Wed, 27 Nov 2024 14:47:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF0D1660E2; Wed, 27 Nov 2024 15:47:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SpKYkurw"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 474CF660C4 for ; Wed, 27 Nov 2024 15:47:04 +0100 (CET) Received: from isaac-ThinkPad-T16-Gen-2.lan (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0F08B842; Wed, 27 Nov 2024 15:46:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1732718801; bh=ON3RX5FbJkQbaB0OgI/MXnHacwExmPFid1+GXqsNG4k=; h=From:To:Cc:Subject:Date:From; b=SpKYkurw+w03f99UPBEJ5FQoaRkBkG0k6alHG7QxJ/juVSa8R8Y/BaVuuNqkK68zt pGgdbws5kIZ6OLgtm0zKEbNDue3O3jfCFe//pd7xm2/k8l1yfgkS4iJFT/7YXX846f dGYQf7zBRLUQhIeCWNIYf17Stgtgcs1mbf3QeX7w= From: Isaac Scott To: libcamera devel Cc: Isaac Scott Subject: [RFC PATCH 0/2] Add BitDepthValue for simplified bit depth conversion Date: Wed, 27 Nov 2024 14:46:53 +0000 Message-ID: <20241127144655.1074720-1-isaac.scott@ideasonboard.com> X-Mailer: git-send-email 2.43.0 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" Following recent changes to black-level support, it can be unclear how we define the type used to represent it. There are many instances within the codebase where bitshifting is used inline to convert values from one bit depth to another, or values have been converted manually from values listed in datasheets. This series implements a new BitDepthValue type that makes it explicit what bit depth a value is intended to be. It also allows for the abstraction of the process of converting values from one bit depth to another, and allows users to assign values of one bit depth to another without having to bitshift, improving readability and reducing guesswork. It also avoids the possibility of human error that could come into play when converting values to different bit depths manually, and makes it easier to store black-level values in the form that better matches the datasheets. The camera_sensor_helper classes have been converted to use BitDepthValue, and unit tests are included to verify the functionality of the changes, as well as show how they can be used. I have not included the Doxygen files yet, these will be handled if this is an acceptable approach. Isaac Scott (2): libcamera: bitdepth: Add BitDepth implementation libcamera: bitdepth: Adapt camera_sensor_helper to use BitDepth src/ipa/libipa/bitdepth.h | 86 +++++++++++++++++++ src/ipa/libipa/camera_sensor_helper.cpp | 18 ++-- src/ipa/libipa/camera_sensor_helper.h | 5 +- src/ipa/simple/algorithms/awb.cpp | 3 +- src/ipa/simple/algorithms/blc.cpp | 10 ++- src/ipa/simple/ipa_context.h | 5 +- src/ipa/simple/soft_simple.cpp | 5 +- test/ipa/libipa/bitdepth.cpp | 107 ++++++++++++++++++++++++ 8 files changed, 218 insertions(+), 21 deletions(-) create mode 100644 src/ipa/libipa/bitdepth.h create mode 100644 test/ipa/libipa/bitdepth.cpp