From patchwork Mon Jan 26 10:42:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick ten Wolde X-Patchwork-Id: 25959 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 7F892C3200 for ; Mon, 26 Jan 2026 10:48:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A981F61FD8; Mon, 26 Jan 2026 11:48:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Zkw4eQyb"; dkim-atps=neutral Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7874061A35 for ; Mon, 26 Jan 2026 11:43:03 +0100 (CET) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b87f00ec06aso696167566b.1 for ; Mon, 26 Jan 2026 02:43:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769424183; x=1770028983; 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=mgB6MrQvgMJiEZfORtJ9tLgqcmb2wkUK6G66JSN6xHI=; b=Zkw4eQyb6/gDvQVp3jzEIdfOTphTZSU2CQfgZeMfRNDAukKxtCeXNCocbfOwczlgla aP/vVb/TVv+K+Gdr35U+ZTajj5oNkWXCD/2cglf9Chkeim+9+l9L1RFNK2Jno1+8wSY/ YvJWIs5bSt05s0Cpei6K8VlYH9/4X9G8H+uitNmXf3j6lZIVNAVYBqz0HX48qs/89h6x sqN750KpCxY8ejh49TRuExasE6iv9Fh4j6my/y1pEYYJV/AHdtWq7M06KiyXw18eV9ge L5hBiX47QIBjMzIEqk+ib2GUyzzswUbzwj4ujj4LqUpT7idf0WRmZGIe8cyOtZyNBqjc 20JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769424183; x=1770028983; 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=mgB6MrQvgMJiEZfORtJ9tLgqcmb2wkUK6G66JSN6xHI=; b=hspEaiDDJE928uHEYyoxtWfLbDxj+ZKVebzAKFd+4RzRGN12VkYPdYZiWlNZjmAVRF Ud4V+CaA9vC+DHMntIx9eQIlB3rlHRQRr+SYKoWi3h0Thq/KTT0wxctBCuPEZAqxMpKO 4FsSvIV7QV3ORba1SDTyuBZPhebAJYboFdL8K+OYPKnRbW2gcBzwehdQpNlF+vnrp0o6 UJimX4ShY6VJWQutJ2Tgmo4HIbbApLNCiI/22isW9lOFCaQxQV7iO2nnDTAfHo6+Opnw mbi9RUz8TzH8UKHzlG2m5Np2d6/xHdE4BtifUXiYki78WKeDzw7JVqxwR5J7TNTJvZum Nkvg== X-Gm-Message-State: AOJu0Yw7cr93L7JW17zhV5WwC3ngS0PzSXktfw5Qmq7p4gIBN5vtOrP5 RHdwL9UItLTIhcpZzPx3VFMk0kOTXVx5KXLUoeeJT6hSCv1pKxnLM3D+UozgnQ== X-Gm-Gg: AZuq6aKAlmYbyaR7Iz98HHlTpfFaAOzQl1SooWekUqz/F5/fH6jZdpB4YcA6OD1xDhK T87m6PqaqBxG5z/0lfaThMRERF1St7Y11JQHFBgrRmSP335pXxSvOWuuK45Nevxl2V/SQR3WVbP jfHU8Ff/oFi/WHehrWwGIi5M2T+MMtJ3ZUtsy9dD7cREdlMDSLaorz+hcT4LT7ClqhOLgYRIiFq SfW6tzr93SdRjk4V4ywt+/+ZtUC3nrocDw7/FuPDqOp9pMWzdLOMgwmVpvi6G1Pyl5B+N6V55G+ daxA7a+rd/bY676m1R1Cm93808+5hEeJj8EYW6SztGtB4aC7rAN0alSXvmcyd1bYpWozK+HV4h/ Pelw9JJHVu6rdmnHEHgCmTrd9TvJxkvfW3lnxv/FJhCBECWNjEGnSifE0z83gkYqBssdM83Tzrv L+UIm4jJM2oDK0h3oxlTaTMzaf5scMVKaEboBJWVyy1N+LQ954bjyUZToQxxUIvQb2ZwEJViz5i Q== X-Received: by 2002:a17:907:1b18:b0:b80:4103:537e with SMTP id a640c23a62f3a-b8d2e89cfe6mr286424366b.53.1769424182505; Mon, 26 Jan 2026 02:43:02 -0800 (PST) Received: from castortop.wolde.loc (195-240-110-192.fixed.kpn.net. [195.240.110.192]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b885b7661f7sm599220366b.54.2026.01.26.02.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 02:43:02 -0800 (PST) From: Rick ten Wolde To: libcamera-devel@lists.libcamera.org Cc: xander.c.pronk@gmail.com, derekgielen@outlook.com, 22012540@student.hhs.nl, rick.w.ten.wolde@gmail.com, johannes.goede@oss.qualcomm.com, Rick ten Wolde Subject: [PATCH 1/7] libcamera: software_isp: egl: Add gl_scale_param to createTexture2D() Date: Mon, 26 Jan 2026 11:42:49 +0100 Message-ID: <20260126104256.119697-2-rick.w.ten.wolde@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> References: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 26 Jan 2026 11:48:05 +0100 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" From: Xander Pronk Add a gl_scale_param to createTexture2D() to allow overriding the currently hardcoded GL_NEAREST value. Co-authored-by: Rick ten Wolde Signed-off-by: Rick ten Wolde Signed-off-by: Xander Pronk --- include/libcamera/internal/egl.h | 2 +- src/libcamera/egl.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index a9292112..9c0504fb 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -113,7 +113,7 @@ public: int createInputDMABufTexture2D(eGLImage &eglImage, int fd); int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); void destroyDMABufTexture(eGLImage &eglImage); - void createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, void *data); + void createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, void *data, GLint gl_scale_param=GL_NEAREST); void pushEnv(std::vector &shaderEnv, const char *str); void makeCurrent(); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 0544056b..3565bfd3 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -229,13 +229,14 @@ void eGL::destroyDMABufTexture(eGLImage &eglImage) * \param[in] width Texture width in pixels * \param[in] height Texture height in pixels * \param[in] data Pointer to pixel data, or nullptr for uninitialised texture + * \param[in] gl_scale_param GL texture filter setting * * Creates a 2D texture from a CPU-accessible memory buffer. The texture * is configured with nearest filtering and clamp-to-edge wrapping. This * is useful for uploading static data like lookup tables or uniform color * matrices to the GPU. */ -void eGL::createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, void *data) +void eGL::createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, void *data, GLint gl_scale_param) { ASSERT(tid_ == Thread::currentId()); @@ -246,8 +247,8 @@ void eGL::createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data); // Nearest filtering - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_scale_param); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_scale_param); // Wrap to edge to avoid edge artifacts glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); From patchwork Mon Jan 26 10:42:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick ten Wolde X-Patchwork-Id: 25960 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 8E25CC3200 for ; Mon, 26 Jan 2026 10:48:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2B85B61FD7; Mon, 26 Jan 2026 11:48:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Nya3gXE0"; dkim-atps=neutral Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E24C61FC4 for ; Mon, 26 Jan 2026 11:43:04 +0100 (CET) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-b8842e5a2a1so564059666b.2 for ; Mon, 26 Jan 2026 02:43:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769424184; x=1770028984; 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=wWSSzFiNiBf6L+Vthr8dkX7/VQuxHw04abSGipA7PkA=; b=Nya3gXE0EhFhxquIa9y/4qMAAE5sV3Zfgt1D4wv8MV5iIUcfYdsx767BCGjyWfk+lF 9Lfvrx+Wu3H+OxvAt7R8EBAtMGxe/t0b0bj7V5GYj6mKlJxo7ywRrpck2GL4EwX8xM/K GEVFYfTBGKkRn+vgaXdg2gT1S3DXFLXsQiZxjLLHBOpFh5aIUxThogpMe90HHJQiYg8g H38kWRJeZgGyjAvEt2T1KFyAgYJoWqVk04hevKxKZIs9OdWStNsrAhHTWL6W11/4EeO+ 6iPOTh/8lphCsQbdoYey6z8SWrhUrY3bllAeObOxhmy5D9gte/L/mB/OeKf8qMcG4hE3 OGOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769424184; x=1770028984; 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=wWSSzFiNiBf6L+Vthr8dkX7/VQuxHw04abSGipA7PkA=; b=NHKC2xXh9MnZgjWG9O4FIqD8gRdiXGEPoZbuoSGYSaQfRKNlTdsmPusKfVeidfFLyU aI7WFkkt9kT1PT9lJNYir3isyYc19Wr7x1A3stPubQRsWrlJ1u4dPseQ/DoPiUFXaEe7 O9jGUMMdQOD8U98kqdinLYBkkEtVtErOo5qGrgZpXGu/uP0lmZUm+TpiZgPv/6/cMxZx 1AvETqNvU1XjyFOHsujKIEShcnefhNW/xX2Y9/d2Z2mAFoFXAwSOCeWKFe5i4t6TSJ+x fmZIT4nCz24ue7F5Y5wLrmicSf6mNlC4w+JNb3JIehlBOOlcAwsMw8LKN8/s1wZTvP0D sJBw== X-Gm-Message-State: AOJu0Yy2TOZtOpNJXCUJnUzuhb9DQs7I1whOxGALKmfanCXtIuHN7Bcr 64ccF+detilPbxismwsM1JMxL02qb6FYWdHmxxMhNa6JY6ej1qyK6uMaJ6ynvg== X-Gm-Gg: AZuq6aKfP3PPF1+dKod+zSWJLuoYxggbNutCRu/uRExVZStojvz/4cz7wDLrdIh7DXA mb+iUsX7MYnWj9MqRDI5dToF2xH7K7yQVuL1nrS+zuLpr/wwAUrwMQM3zuNN4k0gcdqj+biPjJi LtZBe04wiYoIpV31rKV+mk0tQMnkUmnrrQEsY3ljEFioapje02SAbo53SBYZalg1zWozoqJHAFx 8s7wb+cmUIwUUKXsYWxbt4cg12EsjO+Tc6lpEexztvcYnyTp1Ruq910A9+wDVJ5v9ePSgEX8iFF 3itMvYer0sKUbHitrguPmhk/5AQgu+QKAZiK7qfGaD6uYsUMG4pdx7Sr9c9ABZmJqlLt7hDGPAX MOyi+OSOTeyhcQIuD0lcHOjxc+l40kYHObt2+oVQkIaTHKP2eKxeeF7V/BpgStCdPh8nVf57f+S GV6KJvEmBrkg+H9IyirwUD0UntABT7syqQD2akdt9diZrnKNFrK/JREh8YTM0uHws= X-Received: by 2002:a17:907:709:b0:b87:73c9:3217 with SMTP id a640c23a62f3a-b8d4f75f70bmr232575966b.49.1769424183493; Mon, 26 Jan 2026 02:43:03 -0800 (PST) Received: from castortop.wolde.loc (195-240-110-192.fixed.kpn.net. [195.240.110.192]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b885b7661f7sm599220366b.54.2026.01.26.02.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 02:43:03 -0800 (PST) From: Rick ten Wolde To: libcamera-devel@lists.libcamera.org Cc: xander.c.pronk@gmail.com, derekgielen@outlook.com, 22012540@student.hhs.nl, rick.w.ten.wolde@gmail.com, johannes.goede@oss.qualcomm.com, Rick ten Wolde Subject: [PATCH 2/7] libcamera: software_isp: Add LSC data to DebayerParams Date: Mon, 26 Jan 2026 11:42:50 +0100 Message-ID: <20260126104256.119697-3-rick.w.ten.wolde@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> References: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 26 Jan 2026 11:48:05 +0100 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" From: Xander Pronk Add separate red, green and blue LSC tables to struct DebayerParams. Co-authored-by: Rick ten Wolde Signed-off-by: Rick ten Wolde Signed-off-by: Xander Pronk --- .../internal/software_isp/debayer_params.h | 6 ++++++ src/libcamera/software_isp/debayer.cpp | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 256c7d43..4252cd2d 100644 --- a/include/libcamera/internal/software_isp/debayer_params.h +++ b/include/libcamera/internal/software_isp/debayer_params.h @@ -30,6 +30,8 @@ struct DebayerParams { using LookupTable = std::array; using CcmLookupTable = std::array; + using LscLookupTable = uint8_t[16*16]; + /* * Color lookup tables when CCM is not used. * @@ -53,6 +55,10 @@ struct DebayerParams { CcmLookupTable blueCcm; LookupTable gammaLut; + LscLookupTable LSC_red; + LscLookupTable LSC_green; + LscLookupTable LSC_blue; + /* * Per frame corrections as calculated by the IPA */ diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 65a1762d..7a8b3462 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -65,6 +65,11 @@ namespace libcamera { * \brief Type of the CCM lookup tables for red, green, blue values */ +/** + * \typedef DebayerParams::LscLookupTable + * \brief Type of the LSC lookup tables + */ + /** * \var DebayerParams::red * \brief Lookup table for red color, mapping input values to output values @@ -120,6 +125,19 @@ namespace libcamera { * \brief Contrast value for GPUISP */ +/** + * \var DebayerParams::LSC_red + * \brief Per frame Lens shading correction red channel + */ +/** + * \var DebayerParams::LSC_green + * \brief Per frame Lens shading correction red channel + */ +/** + * \var DebayerParams::LSC_blue + * \brief Per frame Lens shading correction red channel + */ + /** * \class Debayer * \brief Base debayering class From patchwork Mon Jan 26 10:42:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick ten Wolde X-Patchwork-Id: 25961 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 3AEA5C328D for ; Mon, 26 Jan 2026 10:48:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CF78D61FD6; Mon, 26 Jan 2026 11:48:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UY0b3RIO"; dkim-atps=neutral Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 87E3061FCB for ; Mon, 26 Jan 2026 11:43:05 +0100 (CET) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-b885e8c6700so504149366b.0 for ; Mon, 26 Jan 2026 02:43:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769424185; x=1770028985; 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=BuGJ6GBXuA/foj3gVZf4nP7l068XJowglMv0fhOWjtQ=; b=UY0b3RIO+IG52Cg/rNTLsMTfeLbFH3aRqt/vVFGwNVftjmF+9VXAO25NHB/bD9Vp8u 2uRwdLwn7UyB/gX/kp/qlUwuUN6q+43Kw/z9co4QBJOvCykTEtZEq/q29RJcM+1MhA7t kSsV5CHQaxLxXwkx4031SBSrrOU4Go5EMDKiPvCtJIYJPqWqtiAKp27v1RYehv0MlShJ Ba6+x7PY2d6gwxADGbZne3wHta6DdP4Pxe3Cis9izEbEbUADnXTjSq+kiZVOW1QywCC5 2hcDpMM7uAknCTA9P/zeT61RdsskCB+s0j1YbyYu766nvCxHHY1u3dJYUQsJ58/ZrT6o CRjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769424185; x=1770028985; 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=BuGJ6GBXuA/foj3gVZf4nP7l068XJowglMv0fhOWjtQ=; b=lRCe9NcB/v9U/e4NAaqsxsePPWOxU/Zscl0DlEVSw2Bf+hZOnRWyxA9qMf5po5fnwn z0sO892g4z2WH8KUoNGqS7XeTt+zFgpA/uWSHVScI1zNDpUP6v4xBxUKY6ekX61navaq PgEZ67QyD+KDMkEGEdFQhIyvCMsUKhx5OKtcmTdqdA16Pead6ek+NLpCnbLZ9D2J1xUX o4aGR2VlCkq5n193aNUQARzJ/qkdra4XJViTXjV2td/y3WCckxiF0QJyBnLqH42IpMES gNcrAL7VxCz1xakGW84MzCaVMZcFhOcLkTpFJMBytoRHZ43qiXWUuuPGDNbY7Y6V+J92 aHrA== X-Gm-Message-State: AOJu0YwaJNT452I6mEjfO8jUA9CxRrmMIa/bCae6lVDM7jazVW66n6iT 2FpJysO5NekQ9zhvscAXbfBwQIBOFuQHvqTOjLt8R/MY82dntavnbFvgZ2zPPw== X-Gm-Gg: AZuq6aJVPf2s0jpI/KDssnQtbOAUwEyRQLkoa1MJH4xfdOItDmpfume4V+IkpBfOzlZ wxDK59jIq1udXzAQlPLzmkP79COPkwm4UehjjVTw1BaIQgMMMqw9bfavG3rIJI5tlbZjv+fqGvQ +c7MdhsU85nX+msGhWnp7Zstfyu/Ho44TruL4UuZYC/dHsyRkb6SwswqdNXvHMivxH3jMx0gaz5 VsklqVXd3Cyu5qB4t/euEGD/uNjjxgeKVB7qkuoUvgKR9JhN3rGWp801ZEVUrxW7OFcneUE7EL5 8A96YjhXKwUHJu0PMnXmQMgGPIICTXqK4x9o9PBiFbBDJzMvS6tsIsQajc6vxaW7RLZAIhBOTzT m42dhxrClLMRvKyEiscW5Nnu8YAy5aI6WRTGbxrjOmD0/0oTxxsw+tQGXpxpLRikbKjKPY87BmE yEjETPUI6vwdB6kIfAT8rK5D6RSKURzp4YDWGGxNhIZv0PLrcAU+OtGTvby3Y2660= X-Received: by 2002:a17:907:1c15:b0:b88:5957:2d65 with SMTP id a640c23a62f3a-b8d20e49d2dmr287851366b.37.1769424184303; Mon, 26 Jan 2026 02:43:04 -0800 (PST) Received: from castortop.wolde.loc (195-240-110-192.fixed.kpn.net. [195.240.110.192]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b885b7661f7sm599220366b.54.2026.01.26.02.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 02:43:03 -0800 (PST) From: Rick ten Wolde To: libcamera-devel@lists.libcamera.org Cc: xander.c.pronk@gmail.com, derekgielen@outlook.com, 22012540@student.hhs.nl, rick.w.ten.wolde@gmail.com, johannes.goede@oss.qualcomm.com, Rick ten Wolde Subject: [PATCH 3/7] ipa: simple: Add LSC algorithm Date: Mon, 26 Jan 2026 11:42:51 +0100 Message-ID: <20260126104256.119697-4-rick.w.ten.wolde@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> References: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 26 Jan 2026 11:48:05 +0100 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" From: Xander Pronk Add LSC algorithm module. Co-authored-by: Rick ten Wolde Signed-off-by: Rick ten Wolde Signed-off-by: Xander Pronk --- src/ipa/simple/algorithms/lsc.cpp | 69 +++++++++++++++++++++++++++ src/ipa/simple/algorithms/lsc.h | 49 +++++++++++++++++++ src/ipa/simple/algorithms/meson.build | 1 + 3 files changed, 119 insertions(+) create mode 100644 src/ipa/simple/algorithms/lsc.cpp create mode 100644 src/ipa/simple/algorithms/lsc.h diff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp new file mode 100644 index 00000000..95783e4e --- /dev/null +++ b/src/ipa/simple/algorithms/lsc.cpp @@ -0,0 +1,69 @@ +#include "lsc.h" + +#include + +#include +#include + +#include + +#include "libcamera/internal/matrix.h" + + +namespace libcamera { + +namespace ipa::soft::algorithms { + +LOG_DEFINE_CATEGORY(IPASoftLsc) +int Lsc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) +{ + int ret_r = lsc_r.readYaml(tuningData["grids"], "ct", "r"); + int ret_g = lsc_r.readYaml(tuningData["grids"], "ct", "g"); + int ret_b = lsc_r.readYaml(tuningData["grids"], "ct", "b"); + + if (ret_r < 0 || ret_g < 0 || ret_b < 0) { + LOG(IPASoftLsc, Error) + << "Failed to parse 'lsc' parameter from tuning file."; + return -1; + } + + return 0; +} + +int Lsc::configure([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const IPAConfigInfo &configInfo) +{ + return 0; +} + + +void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params) +{ + unsigned int ct = context.activeState.awb.temperatureK; + if (ct == 0) + ct = 2700; + const Matrix matrix_r = lsc_r.getInterpolated(ct); + const Matrix matrix_g = lsc_r.getInterpolated(ct); + const Matrix matrix_b = lsc_r.getInterpolated(ct); + + for (unsigned long i = 0; i < matrix_r.data().size(); ++i) { + params->LSC_red[i] = matrix_r.data()[i]; + params->LSC_green[i] = matrix_g.data()[i]; + params->LSC_blue[i] = matrix_b.data()[i]; + } +} + +void Lsc::process([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + [[maybe_unused]] const SwIspStats *stats, + [[maybe_unused]] ControlList &metadata) +{ +} + +REGISTER_IPA_ALGORITHM(Lsc, "Lsc") + +} /* namespace ipa::soft::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/simple/algorithms/lsc.h b/src/ipa/simple/algorithms/lsc.h new file mode 100644 index 00000000..8a3123ad --- /dev/null +++ b/src/ipa/simple/algorithms/lsc.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024-2025, Red Hat Inc. + * + * Color correction matrix + */ + +#pragma once + +#include + +#include "libcamera/internal/matrix.h" + +#include + +#include "algorithm.h" + +namespace libcamera { + +namespace ipa::soft::algorithms { + + +class Lsc : public Algorithm +{ +public: + Lsc() = default; + ~Lsc() = default; + + int init(IPAContext &context, const YamlObject &tuningData) override; + int configure(IPAContext &context, + const IPAConfigInfo &configInfo) override; + void prepare(IPAContext &context, + const uint32_t frame, + IPAFrameContext &frameContext, + DebayerParams *params) override; + void process(IPAContext &context, const uint32_t frame, + IPAFrameContext &frameContext, + const SwIspStats *stats, + ControlList &metadata) override; + +private: + Interpolator> lsc_r; + Interpolator> lsc_g; + Interpolator> lsc_b; +}; + +} /* namespace ipa::soft::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/simple/algorithms/meson.build b/src/ipa/simple/algorithms/meson.build index 2d0adb05..9cfc8030 100644 --- a/src/ipa/simple/algorithms/meson.build +++ b/src/ipa/simple/algorithms/meson.build @@ -6,4 +6,5 @@ soft_simple_ipa_algorithms = files([ 'blc.cpp', 'ccm.cpp', 'lut.cpp', + 'lsc.cpp', ]) From patchwork Mon Jan 26 10:42:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick ten Wolde X-Patchwork-Id: 25962 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 7F43CC3200 for ; Mon, 26 Jan 2026 10:48:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8A76261FD5; Mon, 26 Jan 2026 11:48:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KzgEoY+9"; dkim-atps=neutral Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 51F0D61FC6 for ; Mon, 26 Jan 2026 11:43:06 +0100 (CET) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-65814266b08so8138674a12.3 for ; Mon, 26 Jan 2026 02:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769424185; x=1770028985; 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=hUrNU95/FgP7yuTKuaSCsMb4lMgbTn8lfvIZcnyIu30=; b=KzgEoY+9ef7aNT0BwoVpPFFVA8Yfsxnu9PS4h9L/aOY/v/zkwBlYMjpZHgzRgUthss 2NCmznejTJdncjDG4o1xIvYDesSzSCvB7/aDRrW00y6SNds+TrN6H5FK5CMrwokQXGui D4kYCKyKVAjzWwguKU41Cja/DlqVT3FjrbtfpWDJU2sXMnoqmO3rLBC1xXto4qX9qxp/ tBmYrobzdds9nVJ4cgiqyOL/IB2DOBEaWlkf19Te9N6sP+51X0iZoKfn7zcyJaNyfRsZ tPRgodMhOwShaZLGhHMCrRlySmz64Nv73CMlWiNq2uq98YG8EM9j3fB5jFYLD9sXbwh3 /kvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769424185; x=1770028985; 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=hUrNU95/FgP7yuTKuaSCsMb4lMgbTn8lfvIZcnyIu30=; b=G0hhfswG9KZnC0IR12CBE8ee/gYRwjBTqzQ1qNJY+HXPmf0NswWLw17Mo7CjtEHx9b XO2D8d3q1rdAQmJ8F5118csAnP2tVhTEDEztZn0VojLNNx15crC9QU9kpfaAgyobOHWX bY0fa/e+fzgOJsfuS/t8Wwu5EAMaiY0QDav6zQhvQmur8xh1IjCQHiXJdwWxMIsKBQt5 HbWTOMmRddcpmpvNaZqY+shyBrormlT28wSqISRCUlsPuDBh6wrGZ1Pa6N1UvQSKFgt0 KSPMnU63udNJgGReQGBfkGhzzJaH6t/+r5TkXcFQzzBO2QZH7zJdOv1Kncgtp+sgreJo EtZA== X-Gm-Message-State: AOJu0Yxqo7l4XP7zPEpnUoihMFrdFmia1mM1b3y5vW2wBkwoJaraH08n MA/OLJh6Pmei/RH+f6GbW7eqSp6C3mZ3SIDg4DsF3Lco6LrOYK3K+dOT4R9UdQ== X-Gm-Gg: AZuq6aKI1qQD94khhbrBgI13LEW2PcgCTbHcGyq4Hl/e8nRTldfKWZIqrgO1xeuAIfA ULGFzaIIwQFDdcHktXLpMP0Ld26UFMypdXKesYkRoZwmTw68XUyhHw9r/ZUiSF0aXqmzZ6ol6to 0LZ3z7RZg+81fVD7q21+INn4XGtfXi/9TPAzrT8hN3tITqD3quz9PfCaF5LhJ7UwWcbl7Tod9W6 Ytl+WpTKEyN6aj0Yyk53ss9gkHTBYqPovX5hiEmysxQ8KIQkESB4W/eM5JH01ilUIS89NWfm4ML mmEkDleKTKiPyLVhevpM5mS5Xc4MZpGxhqp5OUv38e4rJbu0/cBrJfObaIDbbVZlnvwdgJk8ZAB goZQ96NYz/fq3x0PURH0DB61U8m7Qhcl8psnDM3U03tnOv0S2ds+bKUz5pkDvcNoviNcwuC8gWu u8feQFgphsat9HA8KZT3mjk/2q7+tPqujpXNPdjwe45WlQdpF6+yaX1xBY7N4E3nwEfVI8zYtXI Q== X-Received: by 2002:a17:907:3da5:b0:b75:7b39:88bc with SMTP id a640c23a62f3a-b8d2e833e71mr300233166b.58.1769424185235; Mon, 26 Jan 2026 02:43:05 -0800 (PST) Received: from castortop.wolde.loc (195-240-110-192.fixed.kpn.net. [195.240.110.192]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b885b7661f7sm599220366b.54.2026.01.26.02.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 02:43:04 -0800 (PST) From: Rick ten Wolde To: libcamera-devel@lists.libcamera.org Cc: xander.c.pronk@gmail.com, derekgielen@outlook.com, 22012540@student.hhs.nl, rick.w.ten.wolde@gmail.com, johannes.goede@oss.qualcomm.com, Rick ten Wolde Subject: [PATCH 4/7] libcamera: shaders: Add LSC support Date: Mon, 26 Jan 2026 11:42:52 +0100 Message-ID: <20260126104256.119697-5-rick.w.ten.wolde@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> References: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 26 Jan 2026 11:48:05 +0100 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" From: Xander Pronk Apply LSC after black-level and before CCM operations. Co-authored-by: Rick ten Wolde Signed-off-by: Rick ten Wolde Signed-off-by: Xander Pronk --- src/libcamera/shaders/bayer_1x_packed.frag | 10 ++++++++++ src/libcamera/shaders/bayer_unpacked.frag | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag index 23747f78..7993ea1d 100644 --- a/src/libcamera/shaders/bayer_1x_packed.frag +++ b/src/libcamera/shaders/bayer_1x_packed.frag @@ -70,6 +70,10 @@ uniform vec3 blacklevel; uniform float gamma; uniform float contrastExp; +uniform sampler2D lsc_tex_red; +uniform sampler2D lsc_tex_blue; +uniform sampler2D lsc_tex_green; + float apply_contrast(float value) { // Apply simple S-curve @@ -227,6 +231,12 @@ void main(void) rgb = rgb - blacklevel; + #if defined(DO_LSC) + rgb.r = rgb.r + rgb.r * 3.0 * texture2D(lsc_tex_red, textureOut).x; + rgb.g = rgb.g + rgb.g * 3.0 * texture2D(lsc_tex_green, textureOut).x; + rgb.b = rgb.b + rgb.b * 3.0 * texture2D(lsc_tex_blue, textureOut).x; + #endif + /* * CCM is a 3x3 in the format * diff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag index 1b85196a..f0b9a6cc 100644 --- a/src/libcamera/shaders/bayer_unpacked.frag +++ b/src/libcamera/shaders/bayer_unpacked.frag @@ -29,6 +29,10 @@ uniform vec3 blacklevel; uniform float gamma; uniform float contrastExp; +uniform sampler2D lsc_tex_red; +uniform sampler2D lsc_tex_blue; +uniform sampler2D lsc_tex_green; + float apply_contrast(float value) { // Apply simple S-curve @@ -130,6 +134,12 @@ void main(void) { rgb = rgb - blacklevel; + #if defined(DO_LSC) + rgb.r = rgb.r + rgb.r * 3.0 * texture2D(lsc_tex_red, center.xy).x; + rgb.g = rgb.g + rgb.g * 3.0 * texture2D(lsc_tex_green, center.xy).x; + rgb.b = rgb.b + rgb.b * 3.0 * texture2D(lsc_tex_blue, center.xy).x; + #endif + /* * CCM is a 3x3 in the format * From patchwork Mon Jan 26 10:42:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick ten Wolde X-Patchwork-Id: 25963 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 98C7EC328D for ; Mon, 26 Jan 2026 10:48:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3711F61FD0; Mon, 26 Jan 2026 11:48:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="O++7Y6JV"; dkim-atps=neutral Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BCD661FC6 for ; Mon, 26 Jan 2026 11:43:07 +0100 (CET) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b8845cb5862so655827066b.3 for ; Mon, 26 Jan 2026 02:43:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769424186; x=1770028986; 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=s9qGY5xhUN7J9aorua9sfoM5bJq/KrIFPoQOSqH6Ufk=; b=O++7Y6JViseowHgXOvwc1IlifyiBcQ2/d5mPvwvalLr0pqTUxwM8SFCskCKrJD2jld 5T7OEMCHdbL/yeD2X81iiH9+aT/u0qzXKjspRzkTJ1TACAigGcNEsezPJqqB3onEkzp4 8cpsU2R+ptfe37smCFxFMyTlyNK/8QRz8j/CWOH9HDh7PJTxZ72EQVGvmdP6yFeDdMq8 vEQEMKRM7f2/dc4WGlk4pApAHNlZxNFG5LBNNhmiirGAEjHmGSJf7ZxL9bdpV5H8qr/M VoIfQImyUnDiQ8sOmAfSByC92hEFhKg36vPC8pydkKUwu3FoJdIDR8FHs1XISf9RVusf ggLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769424186; x=1770028986; 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=s9qGY5xhUN7J9aorua9sfoM5bJq/KrIFPoQOSqH6Ufk=; b=OmZOjiySD+rUDPMgDA3dUEwKTBq82MSkb3K3H8Sp8uGJL8DOJZBZoot3n9lhzGyz1f 4gseVuXGtGC8l8stJa3juRHMW/of0WZjHTbM4RhTttPx3FidsMJYmzNoKNFTisQ8CNxC GO+Y+KSI4yZXdh/DIhj7MWHmWhQmAvIxHaVoWoR7T/GRtFGZANIWTE74aWAN9kWvAEE4 ZhNTMkAedG81H3y8+knIQTGDsHg2mTuEoHSOggz2O8muUaCFdtf6cqIyoSUR4XIaWxrZ ZeW6b8uxD/xp+SFRdjch1m96IJMwhLkZ+3CRhTUB4LkWSCGZSnEfa+jZgeD4/hSf5sLa qisw== X-Gm-Message-State: AOJu0YyvNFEVrrVYykK6eGy7LKMY6lnqPoAqyLqLXVgr06UgOHkkUF3y Iuqtw5tZSYcOtOSahaYyfc+ak1/lyr2ObIJf7cqOPu3hvfC6lj7GrsoTJFbNlg== X-Gm-Gg: AZuq6aJEjTb48RixPOU132upIyGaGtTRqSuDloZFw8i71s7fHWyvzZU4qP2uYcYkWdS cK2bj9Nfu3LUNw7k6sQEkS656ViUc9L8MtUQmIhL/peSn3TnP3ISgcNTedTW83GzxXsBtM6sGdm NVB9JENVcE61vL8Zj3zk8ZGjOVUiu0m61ED5Z0ZJD9P7fhHlKOUy9aVLTZvIE3mQ6dVQR19h8s5 7XhRlkGaam6aIxYZc2nZqklAARwmyJL0ljPZGPEtSkorZ2xU50B3P0LewLpIXakJBBbXSUAD1SV eF/QOBxPXmiifQVTf2GvSuJSrQY1uisHvKp5sh7Ge6/AP3JOmo/iBWKATyjzGyeu4ZbY9VKWIdT VstYX+UFRC50O9C/Ljwuj/ugvOEDXIsqTtO+FciyTFXxsD9/zFP5N8IwZVx1j+5EOKa/Ie+pHS4 OToP6nYiU0DUDoVqvfdOTB5gaLD+POa++sqwu1kzlKUwEV4MRa4iBq/XjAi/Bx2PA= X-Received: by 2002:a17:907:868e:b0:b87:2f29:2060 with SMTP id a640c23a62f3a-b8d20d83807mr311882566b.26.1769424186118; Mon, 26 Jan 2026 02:43:06 -0800 (PST) Received: from castortop.wolde.loc (195-240-110-192.fixed.kpn.net. [195.240.110.192]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b885b7661f7sm599220366b.54.2026.01.26.02.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 02:43:05 -0800 (PST) From: Rick ten Wolde To: libcamera-devel@lists.libcamera.org Cc: xander.c.pronk@gmail.com, derekgielen@outlook.com, 22012540@student.hhs.nl, rick.w.ten.wolde@gmail.com, johannes.goede@oss.qualcomm.com, Rick ten Wolde Subject: [PATCH 5/7] libcamera: software_isp: debayer_egl: Add LSC support Date: Mon, 26 Jan 2026 11:42:53 +0100 Message-ID: <20260126104256.119697-6-rick.w.ten.wolde@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> References: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 26 Jan 2026 11:48:05 +0100 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" From: Xander Pronk Add support for passing the LSC tables from debayerParams to the shaders. Co-authored-by: Rick ten Wolde Signed-off-by: Rick ten Wolde Signed-off-by: Xander Pronk --- src/libcamera/software_isp/debayer_egl.cpp | 21 +++++++++++++++++++++ src/libcamera/software_isp/debayer_egl.h | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 8e089032..0f36b149 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -111,6 +111,10 @@ int DebayerEGL::getShaderVariableLocations(void) textureUniformBayerFirstRed_ = glGetUniformLocation(programId_, "tex_bayer_first_red"); textureUniformProjMatrix_ = glGetUniformLocation(programId_, "proj_matrix"); + textureUniformLSCRed_ = glGetUniformLocation(programId_, "lsc_tex_red"); + textureUniformLSCGreen_ = glGetUniformLocation(programId_, "lsc_tex_green"); + textureUniformLSCBlue_ = glGetUniformLocation(programId_, "lsc_tex_blue"); + LOG(Debayer, Debug) << "vertexIn " << attributeVertex_ << " textureIn " << attributeTexture_ << " tex_y " << textureUniformBayerDataIn_ << " ccm " << ccmUniformDataIn_ @@ -140,6 +144,9 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm /* Specify GL_OES_EGL_image_external */ egl_.pushEnv(shaderEnv, "#extension GL_OES_EGL_image_external: enable"); + /* Always use LSC */ + egl_.pushEnv(shaderEnv, "#define DO_LSC"); + /* * Tell shaders how to re-order output taking account of how the * pixels are actually stored by GBM @@ -349,6 +356,12 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, */ stats_->setWindow(Rectangle(window_.size())); + eglImageLSCLookupRed_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5); + eglImageLSCLookupGreen_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5); + eglImageLSCLookupBlue_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5); + if (!eglImageLSCLookupRed_ || !eglImageLSCLookupGreen_ || !eglImageLSCLookupBlue_) + return -ENOMEM; + return 0; } @@ -488,6 +501,14 @@ void DebayerEGL::setShaderVariableValues(DebayerParams ¶ms) glUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm); LOG(Debayer, Debug) << " ccmUniformDataIn_ " << ccmUniformDataIn_ << " data " << params.ccm; + egl_.createTexture2D(*eglImageLSCLookupRed_, GL_LUMINANCE, 16, 16, ¶ms.LSC_red, GL_LINEAR); + egl_.createTexture2D(*eglImageLSCLookupBlue_, GL_LUMINANCE, 16, 16, ¶ms.LSC_green, GL_LINEAR); + egl_.createTexture2D(*eglImageLSCLookupGreen_, GL_LUMINANCE, 16, 16, ¶ms.LSC_blue, GL_LINEAR); + + glUniform1i(textureUniformLSCRed_, eglImageLSCLookupRed_->texture_unit_uniform_id_); + glUniform1i(textureUniformLSCGreen_, eglImageLSCLookupGreen_->texture_unit_uniform_id_); + glUniform1i(textureUniformLSCBlue_, eglImageLSCLookupBlue_->texture_unit_uniform_id_); + /* * 0 = Red, 1 = Green, 2 = Blue */ diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index a5033bc6..61feadab 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -85,6 +85,11 @@ private: std::unique_ptr eglImageBayerIn_; std::unique_ptr eglImageBayerOut_; + /* Pointer to object representing input texture */ + eGLImage *eglImageLSCLookupRed_; + eGLImage *eglImageLSCLookupBlue_; + eGLImage *eglImageLSCLookupGreen_; + /* Shader parameters */ float firstRed_x_; float firstRed_y_; @@ -98,6 +103,10 @@ private: GLint textureUniformBayerDataIn_; + GLint textureUniformLSCRed_; + GLint textureUniformLSCGreen_; + GLint textureUniformLSCBlue_; + /* Represent per-frame CCM as a uniform vector of floats 3 x 3 */ GLint ccmUniformDataIn_; From patchwork Mon Jan 26 10:42:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick ten Wolde X-Patchwork-Id: 25964 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 792CBC32E7 for ; Mon, 26 Jan 2026 10:48:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E5B4C61FD1; Mon, 26 Jan 2026 11:48:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BiVQyINT"; dkim-atps=neutral Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3399C61FD3 for ; Mon, 26 Jan 2026 11:43:08 +0100 (CET) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-b8850aa5b56so622017866b.2 for ; Mon, 26 Jan 2026 02:43:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769424187; x=1770028987; 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=UGMhLAQJP7biuVIZMSesOWnaMhbq21WkJYjcWc6nhwQ=; b=BiVQyINTRtuMoSFKmFBtaVpfqeZqz5rQ2dsi5KveDjpb6HbnvFC6nY4p9Gp7Ky1FNn aNoxO989p3Uj8w5HI8hZFe5/iymYryWIJkwnxpxHhieoHI3pY74Q3oRHZqyV8igzWEWh /RJPfhpxy9RnOBcrFAdLDSJVYQcuLWxZ8JxcznD9y5BRB+cys5R108IyOiIL989l7u8A FnnW8eGa5M4BOrcZo7NX3+tuTFZzZB9QIXZrzK0aENkx5GrAFKzfVEmO3RlRgS73slHE 70/Osve22Q0mM20lWvMQpuaBLIWC0lK/p1aT9olgut+Oh18G2cyzB4aI6oHtBayUehK/ 5N/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769424187; x=1770028987; 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=UGMhLAQJP7biuVIZMSesOWnaMhbq21WkJYjcWc6nhwQ=; b=GRjrO6DEpuWyK6wPf6Vy3Z1uiqL3tQwHmT5Id1MKtgZjmy2sDCTcLNDYTfQQvKCoPM Se5WWomiDym4F6eftqqMCpFU2hUdsNkVSgLbmwAu+4no7Nsm9pd8WfKBKnl7J1olAa8V +7ylBK32OZ3ECWmCAAubLjmkwhJI92pGxYc+LfzFNLSy6my6kAyiujL7vzPvVrDuhQAA dsiVUBHyeEhJ/5kcooY3jH057pIR1y59RpJn+KcZTG0GAlpoKIvUEjpzlBy7YjN+QnBH 4EXVMdJgOgnLExZF6KouqNb3PcVW+3VwKQXt2AWFLAJv39aUAdJ1bGfjRnbDZs+FcDMf o9RQ== X-Gm-Message-State: AOJu0YxRH0bogJ1fMlXyM3OrS/UDU7cZnp7MK+x73eLUl22zaGHp0qFW /Hp5pHCxCZfRWuL6Si5mIY+uEvqkdBx7SsgyYk0UJfHAa5wnEuvF4P55+cNrPw== X-Gm-Gg: AZuq6aKkFGrITgDbsYMZL0+WXnfr8juzpyaHNIrYRiN9M4XW4zmPSOss7JfqcjKhT8r oSbfsHQAAyozfIRm7iSi3h9a2QYpJRiX9Dg67iw9scMcCSN00GPDbSALWU5y1jR0pgxp4GZrPhL X99er6sn02sPsvkr69ZvsSUglmmUek6dv0Pdd8jedmRwN7Y/UWDDlejtNIHiGaY6gdYreGIxR8p TAgpgpnOPrY2MvWnyl2QTXnsTM+V/lGqCmV3rAPJpFgbp0vey57G+sTmsJPYv7kMXyhsBcELj+A NQOUO2Glx8MCHqBGq6shoyn8PQiIumIxCMPst7L6HiRpLbY3HmLTJp+bFKYvRI0Fc7EFABmQxtc MtJx7xXIrtkUoDs+Q6aQlcg7sH5YBM+iLC539Ot/Fnio5A2F8VLCf6didyvdRg7u/GtK+NF/8j0 hFUtp87gTOXFcbmmqwprn/QuKIOb/7B2/zt1KPl/0sEiaY9VAFpo0Je9tkgjuh7m4= X-Received: by 2002:a17:907:7b85:b0:b88:2848:dec8 with SMTP id a640c23a62f3a-b8d2e8330ddmr324052666b.54.1769424187157; Mon, 26 Jan 2026 02:43:07 -0800 (PST) Received: from castortop.wolde.loc (195-240-110-192.fixed.kpn.net. [195.240.110.192]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b885b7661f7sm599220366b.54.2026.01.26.02.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 02:43:06 -0800 (PST) From: Rick ten Wolde To: libcamera-devel@lists.libcamera.org Cc: xander.c.pronk@gmail.com, derekgielen@outlook.com, 22012540@student.hhs.nl, rick.w.ten.wolde@gmail.com, johannes.goede@oss.qualcomm.com, Aron Dosti Subject: [PATCH 6/7] utils/tuning: Add LSC scripts Date: Mon, 26 Jan 2026 11:42:54 +0100 Message-ID: <20260126104256.119697-7-rick.w.ten.wolde@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> References: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 26 Jan 2026 11:48:05 +0100 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" From: Derek Gielen Add script for the conversion of the tuning file to a format usable by the lens shading correction shader. Add script for visualizing the lens shading correction using pyplot. Co-authored-by: Aron Dosti Signed-off-by: Aron Dosti Signed-off-by: Derek Gielen --- utils/tuning/exportTuningToLscShader.py | 120 ++++++++++++++++++++++++ utils/tuning/generate_lsc_map_plot.py | 76 +++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 utils/tuning/exportTuningToLscShader.py create mode 100644 utils/tuning/generate_lsc_map_plot.py diff --git a/utils/tuning/exportTuningToLscShader.py b/utils/tuning/exportTuningToLscShader.py new file mode 100644 index 00000000..4f07aa1e --- /dev/null +++ b/utils/tuning/exportTuningToLscShader.py @@ -0,0 +1,120 @@ +import yaml +import numpy as np +import argparse +import sys + +# --- Configuration --- +GRID_W = 16 +GRID_H = 16 + +# Formula constants +BLACK_LEVEL = 1024.0 +SCALE_FACTOR = 3071 # Divisor to map the range to 0-255 + +def load_and_process_yaml(input_filename, target_ct): + # 1. Load the YAML file + try: + with open(input_filename, 'r') as f: + data = yaml.safe_load(f) + except FileNotFoundError: + print(f"Error: Input file '{input_filename}' not found.") + return None, None, None + + # 2. Find the LensShadingCorrection block + lsc_data = None + for algo in data['algorithms']: + if 'LensShadingCorrection' in algo: + lsc_data = algo['LensShadingCorrection'] + break + + if not lsc_data: + print("Error: LensShadingCorrection block not found.") + return None, None, None + + # 3. Extract the set for the specific Color Temperature (CT) provided in arguments + sets = lsc_data['sets'] + target_set = next((item for item in sets if item['ct'] == target_ct), None) + + if not target_set: + print(f"Error: Set for Color Temperature {target_ct} not found in '{input_filename}'.") + return None, None, None + + print(f"Found data for CT {target_ct}. Applying formula: (x - {int(BLACK_LEVEL)}) / {SCALE_FACTOR} ...") + + # 4. Get Raw Data + r_raw = np.array(target_set['r']) + b_raw = np.array(target_set['b']) + gr_raw = np.array(target_set['gr']) + gb_raw = np.array(target_set['gb']) + + # Calculate Green Channel (Average of GR and GB) + g_raw = (gr_raw + gb_raw) / 2.0 + + # 5. Define the calculation logic + def apply_formula(data_array): + """ + Applies the specific user formula: + 1. Subtract Black Level (1024) + 2. Divide by the Scale Factor (3071) + 3. Multiply by 255 and convert to integer + """ + result = ((data_array - BLACK_LEVEL) / SCALE_FACTOR) * 255 + return result.astype(int) + + # 6. Apply calculation to all channels + r_final = apply_formula(r_raw) + g_final = apply_formula(g_raw) + b_final = apply_formula(b_raw) + + return r_final, g_final, b_final + +def save_custom_grid_yaml(output_filename, r, g, b, target_ct): + + # Helper function to format the array as a visual grid string + def format_array_as_grid_string(arr): + lines = [] + # Loop through the array in chunks of 16 (GRID_W) + for i in range(0, len(arr), GRID_W): + row = arr[i:i+GRID_W] + # Join numbers with commas + row_str = ", ".join(map(str, row)) + lines.append(f" {row_str}") + # Wrap in brackets to form a valid YAML list, but visually formatted + return "[\n" + ",\n".join(lines) + "\n ]" + + # Write the file manually to ensure specific formatting + with open(output_filename, 'w') as f: + f.write(f"description: 'LSC Fixed Formula ((x-{int(BLACK_LEVEL)})/{SCALE_FACTOR})'\n") + f.write(f"source_ct: {target_ct}\n") + f.write(f"grid_size: [{GRID_W}, {GRID_H}]\n") + f.write(f"formula_used: '(RawValue - {int(BLACK_LEVEL)}) / {SCALE_FACTOR} -> [0..255]'\n") + f.write(f"channels:\n") + + f.write(" red: " + format_array_as_grid_string(r) + "\n") + f.write(" green: " + format_array_as_grid_string(g) + "\n") + f.write(" blue: " + format_array_as_grid_string(b) + "\n") + + print(f"Success! Saved formatted grid to '{output_filename}'") + +# --- Main Execution --- +if __name__ == "__main__": + # 1. Setup Argument Parser + parser = argparse.ArgumentParser(description="Convert LSC YAML data to shader grid format.") + parser.add_argument("ct", type=int, help="The Color Temperature to process (e.g. 2700, 5000, 6500)") + + # 2. Parse arguments + args = parser.parse_args() + ct_val = args.ct + + # 3. Construct filenames based on the CT value + # Assumes input file is named 'tuning_XXXX.yaml' + input_file = f'tuning{ct_val}.yaml' + output_file = f'lsc_shader_16x16_{ct_val}_fixed.yaml' + + print(f"--- Processing for Color Temp: {ct_val} ---") + + # 4. Run Process + r, g, b = load_and_process_yaml(input_file, ct_val) + + if r is not None: + save_custom_grid_yaml(output_file, r, g, b, ct_val) diff --git a/utils/tuning/generate_lsc_map_plot.py b/utils/tuning/generate_lsc_map_plot.py new file mode 100644 index 00000000..67b3a041 --- /dev/null +++ b/utils/tuning/generate_lsc_map_plot.py @@ -0,0 +1,76 @@ +import yaml +import numpy as np +import matplotlib.pyplot as plt + +# 1. Load the data +try: + with open('tuning2700.yaml', 'r') as f: + data = yaml.safe_load(f) +except FileNotFoundError: + print("Error: 'tuning.yaml' not found. Please ensure the file exists.") + exit() + +# 2. Find LensShadingCorrection safely +lsc_data = None +for algo in data['algorithms']: + if 'LensShadingCorrection' in algo: + lsc_data = algo['LensShadingCorrection'] + break + +if not lsc_data: + print("Error: LensShadingCorrection block not found in YAML.") + exit() + +# 3. Extract the set for disirable Kelvin +kelvin = 2700 +sets = lsc_data['sets'] +target_set = next((item for item in sets if item['ct'] == kelvin), None) + +if not target_set: + print("Error: CT 6500 not found in sets.") + exit() + +# 4. Get lists and normalize (1024 = 1.0 gain) +r_list = np.array(target_set['r']) +gr_list = np.array(target_set['gr']) +gb_list = np.array(target_set['gb']) +b_list = np.array(target_set['b']) + +r_norm = r_list / 1024.0 +b_norm = b_list / 1024.0 +# Average the two greens for the shader +g_norm = (gr_list + gb_list) / 2.0 / 1024.0 + +# 5. Reshape into 17x17 Grids +grid_size = (17, 17) +r_grid = r_norm.reshape(grid_size) +g_grid = g_norm.reshape(grid_size) +b_grid = b_norm.reshape(grid_size) + +# 6. Visualization +# We create 3 separate plots to see the data distribution correctly +fig, axs = plt.subplots(1, 3, figsize=(15, 5)) + +# Plot Red +im1 = axs[0].imshow(r_grid, cmap='viridis') +axs[0].set_title('Red Gain Map') +fig.colorbar(im1, ax=axs[0]) + +# Plot Green +im2 = axs[1].imshow(g_grid, cmap='viridis') +axs[1].set_title('Green Gain Map') +fig.colorbar(im2, ax=axs[1]) + +# Plot Blue +im3 = axs[2].imshow(b_grid, cmap='viridis') +axs[2].set_title('Blue Gain Map') +fig.colorbar(im3, ax=axs[2]) + +plt.suptitle(f"LSC Gain Maps (Center ~1.0, Corners > 1.0) for collor temprature {kelvin}") +plt.show() + +# 7. Prepare Texture for Export (Optional) +# Stack them for your shader: (17, 17, 3) +lsc_texture = np.dstack((r_grid, g_grid, b_grid)) +print(f"Final Texture Shape: {lsc_texture.shape}") +print(f"Sample Blue Value at Corner: {b_grid[0,0]}") From patchwork Mon Jan 26 10:42:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick ten Wolde X-Patchwork-Id: 25965 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 117A2C32EA for ; Mon, 26 Jan 2026 10:48:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2634F61FC4; Mon, 26 Jan 2026 11:48:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="H2v/Subi"; dkim-atps=neutral Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4770761FC8 for ; Mon, 26 Jan 2026 11:43:09 +0100 (CET) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b8869cd7bb1so460013766b.1 for ; Mon, 26 Jan 2026 02:43:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769424188; x=1770028988; 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=wUzt/fC0jiCY2Twb7JUKPXPppPbItoi7piOn2nAFcDM=; b=H2v/Subiumere8Z2Q2NdQ5DuZLLqk7Pv7zjkLbIIzwkneIj5G7N7UkEAY5FU+tqeCg s7GWUxX+j6zOjcaIZk6Y3rCvNYGZg1FQoRb5RyuF/7/0E0UbrTTkY0m/vfb70B8M/LK1 NrYe4hmZ1K3KuWnecEDpZkwvtpaj3itmkInn3tOwSWYdOSr5cFQHR7QS8RjwMHS2FplN Grc7lrXZIwgwQyZsylq4GgrfU5Ct07dGo/ZlP02q24ehPHbCNeafeBMkC/J0VsTkWxHf TP/7WwevvtBoz4m/j2GSzrmZC1OWbE44BA8SWvaoeDclv8WMta5UM/PjFVIvQx7BsO8T dw8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769424188; x=1770028988; 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=wUzt/fC0jiCY2Twb7JUKPXPppPbItoi7piOn2nAFcDM=; b=ROK6rep7GTECi5R0UTtsNulRYUzfDjKW6190pIn5CtPo1CiHt+UruTjchhJ6hL2JAf 1uG/2RwrX/uDAYw1lkoNJjuPPdTGGu8Y1uWgQnjRnnyjgUFYjkBSpZMWUvjA5YxGfiiA JQTbiJIWUiRWx4BUDb5IRhRSXB328y/IlbgcXMz73vNp/mO4brZPYiaBEvrKy19GB1eR n+4hTga/mNmZVpvEKRlViG13QS0JWOHDOhoVzhdl0+f4YfqrKBO1nyv9vUGHL54sXR1g m/cw8hb7dAoKkWeHuEH8XaJkx8BGQtNxqOLdnikKgifgj3Eh4XVhls4iDQAal0h5QS25 aZDQ== X-Gm-Message-State: AOJu0YzCe1GOl14qVkxTDUQKLMntW+3uSV13nAuBtlEtvaRWpirvItdm ay7K0hFp4R9b1210CZI1kCBwmQi7wczyYxig9z+OcpzxJ1ZqIhp+C92iSY2SnA== X-Gm-Gg: AZuq6aLpjXu2O/nWEKscp83C0GOvixlcHlB3oDG2arCKgUUvnjc69KHfYNmOdUsUaKI KvGnOuGIyPF+ftwNjB8SCEVxvmMd3LMInjWh7CE1kPtQK33iuq9+KyXKGUFFw6x/XrF/drGuOe6 aNYz6d3VmhMt3Z9Jw6ouAR0VfCFOpbkfev/uPcoeNcMoLAvH29kmGnoM8EPecjTKVdIPWjGhYUL +kLgu7pdVF6q0xw1huQrLT90cQyauyQdS2ULckj4xjwMXn/RmUajt92PPKPAyJFmMQVj2ugTkeX phWmhrCyHvTL4olZF91e8K1fHK/O4Czrm5BB5nkPD31WBcFAndTQniFd9BjiYPiDJXOfuyhGqcN 3ipWTW7NBcQQzZYh54X2FVFBIaFvbBXpkXo4OyR/SXGln3Uxfm7et8FnFB7wMHdkPiioISKs5ip em5jrLPhWvGn3sIOgLEIRmGLbHU3Llu+GqpQr2ymGsNSxIk2nPNTQakNns5abXEGJ/69tj91Uv0 Q== X-Received: by 2002:a17:907:d14:b0:b87:1d55:2310 with SMTP id a640c23a62f3a-b8d3fbba433mr247548466b.37.1769424188229; Mon, 26 Jan 2026 02:43:08 -0800 (PST) Received: from castortop.wolde.loc (195-240-110-192.fixed.kpn.net. [195.240.110.192]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b885b7661f7sm599220366b.54.2026.01.26.02.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 02:43:07 -0800 (PST) From: Rick ten Wolde To: libcamera-devel@lists.libcamera.org Cc: xander.c.pronk@gmail.com, derekgielen@outlook.com, 22012540@student.hhs.nl, rick.w.ten.wolde@gmail.com, johannes.goede@oss.qualcomm.com, Rick ten Wolde Subject: [PATCH 7/7] HACK: Add test LSC to src/ipa/simple/data/uncalibrated.yaml Date: Mon, 26 Jan 2026 11:42:55 +0100 Message-ID: <20260126104256.119697-8-rick.w.ten.wolde@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> References: <20260126104256.119697-1-rick.w.ten.wolde@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 26 Jan 2026 11:48:05 +0100 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" From: Xander Pronk Add test LSC to src/ipa/simple/data/uncalibrated.yaml. Co-authored-by: Rick ten Wolde Signed-off-by: Rick ten Wolde Signed-off-by: Xander Pronk --- src/ipa/simple/data/uncalibrated.yaml | 183 +++++++++++++++++++++++++- 1 file changed, 179 insertions(+), 4 deletions(-) diff --git a/src/ipa/simple/data/uncalibrated.yaml b/src/ipa/simple/data/uncalibrated.yaml index 8b6df9af..91fa8897 100644 --- a/src/ipa/simple/data/uncalibrated.yaml +++ b/src/ipa/simple/data/uncalibrated.yaml @@ -5,15 +5,190 @@ version: 1 algorithms: - BlackLevel: - Awb: - # Color correction matrices can be defined here. The CCM algorithm - # has a significant performance impact, and should only be enabled - # if tuned. - Ccm: ccms: - ct: 6500 ccm: [ 1, 0, 0, 0, 1, 0, - 0, 0, 1] + 0, 0, 1 ] - Lut: - Agc: + - Lsc: + grids: + # =========================== + # Source CT: 2700K (Tungsten) + # =========================== + - ct: 2700 + r: [ + 70, 54, 41, 26, 13, 3, 0, 0, 0, 0, 5, 17, 32, 46, 64, 82, + 60, 48, 33, 17, 3, 0, 0, 0, 0, 0, 0, 7, 23, 39, 55, 69, + 53, 42, 26, 8, 0, 0, 0, 0, 0, 0, 0, 1, 15, 33, 49, 60, + 49, 38, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 8, 27, 44, 55, + 46, 33, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 21, 41, 52, + 43, 29, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17, 37, 49, + 42, 25, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 35, 49, + 41, 23, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 33, 48, + 41, 23, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 33, 48, + 41, 24, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 35, 48, + 42, 27, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17, 37, 49, + 43, 31, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 21, 40, 52, + 46, 35, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 7, 26, 44, 55, + 50, 39, 23, 5, 0, 0, 0, 0, 0, 0, 0, 1, 14, 32, 48, 60, + 56, 42, 29, 12, 1, 0, 0, 0, 0, 0, 0, 6, 21, 38, 53, 68, + 65, 46, 33, 19, 5, 0, 0, 0, 0, 0, 3, 14, 28, 43, 61, 81 + ] + g: [ + 61, 45, 33, 20, 9, 1, 0, 0, 0, 0, 3, 12, 25, 37, 54, 72, + 51, 39, 27, 13, 2, 0, 0, 0, 0, 0, 0, 4, 18, 31, 46, 59, + 44, 35, 21, 6, 0, 0, 0, 0, 0, 0, 0, 0, 11, 26, 40, 51, + 39, 30, 14, 1, 0, 0, 0, 0, 0, 0, 0, 0, 5, 21, 36, 46, + 36, 26, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 16, 33, 43, + 33, 22, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 30, 40, + 32, 19, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 28, 39, + 32, 17, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 26, 39, + 32, 17, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 26, 39, + 32, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 28, 39, + 33, 20, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 30, 40, + 34, 24, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 17, 33, 43, + 37, 28, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 22, 37, 46, + 41, 32, 18, 4, 0, 0, 0, 0, 0, 0, 0, 0, 11, 27, 41, 52, + 47, 35, 24, 9, 0, 0, 0, 0, 0, 0, 0, 4, 18, 32, 46, 60, + 57, 39, 27, 15, 3, 0, 0, 0, 0, 0, 1, 11, 23, 36, 54, 73 + ] + b: [ + 141, 120, 103, 87, 70, 56, 46, 43, 43, 46, 58, 72, 90, 105, 127, 149, + 128, 112, 95, 76, 58, 47, 37, 33, 33, 38, 49, 61, 80, 98, 116, 133, + 119, 106, 87, 66, 49, 37, 29, 24, 24, 31, 38, 52, 70, 91, 108, 122, + 113, 100, 78, 57, 41, 29, 22, 16, 16, 24, 31, 44, 62, 84, 103, 115, + 108, 93, 70, 50, 34, 22, 15, 9, 9, 16, 25, 38, 55, 77, 98, 111, + 105, 88, 64, 44, 28, 16, 8, 4, 5, 9, 19, 33, 49, 72, 94, 108, + 103, 84, 59, 40, 24, 12, 3, 1, 3, 5, 16, 29, 46, 68, 91, 107, + 103, 82, 57, 38, 22, 10, 1, 0, 0, 3, 14, 28, 45, 66, 90, 107, + 103, 82, 57, 38, 22, 10, 1, 0, 0, 3, 14, 28, 45, 66, 90, 107, + 103, 84, 59, 39, 24, 11, 3, 1, 3, 5, 16, 30, 47, 69, 92, 107, + 104, 87, 63, 43, 28, 15, 9, 4, 5, 10, 20, 34, 51, 73, 96, 109, + 107, 93, 69, 48, 33, 21, 15, 9, 10, 16, 26, 40, 57, 79, 101, 112, + 111, 98, 77, 55, 39, 27, 21, 16, 16, 25, 32, 47, 64, 87, 106, 117, + 117, 104, 86, 64, 46, 36, 27, 25, 25, 32, 40, 55, 74, 96, 112, 125, + 126, 110, 94, 75, 56, 46, 36, 34, 34, 40, 50, 65, 84, 104, 120, 137, + 139, 117, 101, 85, 67, 55, 44, 44, 44, 50, 61, 77, 94, 112, 133, 155 + ] + + # =========================== + # Source CT: 5000K (Daylight) + # =========================== + - ct: 5000 + r: [ + 87, 69, 54, 39, 23, 12, 3, 2, 2, 5, 15, 28, 44, 58, 79, 99, + 76, 61, 46, 28, 13, 4, 0, 0, 0, 0, 7, 17, 35, 52, 69, 85, + 68, 56, 38, 19, 5, 0, 0, 0, 0, 0, 0, 9, 26, 45, 62, 75, + 63, 51, 30, 11, 0, 0, 0, 0, 0, 0, 0, 3, 18, 39, 57, 69, + 60, 45, 24, 5, 0, 0, 0, 0, 0, 0, 0, 0, 12, 32, 53, 66, + 57, 41, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 7, 28, 50, 63, + 55, 38, 15, 1, 0, 0, 0, 0, 0, 0, 0, 0, 5, 24, 47, 62, + 55, 35, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 23, 45, 61, + 55, 35, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 23, 45, 61, + 55, 36, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 47, 61, + 55, 39, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 7, 28, 49, 63, + 57, 43, 21, 3, 0, 0, 0, 0, 0, 0, 0, 0, 11, 32, 52, 65, + 60, 47, 27, 8, 0, 0, 0, 0, 0, 0, 0, 2, 17, 38, 56, 69, + 65, 51, 34, 15, 1, 0, 0, 0, 0, 0, 0, 8, 24, 44, 61, 74, + 71, 56, 40, 23, 7, 0, 0, 0, 0, 0, 3, 15, 32, 50, 67, 83, + 81, 60, 45, 29, 15, 5, 0, 0, 0, 2, 11, 24, 39, 55, 75, 97 + ] + g: [ + 26, 13, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 20, 34, + 18, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 13, 24, + 13, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 17, + 9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 13, + 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 11, + 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 9, + 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, + 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, + 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, + 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, + 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 9, + 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 11, + 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 13, + 10, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 17, + 14, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 12, 23, + 21, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 18, 33 + ] + b: [ + 92, 73, 58, 44, 30, 19, 11, 9, 9, 12, 21, 32, 46, 59, 79, 100, + 80, 66, 51, 35, 21, 12, 5, 2, 2, 5, 14, 23, 38, 54, 70, 86, + 72, 61, 44, 27, 14, 5, 0, 0, 0, 1, 5, 16, 31, 48, 63, 76, + 67, 56, 37, 20, 8, 0, 0, 0, 0, 0, 1, 10, 24, 42, 59, 70, + 63, 50, 31, 14, 3, 0, 0, 0, 0, 0, 0, 5, 18, 36, 55, 66, + 60, 46, 26, 10, 0, 0, 0, 0, 0, 0, 0, 2, 14, 32, 51, 63, + 59, 42, 22, 7, 0, 0, 0, 0, 0, 0, 0, 1, 12, 29, 49, 63, + 58, 40, 20, 5, 0, 0, 0, 0, 0, 0, 0, 0, 10, 28, 47, 62, + 58, 40, 20, 5, 0, 0, 0, 0, 0, 0, 0, 0, 10, 28, 47, 62, + 58, 42, 22, 6, 0, 0, 0, 0, 0, 0, 0, 1, 12, 29, 49, 62, + 59, 45, 25, 9, 0, 0, 0, 0, 0, 0, 0, 3, 15, 33, 52, 64, + 61, 49, 29, 12, 1, 0, 0, 0, 0, 0, 0, 6, 19, 38, 56, 66, + 65, 53, 35, 17, 5, 0, 0, 0, 0, 0, 1, 11, 25, 43, 60, 70, + 70, 58, 42, 24, 10, 2, 0, 0, 0, 1, 6, 17, 32, 50, 65, 77, + 77, 63, 49, 33, 17, 10, 2, 2, 2, 6, 14, 25, 40, 57, 71, 87, + 88, 68, 54, 41, 26, 16, 8, 8, 8, 13, 22, 33, 48, 63, 82, 102 + ] + + # =========================== + # Source CT: 6500K (Overcast) + # =========================== + - ct: 6500 + r: [ + 90, 71, 55, 40, 25, 14, 4, 3, 3, 6, 16, 29, 45, 59, 80, 101, + 78, 63, 48, 30, 15, 6, 0, 0, 0, 0, 8, 19, 35, 53, 70, 86, + 70, 58, 40, 21, 6, 0, 0, 0, 0, 0, 0, 10, 27, 46, 63, 76, + 65, 52, 32, 13, 1, 0, 0, 0, 0, 0, 0, 4, 19, 40, 58, 70, + 62, 47, 26, 7, 0, 0, 0, 0, 0, 0, 0, 1, 13, 33, 54, 66, + 59, 43, 21, 3, 0, 0, 0, 0, 0, 0, 0, 0, 9, 29, 50, 63, + 57, 39, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 6, 25, 47, 62, + 57, 37, 15, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 46, 62, + 57, 37, 15, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 46, 62, + 57, 38, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 5, 25, 47, 62, + 57, 41, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 8, 28, 50, 63, + 59, 45, 23, 5, 0, 0, 0, 0, 0, 0, 0, 0, 13, 33, 53, 66, + 62, 49, 29, 10, 0, 0, 0, 0, 0, 0, 0, 3, 18, 39, 57, 69, + 66, 53, 36, 17, 3, 0, 0, 0, 0, 0, 0, 9, 25, 45, 61, 75, + 73, 57, 42, 25, 9, 1, 0, 0, 0, 0, 4, 17, 33, 51, 67, 84, + 83, 61, 46, 31, 17, 6, 1, 0, 0, 4, 12, 25, 40, 56, 76, 98 + ] + g: [ + 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 15, + 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, + 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 14 + ] + b: [ + 52, 36, 25, 14, 3, 0, 0, 0, 0, 0, 0, 4, 15, 25, 41, 58, + 43, 31, 20, 7, 0, 0, 0, 0, 0, 0, 0, 0, 9, 21, 34, 46, + 36, 27, 14, 2, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 29, 39, + 32, 23, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 12, 25, 34, + 29, 19, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 22, 31, + 27, 15, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 19, 29, + 25, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 17, 28, + 25, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 16, 28, + 25, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 16, 28, + 25, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 17, 28, + 26, 14, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 20, 29, + 27, 18, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 22, 31, + 30, 21, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 13, 26, 34, + 34, 25, 12, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 18, 29, 39, + 40, 28, 18, 5, 0, 0, 0, 0, 0, 0, 0, 0, 10, 23, 34, 47, + 49, 33, 22, 11, 1, 0, 0, 0, 0, 0, 0, 5, 16, 28, 43, 59 + ] ...