Show a patch.

GET /api/patches/19407/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 19407,
    "url": "https://patchwork.libcamera.org/api/patches/19407/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19407/",
    "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": "<20240113142218.28063-18-hdegoede@redhat.com>",
    "date": "2024-01-13T14:22:17",
    "name": "[libcamera-devel,v2,17/18] libcamera: debayer_cpu: Add support for 8 and 10 bpp unpacked bayer input",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "58c086a3e53c0ca653403b856a8bdd19efba744b",
    "submitter": {
        "id": 102,
        "url": "https://patchwork.libcamera.org/api/people/102/?format=api",
        "name": "Hans de Goede",
        "email": "hdegoede@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19407/mbox/",
    "series": [
        {
            "id": 4142,
            "url": "https://patchwork.libcamera.org/api/series/4142/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4142",
            "date": "2024-01-13T14:22:00",
            "name": "[libcamera-devel,v2,01/18] libcamera: pipeline: simple: fix size adjustment in validate()",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4142/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19407/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19407/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 F2CE3C328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 13 Jan 2024 14:23:13 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 96BFE628D8;\n\tSat, 13 Jan 2024 15:23:13 +0100 (CET)",
            "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 B660E628BA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jan 2024 15:23:11 +0100 (CET)",
            "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n\t[66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-454-FfISoMptMAKqHZhugg4pOw-1; Sat, 13 Jan 2024 09:23:07 -0500",
            "from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1])\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 3628B85A589;\n\tSat, 13 Jan 2024 14:23:07 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.39.192.58])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 3EB053C25;\n\tSat, 13 Jan 2024 14:23:05 +0000 (UTC)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1705155793;\n\tbh=SDHhaQ6+Ym6KOnX6DRinkpCo6BVpc5mSXiCTgqa1lL8=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=b4YXJVHn/m0fFhLfRYyS6Ly8ClRh988dm2RPqmGPb6ypcaoSeOtga7oZ6YeH+oc1G\n\tpSgLZEtpu0zPiC8+BoQx2yyJjN0IkhAuBN0lMXZmyWUyNdYTHXMztX7RVcJLgsLg1D\n\tgOeMsASh8/TzgQpAa8fM1i+wk8bfKuFbjNQr6dJ0U0WsMc8G3RmHBYUCsw0BJTs+Jd\n\tQGOEPtOo2h/KQMPKUgvAY4ZejgQIRGC9sS42yNbeOL3UOhPtMvDVyfUj0p470af9gC\n\t5jUu1D8BUIR49qfxfl+1vvAxTPqEDnSe6Y3QGXDpDXeFsGz7zLhkaVPpckw70kzwqg\n\tBFQZSchz3Bf3A==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1705155790;\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=i+hhMJI4JwhF6806NjP/595IzSd4eALvqtFpD2YFpZ4=;\n\tb=MMvARURBUmvZF4fP376FMApMnzT/gdns3iplBZFaWIFDCa7v85axxEYg6RZKPeKIZfZuOU\n\tac1S4xpFT8sUXg7rUZcJ/VoMinPG3cQCHAQD5eyD1IEU1FDdUfYq15Y9hZ3er1ZJJyw2Ob\n\tbk0EnPEFJ9mahcJFvQiB3AUmkIhYCSc="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"MMvARURB\"; \n\tdkim-atps=neutral",
        "X-MC-Unique": "FfISoMptMAKqHZhugg4pOw-1",
        "To": "libcamera-devel@lists.libcamera.org,\n\tAndrey Konovalov <andrey.konovalov.ynk@gmail.com>",
        "Date": "Sat, 13 Jan 2024 15:22:17 +0100",
        "Message-ID": "<20240113142218.28063-18-hdegoede@redhat.com>",
        "In-Reply-To": "<20240113142218.28063-1-hdegoede@redhat.com>",
        "References": "<20240113142218.28063-1-hdegoede@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.1",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "Subject": "[libcamera-devel] [PATCH v2 17/18] libcamera: debayer_cpu: Add\n\tsupport for 8 and 10 bpp unpacked bayer input",
        "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>",
        "From": "Hans de Goede via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Hans de Goede <hdegoede@redhat.com>",
        "Cc": "Maxime Ripard <mripard@redhat.com>, g.martti@gmail.com,\n\tt.langendam@gmail.com, srinivas.kandagatla@linaro.org,\n\tPavel Machek <pavel@ucw.cz>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>, admin@dennisbonke.com",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add support for 8 and 10 bpp unpacked bayer input for all 4 standard\nbayer orders.\n\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\n---\n .../internal/software_isp/debayer_cpu.h       |   9 ++\n src/libcamera/software_isp/debayer_cpu.cpp    | 100 ++++++++++++++++++\n 2 files changed, 109 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/software_isp/debayer_cpu.h b/include/libcamera/internal/software_isp/debayer_cpu.h\nindex 78573f44..99914e2a 100644\n--- a/include/libcamera/internal/software_isp/debayer_cpu.h\n+++ b/include/libcamera/internal/software_isp/debayer_cpu.h\n@@ -17,6 +17,7 @@\n \n #include <libcamera/base/object.h>\n \n+#include \"libcamera/internal/bayer_format.h\"\n #include \"libcamera/internal/software_isp/swstats_cpu.h\"\n #include \"libcamera/internal/software_isp/debayer.h\"\n \n@@ -80,6 +81,12 @@ private:\n \tvoid shiftLinePointers(const uint8_t *linePointers[], const uint8_t *src);\n \tvoid process2(const uint8_t *src, uint8_t *dst);\n \tvoid process4(const uint8_t *src, uint8_t *dst);\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/* 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 +110,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 \n \tuint8_t gamma_[1024];\n@@ -119,6 +127,7 @@ private:\n \tstd::unique_ptr<SwStatsCpu> stats_;\n \tuint8_t *lineBuffers_[5];\n \tunsigned int lineBufferIndex_;\n+\tunsigned int x_shift_; /* Offset of 0/1 applied to window_.x */\n \tbool enableInputMemcpy_;\n \tfloat gamma_correction_;\n \tint measuredFrames_;\ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex e0c3c658..d1f8fa15 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -45,6 +45,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] + x_shift_; \\\n+\tconst pixel_t *curr = (const pixel_t *)src[1] + x_shift_; \\\n+\tconst pixel_t *next = (const pixel_t *)src[2] + x_shift_;\n+\n // RGR\n // GBG\n // RGR\n@@ -81,6 +86,46 @@ 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\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\tGRBG_BGR888(1, 1, 4)\n+\t\tRGGB_BGR888(1, 1, 4)\n+\t}\n+}\n+\n void DebayerCpu::debayer10P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\n {\n \tconst int width_in_bytes = window_.width * 5 / 4;\n@@ -170,6 +215,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) &&\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@@ -197,12 +252,57 @@ int DebayerCpu::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &c\n \treturn -EINVAL;\n }\n \n+/*\n+ * Check for standard Bayer orders and set x_shift_ 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\tx_shift_ = 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\tx_shift_ = 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 for now */\n int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, [[maybe_unused]] PixelFormat outputFormat)\n {\n \tBayerFormat bayerFormat =\n \t\tBayerFormat::fromPixelFormat(inputFormat);\n \n+\tx_shift_ = 0;\n+\n+\tif ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10) &&\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\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) {\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "17/18"
    ]
}