Patch Detail
Show a patch.
GET /api/1.1/patches/20347/?format=api
{ "id": 20347, "url": "https://patchwork.libcamera.org/api/1.1/patches/20347/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20347/", "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": "<20240617174131.269437-1-robert.mader@collabora.com>", "date": "2024-06-17T17:41:19", "name": "[v2] libcamera: debayer_cpu: Add 32bits/aligned output formats", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "50207b19577ea427b3add433677d0498a24b74df", "submitter": { "id": 140, "url": "https://patchwork.libcamera.org/api/1.1/people/140/?format=api", "name": "Robert Mader", "email": "robert.mader@collabora.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20347/mbox/", "series": [ { "id": 4403, "url": "https://patchwork.libcamera.org/api/1.1/series/4403/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4403", "date": "2024-06-17T17:41:19", "name": "[v2] libcamera: debayer_cpu: Add 32bits/aligned output formats", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4403/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20347/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20347/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 E9429C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Jun 2024 17:42:10 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 991A961A1C;\n\tMon, 17 Jun 2024 19:42:10 +0200 (CEST)", "from madrid.collaboradmins.com (madrid.collaboradmins.com\n\t[46.235.227.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7682F61A1C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Jun 2024 19:42:08 +0200 (CEST)", "from desktop-fedora.fritz.box (cola.collaboradmins.com\n\t[195.201.22.229])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (4096 bits)\n\tserver-digest SHA256)\n\t(No client certificate requested) (Authenticated sender: rmader)\n\tby madrid.collaboradmins.com (Postfix) with ESMTPSA id 18CEE378213C; \n\tMon, 17 Jun 2024 17:42:08 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=collabora.com header.i=@collabora.com\n\theader.b=\"RckU+dCj\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com;\n\ts=mail; t=1718646128;\n\tbh=VfYeZowfRjyybbHyY/EMbnkMSwaQWlDzijB0xzTKlvk=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=RckU+dCj7B1RpvqG2awLLI8IUXgqZhcVwVxAcM3nw89kWR7I/a+ii7jntnzdBg5dl\n\tzlO+P3hAkJla2kJnfwMEhAhjU8wwQex+ZEAgbkjm/Zv07bsit3Kdu+0K/XvQUa8Pwa\n\tWmvX1dWMI+XiAmMQgOUs7eJuP1hYgYN+w34OHhLz+YNqg2DLE9qz5JYO9+tkHYwdxE\n\tuOrrVUGt1hG01NIXVRHBgYpbcBSlXN4kftClMu4VCDQSR3O7Iy+mhuOBJQEJltZcPm\n\tRa8WfPdvnP7PAdcai8M8/6EbSmHGme+/Td4Z4so09Of953ra/6QTFtbQUPJj8Qo36a\n\twHCgmuKAAJdpA==", "From": "Robert Mader <robert.mader@collabora.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Robert Mader <robert.mader@collabora.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[PATCH v2] libcamera: debayer_cpu: Add 32bits/aligned output formats", "Date": "Mon, 17 Jun 2024 19:41:19 +0200", "Message-ID": "<20240617174131.269437-1-robert.mader@collabora.com>", "X-Mailer": "git-send-email 2.45.2", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "In order to be more compatible with modern hardware and APIs. This\nnotably allows GL implementations to directly import the buffers more\noften and seems to be required for Wayland.\n\nFurther more, as we already enforce a 8 byte stride, these formats work\nbetter for clients that don't support padding - such as libwebrtc at the\ntime of writing.\n\nTested devices:\n - Librem5\n - PinePhone\n - Thinkpad X13s\n\nSigned-off-by: Robert Mader <robert.mader@collabora.com>\nTested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/software_isp/debayer_cpu.cpp | 101 ++++++++++++++-------\n src/libcamera/software_isp/debayer_cpu.h | 1 +\n 2 files changed, 68 insertions(+), 34 deletions(-)", "diff": "diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex c038eed4..79bb4d87 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -70,10 +70,11 @@ DebayerCpu::~DebayerCpu()\n * GBG\n * RGR\n */\n-#define BGGR_BGR888(p, n, div) \\\n+#define BGGR_BGR888(p, n, div, addAlphaBit) \\\n \t*dst++ = blue_[curr[x] / (div)]; \\\n \t*dst++ = green_[(prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div))]; \\\n \t*dst++ = red_[(prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div))]; \\\n+\tif (addAlphaBit) *dst++ = 255; \\\n \tx++;\n \n /*\n@@ -81,10 +82,11 @@ DebayerCpu::~DebayerCpu()\n * RGR\n * GBG\n */\n-#define GRBG_BGR888(p, n, div) \\\n+#define GRBG_BGR888(p, n, div, addAlphaBit) \\\n \t*dst++ = blue_[(prev[x] + next[x]) / (2 * (div))]; \\\n \t*dst++ = green_[curr[x] / (div)]; \\\n \t*dst++ = red_[(curr[x - p] + curr[x + n]) / (2 * (div))]; \\\n+\tif (addAlphaBit) *dst++ = 255; \\\n \tx++;\n \n /*\n@@ -92,10 +94,11 @@ DebayerCpu::~DebayerCpu()\n * BGB\n * GRG\n */\n-#define GBRG_BGR888(p, n, div) \\\n+#define GBRG_BGR888(p, n, div, addAlphaBit) \\\n \t*dst++ = blue_[(curr[x - p] + curr[x + n]) / (2 * (div))]; \\\n \t*dst++ = green_[curr[x] / (div)]; \\\n \t*dst++ = red_[(prev[x] + next[x]) / (2 * (div))]; \\\n+\tif (addAlphaBit) *dst++ = 255; \\\n \tx++;\n \n /*\n@@ -103,10 +106,11 @@ DebayerCpu::~DebayerCpu()\n * GRG\n * BGB\n */\n-#define RGGB_BGR888(p, n, div) \\\n+#define RGGB_BGR888(p, n, div, addAlphaBit) \\\n \t*dst++ = blue_[(prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div))]; \\\n \t*dst++ = green_[(prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div))]; \\\n \t*dst++ = red_[curr[x] / (div)]; \\\n+\tif (addAlphaBit) *dst++ = 255; \\\n \tx++;\n \n void DebayerCpu::debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\n@@ -114,8 +118,8 @@ void DebayerCpu::debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\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\tBGGR_BGR888(1, 1, 1, addAlphaBit_)\n+\t\tGBRG_BGR888(1, 1, 1, addAlphaBit_)\n \t}\n }\n \n@@ -124,8 +128,8 @@ void DebayerCpu::debayer8_GRGR_BGR888(uint8_t *dst, const uint8_t *src[])\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\tGRBG_BGR888(1, 1, 1, addAlphaBit_)\n+\t\tRGGB_BGR888(1, 1, 1, addAlphaBit_)\n \t}\n }\n \n@@ -135,8 +139,8 @@ void DebayerCpu::debayer10_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\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\tBGGR_BGR888(1, 1, 4, addAlphaBit_)\n+\t\tGBRG_BGR888(1, 1, 4, addAlphaBit_)\n \t}\n }\n \n@@ -146,8 +150,8 @@ void DebayerCpu::debayer10_GRGR_BGR888(uint8_t *dst, const uint8_t *src[])\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\tGRBG_BGR888(1, 1, 4, addAlphaBit_)\n+\t\tRGGB_BGR888(1, 1, 4, addAlphaBit_)\n \t}\n }\n \n@@ -157,8 +161,8 @@ void DebayerCpu::debayer12_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\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\tBGGR_BGR888(1, 1, 16, addAlphaBit_)\n+\t\tGBRG_BGR888(1, 1, 16, addAlphaBit_)\n \t}\n }\n \n@@ -168,8 +172,8 @@ void DebayerCpu::debayer12_GRGR_BGR888(uint8_t *dst, const uint8_t *src[])\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\tGRBG_BGR888(1, 1, 16, addAlphaBit_)\n+\t\tRGGB_BGR888(1, 1, 16, addAlphaBit_)\n \t}\n }\n \n@@ -187,12 +191,12 @@ void DebayerCpu::debayer10P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\n \t */\n \tfor (int x = 0; x < widthInBytes;) {\n \t\t/* First pixel */\n-\t\tBGGR_BGR888(2, 1, 1)\n+\t\tBGGR_BGR888(2, 1, 1, addAlphaBit_)\n \t\t/* Second pixel BGGR -> GBRG */\n-\t\tGBRG_BGR888(1, 1, 1)\n+\t\tGBRG_BGR888(1, 1, 1, addAlphaBit_)\n \t\t/* Same thing for third and fourth pixels */\n-\t\tBGGR_BGR888(1, 1, 1)\n-\t\tGBRG_BGR888(1, 2, 1)\n+\t\tBGGR_BGR888(1, 1, 1, addAlphaBit_)\n+\t\tGBRG_BGR888(1, 2, 1, addAlphaBit_)\n \t\t/* Skip 5th src byte with 4 x 2 least-significant-bits */\n \t\tx++;\n \t}\n@@ -207,12 +211,12 @@ void DebayerCpu::debayer10P_GRGR_BGR888(uint8_t *dst, const uint8_t *src[])\n \n \tfor (int x = 0; x < widthInBytes;) {\n \t\t/* First pixel */\n-\t\tGRBG_BGR888(2, 1, 1)\n+\t\tGRBG_BGR888(2, 1, 1, addAlphaBit_)\n \t\t/* Second pixel GRBG -> RGGB */\n-\t\tRGGB_BGR888(1, 1, 1)\n+\t\tRGGB_BGR888(1, 1, 1, addAlphaBit_)\n \t\t/* Same thing for third and fourth pixels */\n-\t\tGRBG_BGR888(1, 1, 1)\n-\t\tRGGB_BGR888(1, 2, 1)\n+\t\tGRBG_BGR888(1, 1, 1, addAlphaBit_)\n+\t\tRGGB_BGR888(1, 2, 1, addAlphaBit_)\n \t\t/* Skip 5th src byte with 4 x 2 least-significant-bits */\n \t\tx++;\n \t}\n@@ -227,12 +231,12 @@ void DebayerCpu::debayer10P_GBGB_BGR888(uint8_t *dst, const uint8_t *src[])\n \n \tfor (int x = 0; x < widthInBytes;) {\n \t\t/* Even pixel */\n-\t\tGBRG_BGR888(2, 1, 1)\n+\t\tGBRG_BGR888(2, 1, 1, addAlphaBit_)\n \t\t/* Odd pixel GBGR -> BGGR */\n-\t\tBGGR_BGR888(1, 1, 1)\n+\t\tBGGR_BGR888(1, 1, 1, addAlphaBit_)\n \t\t/* Same thing for next 2 pixels */\n-\t\tGBRG_BGR888(1, 1, 1)\n-\t\tBGGR_BGR888(1, 2, 1)\n+\t\tGBRG_BGR888(1, 1, 1, addAlphaBit_)\n+\t\tBGGR_BGR888(1, 2, 1, addAlphaBit_)\n \t\t/* Skip 5th src byte with 4 x 2 least-significant-bits */\n \t\tx++;\n \t}\n@@ -247,12 +251,12 @@ void DebayerCpu::debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[])\n \n \tfor (int x = 0; x < widthInBytes;) {\n \t\t/* Even pixel */\n-\t\tRGGB_BGR888(2, 1, 1)\n+\t\tRGGB_BGR888(2, 1, 1, addAlphaBit_)\n \t\t/* Odd pixel RGGB -> GRBG */\n-\t\tGRBG_BGR888(1, 1, 1)\n+\t\tGRBG_BGR888(1, 1, 1, addAlphaBit_)\n \t\t/* Same thing for next 2 pixels */\n-\t\tRGGB_BGR888(1, 1, 1)\n-\t\tGRBG_BGR888(1, 2, 1)\n+\t\tRGGB_BGR888(1, 1, 1, addAlphaBit_)\n+\t\tGRBG_BGR888(1, 2, 1, addAlphaBit_)\n \t\t/* Skip 5th src byte with 4 x 2 least-significant-bits */\n \t\tx++;\n \t}\n@@ -280,7 +284,14 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf\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, formats::BGR888 });\n+\t\tconfig.outputFormats = std::vector<PixelFormat>({\n+\t\t\tformats::RGB888,\n+\t\t\tformats::XRGB8888,\n+\t\t\tformats::ARGB8888,\n+\t\t\tformats::BGR888,\n+\t\t\tformats::XBGR8888,\n+\t\t\tformats::ABGR8888\n+\t\t});\n \t\treturn 0;\n \t}\n \n@@ -290,7 +301,14 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf\n \t\tconfig.bpp = 10;\n \t\tconfig.patternSize.width = 4; /* 5 bytes per *4* pixels */\n \t\tconfig.patternSize.height = 2;\n-\t\tconfig.outputFormats = std::vector<PixelFormat>({ formats::RGB888, formats::BGR888 });\n+\t\tconfig.outputFormats = std::vector<PixelFormat>({\n+\t\t\tformats::RGB888,\n+\t\t\tformats::XRGB8888,\n+\t\t\tformats::ARGB8888,\n+\t\t\tformats::BGR888,\n+\t\t\tformats::XBGR8888,\n+\t\t\tformats::ABGR8888\n+\t\t});\n \t\treturn 0;\n \t}\n \n@@ -306,6 +324,12 @@ int DebayerCpu::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &c\n \t\treturn 0;\n \t}\n \n+\tif (outputFormat == formats::XRGB8888 || outputFormat == formats::ARGB8888 ||\n+\t outputFormat == formats::XBGR8888 || outputFormat == formats::ABGR8888) {\n+\t\tconfig.bpp = 32;\n+\t\treturn 0;\n+\t}\n+\n \tLOG(Debayer, Info)\n \t\t<< \"Unsupported output format \" << outputFormat.toString();\n \treturn -EINVAL;\n@@ -344,6 +368,7 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputF\n \n \txShift_ = 0;\n \tswapRedBlueGains_ = false;\n+\taddAlphaBit_ = false;\n \n \tauto invalidFmt = []() -> int {\n \t\tLOG(Debayer, Error) << \"Unsupported input output format combination\";\n@@ -351,8 +376,16 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputF\n \t};\n \n \tswitch (outputFormat) {\n+\tcase formats::XRGB8888:\n+\tcase formats::ARGB8888:\n+\t addAlphaBit_ = true;\n+\t [[fallthrough]];\n \tcase formats::RGB888:\n \t\tbreak;\n+\tcase formats::XBGR8888:\n+\tcase formats::ABGR8888:\n+\t addAlphaBit_ = true;\n+\t [[fallthrough]];\n \tcase formats::BGR888:\n \t\t/* Swap R and B in bayer order to generate BGR888 instead of RGB888 */\n \t\tswapRedBlueGains_ = true;\ndiff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\nindex be7dcdca..4f77600d 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -132,6 +132,7 @@ private:\n \tdebayerFn debayer1_;\n \tdebayerFn debayer2_;\n \tdebayerFn debayer3_;\n+\tbool addAlphaBit_;\n \tRectangle window_;\n \tDebayerInputConfig inputConfig_;\n \tDebayerOutputConfig outputConfig_;\n", "prefixes": [ "v2" ] }