Patch Detail
Show a patch.
GET /api/1.1/patches/3823/?format=api
{ "id": 3823, "url": "https://patchwork.libcamera.org/api/1.1/patches/3823/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3823/", "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": "<20200519165543.30465-2-laurent.pinchart@ideasonboard.com>", "date": "2020-05-19T16:55:42", "name": "[libcamera-devel,v2,2/3] libcamera: pipeline: simple: converter: Add scaling support", "commit_ref": "fd76304e005903d6fe7ad28fa537f356b1048454", "pull_url": null, "state": "accepted", "archived": false, "hash": "646f4db2d9bcd1639f45b6ff1fbd74ad1216fcdc", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3823/mbox/", "series": [ { "id": 915, "url": "https://patchwork.libcamera.org/api/1.1/series/915/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=915", "date": "2020-05-19T16:55:41", "name": "[libcamera-devel,v2,1/3] libcamera: pipeline: simple: Add stride support", "version": 2, "mbox": "https://patchwork.libcamera.org/series/915/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3823/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3823/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 1E0116041F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 18:55:58 +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 AA3169CD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 18:55:57 +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=\"AGDR3UBs\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1589907357;\n\tbh=3G3Zug1duQL5eIFrXq9GAoEZXAUxMluKzehA9fmN8/E=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=AGDR3UBsBgKijUU/ygshEv5G7uztKvGEAEmI/Ld5OEbMLA4gw5ioveJg3kCGljWEs\n\t56pojQ799MdUp8RONLGsvfFWAj0J9qtFteT1vHJW+T7xL1YDI68EMhWBZDtIsm+QtM\n\tPYRB01vz+spXQt34jKxIm1nb1db4wcyEuajrYsZE=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 19 May 2020 19:55:42 +0300", "Message-Id": "<20200519165543.30465-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.26.2", "In-Reply-To": "<20200519165543.30465-1-laurent.pinchart@ideasonboard.com>", "References": "<20200519165543.30465-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 2/3] 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 16:55:58 -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>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/pipeline/simple/converter.cpp | 58 ++++++++++++++++++---\n src/libcamera/pipeline/simple/converter.h | 5 +-\n src/libcamera/pipeline/simple/simple.cpp | 3 +-\n 3 files changed, 57 insertions(+), 9 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\nindex 7a9d67b37624..e5e2f0fddb62 100644\n--- a/src/libcamera/pipeline/simple/converter.cpp\n+++ b/src/libcamera/pipeline/simple/converter.cpp\n@@ -8,6 +8,7 @@\n #include \"converter.h\"\n \n #include <algorithm>\n+#include <limits.h>\n \n #include <libcamera/buffer.h>\n #include <libcamera/geometry.h>\n@@ -93,7 +94,52 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n \treturn pixelFormats;\n }\n \n-int SimpleConverter::configure(PixelFormat inputFormat,\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@@ -101,7 +147,7 @@ int SimpleConverter::configure(PixelFormat inputFormat,\n \n \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);\n \tformat.fourcc = videoFormat;\n-\tformat.size = cfg->size;\n+\tformat.size = inputSize;\n \n \tret = m2m_->output()->setFormat(&format);\n \tif (ret < 0) {\n@@ -110,18 +156,16 @@ int SimpleConverter::configure(PixelFormat inputFormat,\n \t\treturn ret;\n \t}\n \n-\tif (format.fourcc != videoFormat || format.size != cfg->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+\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) {\ndiff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h\nindex 0beb96a55d5b..1f770eb844b5 100644\n--- a/src/libcamera/pipeline/simple/converter.h\n+++ b/src/libcamera/pipeline/simple/converter.h\n@@ -20,6 +20,7 @@ namespace libcamera {\n class FrameBuffer;\n class MediaDevice;\n struct Size;\n+class SizeRange;\n struct StreamConfiguration;\n class V4L2M2MDevice;\n \n@@ -33,8 +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, StreamConfiguration *cfg);\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 68595bc29726..686639c3b0c9 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -555,7 +555,8 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \tuseConverter_ = config->needConversion();\n \n \tif (useConverter_) {\n-\t\tint ret = converter_->configure(pipeConfig.pixelFormat, &cfg);\n+\t\tint ret = converter_->configure(pipeConfig.pixelFormat,\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", "v2", "2/3" ] }