From patchwork Wed Dec 10 00:53:31 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: 25420 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 A8C8BC3257 for ; Wed, 10 Dec 2025 00:54:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 680CA61433; Wed, 10 Dec 2025 01:54:26 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Q3OMJt8A"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CC2226143F for ; Wed, 10 Dec 2025 01:54:24 +0100 (CET) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-7d26a7e5639so7067341b3a.1 for ; Tue, 09 Dec 2025 16:54:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765328063; x=1765932863; 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=nKh2R98CltskZ5B+8q1efHLRqihcypTsWoFDV8/z7vs=; b=Q3OMJt8AciliIdJy17m45LVyNFRwpJfm03i0uTOJ/HJnbBiDDVaqTQiIj1cgvc/pwt q2RN5UFy0BMv9NKbsxGFsHkUax6H8z8fP7WP8F4PeXMzp6/jWHqkK/u1Qh3RrNY+xfaN 9/tThB23AQ9PZ4veuAD4cilUZ8UHPmZL4s9WeEZvVhCHQLmi6t0UoVWzT8tqmWlmSmIS 5qyJFheZ4djziro6KKuydR05OtvK91C0nB0oa2PF97O+xYt8j6Ja762w4nYyv6jYYHis JuY6+beAjpSL7O86abB1rm/Lx4AIwV7WIrc/a7RUl1vbE6S3RmX1svTjg24l3F4loG6N uStg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765328063; x=1765932863; 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=nKh2R98CltskZ5B+8q1efHLRqihcypTsWoFDV8/z7vs=; b=DzxLmlzpfzSwG5OA9+3T5bqNJZaLZDw9LwezcNqNq1GJh1L1K6bFJxfa00816jr6MU j0HF6vsfJ+yoGIoI13Lv4tuzlVnZf8y/d3NGLtnWzI1LJelQf5p2LwVz6fB8dGQ78HB+ 76N+ePOgRHBWc6VTf8NkG+T+vHE8BmFspeGmRx+o99o1BhJ7kYLKjv3X5v/t0uj8qiXI ucjcm3kJ3WAP/pEXaIVGeq1i2iFrlZiz2XJ3oXDjmdI9P/EoZBnQjXacvwhAQZ5VnRwP dPCGw0NmxQZVzDkocm1lUlACf52oMtF8hFK4Ccen5t15cw9FdMEHyRonhjtE2qLqVfZZ 75BA== X-Gm-Message-State: AOJu0Yw/9eEejn9VD1u614ckCOtLThl8Ox80A7CM0YJDYkd+jsqElPRU D1uCGWv+mBQ/uPrQ+UzK+yQVaYPoU+rt2vg9CXUttnPQOmpbfPaFnqxrZo2Yd9IxpPE3QoSYn1m yQ40k X-Gm-Gg: ASbGncuLuEV2s9NlcgWC/gtu0GQeF6djdfFcl+eCa6iI8Nlx2JHZ3vdnfWiWaCHZ4Ta 936cTAr+iPVJybj86J3193uOSOzwENH3S0lF6s0uBT3Ym2v6vlnw//fmjvdKPR5y1r7VKmw3k9D kkvAj0WPByuqGu6CLMtg5qiAj+6YCTEIAYUJ7YZFwWaUFa3F/MtzVCRaXw8+Bt6wSP/UKS689uv ab8QxnHkVTmZ84OEe6kYWuvZC+66QLA0Z0BkhiC96IO78Ty4cxU3zdBCfoWevbAO+g7op8xniRr P1rzN6Xx2H5+rr+IhTueHnaMQ0uCYzxg339rh0VMyFOeAvs7alweF3apC87LRu+m3XufBeSNsBq KUFRQctyN70s2caD1mnMKKGWq8kxzPP6mxne6ITW5+Mie+lxXaiSZ7wKxFPf1wnqIMFcWbNDDh3 GO3j4byGqx63XWBYC5gLimJsrNO1rmYkeqO3eVsv6iILQIjZz9Ydcxrfiej0pNzWPy X-Google-Smtp-Source: AGHT+IEz93e1CK0fP1bBoZBpnWosaStK6vQ5f3Lg0dC2s2LSt7B97AQCggyRorW34QSmzV9iDARmyQ== X-Received: by 2002:a05:6a20:3d0f:b0:366:14ac:e20f with SMTP id adf61e73a8af0-366e3ac8ae9mr530157637.77.1765328063126; Tue, 09 Dec 2025 16:54:23 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-bf6875cc8eesm16057762a12.16.2025.12.09.16.54.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:54:22 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v7 03/26] qcam: viewfinder_gl: Set no-op Bayer shader values Date: Wed, 10 Dec 2025 00:53:31 +0000 Message-ID: <20251210005354.44726-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210005354.44726-1-bryan.odonoghue@linaro.org> References: <20251210005354.44726-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. 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_ */ };