Patch Detail
Show a patch.
GET /api/patches/26880/?format=api
{ "id": 26880, "url": "https://patchwork.libcamera.org/api/patches/26880/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26880/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260615-libipa-algorithms-v1-3-e949c937422e@ideasonboard.com>", "date": "2026-06-15T14:05:28", "name": "[03/11] softisp: Split AWB from Combined Matrix", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "899d2b6871725bc6c98dbd1160e268ef4249ad1e", "submitter": { "id": 143, "url": "https://patchwork.libcamera.org/api/people/143/?format=api", "name": "Jacopo Mondi", "email": "jacopo.mondi@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26880/mbox/", "series": [ { "id": 5992, "url": "https://patchwork.libcamera.org/api/series/5992/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5992", "date": "2026-06-15T14:05:25", "name": "ipa: libipa: Introduce libipa algorithms", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5992/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26880/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26880/checks/", "tags": {}, "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 0B585C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 15 Jun 2026 14:06:00 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C1CE623FC;\n\tMon, 15 Jun 2026 16:05:54 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AD592623E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Jun 2026 16:05:47 +0200 (CEST)", "from [192.168.1.104] (net-93-65-100-155.cust.vodafonedsl.it\n\t[93.65.100.155])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DD121C59;\n\tMon, 15 Jun 2026 16:05:14 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BgRCbChG\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1781532315;\n\tbh=ZiPclq2MeaNu27qrQtHqVVg0Naj67q9W+X5UXQ/0yl4=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=BgRCbChGm7BjjTtDXCWmvSygvzKQd3WKBmUKlch68iQKOFLgDpPQFWLBKySNK/ZgL\n\tEFQ14LWua1+mpgLynhlMaWN8UcyD/682TZIpJXry5GHfFTvmnnQbFoVHrYP4wns3Cg\n\tzYSPH6qtz27smeXOEdhNpHyzWv3qo2omx7Ny/iXo=", "From": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Date": "Mon, 15 Jun 2026 16:05:28 +0200", "Subject": "[PATCH 03/11] softisp: Split AWB from Combined Matrix", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260615-libipa-algorithms-v1-3-e949c937422e@ideasonboard.com>", "References": "<20260615-libipa-algorithms-v1-0-e949c937422e@ideasonboard.com>", "In-Reply-To": "<20260615-libipa-algorithms-v1-0-e949c937422e@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>, \n\tKieran Bingham <kieran.bingham@ideasonboard.com>", "X-Mailer": "b4 0.14.3", "X-Developer-Signature": "v=1; a=openpgp-sha256; l=5890;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=sI2mHqGV/pTQpVaqsTnK9HOkhX5mykscCA5981d1dJk=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqMAa4hoOSNrIAZTLDfnP3B7TVdinXeVKbnz+JO\n\tukUG/ysgjKJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCajAGuAAKCRByNAaPFqFW\n\tPL7nD/4nl0nLbHWgIzdC6CFLw2MPP9V9qYqUeVchpWfXEfnmvdtpBjzEi+YrxYtTkrV11emsvm0\n\t2H/ktklsGikHxE/XhzTJ27hacqv7ZS6/11dP7RRbuSKWkRX5UmiTRT37bvZFEEeFpDNu2FwF5v4\n\tWLwUWsH9ckTwvdqO8NKxvZGUy7BKgV2d7eYJic9YIpdbjKpaGHoXO5nEE8EpRA1NOf2VQG7HmbH\n\tCj7VJkBuY4m1mUEPC/4ZRe1NfdmIE0m+A8tfJRXceyI7zkkUjj+L6WTfmQ5U6lylBdjtrf2DTGQ\n\tEH4PaVi85IK8MPjAAfbX3oGywDFbdrbzMcWIQxqLDuYeeI7SU1QRYTAm3YUVuxvi/0ExmJ24x1A\n\thZPhQHWPwVoRVjgeE4xFEJj9Xtqu11Lr9bgqjvuDMtVvg6SbDAuG01x3XDFgot69camWFA9t8rG\n\t6CfumjXE5pcKfBIZaXomiBVzNRGDpWhF0tpdJFEG6TjF3YWyPmn7wPPXaSjVDLAdcqqKDiNJs1Z\n\t7fb7JY77yALTPY9c2AT5VcQ5oYJsQdIKARkQjRSRz3v3Vdaig2ORTzCx76+0GotHYAcBAkDM7XI\n\tc+XwinbWSwhG6M5g5pkCb2ZLsHWfF+i3l52K5msTRs7UG5dNawxvwDx5MM342ZshMFIra1FIV8D\n\tY32khVWsW/KytkA==", "X-Developer-Key": "i=jacopo.mondi@ideasonboard.com; a=openpgp;\n\tfpr=72392EDC88144A65C701EA9BA5826A2587AD026B", "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>" }, "content": "From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nMove the AWB gains out of the combined matrix and pass\nthem directly to the EGL shaders.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/simple/algorithms/awb.cpp | 16 +++-------------\n src/ipa/simple/ipa_context.h | 5 +----\n src/libcamera/shaders/bayer_1x_packed.frag | 4 ++++\n src/libcamera/shaders/bayer_unpacked.frag | 4 ++++\n src/libcamera/software_isp/debayer_egl.cpp | 5 +++++\n src/libcamera/software_isp/debayer_egl.h | 3 +++\n 6 files changed, 20 insertions(+), 17 deletions(-)", "diff": "diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\nindex f5c88ea6f896..05155c83d172 100644\n--- a/src/ipa/simple/algorithms/awb.cpp\n+++ b/src/ipa/simple/algorithms/awb.cpp\n@@ -38,15 +38,8 @@ void Awb::prepare(IPAContext &context,\n \t\t DebayerParams *params)\n {\n \tauto &gains = context.activeState.awb.gains;\n-\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n-\t\t\t\t\t 0, gains.g(), 0,\n-\t\t\t\t\t 0, 0, gains.b() } };\n-\tcontext.activeState.combinedMatrix =\n-\t\tgainMatrix * context.activeState.combinedMatrix;\n-\n-\tframeContext.gains.red = gains.r();\n-\tframeContext.gains.blue = gains.b();\n \n+\tframeContext.gains = gains;\n \tparams->gains = gains;\n }\n \n@@ -59,11 +52,8 @@ void Awb::process(IPAContext &context,\n \tconst SwIspStats::Histogram &histogram = stats->yHistogram;\n \tconst uint8_t blackLevel = context.activeState.blc.level;\n \n-\tconst float mdGains[] = {\n-\t\tstatic_cast<float>(frameContext.gains.red),\n-\t\tstatic_cast<float>(frameContext.gains.blue)\n-\t};\n-\tmetadata.set(controls::ColourGains, mdGains);\n+\tmetadata.set(controls::ColourGains, { frameContext.gains.r(),\n+\t\t\t\t\t frameContext.gains.b() });\n \n \tif (!stats->valid)\n \t\treturn;\ndiff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\nindex 34f7403a41d6..8ccfacb46a59 100644\n--- a/src/ipa/simple/ipa_context.h\n+++ b/src/ipa/simple/ipa_context.h\n@@ -71,10 +71,7 @@ struct IPAFrameContext : public FrameContext {\n \t\tdouble gain;\n \t} sensor;\n \n-\tstruct {\n-\t\tdouble red;\n-\t\tdouble blue;\n-\t} gains;\n+\tRGB<float> gains;\n \n \tfloat gamma;\n \tstd::optional<float> contrast;\ndiff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag\nindex 23747f78a631..9a1992e219dd 100644\n--- a/src/libcamera/shaders/bayer_1x_packed.frag\n+++ b/src/libcamera/shaders/bayer_1x_packed.frag\n@@ -65,6 +65,7 @@ uniform vec2 tex_step;\n uniform vec2 tex_bayer_first_red;\n \n uniform sampler2D tex_y;\n+uniform vec3 awb;\n uniform mat3 ccm;\n uniform vec3 blacklevel;\n uniform float gamma;\n@@ -227,6 +228,9 @@ void main(void)\n \n \trgb = rgb - blacklevel;\n \n+\t/* Apply AWB gains, and saturate each channel at sensor range */\n+\trgb = clamp(rgb * awb, vec3(0.0), vec3(1.0) - blacklevel);\n+\n \t/*\n \t * CCM is a 3x3 in the format\n \t *\ndiff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag\nindex 1b85196ae161..2def33c82c8e 100644\n--- a/src/libcamera/shaders/bayer_unpacked.frag\n+++ b/src/libcamera/shaders/bayer_unpacked.frag\n@@ -24,6 +24,7 @@ uniform sampler2D tex_y;\n varying vec4 center;\n varying vec4 yCoord;\n varying vec4 xCoord;\n+uniform vec3 awb;\n uniform mat3 ccm;\n uniform vec3 blacklevel;\n uniform float gamma;\n@@ -130,6 +131,9 @@ void main(void) {\n \n rgb = rgb - blacklevel;\n \n+ /* Apply AWB gains, and saturate each channel at sensor range */\n+ rgb = clamp(rgb * awb, vec3(0.0), vec3(1.0) - blacklevel);\n+\n /*\n * CCM is a 3x3 in the format\n *\ndiff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex fd8de3942aa3..227f698a1fac 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -115,6 +115,7 @@ int DebayerEGL::getShaderVariableLocations(void)\n \tattributeTexture_ = glGetAttribLocation(programId_, \"textureIn\");\n \n \ttextureUniformBayerDataIn_ = glGetUniformLocation(programId_, \"tex_y\");\n+\tawbUniformDataIn_ = glGetUniformLocation(programId_, \"awb\");\n \tccmUniformDataIn_ = glGetUniformLocation(programId_, \"ccm\");\n \tblackLevelUniformDataIn_ = glGetUniformLocation(programId_, \"blacklevel\");\n \tgammaUniformDataIn_ = glGetUniformLocation(programId_, \"gamma\");\n@@ -128,6 +129,7 @@ int DebayerEGL::getShaderVariableLocations(void)\n \n \tLOG(Debayer, Debug) << \"vertexIn \" << attributeVertex_ << \" textureIn \" << attributeTexture_\n \t\t\t << \" tex_y \" << textureUniformBayerDataIn_\n+\t\t\t << \" awb \" << awbUniformDataIn_\n \t\t\t << \" ccm \" << ccmUniformDataIn_\n \t\t\t << \" blacklevel \" << blackLevelUniformDataIn_\n \t\t\t << \" gamma \" << gammaUniformDataIn_\n@@ -502,6 +504,9 @@ void DebayerEGL::setShaderVariableValues(const DebayerParams ¶ms)\n \tglUniform3f(blackLevelUniformDataIn_, params.blackLevel[0], params.blackLevel[1], params.blackLevel[2]);\n \tLOG(Debayer, Debug) << \" blackLevelUniformDataIn_ \" << blackLevelUniformDataIn_ << \" data \" << params.blackLevel;\n \n+\tglUniform3f(awbUniformDataIn_, params.gains[0], params.gains[1], params.gains[2]);\n+\tLOG(Debayer, Debug) << \" awbUniformDataIn_ \" << awbUniformDataIn_ << \" data \" << params.gains;\n+\n \t/*\n \t * Gamma\n \t */\ndiff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\nindex 943410fdd1fc..43038b45a109 100644\n--- a/src/libcamera/software_isp/debayer_egl.h\n+++ b/src/libcamera/software_isp/debayer_egl.h\n@@ -90,6 +90,9 @@ private:\n \n \tGLint textureUniformBayerDataIn_;\n \n+\t/* Per-frame AWB gains */\n+\tGLint awbUniformDataIn_;\n+\n \t/* Represent per-frame CCM as a uniform vector of floats 3 x 3 */\n \tGLint ccmUniformDataIn_;\n \n", "prefixes": [ "03/11" ] }