From patchwork Thu Nov 27 02:37:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25245 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 B093DC0F2A for ; Thu, 27 Nov 2025 02:38:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 371E460ABD; Thu, 27 Nov 2025 03:38:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="UuqsVFEs"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 52C8C609DE for ; Thu, 27 Nov 2025 03:38:04 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4777771ed1aso1615485e9.2 for ; Wed, 26 Nov 2025 18:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764211084; x=1764815884; 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=a4Z5xi4jidv2phyy2JrFxGl8iOtQb7kkkaWyXWfEsJk=; b=UuqsVFEsAqeu3wY4y6uWmPcAywTZhWZToBQJhgjR7JDl2I9ROwkmZqqcf98mYdod8o M3q1DNnkTz+sgTSWYo0xxxDNB4sVDIUQcKKnYJC1MgVJyqJ0P0EGuGqGVUNt3CgA/z5S qtV2FkREM4KzVPfsm0rdwxWKCy41fia71zPML/kBT71CQiYN/z1po512APl53YBiX2NI H7aYMzBHwz9bqbJicBE4KamKsKzK30qCyL1CGpO9tSEPr+Ao7nCwWNDnzAssY/Wq2ooQ oHjYv/zqwsS5dRv/X7nicK86IwMcrulnKIjFUFzMkYEzQj2qYMz5A8P2nJA9bh810qwU h0hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764211084; x=1764815884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=a4Z5xi4jidv2phyy2JrFxGl8iOtQb7kkkaWyXWfEsJk=; b=OWqJ3qcLKmgxdGDS0OvHGnAi/0OXEb9AxWWsgKPCFVL+f5TtjKgNkIb0MLr2Zes/cD GAhnQJGTD6yNrAnpPf4YZm+bsq163Sjy21p81aLsJkLnJTXpHIvHY0J8O9LGvrbCWyYJ GDDX2OrNNJaZBWH56Y9HTIzzHicAZyB6wQQLLONJzbNOQLKYMIpXQHuCYXXmRWzBjhbs FH1B/F5ak9Pd5/hs3ky5lKFkOX16LPsX61zhTqv/ukANT59FbXBc1chlMcccs/TcKJlR XHaDWLAs9aI82j1X51ZEUWC9gAoB0+VFWb/Jx8LLvsFnmjl7ZJYlNNjiLOUwimbHZxt0 6qyA== X-Gm-Message-State: AOJu0YwCJFrzszDyLZGw33yu6W58QuRtZpLG7yg2iuPjCMS7hhEq1TUt lCBudiqHBsjZ8L0Frw9jAi+ofzVDsaGa4l2Crju79U7zIYJBmKNx+uUrFDmUhlyYLw1ZYEwjACE iPXp1QaM= X-Gm-Gg: ASbGncvPSvyMwsxdksiOr6Bx8Ov2ZMuGQIwSI6xgH2R3EOvJl7fU5VPzllLws/SKDh4 KTMQEWAx+qo/75JSsQTbt0sN93nUnN5ltzYmdB7xWyCM+3WGEFT6TGIIDed2JW+ioNPZfQ+1ZrE SOVaYPWm/B/sshvfV53kI/zpoitBrqFv69qb2H1yOB+lTIcu+2f+C21bM+z2xv6lK/di5UwEI4l 4Em22/K8SGSZG3+HGgc7gAYazF783j8U3pQ8VyU4/PQ0mBBjUisMUIpXCaXomucAegFtVWZ0rzT PZZ2GqJoJ7GHTtCbFw+lRYHKG5ctuOqQm59CcHixBlfYHD1vovn2wCj7Z/XUWthEXy1wQWul9Dz qyvPuY/iiCtOGCHy3VkzyXP90fbZzylEy6El+2x70/jI+yWrVbm5OzuiJ31X1VRDOmj8sLrr6eh bGj5ZSl2BB2kL4dYce2lc60MUDyepySSU2KEPyFLMq94W9qhW02r9FSTY7Cdsa4yxlos4= X-Google-Smtp-Source: AGHT+IH92azTQU6T9RAid0GlJZFMQN6FvmT+wF5sn3rj90loHi7C9BAmy6nviH5Lzg0qe/HbCe1OAA== X-Received: by 2002:a05:600c:3146:b0:477:df7:b020 with SMTP id 5b1f17b1804b1-477c01b2211mr216760505e9.18.1764211083726; Wed, 26 Nov 2025 18:38:03 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790552c3c9sm58186345e9.0.2025.11.26.18.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:38:03 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v5 08/24] libcamera: shaders: Add support for black level compenstation Date: Thu, 27 Nov 2025 02:37:23 +0000 Message-ID: <20251127023739.179652-9-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127023739.179652-1-bryan.odonoghue@linaro.org> References: <20251127023739.179652-1-bryan.odonoghue@linaro.org> 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" Add the ability to apply a int blacklevel gain against the demosaiced data prior to application of colour correction data. We calculate the index into the RGB black-level table so that we can apply the black level when we sample the input prior to the demosiac operation. Don't do this when using the lookup tables as the black level is already calculated in those. Signed-off-by: Bryan O'Donoghue --- src/libcamera/shaders/bayer_1x_packed.frag | 4 ++++ src/libcamera/shaders/bayer_unpacked.frag | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag index c0632eb1f..6bca07b6e 100644 --- a/src/libcamera/shaders/bayer_1x_packed.frag +++ b/src/libcamera/shaders/bayer_1x_packed.frag @@ -69,6 +69,7 @@ uniform sampler2D red_param; uniform sampler2D green_param; uniform sampler2D blue_param; uniform mat3 ccm; +uniform vec3 blacklevel; void main(void) { @@ -217,6 +218,9 @@ void main(void) vec3(patterns.wz, C)); #if defined(APPLY_CCM_PARAMETERS) + + rgb = rgb - blacklevel; + /* * CCM is a 3x3 in the format * diff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag index a9996b94e..66cece56b 100644 --- a/src/libcamera/shaders/bayer_unpacked.frag +++ b/src/libcamera/shaders/bayer_unpacked.frag @@ -28,6 +28,7 @@ varying vec4 center; varying vec4 yCoord; varying vec4 xCoord; uniform mat3 ccm; +uniform vec3 blacklevel; void main(void) { vec3 rgb; @@ -112,6 +113,9 @@ void main(void) { vec3(PATTERN.yx, C)); #if defined(APPLY_CCM_PARAMETERS) + + rgb = rgb - blacklevel; + /* * CCM is a 3x3 in the format *