[{"id":37249,"web_url":"https://patchwork.libcamera.org/comment/37249/","msgid":"<85cy4m5swt.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-12-10T14:10:42","subject":"Re: [PATCH v7 03/26] qcam: viewfinder_gl: Set no-op Bayer shader\n\tvalues","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n\n> Populate qcam viewfinder_gl to set default Bayer values so that the\n> shaders can be used in their original mode without conditional compilation.\n>\n> Set an identity CCM, identity Black Level and set Gamma and Contrast to\n> 1.0f respectively.\n>\n> Once this change is made we can use the Bayer shaders in their original\n> format in qcam with raw streams.\n>\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  src/apps/qcam/viewfinder_gl.cpp | 25 +++++++++++++++++++++++++\n>  src/apps/qcam/viewfinder_gl.h   | 12 ++++++++++++\n>  2 files changed, 37 insertions(+)\n>\n> diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp\n> index 1554c94d5..69b7c6e59 100644\n> --- a/src/apps/qcam/viewfinder_gl.cpp\n> +++ b/src/apps/qcam/viewfinder_gl.cpp\n> @@ -473,6 +473,10 @@ bool ViewFinderGL::createFragmentShader()\n>  \ttextureUniformSize_ = shaderProgram_.uniformLocation(\"tex_size\");\n>  \ttextureUniformStrideFactor_ = shaderProgram_.uniformLocation(\"stride_factor\");\n>  \ttextureUniformBayerFirstRed_ = shaderProgram_.uniformLocation(\"tex_bayer_first_red\");\n> +\tccmUniformDataIn_ = shaderProgram_.uniformLocation(\"ccm\");\n> +\tblackLevelUniformDataIn_ = shaderProgram_.uniformLocation(\"blacklevel\");\n> +\tgammaUniformDataIn_ = shaderProgram_.uniformLocation(\"gamma\");\n> +\tcontrastUniformDataIn_ = shaderProgram_.uniformLocation(\"contrast\");\n>  \n>  \t/* Create the textures. */\n>  \tfor (std::unique_ptr<QOpenGLTexture> &texture : textures_) {\n> @@ -542,6 +546,15 @@ void ViewFinderGL::doRender()\n>  \t/* Stride of the first plane, in pixels. */\n>  \tunsigned int stridePixels;\n>  \n> +\t/* Identity CCM */\n> +\tfloat ccm[] = {1.0f, 0.0f, 0.0f,\n> +\t\t       0.0f, 1.0f, 0.0f,\n> +\t\t       0.0f, 0.0f, 1.0f };\n> +\tQMatrix3x3 qCcmMat(ccm);\n> +\n> +\t/* Black Level */\n> +\tQVector3D qBlackLevelVec(0.0f, 0.0f, 0.0f);\n> +\n>  \tswitch (format_) {\n>  \tcase libcamera::formats::NV12:\n>  \tcase libcamera::formats::NV21:\n> @@ -788,6 +801,18 @@ void ViewFinderGL::doRender()\n>  \t\t * the generic stride factor to 1.0.\n>  \t\t */\n>  \t\tstridePixels = size_.width();\n> +\n> +\t\t /* Colour Correction Matrix */\n> +\t\tshaderProgram_.setUniformValue(ccmUniformDataIn_, qCcmMat);\n> +\n> +\t\t/* Black Level */\n> +\t\tshaderProgram_.setUniformValue(blackLevelUniformDataIn_, qBlackLevelVec);\n> +\n> +\t\t/* Gamma */\n> +\t\tshaderProgram_.setUniformValue(gammaUniformDataIn_, 1.0f);\n> +\n> +\t\t/* Contrast */\n> +\t\tshaderProgram_.setUniformValue(contrastUniformDataIn_, 1.0f);\n>  \t\tbreak;\n>  \n>  \tdefault:\n> diff --git a/src/apps/qcam/viewfinder_gl.h b/src/apps/qcam/viewfinder_gl.h\n> index 23c657bcf..c1b2d9d51 100644\n> --- a/src/apps/qcam/viewfinder_gl.h\n> +++ b/src/apps/qcam/viewfinder_gl.h\n> @@ -103,5 +103,17 @@ private:\n>  \tGLuint textureUniformBayerFirstRed_;\n>  \tQPointF firstRed_;\n>  \n> +\t// Represent per-frame CCM as a uniform vector of floats 3 x 3\n> +\tGLint ccmUniformDataIn_;\n> +\n> +\t// Black Level compensation\n> +\tGLint blackLevelUniformDataIn_;\n> +\n> +\t// Gamma\n> +\tGLint gammaUniformDataIn_;\n> +\n> +\t// Contrast\n> +\tGLint contrastUniformDataIn_;\n\n/* ... */ style comments (if they are needed at all here).\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\n> +\n>  \tQMutex mutex_; /* Prevent concurrent access to image_ */\n>  };","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1FEFFC3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Dec 2025 14:12:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D095A61477;\n\tWed, 10 Dec 2025 15:12:12 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 86B6B613CB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Dec 2025 15:12:10 +0100 (CET)","from mail-wr1-f71.google.com (mail-wr1-f71.google.com\n\t[209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-329-hZEx4hqDNjaz7og4rWGzXA-1; Wed, 10 Dec 2025 09:10:45 -0500","by mail-wr1-f71.google.com with SMTP id\n\tffacd0b85a97d-42b352355a1so488137f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Dec 2025 06:10:44 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb ([213.175.37.14])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-42f7ca4f219sm36072704f8f.0.2025.12.10.06.10.42\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 10 Dec 2025 06:10:43 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"Ua76pNyR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1765375929;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=KjxL1P88nRFT+hBLt1MUpBQCpKMqIjRo+EOedyWUsxc=;\n\tb=Ua76pNyREc8khjfHi6V63V9YAFCoDtFnPh8IJptYWd06vyd0KJHNtT4WHlzgD+KBb2YltI\n\t2jlEhJv2fZzbCshblvpa/+P6KNYX1qiN5QrMLqkbmdqYFmc2Q4qURbDV0lkIhHJMqIyarA\n\tTZB5DFuu4OMfc3rWaegpUkKAjzqZYE0=","X-MC-Unique":"hZEx4hqDNjaz7og4rWGzXA-1","X-Mimecast-MFC-AGG-ID":"hZEx4hqDNjaz7og4rWGzXA_1765375844","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1765375844; x=1765980644;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=KjxL1P88nRFT+hBLt1MUpBQCpKMqIjRo+EOedyWUsxc=;\n\tb=aB87vu0mba3xTtsea8XNYrC5nZVj0IL16AOsgyNf0GlXWadr+VcLcyOJVz6TkQnPVB\n\t3L8NEMcxO4GyDxS2LboKNeshlpCcWsKKFyuFbH+cmxURV78diiupem2kDe3aq/JCU9ri\n\tyT7AmLgM/zl3AekrWX3f8r8f0YrYIMnI6aHh6gGpALnj+ScxRp5PZPICHvVtmvDW3qzF\n\tINq6FH4+jNIZHH/DK8y5H8/1dBlS7OB7lBhHEGJovjhM7i5Pnh9bgRUHusDIsJinvMLC\n\tMcCeJU+7sVHDHkNtAK9/ZTpRngIskKGL6Z+lgzVChogbb3/p/O9EBO2UeE4iFktYJX//\n\tEYFg==","X-Gm-Message-State":"AOJu0YwGjSjgDGIHWjPaJXD8qvbwLmohhKyDtiJVK2iyCjn02dUglMXM\n\tJOyJL08z4YDKiq39cvOKrEyA678+Cudd9oqybIJ03fu8B16PRZ4V0OO8twH0YiA4z2JCYdeHn/h\n\t33sYXce8smas2nNM5hyBDFcwr830zZ+dicOCsRmH0tE6xNQYGa1fuBxmqNCZ7BspkFW1YL1mKF8\n\tk=","X-Gm-Gg":"AY/fxX4u+gj8xq8hJ8jOWKp+SNPw1b6gu30+43zKWmgoBwlBC9/E30d6lfUXMbivZtp\n\td3aX6b6eE0ZIXhTWAuy5FqYUJH9bsA7PY4MozKrQVbTOvkDs11JTJuetSbn7Y/Q1YeSt9bpD33l\n\tJaa+v9/0y20wNwnEgPBVW+2/obcyf+YVbm8a2lgdLRX4UkufBFuB5husUFkZr0EUoMG0mUHHxRx\n\tp8Ax6DgwZZAu1N1d169L/FoXmUeedC05d47yWv7TLC74wykHhN+SmkyI1cNO+Vis6AMr+FVHLZV\n\tJG8Rrk84X4r+hhNAjmBC4J6BaTCfoVSQoWCmyW9nmJemibsCI/Y2HRnLjwoa4ykyvymEhPpPslQ\n\tAqwxpH4OGU/M67QweJOcKSOhoFQ==","X-Received":["by 2002:a05:6000:220d:b0:42b:32d1:28ae with SMTP id\n\tffacd0b85a97d-42fa08628b6mr5810248f8f.22.1765375843846; \n\tWed, 10 Dec 2025 06:10:43 -0800 (PST)","by 2002:a05:6000:220d:b0:42b:32d1:28ae with SMTP id\n\tffacd0b85a97d-42fa08628b6mr5810221f8f.22.1765375843434; \n\tWed, 10 Dec 2025 06:10:43 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IHoVZixFDrQI/usA+Dk+3zd5IJlXkMNW4REzplKV3M59ixC1dWIy2L8TKltkcgk6FBlUK4cHw==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org,  pavel@ucw.cz","Subject":"Re: [PATCH v7 03/26] qcam: viewfinder_gl: Set no-op Bayer shader\n\tvalues","In-Reply-To":"<20251210005354.44726-4-bryan.odonoghue@linaro.org> (Bryan\n\tO'Donoghue's message of \"Wed, 10 Dec 2025 00:53:31 +0000\")","References":"<20251210005354.44726-1-bryan.odonoghue@linaro.org>\n\t<20251210005354.44726-4-bryan.odonoghue@linaro.org>","Date":"Wed, 10 Dec 2025 15:10:42 +0100","Message-ID":"<85cy4m5swt.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"E18WaXXNhRI5vJD-7vMDdpjZBGSU9qQl-bPpnbJwMro_1765375844","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]