Show a patch.

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

{
    "id": 1148,
    "url": "https://patchwork.libcamera.org/api/patches/1148/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1148/",
    "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": "<20190502162723.30511-1-laurent.pinchart@ideasonboard.com>",
    "date": "2019-05-02T16:27:23",
    "name": "[libcamera-devel] qcam: format_converter: Add RGB formats support",
    "commit_ref": "28382ff2b181441334f2ccbb3ce82ae491dcc771",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "9346c32c9c8b78cb8a6f25fdfde4879792611ec4",
    "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/1148/mbox/",
    "series": [
        {
            "id": 288,
            "url": "https://patchwork.libcamera.org/api/series/288/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=288",
            "date": "2019-05-02T16:27:23",
            "name": "[libcamera-devel] qcam: format_converter: Add RGB formats support",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/288/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1148/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1148/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C7A8760E5B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 May 2019 18:27:40 +0200 (CEST)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 27BBC510\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 May 2019 18:27:40 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1556814460;\n\tbh=r4prMQ4JdH3LJ2Ddw7D4nBPM78HBQgVcpDt2++YAcWU=;\n\th=From:To:Subject:Date:From;\n\tb=fRha2sn+zuncukQQ7URC/v6vPsrbr9LHZI2tHJUSyXmnfplhWjphukXKuEjAYlobU\n\t3YeytUFp4RUAwboJhIm1utw7N+LiuYCDxrlehxUpl1cgvGWt0PNUtyRIdfL91hZcLC\n\tjd112eAroL0QpdwmE438IRitPLl2pa2y8Mr5ikCQ=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu,  2 May 2019 19:27:23 +0300",
        "Message-Id": "<20190502162723.30511-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] qcam: format_converter: Add RGB formats\n\tsupport",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Thu, 02 May 2019 16:27:41 -0000"
    },
    "content": "Add support for the RGB format supported by VIMC (V4L2_PIX_FMT_BGR24,\nV4L2_PIX_FMT_RGB24 and V4L2_PIX_FMT_ARGB32).\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/qcam/format_converter.cpp | 52 ++++++++++++++++++++++++++++++++++-\n src/qcam/format_converter.h   |  8 ++++++\n 2 files changed, 59 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\nindex bda9057e17b6..d9088c38f0d4 100644\n--- a/src/qcam/format_converter.cpp\n+++ b/src/qcam/format_converter.cpp\n@@ -31,23 +31,49 @@ int FormatConverter::configure(unsigned int format, unsigned int width,\n \t\t\t       unsigned int height)\n {\n \tswitch (format) {\n+\tcase V4L2_PIX_FMT_BGR24:\n+\t\tyuv_ = false;\n+\t\tr_pos_ = 2;\n+\t\tg_pos_ = 1;\n+\t\tb_pos_ = 0;\n+\t\tbpp_ = 3;\n+\t\tbreak;\n+\tcase V4L2_PIX_FMT_RGB24:\n+\t\tyuv_ = false;\n+\t\tr_pos_ = 0;\n+\t\tg_pos_ = 1;\n+\t\tb_pos_ = 2;\n+\t\tbpp_ = 3;\n+\t\tbreak;\n+\tcase V4L2_PIX_FMT_ARGB32:\n+\t\tyuv_ = false;\n+\t\tr_pos_ = 1;\n+\t\tg_pos_ = 2;\n+\t\tb_pos_ = 3;\n+\t\tbpp_ = 4;\n+\t\tbreak;\n \tcase V4L2_PIX_FMT_VYUY:\n+\t\tyuv_ = true;\n \t\ty_pos_ = 1;\n \t\tcb_pos_ = 2;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_YVYU:\n+\t\tyuv_ = true;\n \t\ty_pos_ = 0;\n \t\tcb_pos_ = 3;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_UYVY:\n+\t\tyuv_ = true;\n \t\ty_pos_ = 1;\n \t\tcb_pos_ = 0;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_YUYV:\n+\t\tyuv_ = true;\n \t\ty_pos_ = 0;\n \t\tcb_pos_ = 1;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_MJPEG:\n+\t\tyuv_ = false;\n \t\tbreak;\n \tdefault:\n \t\treturn -EINVAL;\n@@ -65,8 +91,32 @@ void FormatConverter::convert(const unsigned char *src, size_t size,\n {\n \tif (format_ == V4L2_PIX_FMT_MJPEG)\n \t\tdst->loadFromData(src, size, \"JPEG\");\n-\telse\n+\telse if (yuv_)\n \t\tconvertYUV(src, dst->bits());\n+\telse\n+\t\tconvertRGB(src, dst->bits());\n+}\n+\n+void FormatConverter::convertRGB(const unsigned char *src, unsigned char *dst)\n+{\n+\tunsigned int x, y;\n+\tint r, g, b;\n+\n+\tfor (y = 0; y < height_; y++) {\n+\t\tfor (x = 0; x < width_; x++) {\n+\t\t\tr = src[bpp_ * x + r_pos_];\n+\t\t\tg = src[bpp_ * x + g_pos_];\n+\t\t\tb = src[bpp_ * x + b_pos_];\n+\n+\t\t\tdst[4 * x + 0] = b;\n+\t\t\tdst[4 * x + 1] = g;\n+\t\t\tdst[4 * x + 2] = r;\n+\t\t\tdst[4 * x + 3] = 0xff;\n+\t\t}\n+\n+\t\tsrc += width_ * bpp_;\n+\t\tdst += width_ * 4;\n+\t}\n }\n \n static void yuv_to_rgb(int y, int u, int v, int *r, int *g, int *b)\ndiff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h\nindex 396d0bea116a..76cd9f1cab56 100644\n--- a/src/qcam/format_converter.h\n+++ b/src/qcam/format_converter.h\n@@ -20,11 +20,19 @@ public:\n \tvoid convert(const unsigned char *src, size_t size, QImage *dst);\n \n private:\n+\tvoid convertRGB(const unsigned char *src, unsigned char *dst);\n \tvoid convertYUV(const unsigned char *src, unsigned char *dst);\n \n \tunsigned int format_;\n \tunsigned int width_;\n \tunsigned int height_;\n+\n+\tunsigned int bpp_;\n+\tunsigned int r_pos_;\n+\tunsigned int g_pos_;\n+\tunsigned int b_pos_;\n+\n+\tbool yuv_;\n \tunsigned int y_pos_;\n \tunsigned int cb_pos_;\n };\n",
    "prefixes": [
        "libcamera-devel"
    ]
}