Show a patch.

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

{
    "id": 13706,
    "url": "https://patchwork.libcamera.org/api/patches/13706/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13706/",
    "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": "<20210907002044.7319-4-laurent.pinchart@ideasonboard.com>",
    "date": "2021-09-07T00:20:42",
    "name": "[libcamera-devel,v2,3/5] qcam: format_converter: Rename YUV and NV to YUVPacked and YUVSemiPlanar",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "5ea5acb44255a764e9a5378bfb3120e53816d489",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13706/mbox/",
    "series": [
        {
            "id": 2484,
            "url": "https://patchwork.libcamera.org/api/series/2484/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2484",
            "date": "2021-09-07T00:20:39",
            "name": "qcam: Fix stride handling",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2484/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13706/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13706/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 DE15FBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Sep 2021 00:21:15 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F2A246917C;\n\tTue,  7 Sep 2021 02:21:11 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E39F6916A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Sep 2021 02:21:08 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D7DF9993\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Sep 2021 02:21:07 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"KqoRnepS\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630974068;\n\tbh=EG9+kCAtUs+CzAxar++/juJo7WzLafy5Omntq+M/WSo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=KqoRnepSMqVv4TPc31e7XIkADvjhGBbUW9NvW5sp2/DeYAFu3/NvQ9VRcleEMJBrL\n\tqU2aUC01UE+0+kKs23AoIC26OBMKsYvVovN3+sV/Q1pc22q4FF3r+5ExVVC0WA2ctR\n\tLR5upN6SecC6HrETsigg4IZUGk8TsfHQab9wh+pw=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  7 Sep 2021 03:20:42 +0300",
        "Message-Id": "<20210907002044.7319-4-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.32.0",
        "In-Reply-To": "<20210907002044.7319-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20210907002044.7319-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 3/5] qcam: format_converter: Rename YUV\n\tand NV to YUVPacked and YUVSemiPlanar",
        "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": "To prepare for fully-planar YUV support, rename the existing format\nfamilies YUV and NV to YUVPacked and YUVSemiPlanar respectively.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/qcam/format_converter.cpp | 114 +++++++++++++++++-----------------\n src/qcam/format_converter.h   |   8 +--\n 2 files changed, 61 insertions(+), 61 deletions(-)",
    "diff": "diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\nindex b4c7b0ca0edf..7979ea8a77ff 100644\n--- a/src/qcam/format_converter.cpp\n+++ b/src/qcam/format_converter.cpp\n@@ -34,37 +34,37 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n {\n \tswitch (format) {\n \tcase libcamera::formats::NV12:\n-\t\tformatFamily_ = NV;\n+\t\tformatFamily_ = YUVSemiPlanar;\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 2;\n \t\tnvSwap_ = false;\n \t\tbreak;\n \tcase libcamera::formats::NV21:\n-\t\tformatFamily_ = NV;\n+\t\tformatFamily_ = YUVSemiPlanar;\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 2;\n \t\tnvSwap_ = true;\n \t\tbreak;\n \tcase libcamera::formats::NV16:\n-\t\tformatFamily_ = NV;\n+\t\tformatFamily_ = YUVSemiPlanar;\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 1;\n \t\tnvSwap_ = false;\n \t\tbreak;\n \tcase libcamera::formats::NV61:\n-\t\tformatFamily_ = NV;\n+\t\tformatFamily_ = YUVSemiPlanar;\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 1;\n \t\tnvSwap_ = true;\n \t\tbreak;\n \tcase libcamera::formats::NV24:\n-\t\tformatFamily_ = NV;\n+\t\tformatFamily_ = YUVSemiPlanar;\n \t\thorzSubSample_ = 1;\n \t\tvertSubSample_ = 1;\n \t\tnvSwap_ = false;\n \t\tbreak;\n \tcase libcamera::formats::NV42:\n-\t\tformatFamily_ = NV;\n+\t\tformatFamily_ = YUVSemiPlanar;\n \t\thorzSubSample_ = 1;\n \t\tvertSubSample_ = 1;\n \t\tnvSwap_ = true;\n@@ -121,22 +121,22 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n \t\tbreak;\n \n \tcase libcamera::formats::VYUY:\n-\t\tformatFamily_ = YUV;\n+\t\tformatFamily_ = YUVPacked;\n \t\ty_pos_ = 1;\n \t\tcb_pos_ = 2;\n \t\tbreak;\n \tcase libcamera::formats::YVYU:\n-\t\tformatFamily_ = YUV;\n+\t\tformatFamily_ = YUVPacked;\n \t\ty_pos_ = 0;\n \t\tcb_pos_ = 3;\n \t\tbreak;\n \tcase libcamera::formats::UYVY:\n-\t\tformatFamily_ = YUV;\n+\t\tformatFamily_ = YUVPacked;\n \t\ty_pos_ = 1;\n \t\tcb_pos_ = 0;\n \t\tbreak;\n \tcase libcamera::formats::YUYV:\n-\t\tformatFamily_ = YUV;\n+\t\tformatFamily_ = YUVPacked;\n \t\ty_pos_ = 0;\n \t\tcb_pos_ = 1;\n \t\tbreak;\n@@ -163,14 +163,14 @@ void FormatConverter::convert(const Image *src, size_t size, QImage *dst)\n \tcase MJPEG:\n \t\tdst->loadFromData(src->data(0).data(), size, \"JPEG\");\n \t\tbreak;\n-\tcase YUV:\n-\t\tconvertYUV(src, dst->bits());\n-\t\tbreak;\n \tcase RGB:\n \t\tconvertRGB(src, dst->bits());\n \t\tbreak;\n-\tcase NV:\n-\t\tconvertNV(src, dst->bits());\n+\tcase YUVPacked:\n+\t\tconvertYUVPacked(src, dst->bits());\n+\t\tbreak;\n+\tcase YUVSemiPlanar:\n+\t\tconvertYUVSemiPlanar(src, dst->bits());\n \t\tbreak;\n \t};\n }\n@@ -185,47 +185,6 @@ static void yuv_to_rgb(int y, int u, int v, int *r, int *g, int *b)\n \t*b = CLIP(( 298 * c + 516 * d           + 128) >> RGBSHIFT);\n }\n \n-void FormatConverter::convertNV(const Image *srcImage, unsigned char *dst)\n-{\n-\tunsigned int c_stride = stride_ * (2 / horzSubSample_);\n-\tunsigned int c_inc = horzSubSample_ == 1 ? 2 : 0;\n-\tunsigned int cb_pos = nvSwap_ ? 1 : 0;\n-\tunsigned int cr_pos = nvSwap_ ? 0 : 1;\n-\tconst unsigned char *src = srcImage->data(0).data();\n-\tconst unsigned char *src_c = srcImage->data(1).data();\n-\tint r, g, b;\n-\n-\tfor (unsigned int y = 0; y < height_; y++) {\n-\t\tconst unsigned char *src_y = src + y * stride_;\n-\t\tconst unsigned char *src_cb = src_c + (y / vertSubSample_) *\n-\t\t\t\t\t      c_stride + cb_pos;\n-\t\tconst unsigned char *src_cr = src_c + (y / vertSubSample_) *\n-\t\t\t\t\t      c_stride + cr_pos;\n-\n-\t\tfor (unsigned int x = 0; x < width_; x += 2) {\n-\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n-\t\t\tdst[0] = b;\n-\t\t\tdst[1] = g;\n-\t\t\tdst[2] = r;\n-\t\t\tdst[3] = 0xff;\n-\t\t\tsrc_y++;\n-\t\t\tsrc_cb += c_inc;\n-\t\t\tsrc_cr += c_inc;\n-\t\t\tdst += 4;\n-\n-\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n-\t\t\tdst[0] = b;\n-\t\t\tdst[1] = g;\n-\t\t\tdst[2] = r;\n-\t\t\tdst[3] = 0xff;\n-\t\t\tsrc_y++;\n-\t\t\tsrc_cb += 2;\n-\t\t\tsrc_cr += 2;\n-\t\t\tdst += 4;\n-\t\t}\n-\t}\n-}\n-\n void FormatConverter::convertRGB(const Image *srcImage, unsigned char *dst)\n {\n \tconst unsigned char *src = srcImage->data(0).data();\n@@ -249,7 +208,7 @@ void FormatConverter::convertRGB(const Image *srcImage, unsigned char *dst)\n \t}\n }\n \n-void FormatConverter::convertYUV(const Image *srcImage, unsigned char *dst)\n+void FormatConverter::convertYUVPacked(const Image *srcImage, unsigned char *dst)\n {\n \tconst unsigned char *src = srcImage->data(0).data();\n \tunsigned int src_x, src_y, dst_x, dst_y;\n@@ -287,3 +246,44 @@ void FormatConverter::convertYUV(const Image *srcImage, unsigned char *dst)\n \t\t}\n \t}\n }\n+\n+void FormatConverter::convertYUVSemiPlanar(const Image *srcImage, unsigned char *dst)\n+{\n+\tunsigned int c_stride = stride_ * (2 / horzSubSample_);\n+\tunsigned int c_inc = horzSubSample_ == 1 ? 2 : 0;\n+\tunsigned int cb_pos = nvSwap_ ? 1 : 0;\n+\tunsigned int cr_pos = nvSwap_ ? 0 : 1;\n+\tconst unsigned char *src = srcImage->data(0).data();\n+\tconst unsigned char *src_c = srcImage->data(1).data();\n+\tint r, g, b;\n+\n+\tfor (unsigned int y = 0; y < height_; y++) {\n+\t\tconst unsigned char *src_y = src + y * stride_;\n+\t\tconst unsigned char *src_cb = src_c + (y / vertSubSample_) *\n+\t\t\t\t\t      c_stride + cb_pos;\n+\t\tconst unsigned char *src_cr = src_c + (y / vertSubSample_) *\n+\t\t\t\t\t      c_stride + cr_pos;\n+\n+\t\tfor (unsigned int x = 0; x < width_; x += 2) {\n+\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n+\t\t\tdst[0] = b;\n+\t\t\tdst[1] = g;\n+\t\t\tdst[2] = r;\n+\t\t\tdst[3] = 0xff;\n+\t\t\tsrc_y++;\n+\t\t\tsrc_cb += c_inc;\n+\t\t\tsrc_cr += c_inc;\n+\t\t\tdst += 4;\n+\n+\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n+\t\t\tdst[0] = b;\n+\t\t\tdst[1] = g;\n+\t\t\tdst[2] = r;\n+\t\t\tdst[3] = 0xff;\n+\t\t\tsrc_y++;\n+\t\t\tsrc_cb += 2;\n+\t\t\tsrc_cr += 2;\n+\t\t\tdst += 4;\n+\t\t}\n+\t}\n+}\ndiff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h\nindex bb04aa959a1a..9ce2cc6da7f2 100644\n--- a/src/qcam/format_converter.h\n+++ b/src/qcam/format_converter.h\n@@ -27,14 +27,14 @@ public:\n private:\n \tenum FormatFamily {\n \t\tMJPEG,\n-\t\tNV,\n \t\tRGB,\n-\t\tYUV,\n+\t\tYUVPacked,\n+\t\tYUVSemiPlanar,\n \t};\n \n-\tvoid convertNV(const Image *src, unsigned char *dst);\n \tvoid convertRGB(const Image *src, unsigned char *dst);\n-\tvoid convertYUV(const Image *src, unsigned char *dst);\n+\tvoid convertYUVPacked(const Image *src, unsigned char *dst);\n+\tvoid convertYUVSemiPlanar(const Image *src, unsigned char *dst);\n \n \tlibcamera::PixelFormat format_;\n \tunsigned int width_;\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "3/5"
    ]
}