Show a patch.

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

{
    "id": 3809,
    "url": "https://patchwork.libcamera.org/api/patches/3809/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3809/",
    "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": "<20200519030624.15985-1-laurent.pinchart@ideasonboard.com>",
    "date": "2020-05-19T03:06:23",
    "name": "[libcamera-devel,1/2] libcamera: pipeline: simple: converter: Add scaling support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "51ad71b94a0ff7bbab0533532c43bfef750df656",
    "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/3809/mbox/",
    "series": [
        {
            "id": 911,
            "url": "https://patchwork.libcamera.org/api/series/911/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=911",
            "date": "2020-05-19T03:06:23",
            "name": "[libcamera-devel,1/2] libcamera: pipeline: simple: converter: Add scaling support",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/911/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3809/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3809/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 4587A60E1A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 05:06:37 +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 E24DA30C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 05:06:36 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ECgg/xvK\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1589857597;\n\tbh=XJwg99kDEgqx3wsun9ibHGE4xDctkxQKWGgTgX6WvzY=;\n\th=From:To:Subject:Date:From;\n\tb=ECgg/xvKprFhM3XrKS6Q5r6gUZp1/tKfI34+4ElR1fk856lb7h7Uqs4VO7cAYPP75\n\tKPrAc12Q5JKkN/wQMvxdkvKjyC0tC6u5bd7mfQbaUq+DsGg8mZkaXPAAfmZboRhbIT\n\tTIRAUmlzHNCKi0GjuXvkzxlzHQOVGz4fp93q3SDA=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 19 May 2020 06:06:23 +0300",
        "Message-Id": "<20200519030624.15985-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.26.2",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: pipeline: simple:\n\tconverter: Add scaling support",
        "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>",
        "X-List-Received-Date": "Tue, 19 May 2020 03:06:37 -0000"
    },
    "content": "Extend the SimpleConverter to support scaling, with reporting of the\nminimum and maximum output sizes supported for a given input size.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/simple/converter.cpp | 67 ++++++++++++++++++---\n src/libcamera/pipeline/simple/converter.h   |  7 ++-\n src/libcamera/pipeline/simple/simple.cpp    |  2 +-\n 3 files changed, 63 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\nindex 02443e7f78ed..e5e2f0fddb62 100644\n--- a/src/libcamera/pipeline/simple/converter.cpp\n+++ b/src/libcamera/pipeline/simple/converter.cpp\n@@ -8,10 +8,12 @@\n #include \"converter.h\"\n \n #include <algorithm>\n+#include <limits.h>\n \n #include <libcamera/buffer.h>\n #include <libcamera/geometry.h>\n #include <libcamera/signal.h>\n+#include <libcamera/stream.h>\n \n #include \"libcamera/internal/log.h\"\n #include \"libcamera/internal/media_device.h\"\n@@ -92,15 +94,60 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n \treturn pixelFormats;\n }\n \n-int SimpleConverter::configure(PixelFormat inputFormat,\n-\t\t\t       PixelFormat outputFormat, const Size &size)\n+SizeRange SimpleConverter::sizes(const Size &input)\n+{\n+\tif (!m2m_)\n+\t\treturn {};\n+\n+\t/*\n+\t * Set the size on the input side (V4L2 output) of the converter to\n+\t * enumerate the scaling capabilities on its output (V4L2 capture).\n+\t */\n+\tV4L2DeviceFormat format;\n+\tformat.fourcc = V4L2PixelFormat();\n+\tformat.size = input;\n+\n+\tint ret = m2m_->output()->setFormat(&format);\n+\tif (ret < 0) {\n+\t\tLOG(SimplePipeline, Error)\n+\t\t\t<< \"Failed to set format: \" << strerror(-ret);\n+\t\treturn {};\n+\t}\n+\n+\tSizeRange sizes;\n+\n+\tformat.size = { 1, 1 };\n+\tret = m2m_->capture()->setFormat(&format);\n+\tif (ret < 0) {\n+\t\tLOG(SimplePipeline, Error)\n+\t\t\t<< \"Failed to set format: \" << strerror(-ret);\n+\t\treturn {};\n+\t}\n+\n+\tsizes.min = format.size;\n+\n+\tformat.size = { UINT_MAX, UINT_MAX };\n+\tret = m2m_->capture()->setFormat(&format);\n+\tif (ret < 0) {\n+\t\tLOG(SimplePipeline, Error)\n+\t\t\t<< \"Failed to set format: \" << strerror(-ret);\n+\t\treturn {};\n+\t}\n+\n+\tsizes.max = format.size;\n+\n+\treturn sizes;\n+}\n+\n+int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,\n+\t\t\t       StreamConfiguration *cfg)\n {\n \tV4L2DeviceFormat format;\n \tint ret;\n \n \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);\n \tformat.fourcc = videoFormat;\n-\tformat.size = size;\n+\tformat.size = inputSize;\n \n \tret = m2m_->output()->setFormat(&format);\n \tif (ret < 0) {\n@@ -109,18 +156,16 @@ int SimpleConverter::configure(PixelFormat inputFormat,\n \t\treturn ret;\n \t}\n \n-\tif (format.fourcc != videoFormat || format.size != size) {\n+\tif (format.fourcc != videoFormat || format.size != inputSize) {\n \t\tLOG(SimplePipeline, Error)\n \t\t\t<< \"Input format not supported\";\n \t\treturn -EINVAL;\n \t}\n \n-\t/*\n-\t * Set the pixel format on the output, the size is identical to the\n-\t * input as we don't support scaling.\n-\t */\n-\tvideoFormat = m2m_->capture()->toV4L2PixelFormat(outputFormat);\n+\t/* Set the pixel format and size on the output. */\n+\tvideoFormat = m2m_->capture()->toV4L2PixelFormat(cfg->pixelFormat);\n \tformat.fourcc = videoFormat;\n+\tformat.size = cfg->size;\n \n \tret = m2m_->capture()->setFormat(&format);\n \tif (ret < 0) {\n@@ -129,12 +174,14 @@ int SimpleConverter::configure(PixelFormat inputFormat,\n \t\treturn ret;\n \t}\n \n-\tif (format.fourcc != videoFormat || format.size != size) {\n+\tif (format.fourcc != videoFormat || format.size != cfg->size) {\n \t\tLOG(SimplePipeline, Error)\n \t\t\t<< \"Output format not supported\";\n \t\treturn -EINVAL;\n \t}\n \n+\tcfg->stride = format.planes[0].bpl;\n+\n \treturn 0;\n }\n \ndiff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h\nindex a33071fa8578..1f770eb844b5 100644\n--- a/src/libcamera/pipeline/simple/converter.h\n+++ b/src/libcamera/pipeline/simple/converter.h\n@@ -20,6 +20,8 @@ namespace libcamera {\n class FrameBuffer;\n class MediaDevice;\n struct Size;\n+class SizeRange;\n+struct StreamConfiguration;\n class V4L2M2MDevice;\n \n class SimpleConverter\n@@ -32,9 +34,10 @@ public:\n \tvoid close();\n \n \tstd::vector<PixelFormat> formats(PixelFormat input);\n+\tSizeRange sizes(const Size &input);\n \n-\tint configure(PixelFormat inputFormat, PixelFormat outputFormat,\n-\t\t      const Size &size);\n+\tint configure(PixelFormat inputFormat, const Size &inputSize,\n+\t\t      StreamConfiguration *cfg);\n \tint exportBuffers(unsigned int count,\n \t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n \ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 2565190082c8..b21ad82e1a05 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -554,7 +554,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \n \tif (useConverter_) {\n \t\tint ret = converter_->configure(pipeConfig.pixelFormat,\n-\t\t\t\t\t\tcfg.pixelFormat, cfg.size);\n+\t\t\t\t\t\tcfg.size, &cfg);\n \t\tif (ret < 0) {\n \t\t\tLOG(SimplePipeline, Error)\n \t\t\t\t<< \"Unable to configure converter\";\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}