Show a patch.

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

{
    "id": 9545,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/9545/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9545/",
    "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": "<20200908150739.1552-3-andrey.konovalov@linaro.org>",
    "date": "2020-09-08T15:07:39",
    "name": "[libcamera-devel,RFC,v2,2/2] qcam: format_converter: add 10 and 12 bit packed raw Bayer formats",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "bfa3e551051b35ca3aeb64b5a90bcae7ef884531",
    "submitter": {
        "id": 25,
        "url": "https://patchwork.libcamera.org/api/1.1/people/25/?format=api",
        "name": "Andrey Konovalov",
        "email": "andrey.konovalov@linaro.org"
    },
    "delegate": {
        "id": 14,
        "url": "https://patchwork.libcamera.org/api/1.1/users/14/?format=api",
        "username": "pinchartl",
        "first_name": "Laurent",
        "last_name": "Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "mbox": "https://patchwork.libcamera.org/patch/9545/mbox/",
    "series": [
        {
            "id": 1275,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1275/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1275",
            "date": "2020-09-08T15:07:37",
            "name": "qcam: format_converter: add 10 and 12 bit packed raw Bayer formats",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1275/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9545/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9545/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 5FEAFBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Sep 2020 15:08:14 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2CE2062CB2;\n\tTue,  8 Sep 2020 17:08:14 +0200 (CEST)",
            "from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0648D6056C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Sep 2020 17:08:13 +0200 (CEST)",
            "by mail-lj1-x244.google.com with SMTP id w3so20482003ljo.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Sep 2020 08:08:13 -0700 (PDT)",
            "from localhost.localdomain (37-144-159-139.broadband.corbina.ru.\n\t[37.144.159.139]) by smtp.googlemail.com with ESMTPSA id\n\tf19sm10614121lfs.85.2020.09.08.08.08.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 08 Sep 2020 08:08:11 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"Fh6/Ow8F\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=hOBNU2TJIcHiBs8ViVf9SAf9Eo1RLhlaLf8wscXGp18=;\n\tb=Fh6/Ow8F1T5o1AjkL0r+YV775lGNy1pXhzKi1xiIw6MI9YffmgJauNyIEBibpnjqtO\n\t4YmGUJ/U1aRbQv9kc4bVfpJZZcf2A6ASAVRC8Coz00mb/T0ohvT7UPmqVWs+jY0P50bu\n\t5qSAhgjRk1R0FT8xnJIr+fandkd0UfS6r9NAB9W2hpHBTMflKP/cLnhrvt7F4lVi1Y2q\n\tkWfakRcFtf2VA8Vm/ev0SL5kboDn1Q1qUeAPuMCCVUdyjfajQMFMZczCPfqhPP4t7EiV\n\tM1gakU9p1sui5wiac+RbB3nMvyKZsxQKKJ4joKs9g+6C56Y+ECh65N8VJ5WecJOtIxGE\n\t7NiQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=hOBNU2TJIcHiBs8ViVf9SAf9Eo1RLhlaLf8wscXGp18=;\n\tb=rLlUPqasnirgFitrlCJWMypiDxSCqeHmpG5zT1nEfjT0oBitKV0fzWi0xIQsK5gkT2\n\ti2qbayP66iuKAYN+0tyKTOfhh2ed0LNoaNZTZSLHiWu0Q9LwGNzmcJWWmIr0lmZQjiFp\n\tRSjlQiHHyo/6Mc7TFKFmPW556EplvH2UdqcPmh/noOPVdokyC4dDRtfD41zZEu2+WYqo\n\tsxKcTgi9KiMjexW4jN7Bq24LWs0H1dIPf9yUfUs3D5GjXLfrc1vZoy+VGHUijPNQ3Kn4\n\tJfMC4xSBt57tMiwCGfhlT+M2Kih+EJTR1wKDx88h6QOBLYkpEcOuB0kfLW4aFaYEhbu+\n\tiNZQ==",
        "X-Gm-Message-State": "AOAM53212olPR0phUotxQsMei20OEr2F1Qd5oB7di5kljjpMs/xVTjKV\n\t/sNXqIx5Ur1Stv9VEBdNOD8NX2IyEWiCZQ==",
        "X-Google-Smtp-Source": "ABdhPJwYJ9aKfz6cmxT/WtAtjlITz0SVZkIJcOvqOEH9FJE7WIBnhbf+vQxaBIlY5zJFwlfrZHBGmA==",
        "X-Received": "by 2002:a2e:5051:: with SMTP id\n\tv17mr12239180ljd.295.1599577691919; \n\tTue, 08 Sep 2020 08:08:11 -0700 (PDT)",
        "From": "Andrey Konovalov <andrey.konovalov@linaro.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  8 Sep 2020 18:07:39 +0300",
        "Message-Id": "<20200908150739.1552-3-andrey.konovalov@linaro.org>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200908150739.1552-1-andrey.konovalov@linaro.org>",
        "References": "<20200908150739.1552-1-andrey.konovalov@linaro.org>",
        "Subject": "[libcamera-devel] [RFC PATCH v2 2/2] qcam: format_converter: add 10\n\tand 12 bit packed raw Bayer formats",
        "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>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "No interpolation is used to get more speed by the price of lower image\nquality. In qcam format_converter is used for viewfinder only, and in\nthis case lower lag is more important than the image quality.\n\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n---\n src/qcam/format_converter.cpp | 138 ++++++++++++++++++++++++++++++++++\n src/qcam/format_converter.h   |  21 ++++++\n 2 files changed, 159 insertions(+)",
    "diff": "diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\nindex 3481330..f370907 100644\n--- a/src/qcam/format_converter.cpp\n+++ b/src/qcam/format_converter.cpp\n@@ -10,6 +10,7 @@\n #include <errno.h>\n \n #include <QImage>\n+#include <QtDebug>\n \n #include <libcamera/formats.h>\n \n@@ -132,6 +133,62 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n \t\tparams_.yuv.cb_pos = 1;\n \t\tbreak;\n \n+\tcase libcamera::formats::SRGGB10_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tparams_.rawp.bpp_numer = 5;\t/* 1.25 bytes per pixel */\n+\t\tparams_.rawp.bpp_denom = 4;\n+\t\tparams_.rawp.r_pos = 0;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SGRBG10_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tparams_.rawp.bpp_numer = 5;\n+\t\tparams_.rawp.bpp_denom = 4;\n+\t\tparams_.rawp.r_pos = 1;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SGBRG10_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tparams_.rawp.bpp_numer = 5;\n+\t\tparams_.rawp.bpp_denom = 4;\n+\t\tparams_.rawp.r_pos = 2;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SBGGR10_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tparams_.rawp.bpp_numer = 5;\n+\t\tparams_.rawp.bpp_denom = 4;\n+\t\tparams_.rawp.r_pos = 3;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SRGGB12_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tparams_.rawp.bpp_numer = 3;\t/* 1.5 bytes per pixel */\n+\t\tparams_.rawp.bpp_denom = 2;\n+\t\tparams_.rawp.r_pos = 0;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SGRBG12_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tparams_.rawp.bpp_numer = 3;\n+\t\tparams_.rawp.bpp_denom = 2;\n+\t\tparams_.rawp.r_pos = 1;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SGBRG12_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tparams_.rawp.bpp_numer = 3;\n+\t\tparams_.rawp.bpp_denom = 2;\n+\t\tparams_.rawp.r_pos = 2;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SBGGR12_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tparams_.rawp.bpp_numer = 3;\n+\t\tparams_.rawp.bpp_denom = 2;\n+\t\tparams_.rawp.r_pos = 3;\n+\t\tbreak;\n+\n \tcase libcamera::formats::MJPEG:\n \t\tformatFamily_ = MJPEG;\n \t\tbreak;\n@@ -144,6 +201,45 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n \twidth_ = size.width();\n \theight_ = size.height();\n \n+\tif (formatFamily_ == RAW_CSI2P) {\n+\t\t/*\n+\t\t * For RAW_CSI2P the assumption is that height_ and width_\n+\t\t * are even numbers.\n+\t\t */\n+\t\tif ( width_ % 2 != 0 || height_ % 2 != 0 ) {\n+\t\t\tqWarning() << \"Image width or height isn't even number\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tparams_.rawp.srcLineLength = width_ * params_.rawp.bpp_numer /\n+\t\t\t\t\t     params_.rawp.bpp_denom;\n+\n+\t\t/*\n+\t\t * Calculate [g1,g2,b]_pos based on r_pos.\n+\t\t * On entrance, r_pos is the position of red pixel in the\n+\t\t * 2-by-2 pixel Bayer pattern, and is from 0 to 3 range:\n+\t\t *    +---+---+\n+\t\t *    | 0 | 1 |\n+\t\t *    +---+---+\n+\t\t *    | 2 | 3 |\n+\t\t *    +---+---+\n+\t\t * At exit, [r,g1,g2,b]_pos are offsetts of the color\n+\t\t * values in the source buffer.\n+\t\t */\n+\t\tif (params_.rawp.r_pos > 1) {\n+\t\t\tparams_.rawp.r_pos = params_.rawp.r_pos - 2 +\n+\t\t\t\t\t     params_.rawp.srcLineLength;\n+\t\t\tparams_.rawp.b_pos = 3 - params_.rawp.r_pos;\n+\t\t} else {\n+\t\t\tparams_.rawp.b_pos = 1 - params_.rawp.r_pos +\n+\t\t\t\t\t     params_.rawp.srcLineLength;\n+\t\t}\n+\t\tparams_.rawp.g1_pos = (params_.rawp.r_pos == 0 ||\n+\t\t\t\t       params_.rawp.b_pos == 0) ? 1 : 0;\n+\t\tparams_.rawp.g2_pos = 1 - params_.rawp.g1_pos +\n+\t\t\t\t      params_.rawp.srcLineLength;\n+\t}\n+\n \treturn 0;\n }\n \n@@ -163,9 +259,51 @@ void FormatConverter::convert(const unsigned char *src, size_t size,\n \tcase NV:\n \t\tconvertNV(src, dst->bits());\n \t\tbreak;\n+\tcase RAW_CSI2P:\n+\t\tconvertRawCSI2P(src, dst->bits());\n+\t\tbreak;\n \t};\n }\n \n+void FormatConverter::convertRawCSI2P(const unsigned char *src,\n+\t\t\t\t      unsigned char *dst)\n+{\n+\tunsigned int g;\n+\tstatic unsigned char dst_buf[8] = { 0, 0, 0, 0xff };\n+\tunsigned int dstLineLength = width_ * 4;\n+\n+\tfor (unsigned int y = 0; y < height_; y += 2) {\n+\t\tfor (unsigned x = 0; x < width_; x += params_.rawp.bpp_denom) {\n+\t\t\tfor (unsigned int i = 0; i < params_.rawp.bpp_denom ;\n+\t\t\t     i += 2) {\n+\t\t\t\t/*\n+\t\t\t\t * Process the current 2x2 group.\n+\t\t\t\t * Use the average of the two green pixels as\n+\t\t\t\t * the green value for all the pixels in the\n+\t\t\t\t * group.\n+\t\t\t\t */\n+\t\t\t\tdst_buf[0] = src[params_.rawp.b_pos];\n+\t\t\t\tg = src[params_.rawp.g1_pos];\n+\t\t\t\tg = (g + src[params_.rawp.g2_pos]) >> 1;\n+\t\t\t\tdst_buf[1] = (unsigned char)g;\n+\t\t\t\tdst_buf[2] = src[params_.rawp.r_pos];\n+\t\t\t\tsrc += 2;\n+\n+\t\t\t\tmemcpy(dst_buf + 4, dst_buf, 4);\n+\t\t\t\tmemcpy(dst, dst_buf, 8);\n+\t\t\t\tmemcpy(dst + dstLineLength, dst_buf, 8);\n+\t\t\t\tdst += 8;\n+\t\t\t}\n+\t\t\tsrc += params_.rawp.bpp_numer - params_.rawp.bpp_denom;\n+\t\t}\n+\t\t/* odd lines are copies of the even lines they follow: */\n+\t\tmemcpy(dst, dst-dstLineLength, dstLineLength);\n+\t\t/* move to the next even line: */\n+\t\tsrc += params_.rawp.srcLineLength;\n+\t\tdst += dstLineLength;\n+\t}\n+}\n+\n static void yuv_to_rgb(int y, int u, int v, int *r, int *g, int *b)\n {\n \tint c = y - 16;\ndiff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h\nindex c53fa28..dc20e0d 100644\n--- a/src/qcam/format_converter.h\n+++ b/src/qcam/format_converter.h\n@@ -26,11 +26,13 @@ private:\n \tenum FormatFamily {\n \t\tMJPEG,\n \t\tNV,\n+\t\tRAW_CSI2P,\n \t\tRGB,\n \t\tYUV,\n \t};\n \n \tvoid convertNV(const unsigned char *src, unsigned char *dst);\n+\tvoid convertRawCSI2P(const unsigned char *src, unsigned char *dst);\n \tvoid convertRGB(const unsigned char *src, unsigned char *dst);\n \tvoid convertYUV(const unsigned char *src, unsigned char *dst);\n \n@@ -48,6 +50,25 @@ private:\n \t\t\tbool nvSwap;\n \t\t} nv;\n \n+\t\t/* RAW Bayer CSI2P parameters */\n+\t\tstruct raw_csi2p_params {\n+\t\t\t/*\n+\t\t\t * Bytes per pixel is a fractional number, and is\n+\t\t\t * represented by integer numerator and denominator.\n+\t\t\t */\n+\t\t\tunsigned int bpp_numer;\n+\t\t\tunsigned int bpp_denom;\n+\t\t\tunsigned int r_pos;\n+\t\t\t/*\n+\t\t\t * The fields below are used to hold the values computed\n+\t\t\t * in configure() based on r_pos and width_.\n+\t\t\t */\n+\t\t\tunsigned int g1_pos;\n+\t\t\tunsigned int g2_pos;\n+\t\t\tunsigned int b_pos;\n+\t\t\tunsigned int srcLineLength;\n+\t\t} rawp;\n+\n \t\t/* RGB parameters */\n \t\tstruct rgb_params {\n \t\t\tunsigned int bpp;\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "v2",
        "2/2"
    ]
}