From patchwork Fri Dec 12 00:29:14 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: 25518 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 68F0EBD1F1 for ; Fri, 12 Dec 2025 00:33:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2EEAC61637; Fri, 12 Dec 2025 01:33:34 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="T6s16xEI"; dkim-atps=neutral Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA7F461613 for ; Fri, 12 Dec 2025 01:33:32 +0100 (CET) Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-3438d4ae152so757924a91.1 for ; Thu, 11 Dec 2025 16:33:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765499611; x=1766104411; 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=II6CNKAdf/lZ/qp3rhzbc8QP/zzmnb1ppQZ/htfgUOs=; b=T6s16xEI61eN7a9mHZq0uRApXIvZNRcHI+hjm1dgnUlyprrsbIdIxKevcdhfGhrEmo SRAAIJrR1R4RZZM8+/u27puzEtLu+eaZaiwTXr49L7J4em/PIaAXGDG73y0aJLmriW8+ XHqzTUbpvSoY6MhmpTmJ18Zw/giTqmstIzmEFHNvGtmhDiMcBkrxXs/VR/s2pRZd30aq jsJGbeGziGinvdgAEpWEGIfXp3EhmkT6ct/yut9F+7/cRRUBCk/1ZM7mwZAJSLb4YuqX OwgLV+QnqWQyP5kfWLMe8371Yb01K8TgTpbkSGPJzVhepyspl4jy4123V0yXA9IsrF6r jm3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765499611; x=1766104411; 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=II6CNKAdf/lZ/qp3rhzbc8QP/zzmnb1ppQZ/htfgUOs=; b=i/gbXGYrLtUKFmzegP8mzaZqyQliVPAN2siQeKsUXe7qb6+LaiBJp3d8Zp9Vke+IY3 JqgAj+tRwlmFyJTqwLs7kUhcRHdB/67H5iFhm4ZD5bKoZoxJ63MA+OVwDR83Wy7CKU7h sqDCX24YZqCVxNPhjOFi9dfUN3NWTMtwcF6oamiI5HzzVMN4WC5sxYuFlQ2BSudEMmcJ Ep4V0dcCSNvG/P9FhlsQzgge5DnQEpbOgS6xZukMlxz8LzyoAWNdvxvrqi/UWqtcxMz9 9n+RAXp2bbRN6pwDGKzrrH1sxtRQ38eiUWGNXxBrKnEgNhRU56Qp2tzIgTQBSAyndwaF p9OA== X-Gm-Message-State: AOJu0YzYNs9VigsTzASyt6O9AOg2DT5u78cvG7XAPyXp6EFCkRsiah9U 5/vEmll4fSG1hfKLgYGClZEjF68Vz4fksDUEGD3kwEGnbja+W6y2XgaY53p1d9M/v83fQB68VOh nuYWD X-Gm-Gg: AY/fxX7U0q226wnwTV2SP1IwcNL0agnQBan3qzNVbJxM59Lvfo/6HnauAKyLtY24WUs oUeoi4BZf0WYaOBK+5H25e2S+lFZbuaxs7D0UT+DmESgQniCvpsVN0xM92428QoxbHjamnKHxyB nZAOH0mQDqe2LGRBinjf5VzYKxh+vV5yMZOz3v6kWNoD/UGwmB4pEfP182skznyEXFmg2NF1Yk1 fR9w0ELVet8vzJSprDqIppavRlGMsAuofFcGJ/V+tl1n1Jv6UbIRQfd7KCQT5LwMbLxbdCnbwqI ipCxV78k7hxT3Uk12UyqNHi7+6NgmUTDX/AdKyf/S6sko6lpM3yswCe4mCOYO4WXdBNG3lsl7T3 R+wuGaj1jptpT6zA4Lg3wYiyC5cyGzXcOufyIENl3OqEdRmRk5nUdRYCZjlf8smYsqv5gQh+zif eNdFXdf7PUsYKkQKDlLLgW+7vlEOkr1W1xruwyr66nF1+nJ1UNUjyvhiLaqKA= X-Google-Smtp-Source: AGHT+IFCrsq9Mnvc2KoWoBOxjvbj/0sIvnK4eglh1u1FvXFLkSz4CojcbdV6XRJWgPa+5W5bm1VlEQ== X-Received: by 2002:a17:90b:2b4d:b0:32d:f352:f764 with SMTP id 98e67ed59e1d1-34abe3e0134mr173771a91.2.1765499611114; Thu, 11 Dec 2025 16:33:31 -0800 (PST) Received: from inspiron14p-linux (p99250-ipoefx.ipoe.ocn.ne.jp. [153.246.134.249]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c0c26eb0f6bsm3317282a12.14.2025.12.11.16.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 16:33:30 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal Subject: [PATCH v8 03/26] qcam: viewfinder_gl: Set no-op Bayer shader values Date: Fri, 12 Dec 2025 00:29:14 +0000 Message-ID: <20251212002937.3118-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251212002937.3118-1-bryan.odonoghue@linaro.org> References: <20251212002937.3118-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 | 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..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_ */ };