[{"id":24233,"web_url":"https://patchwork.libcamera.org/comment/24233/","msgid":"<YuL38KMgIK6DxYFw@pendragon.ideasonboard.com>","date":"2022-07-28T20:56:16","subject":"Re: [libcamera-devel] [PATCH v2] cam: capture_script: Add support\n\tfor Rectangle and Size controls","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Thu, Jul 28, 2022 at 04:23:11PM +0900, Paul Elder via libcamera-devel wrote:\n> Add support for Rectangle and Size control values in the capture script\n> parser.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\nHave you seen\nhttps://lists.libcamera.org/pipermail/libcamera-devel/2022-June/031627.html\n?\n\n> ---\n> Changes 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(-)\n> \n> diff --git a/src/cam/capture_script.cpp b/src/cam/capture_script.cpp\n> index 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>  }\n> diff --git a/src/cam/capture_script.h b/src/cam/capture_script.h\n> index 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,","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 CE7E7C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Jul 2022 20:56:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 538B463312;\n\tThu, 28 Jul 2022 22:56:20 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A6AA6330D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Jul 2022 22:56:19 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DD0FE56D;\n\tThu, 28 Jul 2022 22:56:18 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659041780;\n\tbh=W031fE8TOc5XhxOpD64cIK0Ik1rJ8gEcCiDCkL+zPP8=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=xiKtRl1Nn1IUpfqqTA/m54vLDaTqTvryAlxdNX9B8C+bRNIm8AK/Fa5iLQu2Ltohp\n\tEeBVB+65vQjyu7wjL1bh/SEChQvfyDwW0iekqJZ/ThnwjTDmM7ThvgRc7Q6MEHNk0U\n\tAk9IjOwhCXR+ygPDesoj5z2fgAtJ+P9AL9MBiu+SC7Vrsqh8wQykjUvRN8GUAUlJV7\n\tjr9CBLuFGzlBz1M998ml2FosDJpWZJA8axLNlWfUq7fz82hz+vLXRRJ8EpOAvexua3\n\tRnhF4wv2kVNYdy/2Q5FabhSP1dbgOFxO9qJrvwBZAdAdE8aTkUQ4Lw4nmtq8SPkCne\n\tQDkwiyxgPACXg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659041779;\n\tbh=W031fE8TOc5XhxOpD64cIK0Ik1rJ8gEcCiDCkL+zPP8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LGR23VD2TFs3ZyE0fXsZAWiMJAczaVCH6LxGy0eCZEcbAfccHThzbCUcCpKyPbW3R\n\t1XqPGO5jEtNvH4ZQnpb0QEFjIuJuOyOBOiaaMsRLKlfkGfsVVyaNiMLrcCgUdztqrb\n\t8mRE/wsgzQNy5ADL2tl4WLtUTbXZimp+Z6etTPzY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"LGR23VD2\"; dkim-atps=neutral","Date":"Thu, 28 Jul 2022 23:56:16 +0300","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<YuL38KMgIK6DxYFw@pendragon.ideasonboard.com>","References":"<20220728072311.808238-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220728072311.808238-1-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2] cam: capture_script: Add support\n\tfor Rectangle 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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24234,"web_url":"https://patchwork.libcamera.org/comment/24234/","msgid":"<20220729033428.GM3984498@pyrite.rasen.tech>","date":"2022-07-29T03:34:28","subject":"Re: [libcamera-devel] [PATCH v2] cam: capture_script: Add support\n\tfor Rectangle and Size controls","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Laurent,\n\nOn Thu, Jul 28, 2022 at 11:56:16PM +0300, Laurent Pinchart wrote:\n> Hi Paul,\n> \n> Thank you for the patch.\n> \n> On Thu, Jul 28, 2022 at 04:23:11PM +0900, Paul Elder via libcamera-devel wrote:\n> > Add support for Rectangle and Size control values in the capture script\n> > parser.\n> > \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> Have you seen\n> https://lists.libcamera.org/pipermail/libcamera-devel/2022-June/031627.html\n> ?\n\nOh oops, I had not seen that.\n\nThat looks more featureful.\n\n\nPaul\n\n> \n> > ---\n> > Changes 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(-)\n> > \n> > diff --git a/src/cam/capture_script.cpp b/src/cam/capture_script.cpp\n> > index 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> >  }\n> > diff --git a/src/cam/capture_script.h b/src/cam/capture_script.h\n> > index 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,","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 123ACBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 29 Jul 2022 03:34:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3512263312;\n\tFri, 29 Jul 2022 05:34:37 +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 77E8D603E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Jul 2022 05:34:35 +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 0FF6852F;\n\tFri, 29 Jul 2022 05:34:33 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659065677;\n\tbh=dU7XH1UJi6LZbqh3mHT8fc0HpBC1pIJBU7ds2SbKG9k=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=OJi2YaMsdGm66gcVgXdgeUDU3fc4vcYAvUVQGjMAH0PlkCcKT7XiFHezADfAWBQpz\n\tPK2xpVTkhQP3gFzAkMsUvLY2ike1W0AtmO6cLfmu88eAXlyTzfOw3PmxMlHsCULUhC\n\tSGZF9k5/YaEbAPJPLM+c5wfU/MaOpy7Ay9cc9J2ZHtjjxl6ZBqSgUeGyTQwJWJhWt7\n\tH3XXNiGVTu7awwlKTh1eVjWtf9UPd6uU1MVKBP7y7EBmbvCEsMiycIJhLKFu6IC6dR\n\t7RK0VS8IYHnEHXKxq3/8MjRGuTo6tBnGq6MvEVNvG3QqCmlSLdKu+vfChsDBqaoM5x\n\tPfn9XL/qvSK+w==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659065675;\n\tbh=dU7XH1UJi6LZbqh3mHT8fc0HpBC1pIJBU7ds2SbKG9k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=P1sz79uEtX2wQEcN7hVLyLRXeRk8YKVuVDnoP+9Em5oWoJC19M3dkM1pTw+MnjbHO\n\teKArmS2aHfvkX/4tcgqLjT81WzkG23RiEqnanvUtiN+3zHYylo/R2TewWHgPfJMDIY\n\t1oeMBao11mkIrOjA72ebBaXuJyE/IriL6SyhlBWQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"P1sz79uE\"; dkim-atps=neutral","Date":"Fri, 29 Jul 2022 12:34:28 +0900","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220729033428.GM3984498@pyrite.rasen.tech>","References":"<20220728072311.808238-1-paul.elder@ideasonboard.com>\n\t<YuL38KMgIK6DxYFw@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<YuL38KMgIK6DxYFw@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2] cam: capture_script: Add support\n\tfor Rectangle 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@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24242,"web_url":"https://patchwork.libcamera.org/comment/24242/","msgid":"<YuPM096Gqg5hDoKz@pendragon.ideasonboard.com>","date":"2022-07-29T12:04:35","subject":"Re: [libcamera-devel] [PATCH v2] cam: capture_script: Add support\n\tfor Rectangle and Size controls","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nOn Fri, Jul 29, 2022 at 12:34:28PM +0900, paul.elder@ideasonboard.com wrote:\n> On Thu, Jul 28, 2022 at 11:56:16PM +0300, Laurent Pinchart wrote:\n> > On Thu, Jul 28, 2022 at 04:23:11PM +0900, Paul Elder via libcamera-devel wrote:\n> > > Add support for Rectangle and Size control values in the capture script\n> > > parser.\n> > > \n> > > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > \n> > Have you seen\n> > https://lists.libcamera.org/pipermail/libcamera-devel/2022-June/031627.html\n> > ?\n> \n> Oh oops, I had not seen that.\n> \n> That looks more featureful.\n\nCould you test and review it ? :-)\n\n> > > ---\n> > > Changes 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(-)\n> > > \n> > > diff --git a/src/cam/capture_script.cpp b/src/cam/capture_script.cpp\n> > > index 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> > >  }\n> > > diff --git a/src/cam/capture_script.h b/src/cam/capture_script.h\n> > > index 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,","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 2647ABE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 29 Jul 2022 12:04:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C4D8603EC;\n\tFri, 29 Jul 2022 14:04:41 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0BAB2603EC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Jul 2022 14:04:39 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7404B52F;\n\tFri, 29 Jul 2022 14:04:38 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659096281;\n\tbh=uiPTRxj5nLboBpsUhqTSfTFdEl5jY78Ya9P5QjPBl4w=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=VODt/2YsJahiOICox2AG/3X1i3uOYzzxloKnDqQVek/32S56HK2DsNpIOCT0FteRg\n\tBP7vPtrRC3SvWiaEM8T8UDFP1Ust1NpaSelgSdHlRdizPrrvQnKHO7DQZFA5Lk2xeN\n\t8iSLlsG/zN84rlAgLGNiZ1xl1nUPyBc6BOeDr3msAURNrFHgeqA+KHguRcm4JrbGJu\n\tBvaFOpXwngnZDr83v4pz/sxtG7o+04Qf4apzTRbYjoGO2N9wrel/GxkTt6/oieBEW4\n\t9UbOaDJVwMYFcO6XskTHvT8EYidthnnWQxZWpy4Nwph1Y/aNEfMmhQSZWKh8N5Pv//\n\tHq5oauoOJyIMA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659096278;\n\tbh=uiPTRxj5nLboBpsUhqTSfTFdEl5jY78Ya9P5QjPBl4w=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=NAZzm58ihEblGJprZiqidsDCOfpdwxfnJn05lH/QMEtm9Kn78uK+dcjVrR2/Tw3b0\n\tlWQQ5tcPYlU3s/HzApSRcQ2tdvbxfPc3qyhD15hhIkSVe2VS57Qo4IQyl9I4M88TyA\n\t6FjYBUIBtEqHKPRP8mvUnoFjLL99j/LaD5cpsoW8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"NAZzm58i\"; dkim-atps=neutral","Date":"Fri, 29 Jul 2022 15:04:35 +0300","To":"paul.elder@ideasonboard.com","Message-ID":"<YuPM096Gqg5hDoKz@pendragon.ideasonboard.com>","References":"<20220728072311.808238-1-paul.elder@ideasonboard.com>\n\t<YuL38KMgIK6DxYFw@pendragon.ideasonboard.com>\n\t<20220729033428.GM3984498@pyrite.rasen.tech>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220729033428.GM3984498@pyrite.rasen.tech>","Subject":"Re: [libcamera-devel] [PATCH v2] cam: capture_script: Add support\n\tfor Rectangle 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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]