Show a patch.

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

{
    "id": 8627,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/8627/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/8627/",
    "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": "<20200704133140.1738660-7-paul.elder@ideasonboard.com>",
    "date": "2020-07-04T13:31:24",
    "name": "[libcamera-devel,v3,06/22] libcamera: PixelFormatInfo: Add functions stride and frameSize",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "38fa86126a9a8fcbadf538df8637ef804964d1a7",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/8627/mbox/",
    "series": [
        {
            "id": 1083,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1083/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1083",
            "date": "2020-07-04T13:31:18",
            "name": "Clean up formats in v4l2-compat and pipeline handlers",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1083/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/8627/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/8627/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 5E992BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  4 Jul 2020 13:32:08 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2803860E45;\n\tSat,  4 Jul 2020 15:32:08 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 35AB9609C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Jul 2020 15:32:07 +0200 (CEST)",
            "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B9D2D296;\n\tSat,  4 Jul 2020 15:32:05 +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=\"uDiydM4u\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593869526;\n\tbh=D+f6lceFHOA535RfPSvxnxGwzZdlZQCwTfdtlgJkm+E=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=uDiydM4uo7/uQWdE4mcztGS4E4MFV61UknnfYge8oCCooymTWnuF/2BhtsWR20+xg\n\tq9ZgwSHHg/KfVwK9ZzS+gRTbWPsktTnwxGV2skL4EBugCO9cMOR7/GHXFVmVLH7MW7\n\tRFkzl6SnPVLYZP1amUKjsQ5W5jK+c8sGSVMwqrHc=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat,  4 Jul 2020 22:31:24 +0900",
        "Message-Id": "<20200704133140.1738660-7-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20200704133140.1738660-1-paul.elder@ideasonboard.com>",
        "References": "<20200704133140.1738660-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3 06/22] libcamera: PixelFormatInfo: Add\n\tfunctions stride and frameSize",
        "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>",
        "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": "Add member functions to PixelFormatInfo for calculating stride and frame\nsize. This will simplify existing code that calculates these things.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v3:\n- rename functions to stride and frameSize, from bytesPerLine and\n  imageSize, respectively\n\nChanges in v2:\n- make these functions const\n- add documentation\n- inline DIV_ROUND_UP\n---\n include/libcamera/internal/formats.h |  3 +++\n src/libcamera/formats.cpp            | 40 ++++++++++++++++++++++++++++\n 2 files changed, 43 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h\nindex cf00814..8957059 100644\n--- a/include/libcamera/internal/formats.h\n+++ b/include/libcamera/internal/formats.h\n@@ -52,6 +52,9 @@ public:\n \tstatic const PixelFormatInfo &info(const PixelFormat &format);\n \tstatic const PixelFormatInfo &info(const V4L2PixelFormat &format);\n \n+\tunsigned int stride(unsigned int width, unsigned int plane) const;\n+\tunsigned int frameSize(const Size &size) const;\n+\n \tconst char *name;\n \tPixelFormat format;\n \tV4L2PixelFormat v4l2Format;\ndiff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nindex f96bf1f..6d558f2 100644\n--- a/src/libcamera/formats.cpp\n+++ b/src/libcamera/formats.cpp\n@@ -710,4 +710,44 @@ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format)\n \treturn info->second;\n }\n \n+/**\n+ * \\brief Compute the stride\n+ * \\param[in] width The width of the line, in pixels\n+ * \\param[in] plane The index of the plane whose stride is to be computed\n+ * \\return The number of bytes necessary to store a line, or 0 if the\n+ * PixelFormatInfo instance not valid\n+ */\n+unsigned int PixelFormatInfo::stride(unsigned int width, unsigned int plane) const\n+{\n+\tif (!isValid())\n+\t\treturn 0;\n+\n+\tif (plane > planes.size() || !planes[plane].bytesPerGroup)\n+\t\treturn 0;\n+\n+\t/* ceil(width / pixelsPerGroup) * bytesPerGroup */\n+\treturn ((width + pixelsPerGroup - 1) / pixelsPerGroup) * planes[plane].bytesPerGroup;\n+}\n+\n+/**\n+ * \\brief Compute the bytes necessary to store the frame\n+ * \\param[in] size The size of the frame, in pixels\n+ * \\return The number of bytes necessary to store the frame, or 0 if the\n+ * PixelFormatInfo instance is not valid\n+ */\n+unsigned int PixelFormatInfo::frameSize(const Size &size) const\n+{\n+\t/* stride * ceil(height / verticalSubSampling) */\n+\tunsigned int sum = 0;\n+\tfor (int i = 0; i < 3; i++) {\n+\t\tunsigned int vertSubSample = planes[i].verticalSubSampling;\n+\t\tif (!vertSubSample)\n+\t\t\tcontinue;\n+\t\tsum += stride(size.width, i)\n+\t\t     * ((size.height + vertSubSample - 1) / vertSubSample);\n+\t}\n+\n+\treturn sum;\n+}\n+\n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "06/22"
    ]
}