Patch Detail
Show a patch.
GET /api/patches/16858/?format=api
{ "id": 16858, "url": "https://patchwork.libcamera.org/api/patches/16858/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16858/", "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": "<20220728072311.808238-1-paul.elder@ideasonboard.com>", "date": "2022-07-28T07:23:11", "name": "[libcamera-devel,v2] cam: capture_script: Add support for Rectangle and Size controls", "commit_ref": null, "pull_url": null, "state": "rejected", "archived": false, "hash": "2a9845ce65370656a5440dea677347ed1f9e5e0a", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16858/mbox/", "series": [ { "id": 3339, "url": "https://patchwork.libcamera.org/api/series/3339/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3339", "date": "2022-07-28T07:23:11", "name": "[libcamera-devel,v2] cam: capture_script: Add support for Rectangle and Size controls", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3339/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16858/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16858/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 E0140BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Jul 2022 07:23:24 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4E5F963311;\n\tThu, 28 Jul 2022 09:23:24 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 612E3603EB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Jul 2022 09:23:23 +0200 (CEST)", "from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 068F06D4;\n\tThu, 28 Jul 2022 09:23:21 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658993004;\n\tbh=hZmuHNvutpvWrqKpXGrOkUdnB2GNsWaPrsjvOURRfwo=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=HnQTmFmZdC3gSiwDK+nbglPGSQOh3tNTJ0v5pLAN/esl9BxR9PrKhs1hHZ02EWLwd\n\txauo98GYdivHId35gf1F7eBrthGV6Idwd/DVvtXfoc/1Ti3AJsLsFIwhXAomecHlB0\n\t5ldxxjNexu/1+ngydIYwTZB6yxzsl5Bl2Xk+MeJoyFebrjbZXU8LnOPHbV00yWqQVE\n\tOT4KsFTGfR7ErkCXv1qUKJiV+qnn7PGoq5cowTogK5aT3FoBiSflS4vcPshbY5qhKa\n\tGPeIDqGX0FbX9SEx61u7CZUQF3UYZ+CLsSeBXqlo9pri2u+5FWG84xftlCP5THtDPT\n\tn6+x01JNlVB1Q==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658993003;\n\tbh=hZmuHNvutpvWrqKpXGrOkUdnB2GNsWaPrsjvOURRfwo=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=j2pX2EuTGLo8UHpFohu9rbudnKnrLpDTgfSMRMrl4nimWKwCQJAai15v3T1ORUfiW\n\tNjQDvzZhu1JuP/RCei9xujoee+7bqdGidRruPYrlLHIJIXNbL+77XbjogkxcK8T/vQ\n\ta72gVzF+Y4lUSyldiDVJD+3NVYn35vwi1A/fQztY=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"j2pX2EuT\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 28 Jul 2022 16:23:11 +0900", "Message-Id": "<20220728072311.808238-1-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.30.2", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2] cam: capture_script: Add support for\n\tRectangle and Size controls", "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>", "From": "Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Paul Elder <paul.elder@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add support for Rectangle and Size control values in the capture script\nparser.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v2:\n- fix compilation error for the Size parser\n---\n src/cam/capture_script.cpp | 61 +++++++++++++++++++++++++++++++++++---\n src/cam/capture_script.h | 4 +++\n 2 files changed, 61 insertions(+), 4 deletions(-)", "diff": "diff --git a/src/cam/capture_script.cpp b/src/cam/capture_script.cpp\nindex 9f22d5f7..07b14613 100644\n--- a/src/cam/capture_script.cpp\n+++ b/src/cam/capture_script.cpp\n@@ -252,6 +252,53 @@ std::string CaptureScript::parseScalar()\n \treturn eventScalarValue(event);\n }\n \n+Rectangle CaptureScript::unpackRectangle(const ControlId *id,\n+\t\t\t\t\t const std::string &repr)\n+{\n+\t/* Format: (<left>,<top>)/<width>x<height> */\n+\n+\tstd::map<char, int> delims = { { '(', -1 },\n+\t\t\t\t { ')', -1 },\n+\t\t\t\t { ',', -1 },\n+\t\t\t\t { '/', -1 },\n+\t\t\t\t { 'x', -1 } };\n+\n+\tfor (unsigned int i = 0; i < repr.size(); i++)\n+\t\tif (delims.count(repr[i]))\n+\t\t\tdelims[repr[i]] = i;\n+\n+\tfor (auto &pair : delims) {\n+\t\tif (pair.second == -1) {\n+\t\t\tunpackFailure(id, repr);\n+\t\t\treturn Rectangle{};\n+\t\t}\n+\t}\n+\n+\tint32_t left = strtol(repr.substr(delims['('] + 1, delims[',']).c_str(), NULL, 10);\n+\tint32_t top = strtol(repr.substr(delims[','] + 1, delims[')']).c_str(), NULL, 10);\n+\tint32_t width = strtol(repr.substr(delims['/'] + 1, delims['x']).c_str(), NULL, 10);\n+\tint32_t height = strtol(repr.substr(delims['x'] + 1).c_str(), NULL, 10);\n+\n+\treturn Rectangle(left, top, width, height);\n+}\n+\n+Size CaptureScript::unpackSize(const ControlId *id,\n+\t\t\t const std::string &repr)\n+{\n+\t/* Format: <width>x<height> */\n+\n+\tunsigned int pos = repr.find(\"x\");\n+\tif (pos == std::string::npos) {\n+\t\tunpackFailure(id, repr);\n+\t\treturn Size{};\n+\t}\n+\n+\tint32_t width = strtol(repr.substr(0, pos).c_str(), NULL, 10);\n+\tint32_t height = strtol(repr.substr(pos).c_str(), NULL, 10);\n+\n+\treturn Size(width, height);\n+}\n+\n void CaptureScript::unpackFailure(const ControlId *id, const std::string &repr)\n {\n \tstatic const std::map<unsigned int, const char *> typeNames = {\n@@ -281,6 +328,8 @@ ControlValue CaptureScript::unpackControl(const ControlId *id,\n \t\t\t\t\t const std::string &repr)\n {\n \tControlValue value{};\n+\tRectangle rect;\n+\tSize size;\n \n \tswitch (id->type()) {\n \tcase ControlTypeNone:\n@@ -324,13 +373,17 @@ ControlValue CaptureScript::unpackControl(const ControlId *id,\n \t\tvalue.set<std::string>(repr);\n \t\tbreak;\n \t}\n-\tcase ControlTypeRectangle:\n-\t\t/* \\todo Parse rectangles. */\n+\tcase ControlTypeRectangle: {\n+\t\trect = unpackRectangle(id, repr);\n+\t\tvalue.set<Rectangle>(rect);\n \t\tbreak;\n-\tcase ControlTypeSize:\n-\t\t/* \\todo Parse Sizes. */\n+\t}\n+\tcase ControlTypeSize: {\n+\t\tsize = unpackSize(id, repr);\n+\t\tvalue.set<Size>(size);\n \t\tbreak;\n \t}\n+\t}\n \n \treturn value;\n }\ndiff --git a/src/cam/capture_script.h b/src/cam/capture_script.h\nindex 8b4f8f62..f2dbfdf8 100644\n--- a/src/cam/capture_script.h\n+++ b/src/cam/capture_script.h\n@@ -55,6 +55,10 @@ private:\n \n \tstd::string parseScalar();\n \n+\tlibcamera::Rectangle unpackRectangle(const libcamera::ControlId *id,\n+\t\t\t\t\t const std::string &repr);\n+\tlibcamera::Size unpackSize(const libcamera::ControlId *id,\n+\t\t\t\t const std::string &repr);\n \tvoid unpackFailure(const libcamera::ControlId *id,\n \t\t\t const std::string &repr);\n \tlibcamera::ControlValue unpackControl(const libcamera::ControlId *id,\n", "prefixes": [ "libcamera-devel", "v2" ] }