Patch Detail
Show a patch.
GET /api/patches/19884/?format=api
{ "id": 19884, "url": "https://patchwork.libcamera.org/api/patches/19884/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19884/", "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": "<20240416091357.211951-16-mzamazal@redhat.com>", "date": "2024-04-16T09:13:51", "name": "[v8,15/18] libcamera: debayer_cpu: Add support for 8, 10 and 12 bpp unpacked bayer input", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "4cf3b94c355187b9b96d736443c43120eb29643d", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19884/mbox/", "series": [ { "id": 4257, "url": "https://patchwork.libcamera.org/api/series/4257/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4257", "date": "2024-04-16T09:13:36", "name": "libcamera: introduce Software ISP and Software IPA", "version": 8, "mbox": "https://patchwork.libcamera.org/series/4257/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19884/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19884/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 26C0AC32C9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Apr 2024 09:15:14 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 839CB6337E;\n\tTue, 16 Apr 2024 11:15:13 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 46A5263373\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2024 11:15:03 +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-264-eA2gMajkOjq1dJ8M19Yowg-1;\n\tTue, 16 Apr 2024 05:15:00 -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 75A301C29EB9;\n\tTue, 16 Apr 2024 09:15:00 +0000 (UTC)", "from nuthatch.redhat.com (unknown [10.45.225.245])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 9EE3B2026962;\n\tTue, 16 Apr 2024 09:14:58 +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=\"hZZXNqOk\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1713258902;\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=zAHJPA/1puwOG0xuzyfmwaRaY/H7ZI1G/qxG/5IsvzI=;\n\tb=hZZXNqOkHTdIY2p8ecAberdoJIz/TiQWa7lTtsK1oK0ixlf9o6j2Wx5vbKvOliPPBOH4EK\n\tpBFpY28HWwwN36BI+PdUsOCQyazdSU5AtxvggKv1bcY//g76qF2doEfqBC282gkzT9N20E\n\tOgRwLrLAhV2I88qtp07SVppinetRkt0=", "X-MC-Unique": "eA2gMajkOjq1dJ8M19Yowg-1", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Hans de Goede <hdegoede@redhat.com>, Milan Zamazal <mzamazal@redhat.com>,\n\tAndrei Konovalov <andrey.konovalov.ynk@gmail.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMaxime Ripard <mripard@redhat.com>, Pavel Machek <pavel@ucw.cz>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>", "Subject": "[PATCH v8 15/18] libcamera: debayer_cpu: Add support for 8,\n\t10 and 12 bpp unpacked bayer input", "Date": "Tue, 16 Apr 2024 11:13:51 +0200", "Message-ID": "<20240416091357.211951-16-mzamazal@redhat.com>", "In-Reply-To": "<20240416091357.211951-1-mzamazal@redhat.com>", "References": "<20240416091357.211951-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": "From: Hans de Goede <hdegoede@redhat.com>\n\nAdd support for 8, 10 and 12 bpp unpacked bayer input for all 4 standard\nbayer orders.\n\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\n src/libcamera/software_isp/debayer_cpu.cpp | 128 +++++++++++++++++++++\n src/libcamera/software_isp/debayer_cpu.h | 13 +++\n 2 files changed, 141 insertions(+)", "diff": "diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex 6bc4b167..82163458 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -61,6 +61,11 @@ DebayerCpu::~DebayerCpu()\n \t\tfree(lineBuffers_[i]);\n }\n \n+#define DECLARE_SRC_POINTERS(pixel_t) \\\n+\tconst pixel_t *prev = (const pixel_t *)src[0] + xShift_; \\\n+\tconst pixel_t *curr = (const pixel_t *)src[1] + xShift_; \\\n+\tconst pixel_t *next = (const pixel_t *)src[2] + xShift_;\n+\n /*\n * RGR\n * GBG\n@@ -105,6 +110,70 @@ DebayerCpu::~DebayerCpu()\n \t*dst++ = red_[curr[x] / (div)]; \\\n \tx++;\n \n+void DebayerCpu::debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\n+{\n+\tDECLARE_SRC_POINTERS(uint8_t)\n+\n+\tfor (int x = 0; x < (int)window_.width;) {\n+\t\tBGGR_BGR888(1, 1, 1)\n+\t\tGBRG_BGR888(1, 1, 1)\n+\t}\n+}\n+\n+void DebayerCpu::debayer8_GRGR_BGR888(uint8_t *dst, const uint8_t *src[])\n+{\n+\tDECLARE_SRC_POINTERS(uint8_t)\n+\n+\tfor (int x = 0; x < (int)window_.width;) {\n+\t\tGRBG_BGR888(1, 1, 1)\n+\t\tRGGB_BGR888(1, 1, 1)\n+\t}\n+}\n+\n+void DebayerCpu::debayer10_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\n+{\n+\tDECLARE_SRC_POINTERS(uint16_t)\n+\n+\tfor (int x = 0; x < (int)window_.width;) {\n+\t\t/* divide values by 4 for 10 -> 8 bpp value */\n+\t\tBGGR_BGR888(1, 1, 4)\n+\t\tGBRG_BGR888(1, 1, 4)\n+\t}\n+}\n+\n+void DebayerCpu::debayer10_GRGR_BGR888(uint8_t *dst, const uint8_t *src[])\n+{\n+\tDECLARE_SRC_POINTERS(uint16_t)\n+\n+\tfor (int x = 0; x < (int)window_.width;) {\n+\t\t/* divide values by 4 for 10 -> 8 bpp value */\n+\t\tGRBG_BGR888(1, 1, 4)\n+\t\tRGGB_BGR888(1, 1, 4)\n+\t}\n+}\n+\n+void DebayerCpu::debayer12_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\n+{\n+\tDECLARE_SRC_POINTERS(uint16_t)\n+\n+\tfor (int x = 0; x < (int)window_.width;) {\n+\t\t/* divide values by 16 for 12 -> 8 bpp value */\n+\t\tBGGR_BGR888(1, 1, 16)\n+\t\tGBRG_BGR888(1, 1, 16)\n+\t}\n+}\n+\n+void DebayerCpu::debayer12_GRGR_BGR888(uint8_t *dst, const uint8_t *src[])\n+{\n+\tDECLARE_SRC_POINTERS(uint16_t)\n+\n+\tfor (int x = 0; x < (int)window_.width;) {\n+\t\t/* divide values by 16 for 12 -> 8 bpp value */\n+\t\tGRBG_BGR888(1, 1, 16)\n+\t\tRGGB_BGR888(1, 1, 16)\n+\t}\n+}\n+\n void DebayerCpu::debayer10P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\n {\n \tconst int widthInBytes = window_.width * 5 / 4;\n@@ -206,6 +275,16 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf\n \tBayerFormat bayerFormat =\n \t\tBayerFormat::fromPixelFormat(inputFormat);\n \n+\tif ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10 || bayerFormat.bitDepth == 12) &&\n+\t bayerFormat.packing == BayerFormat::Packing::None &&\n+\t isStandardBayerOrder(bayerFormat.order)) {\n+\t\tconfig.bpp = (bayerFormat.bitDepth + 7) & ~7;\n+\t\tconfig.patternSize.width = 2;\n+\t\tconfig.patternSize.height = 2;\n+\t\tconfig.outputFormats = std::vector<PixelFormat>({ formats::RGB888 });\n+\t\treturn 0;\n+\t}\n+\n \tif (bayerFormat.bitDepth == 10 &&\n \t bayerFormat.packing == BayerFormat::Packing::CSI2 &&\n \t isStandardBayerOrder(bayerFormat.order)) {\n@@ -233,6 +312,32 @@ int DebayerCpu::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &c\n \treturn -EINVAL;\n }\n \n+/*\n+ * Check for standard Bayer orders and set xShift_ and swap debayer0/1, so that\n+ * a single pair of BGGR debayer functions can be used for all 4 standard orders.\n+ */\n+int DebayerCpu::setupStandardBayerOrder(BayerFormat::Order order)\n+{\n+\tswitch (order) {\n+\tcase BayerFormat::BGGR:\n+\t\tbreak;\n+\tcase BayerFormat::GBRG:\n+\t\txShift_ = 1; /* BGGR -> GBRG */\n+\t\tbreak;\n+\tcase BayerFormat::GRBG:\n+\t\tstd::swap(debayer0_, debayer1_); /* BGGR -> GRBG */\n+\t\tbreak;\n+\tcase BayerFormat::RGGB:\n+\t\txShift_ = 1; /* BGGR -> GBRG */\n+\t\tstd::swap(debayer0_, debayer1_); /* GBRG -> RGGB */\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n /* \\todo This ignores outputFormat since there is only 1 supported outputFormat\n for now */\n int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, [[maybe_unused]] PixelFormat outputFormat)\n@@ -240,6 +345,29 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, [[maybe_unused]] Pi\n \tBayerFormat bayerFormat =\n \t\tBayerFormat::fromPixelFormat(inputFormat);\n \n+\txShift_ = 0;\n+\n+\tif ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10 || bayerFormat.bitDepth == 12) &&\n+\t bayerFormat.packing == BayerFormat::Packing::None &&\n+\t isStandardBayerOrder(bayerFormat.order)) {\n+\t\tswitch (bayerFormat.bitDepth) {\n+\t\tcase 8:\n+\t\t\tdebayer0_ = &DebayerCpu::debayer8_BGBG_BGR888;\n+\t\t\tdebayer1_ = &DebayerCpu::debayer8_GRGR_BGR888;\n+\t\t\tbreak;\n+\t\tcase 10:\n+\t\t\tdebayer0_ = &DebayerCpu::debayer10_BGBG_BGR888;\n+\t\t\tdebayer1_ = &DebayerCpu::debayer10_GRGR_BGR888;\n+\t\t\tbreak;\n+\t\tcase 12:\n+\t\t\tdebayer0_ = &DebayerCpu::debayer12_BGBG_BGR888;\n+\t\t\tdebayer1_ = &DebayerCpu::debayer12_GRGR_BGR888;\n+\t\t\tbreak;\n+\t\t}\n+\t\tsetupStandardBayerOrder(bayerFormat.order);\n+\t\treturn 0;\n+\t}\n+\n \tif (bayerFormat.bitDepth == 10 &&\n \t bayerFormat.packing == BayerFormat::Packing::CSI2) {\n \t\tswitch (bayerFormat.order) {\ndiff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\nindex 1b5ad984..598fe021 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -17,6 +17,8 @@\n \n #include <libcamera/base/object.h>\n \n+#include \"libcamera/internal/bayer_format.h\"\n+\n #include \"debayer.h\"\n #include \"swstats_cpu.h\"\n \n@@ -82,6 +84,15 @@ private:\n \t */\n \tusing debayerFn = void (DebayerCpu::*)(uint8_t *dst, const uint8_t *src[]);\n \n+\t/* 8-bit raw bayer format */\n+\tvoid debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]);\n+\tvoid debayer8_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]);\n+\t/* unpacked 10-bit raw bayer format */\n+\tvoid debayer10_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]);\n+\tvoid debayer10_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]);\n+\t/* unpacked 12-bit raw bayer format */\n+\tvoid debayer12_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]);\n+\tvoid debayer12_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]);\n \t/* CSI-2 packed 10-bit raw bayer format (all the 4 orders) */\n \tvoid debayer10P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]);\n \tvoid debayer10P_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]);\n@@ -103,6 +114,7 @@ private:\n \n \tint getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config);\n \tint getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config);\n+\tint setupStandardBayerOrder(BayerFormat::Order order);\n \tint setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputFormat);\n \tvoid setupInputMemcpy(const uint8_t *linePointers[]);\n \tvoid shiftLinePointers(const uint8_t *linePointers[], const uint8_t *src);\n@@ -131,6 +143,7 @@ private:\n \tunsigned int lineBufferLength_;\n \tunsigned int lineBufferPadding_;\n \tunsigned int lineBufferIndex_;\n+\tunsigned int xShift_; /* Offset of 0/1 applied to window_.x */\n \tbool enableInputMemcpy_;\n \tfloat gammaCorrection_;\n \tunsigned int measuredFrames_;\n", "prefixes": [ "v8", "15/18" ] }