Patch Detail
Show a patch.
GET /api/1.1/patches/20095/?format=api
{ "id": 20095, "url": "https://patchwork.libcamera.org/api/1.1/patches/20095/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20095/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20240523112656.559150-6-mzamazal@redhat.com>", "date": "2024-05-23T11:26:56", "name": "[v3,5/5] libcamera: software_isp: Pass color lookup tables as floats", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "c5ac89091980ed96746e1a0b0fd8cadc241fa894", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20095/mbox/", "series": [ { "id": 4323, "url": "https://patchwork.libcamera.org/api/1.1/series/4323/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4323", "date": "2024-05-23T11:26:51", "name": "Software ISP levels cleanup", "version": 3, "mbox": "https://patchwork.libcamera.org/series/4323/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20095/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20095/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 E464EBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 May 2024 11:27:40 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 85CC8634A5;\n\tThu, 23 May 2024 13:27:40 +0200 (CEST)", "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 297BF634A6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 May 2024 13:27:33 +0200 (CEST)", "from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-453-MN-a_gWBP_iz2VCa9EKkMw-1;\n\tThu, 23 May 2024 07:27:27 -0400", "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37B393C025A1;\n\tThu, 23 May 2024 11:27:27 +0000 (UTC)", "from nuthatch.redhat.com (unknown [10.45.226.101])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id ED9C22026D68;\n\tThu, 23 May 2024 11:27:25 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"IjewvqLn\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1716463651;\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\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=skUQ1Y2KuLbcKlSWlti06cq5C2+zC5GBBds10V4jwd0=;\n\tb=IjewvqLnOJXiWmOKmGtyj+RM2iaQj9oM40QnaOcF2ilt7o3UoTR+VqrA+WoX2d9wVcgbIp\n\t2vobuilc8lgOLa492Nh8se/ksMLyVVu/cdd1mKLmu9m1KzrTxnMqxKUekafywoQ8hD++5m\n\ttu+/4Q8EdwKKa0pbPsAlLESM8G0l47U=", "X-MC-Unique": "MN-a_gWBP_iz2VCa9EKkMw-1", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>,\n\tAndrei Konovalov <andrey.konovalov.ynk@gmail.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>", "Subject": "[PATCH v3 5/5] libcamera: software_isp: Pass color lookup tables as\n\tfloats", "Date": "Thu, 23 May 2024 13:26:56 +0200", "Message-ID": "<20240523112656.559150-6-mzamazal@redhat.com>", "In-Reply-To": "<20240523112656.559150-1-mzamazal@redhat.com>", "References": "<20240523112656.559150-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.4", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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": "The color lookup tables are passed from stats processing to debayering\nfor direct use as 8-bit color output values. Let's pass the values as\n0.0..1.0 floats to make the gains color bit width independent.\n\nCompletes software ISP TODO #4.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\nReviewed-by: Andrei Konovalov <andrey.konovalov.ynk@gmail.com>\n---\n .../internal/software_isp/debayer_params.h | 2 +-\n src/ipa/simple/soft_simple.cpp | 4 ++--\n src/libcamera/software_isp/TODO | 13 -------------\n src/libcamera/software_isp/debayer.cpp | 6 +++---\n src/libcamera/software_isp/debayer_cpu.cpp | 18 +++++++++++++++---\n src/libcamera/software_isp/debayer_cpu.h | 10 +++++++---\n 6 files changed, 28 insertions(+), 25 deletions(-)", "diff": "diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h\nindex 7d8fdd48..af959e1a 100644\n--- a/include/libcamera/internal/software_isp/debayer_params.h\n+++ b/include/libcamera/internal/software_isp/debayer_params.h\n@@ -18,7 +18,7 @@ namespace libcamera {\n struct DebayerParams {\n \tstatic constexpr unsigned int kRGBLookupSize = 256;\n \n-\tusing ColorLookupTable = std::array<uint8_t, kRGBLookupSize>;\n+\tusing ColorLookupTable = std::array<float, kRGBLookupSize>;\n \n \tColorLookupTable red;\n \tColorLookupTable green;\ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex cd89e673..11678393 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -86,7 +86,7 @@ private:\n \tBlackLevel blackLevel_;\n \n \tstatic constexpr unsigned int kGammaLookupSize = 1024;\n-\tstd::array<uint8_t, kGammaLookupSize> gammaTable_;\n+\tstd::array<float, kGammaLookupSize> gammaTable_;\n \tint lastBlackLevel_ = -1;\n \n \tint32_t exposureMin_, exposureMax_;\n@@ -283,7 +283,7 @@ void IPASoftSimple::processStats(const ControlList &sensorControls)\n \t\tstd::fill(gammaTable_.begin(), gammaTable_.begin() + blackIndex, 0);\n \t\tconst float divisor = kGammaLookupSize - blackIndex - 1.0;\n \t\tfor (unsigned int i = blackIndex; i < kGammaLookupSize; i++)\n-\t\t\tgammaTable_[i] = UINT8_MAX * powf((i - blackIndex) / divisor, gamma);\n+\t\t\tgammaTable_[i] = powf((i - blackIndex) / divisor, gamma);\n \n \t\tlastBlackLevel_ = blackLevel;\n \t}\ndiff --git a/src/libcamera/software_isp/TODO b/src/libcamera/software_isp/TODO\nindex 4fcee39b..6bdc5905 100644\n--- a/src/libcamera/software_isp/TODO\n+++ b/src/libcamera/software_isp/TODO\n@@ -72,19 +72,6 @@ stats in hardware, such as the i.MX7), but please keep it on your radar.\n \n ---\n \n-4. Hide internal representation of gains from callers\n-\n-> struct DebayerParams {\n-> \tstatic constexpr unsigned int kGain10 = 256;\n-\n-Forcing the caller to deal with the internal representation of gains\n-isn't nice, especially given that it precludes implementing gains of\n-different precisions in different backend. Wouldn't it be better to pass\n-the values as floating point numbers, and convert them to the internal\n-representation in the implementation of process() before using them ?\n-\n----\n-\n 5. Store ISP parameters in per-frame buffers\n \n > /**\ndiff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp\nindex f4a299d5..1c93ac44 100644\n--- a/src/libcamera/software_isp/debayer.cpp\n+++ b/src/libcamera/software_isp/debayer.cpp\n@@ -30,17 +30,17 @@ namespace libcamera {\n \n /**\n * \\var DebayerParams::red\n- * \\brief Lookup table for red color, mapping input values to output values\n+ * \\brief Lookup table for red color, mapping input values to 0.0..1.0\n */\n \n /**\n * \\var DebayerParams::green\n- * \\brief Lookup table for green color, mapping input values to output values\n+ * \\brief Lookup table for green color, mapping input values to 0.0..1.0\n */\n \n /**\n * \\var DebayerParams::blue\n- * \\brief Lookup table for blue color, mapping input values to output values\n+ * \\brief Lookup table for blue color, mapping input values to 0.0..1.0\n */\n \n /**\ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex f3099a62..e71b5057 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -11,6 +11,8 @@\n \n #include \"debayer_cpu.h\"\n \n+#include <stddef.h>\n+#include <stdint.h>\n #include <stdlib.h>\n #include <time.h>\n \n@@ -688,6 +690,14 @@ static inline int64_t timeDiff(timespec &after, timespec &before)\n \t (int64_t)after.tv_nsec - (int64_t)before.tv_nsec;\n }\n \n+void DebayerCpu::updateColorLookupTable(\n+\tconst DebayerParams::ColorLookupTable &src,\n+\tColorLookupTable &dst)\n+{\n+\tfor (std::size_t i = 0; i < src.size(); i++)\n+\t\tdst[i] = src[i] * UINT8_MAX;\n+}\n+\n void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n {\n \ttimespec frameStartTime;\n@@ -697,9 +707,11 @@ void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams\n \t\tclock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime);\n \t}\n \n-\tgreen_ = params.green;\n-\tred_ = swapRedBlueGains_ ? params.blue : params.red;\n-\tblue_ = swapRedBlueGains_ ? params.red : params.blue;\n+\tupdateColorLookupTable(params.green, green_);\n+\tupdateColorLookupTable(swapRedBlueGains_ ? params.blue : params.red,\n+\t\t\t red_);\n+\tupdateColorLookupTable(swapRedBlueGains_ ? params.red : params.blue,\n+\t\t\t blue_);\n \n \t/* Copy metadata from the input buffer */\n \tFrameMetadata &metadata = output->_d()->metadata();\ndiff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\nindex 768a4643..ed1003a9 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -18,6 +18,7 @@\n #include <libcamera/base/object.h>\n \n #include \"libcamera/internal/bayer_format.h\"\n+#include \"libcamera/internal/software_isp/debayer_params.h\"\n \n #include \"debayer.h\"\n #include \"swstats_cpu.h\"\n@@ -125,9 +126,12 @@ private:\n \t/* Max. supported Bayer pattern height is 4, debayering this requires 5 lines */\n \tstatic constexpr unsigned int kMaxLineBuffers = 5;\n \n-\tDebayerParams::ColorLookupTable red_;\n-\tDebayerParams::ColorLookupTable green_;\n-\tDebayerParams::ColorLookupTable blue_;\n+\tusing ColorLookupTable = std::array<uint8_t, DebayerParams::kRGBLookupSize>;\n+\tvoid updateColorLookupTable(const DebayerParams::ColorLookupTable &src,\n+\t\t\t\t ColorLookupTable &dst);\n+\tColorLookupTable red_;\n+\tColorLookupTable green_;\n+\tColorLookupTable blue_;\n \tdebayerFn debayer0_;\n \tdebayerFn debayer1_;\n \tdebayerFn debayer2_;\n", "prefixes": [ "v3", "5/5" ] }