From patchwork Tue Dec 2 13:45: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: 25312 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 3F79FC3257 for ; Tue, 2 Dec 2025 13:46:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 51A1B60C91; Tue, 2 Dec 2025 14:46:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wrwhyC1d"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AA63660C77 for ; Tue, 2 Dec 2025 14:45:56 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-477770019e4so46195725e9.3 for ; Tue, 02 Dec 2025 05:45:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764683156; x=1765287956; 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=amMoQCO1WpNVR7VV2kItwg29g4ljwGAnIqXk1bcdxT4=; b=wrwhyC1djZOoIgYgv6Pu6zHhrb3J1BX9/NvsKj0n5tkOd35GDpkcNsNXeFae/YA/3v QkjUHqE6nSfcRJUq/rQ/cDjyVBjAu746reyeK2QOcwB1xV+PuaxEodVpnd9gSWtlQ+Yw u0wWZ7AjmjCqqR98lUA2LAhr3GSASr9Xe+WfUrEQnL1RKBYxN9Rc0csjtC09Pac1tyEm 9V3FZhPs7SsbAaFLUJGvii44n+ZORZ+IxddaSbLmK256WKS5k028UfyiPLH4GnzBvtow W+2Diek7iiXQj+DpriI8Uv8+qWpBMesWTlb90sgJwhLyhy83elgkJr7WToLoDTJvvycg Bx8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764683156; x=1765287956; 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=amMoQCO1WpNVR7VV2kItwg29g4ljwGAnIqXk1bcdxT4=; b=EUJq32FJZgPTV3SDYzigPAvszfk6MTDVDuUZviuZQk6b6Ew4cSL2MTPxM2VSJ2tQxV VcX+8ZdnWsPlTnlUisJmORNEy6wV2MrBHUsUK25ylu9+Br//sBbpwGF/xX26X3LKiLRe 6ABeB/jRx4Z2MmxoNMkKuVZgomk/L1C+BYzsKwjwJy6xDhwXluoqLlEd8wG64QHTZY5m PElu0NvoJx9936Nd24B7OjxoaKAW98/D956flxGRsdbJws+4BOjRpFQpgXxPdxTRSuAF meo6FtmfiiOoctvIO3bR1ovCUl3enDGUsxaR23IZllaASAYsg0LKsSwv+qkI8JrmmFIy 17rQ== X-Gm-Message-State: AOJu0Yx++mlxWHfT0hWrkTb+nKUxi1g+wTWMeWBpWbBZ+fbCbmOhmOaT WNB4B+qxD/wnU0bYeXyl1a1HSvilHrCWEecmIK9OzDUw+0E7Xbnel3RY5aunOHxIdD4r0TgpGQb oa9+N X-Gm-Gg: ASbGnctR79E7Gd2mQh4CZ1+quxkfB7Qv/UczVWx2dnDclFo/YGFd3zQ6Rx/g/LIxoDs 3GyXSFumqdYXMzFY1u8QDcx5K+l4NFJVSr3n7poXv3yiHJ2t7GDS0J56I4iW7hJ4YY/zL2SBudz 3o+L5zMf8LeF7lxgs/+xCQmN+HQBP+bHWcrO3PA35l1t5+HhPX6vVcCP0h7Pb4Ckee1uzmdT/WG APVye6K+hVGplZ4inw95kCuNER/hmzUCM2+1XbSJarJ2NXIjc4L0bdV3l7H5ts3mvLDlO91tZu2 5i9kYcBbneG9lhkUbrMrY48jALzPqs1fp8bWP/IhlUXX7ASExaf1uq34BN8HrGgN6Q/PPOEBsXI 9KsN7L8V2iCiyLopBXTOiYHbqibnHUAG1Lyu03bkBxEMm8aocff8qHNR8aMu+YhU+SYnFj+Z7Wl rLhpDL2mPq3qufT59QmtRUUOhPWVVq+d+83p+NzDacoIVAyRyA5MC+XHK1dJc9h9UUxJU= X-Google-Smtp-Source: AGHT+IGRDiF22iUsZjPGDrX8ZcsDo4jDMYlPfSU3itkTff+gWN94oVIndJv4kPDXwjb6tuOpqLJn5w== X-Received: by 2002:a05:600c:4f48:b0:471:115e:87bd with SMTP id 5b1f17b1804b1-47904b2494cmr306646675e9.26.1764683155786; Tue, 02 Dec 2025 05:45:55 -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-47926f0ec69sm19383375e9.1.2025.12.02.05.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Dec 2025 05:45:54 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v6 03/24] qcam: viewfinder_gl: Set no-op Bayer shader values Date: Tue, 2 Dec 2025 13:45:23 +0000 Message-ID: <20251202134544.662446-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251202134544.662446-1-bryan.odonoghue@linaro.org> References: <20251202134544.662446-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" Signed-off-by: Bryan O'Donoghue --- src/apps/qcam/viewfinder_gl.cpp | 25 +++++++++++++++++++++++++ src/apps/qcam/viewfinder_gl.h | 12 ++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp index 1554c94d5..69b7c6e59 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,15 @@ 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 +801,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..c1b2d9d51 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_ */ };