Patch Detail
Show a patch.
GET /api/1.1/patches/9435/?format=api
{ "id": 9435, "url": "https://patchwork.libcamera.org/api/1.1/patches/9435/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9435/", "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": "<20200831084645.20683-1-andrey.konovalov@linaro.org>", "date": "2020-08-31T08:46:45", "name": "[libcamera-devel,RFC] qcam: format_converter: add 10 and 12 bit packed raw Bayer formats", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "bae01d26845358ca23671ba7a085af26f73a1b2f", "submitter": { "id": 25, "url": "https://patchwork.libcamera.org/api/1.1/people/25/?format=api", "name": "Andrey Konovalov", "email": "andrey.konovalov@linaro.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9435/mbox/", "series": [ { "id": 1253, "url": "https://patchwork.libcamera.org/api/1.1/series/1253/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1253", "date": "2020-08-31T08:46:45", "name": "[libcamera-devel,RFC] qcam: format_converter: add 10 and 12 bit packed raw Bayer formats", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1253/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9435/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9435/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 D491EBF019\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 31 Aug 2020 08:47:19 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2C39562919;\n\tMon, 31 Aug 2020 10:47:19 +0200 (CEST)", "from mail-lj1-x241.google.com (mail-lj1-x241.google.com\n\t[IPv6:2a00:1450:4864:20::241])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8C78C60376\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Aug 2020 10:47:18 +0200 (CEST)", "by mail-lj1-x241.google.com with SMTP id c2so1604105ljj.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Aug 2020 01:47:18 -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\tr7sm320061lfn.84.2020.08.31.01.47.15\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 31 Aug 2020 01:47:16 -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=\"J5k0agJO\"; 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;\n\tbh=wvvZ9t7LSLOO5MS0bgUpqIuWDGl6eYU25kSszgRyD+0=;\n\tb=J5k0agJOXd263s3JLV0KYCEvnbOTNvQ8nNysSruzoUmddtR3KMvG6WHevDUgN8k6us\n\tnHPtiBNYByEPNJDDTkVckycKxuWohYpXEsN1+dpUx3coR8E2yy3gPi4cixk+OC5Cx+50\n\tQkEZ7HQwa480G2mXwhPzrW2Ng5BO4ay9Cy/yykLw92QXTYzhLjTQcwQ9+UDyXmcGk8Rz\n\tw53QCdoiw3o0/bg/SgX5T3vXyyHABviZCBLvlVmufZXnUlfKsOosuFwNbHMSKuDYXCF9\n\tbagp4fk60CiZpsR092Bt5qwvuY+WqlLU7/D98/VJLgUC2mDvRQg2LJNPLl9z15dTeYzN\n\t64LQ==", "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;\n\tbh=wvvZ9t7LSLOO5MS0bgUpqIuWDGl6eYU25kSszgRyD+0=;\n\tb=YzEg8uKtzZR5F9tQ8XpsSgly640AHIpoFUKZmi9IGwgdjzkiOqDwUwv2CINkuA7fSz\n\tH/uHIO3qPz2PnAfNhsNcCYQJgP6aey4rWVVbcno97u38HsMmhCHUJZ1XFoMqlmFfriq9\n\tK/dzxtxQdQI+/yJ7dhp5gZiwPk/Dk2PJGSZziN7g/rzJq0VouUAGSd0q2Gx5BAFFuEdD\n\tgXyvtrYyyDACvkgFqOYG6LFFtBLOrM9CQnoGe04K5xvKvp5kNQQn9x3aGWTNnlzULi1C\n\tiulEBl6pweZd1MuPHU/T6WcCnRgCq5BXJKKJh+uzJKk7Dl02fEqNYDwiLdG9rxBs7ful\n\tTIcA==", "X-Gm-Message-State": "AOAM530gR9R1KRAm8BGG3JgQlmnL45kyyGit+mGoDiPMA9t/IQGxFl4W\n\t/yObz3FymuPFrE/Kg6dT05ihDe0wuUQN5Q==", "X-Google-Smtp-Source": "ABdhPJzD7jBT9ovl7u3C4tmb+aPEEI/D/bDgdBGHl6ETB6tIPCON2owlJ7nOYvBC78bGNYAZ1rwCrA==", "X-Received": "by 2002:a05:651c:c6:: with SMTP id\n\t6mr166727ljr.237.1598863637208; \n\tMon, 31 Aug 2020 01:47:17 -0700 (PDT)", "From": "Andrey Konovalov <andrey.konovalov@linaro.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 31 Aug 2020 11:46:45 +0300", "Message-Id": "<20200831084645.20683-1-andrey.konovalov@linaro.org>", "X-Mailer": "git-send-email 2.17.1", "Subject": "[libcamera-devel] [RFC PATCH] qcam: format_converter: add 10 and 12\n\tbit 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 Only SRGGB10P and SRGGB12P formats were tested (the ones I can get from\n the camera sensor I am currently using)\n\n src/qcam/format_converter.cpp | 118 ++++++++++++++++++++++++++++++++++\n src/qcam/format_converter.h | 14 ++++\n 2 files changed, 132 insertions(+)", "diff": "diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\nindex 4b9722d..c9f94d3 100644\n--- a/src/qcam/format_converter.cpp\n+++ b/src/qcam/format_converter.cpp\n@@ -136,6 +136,62 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n \t\tformatFamily_ = MJPEG;\n \t\tbreak;\n \n+\tcase libcamera::formats::SRGGB10_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tr_pos_ = 0;\n+\t\tbpp_numer_ = 4;\n+\t\tbpp_denom_ = 5;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SGRBG10_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tr_pos_ = 1;\n+\t\tbpp_numer_ = 4;\n+\t\tbpp_denom_ = 5;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SGBRG10_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tr_pos_ = 2;\n+\t\tbpp_numer_ = 4;\n+\t\tbpp_denom_ = 5;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SBGGR10_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tr_pos_ = 3;\n+\t\tbpp_numer_ = 4;\n+\t\tbpp_denom_ = 5;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SRGGB12_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tr_pos_ = 0;\n+\t\tbpp_numer_ = 2;\n+\t\tbpp_denom_ = 3;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SGRBG12_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tr_pos_ = 1;\n+\t\tbpp_numer_ = 2;\n+\t\tbpp_denom_ = 3;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SGBRG12_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tr_pos_ = 2;\n+\t\tbpp_numer_ = 2;\n+\t\tbpp_denom_ = 3;\n+\t\tbreak;\n+\n+\tcase libcamera::formats::SBGGR12_CSI2P:\n+\t\tformatFamily_ = RAW_CSI2P;\n+\t\tr_pos_ = 3;\n+\t\tbpp_numer_ = 2;\n+\t\tbpp_denom_ = 3;\n+\t\tbreak;\n+\n \tdefault:\n \t\treturn -EINVAL;\n \t};\n@@ -163,9 +219,71 @@ 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\tconvertRAW_CSI2P(src, dst->bits());\n+\t\tbreak;\n \t};\n }\n \n+/*\n+ * The pixels are processed in groups of 4 (2 by 2 squares), and the\n+ * assumption is that height_ and width_ are even numbers.\n+ */\n+void FormatConverter::convertRAW_CSI2P(const unsigned char *src,\n+\t\t\t\t unsigned char *dst)\n+{\n+\tunsigned int r_pos, b_pos, g1_pos, g2_pos;\n+\tunsigned char r, g1, g2, b;\n+\tunsigned int s_linelen = width_ * bpp_denom_ / bpp_numer_;\n+\tunsigned int d_linelen = width_ * 4;\n+\n+\t/*\n+\t * Calculate the offsets of the color values in the src buffer.\n+\t * g1 is green value from the even (upper) line, g2 is the green\n+\t * value from the odd (lower) line.\n+\t */\n+\tif ( r_pos_ > 1) {\n+\t\tr_pos = r_pos_ - 2 + s_linelen;\n+\t\tb_pos = 3 - r_pos_;\n+\t} else {\n+\t\tr_pos = r_pos_;\n+\t\tb_pos = 1 - r_pos_ + s_linelen;\n+\t}\n+\tg1_pos = (r_pos == 0 || b_pos == 0) ? 1 : 0;\n+\tg2_pos = 1 - g1_pos + s_linelen;\n+\n+\tfor (unsigned int y = 0; y < height_; y += 2) {\n+\t\tfor (unsigned x = 0; x < width_; x += bpp_numer_) {\n+\t\t\tfor (unsigned int i = 0; i < bpp_numer_ ; i += 2) {\n+\t\t\t\t/* read the colors for the current 2x2 group: */\n+\t\t\t\tr = src[r_pos];\n+\t\t\t\tg1 = src[g1_pos];\n+\t\t\t\tg2 = src[g2_pos];\n+\t\t\t\tb = src[b_pos];\n+\t\t\t\tsrc += 2;\n+\t\t\t\t/* two left pixels of the four: */\n+\t\t\t\tdst[0] = dst[0 + d_linelen] = b;\n+\t\t\t\tdst[1] = g1;\n+\t\t\t\tdst[1 + d_linelen] = g2;\n+\t\t\t\tdst[2] = dst[2 + d_linelen] = r;\n+\t\t\t\tdst[3] = dst[3 + d_linelen] = 0xff;\n+\t\t\t\tdst += 4;\n+\t\t\t\t/* two right pixels of the four: */\n+\t\t\t\tdst[0] = dst[0 + d_linelen] = b;\n+\t\t\t\tdst[1] = g1;\n+\t\t\t\tdst[1 + d_linelen] = g2;\n+\t\t\t\tdst[2] = dst[2 + d_linelen] = r;\n+\t\t\t\tdst[3] = dst[3 + d_linelen] = 0xff;\n+\t\t\t\tdst += 4;\n+\t\t\t}\n+\t\t\tsrc += bpp_denom_ - bpp_numer_;\n+\t\t}\n+\t\t/* move to the next even line: */\n+\t\tsrc += s_linelen;\n+\t\tdst += d_linelen;\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 e389b24..5d4f31f 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 convertRAW_CSI2P(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@@ -45,6 +47,18 @@ private:\n \tunsigned int vertSubSample_;\n \tbool nvSwap_;\n \n+\t/* RAW Bayer CSI2P parameters */\n+\t/*\n+\t * Bytes per pixel is a fractional number, and is represented by\n+\t * integer numerator and denominator.\n+\t */\n+\tunsigned int bpp_numer_;\n+\tunsigned int bpp_denom_;\n+\t/*\n+\t * Unsigned int r_pos_ from RGB parameters is reused; blue\n+\t * and green positions are deduced from the red one.\n+\t */\n+\n \t/* RGB parameters */\n \tunsigned int bpp_;\n \tunsigned int r_pos_;\n", "prefixes": [ "libcamera-devel", "RFC" ] }