From patchwork Wed Dec 17 10:01:15 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: 25576 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 4D74CC326C for ; Wed, 17 Dec 2025 10:01:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 779BF61A5D; Wed, 17 Dec 2025 11:01:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="H45ZxNTw"; dkim-atps=neutral Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 14E6861A4E for ; Wed, 17 Dec 2025 11:01:46 +0100 (CET) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-47118259fd8so55703995e9.3 for ; Wed, 17 Dec 2025 02:01:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765965705; x=1766570505; 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=fs424H+/NHXIDhotX6BbcvYwsUeY8sQ6tmxWMohUjl4=; b=H45ZxNTwADrQOY9CRzNgFmWrzQc2sFHyBxvsaxWE9C5ycWMiOZ48v4NiM1YJpl041o 3sb0YWvLyyhY/48n/jDfRu9HOZFeM5Kl85RFPMsVbHxWcV8rSe1Ni91q5rKGIx2PZ3+T b1fux7Rt49o99u0bU6Ww6rg2moqqRHSZ7+IO8ZQn8TbZGMhO1tOddcQbzq+mVam4WQIQ YnqFx6sWsJdZwCsUfL/VjJ7hpQ0aMS0L0kpp3Lz0gY5s3lPkyTwLYFtCK4ylGnJS2CqQ DJ7M5IDoEPtz1eVn2C/UMSPy5qUHnLD488QPKxBm0DDF2323QN7g8EAUwGW+M/Rs9YPK y8zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765965705; x=1766570505; 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=fs424H+/NHXIDhotX6BbcvYwsUeY8sQ6tmxWMohUjl4=; b=Ib5WTiYDa7iLruPSAMoeKvZVZXVEUtW8Bn3pgBBlGQ8h8Ivy0+FvdT+vKAoQlbfJbz 5S0Q8fkgsJ19KvXidAGAw6ueS3yGal1eI6+BXO0GT/UQ2pQ4CfUdcCvgbwJZRoZRJfr9 HgXTnHaflxEa5ncpad0cmeJZHpEFFzFKy+cV5CyCawoGOxeI2Qh7bE7Pr7dxn4UkUvUo xu695Avo5tZWFUQMRwtZm497NCtrxDWetyB3TOZuGPwS6e6EJZ1B3RRxVKbQOm8mQoa0 EwQaHRHuu19umZ33AAcRzIxaRFC+DPiIq8yl2hNvEix38zgkDFvRTu8m+PLsxoXFAgkh WZqQ== X-Gm-Message-State: AOJu0YzNTizj1E7no0T65DuqmkghGVToXbDjZggFQoDifOgyNKY42psB 1EWWukw7G1CMov+cJQFb0jExZYZv7xVytZBirAGz1Hooer9ZPNbtIKxdwoJvXqnz6gpN7+/1l1T saHrm X-Gm-Gg: AY/fxX7SlqyGoaq4BCC1yYzH4qZkU2PphbTA8YAPqBcEepBPn6P4WdF+COvGAKP4VqZ SsLEBktRxrmWrZH2gJ1MgD5uokc6wWKRY8jsmSTFOHlvpbYeACW60gVYw3GuK2/mizLny+HFB7X qPRMCEs7JH6RnRXdt/y58PEALhm/e06W+/h1oWnGtOReVEf5SAWa3QvlmwkEL0qElklKAsZk2RE Sjna82I7QA7N5ikMjXSQDmGHacC7apKu3Dcom13EtQeH/oF9eTw9gUXezxc+wXSlVDX091r7RE2 Si16VWnJH83hvSCab9Spcrkwa25KBsdqjIILlo9rXiMXr7XrHPpzgux2NE9E0boIL1a8epXweCQ wcY8JoZQZvPCcsDpjow3yWWin3LIuq0NjWNHsUKBzrWy14u9RlScoOxLAKKG+tlLKW0PN/vhsTX Tpz6V/cwL+S4UrZXBVbPX56giPeSucxAmBscql5LO180CphCeqlABq5tYJJkz+tuUMPRpZ1g5bg WS75Q== X-Google-Smtp-Source: AGHT+IGiegwlJ9BiUeMiyHvDqNL0Wb8/5hwgYfciYdFiBiCZzsS0V/8yzpVWpiGeOUqV8jrh9lQ2Og== X-Received: by 2002:a05:600c:5487:b0:47b:deb9:f8a with SMTP id 5b1f17b1804b1-47bdeb91a35mr8922175e9.30.1765965705124; Wed, 17 Dec 2025 02:01:45 -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-47bdc1583fbsm32292585e9.0.2025.12.17.02.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 02:01:44 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal Subject: [PATCH v9 03/26] qcam: viewfinder_gl: Set no-op Bayer shader values Date: Wed, 17 Dec 2025 10:01:15 +0000 Message-ID: <20251217100138.82525-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217100138.82525-1-bryan.odonoghue@linaro.org> References: <20251217100138.82525-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" Populate qcam viewfinder_gl to set default Bayer values so that the shaders can be used in their original mode without conditional compilation. Set an identity CCM, identity Black Level and set Gamma and Contrast to 1.0f respectively. Once this change is made we can use the Bayer shaders in their original format in qcam with raw streams. Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- src/apps/qcam/viewfinder_gl.cpp | 26 ++++++++++++++++++++++++++ src/apps/qcam/viewfinder_gl.h | 12 ++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp index 1554c94d5..4698c5aac 100644 --- a/src/apps/qcam/viewfinder_gl.cpp +++ b/src/apps/qcam/viewfinder_gl.cpp @@ -473,6 +473,10 @@ bool ViewFinderGL::createFragmentShader() textureUniformSize_ = shaderProgram_.uniformLocation("tex_size"); textureUniformStrideFactor_ = shaderProgram_.uniformLocation("stride_factor"); textureUniformBayerFirstRed_ = shaderProgram_.uniformLocation("tex_bayer_first_red"); + ccmUniformDataIn_ = shaderProgram_.uniformLocation("ccm"); + blackLevelUniformDataIn_ = shaderProgram_.uniformLocation("blacklevel"); + gammaUniformDataIn_ = shaderProgram_.uniformLocation("gamma"); + contrastUniformDataIn_ = shaderProgram_.uniformLocation("contrast"); /* Create the textures. */ for (std::unique_ptr &texture : textures_) { @@ -542,6 +546,16 @@ void ViewFinderGL::doRender() /* Stride of the first plane, in pixels. */ unsigned int stridePixels; + /* Identity CCM */ + float ccm[] = { 1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f }; + + QMatrix3x3 qCcmMat(ccm); + + /* Black Level */ + QVector3D qBlackLevelVec(0.0f, 0.0f, 0.0f); + switch (format_) { case libcamera::formats::NV12: case libcamera::formats::NV21: @@ -788,6 +802,18 @@ void ViewFinderGL::doRender() * the generic stride factor to 1.0. */ stridePixels = size_.width(); + + /* Colour Correction Matrix */ + shaderProgram_.setUniformValue(ccmUniformDataIn_, qCcmMat); + + /* Black Level */ + shaderProgram_.setUniformValue(blackLevelUniformDataIn_, qBlackLevelVec); + + /* Gamma */ + shaderProgram_.setUniformValue(gammaUniformDataIn_, 1.0f); + + /* Contrast */ + shaderProgram_.setUniformValue(contrastUniformDataIn_, 1.0f); break; default: diff --git a/src/apps/qcam/viewfinder_gl.h b/src/apps/qcam/viewfinder_gl.h index 23c657bcf..59f122217 100644 --- a/src/apps/qcam/viewfinder_gl.h +++ b/src/apps/qcam/viewfinder_gl.h @@ -103,5 +103,17 @@ private: GLuint textureUniformBayerFirstRed_; QPointF firstRed_; + /* Represent per-frame CCM as a uniform vector of floats 3 x 3 */ + GLint ccmUniformDataIn_; + + /* Black Level compensation */ + GLint blackLevelUniformDataIn_; + + /* Gamma */ + GLint gammaUniformDataIn_; + + /* Contrast */ + GLint contrastUniformDataIn_; + QMutex mutex_; /* Prevent concurrent access to image_ */ };