[{"id":35766,"web_url":"https://patchwork.libcamera.org/comment/35766/","msgid":"<7dde50e4-4d6b-433a-ad4d-7f14cdc201db@ideasonboard.com>","date":"2025-09-10T14:07:09","subject":"Re: [PATCH 1/2] libcamera: control_serializer: Deserialize array\n\tControlInfos","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 09. 10. 11:35 keltezéssel, Paul Elder írta:\n> Array controls (eg. ColourCorrectionMatrix, FrameDurationLimits,\n> ColourGains) are serialized properly by the ControlSerializer, but are\n> not deserialized properly. This is because their arrayness and size are\n> not considered during deserialization.\n> \n> Fix this by checking arrayness and size of the ControlInfo's default\n> value during deserialization of ControlInfoMap. Only the default value\n> needs to be checked as that is the only part of the ControlInfo that\n> will be non-scalar; min/max are defined to be scalar values.\n\nI wonder if maybe extending `ControlSerializer::store()` to store \"isArray\" and\n\"numElements\" wouldn't provide a more generic and more robust solution?\n\n\nRegards,\nBarnabás Pőcze\n\n> \n> This was not noticed before as the default value of the ControlInfo of\n> other array controls had been set to scalar values similar to min/max,\n> and ColourCorrectionMatrix was the first control to properly define a\n> non-scalar default value.\n> \n> Other array controls that define a scalar default value need to be\n> fixed to define a properly sized default ControlInfo value.\n> \n> Bug: https://bugs.libcamera.org/show_bug.cgi?id=285\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>   include/libcamera/internal/control_serializer.h | 3 ++-\n>   src/libcamera/control_serializer.cpp            | 9 ++++++---\n>   2 files changed, 8 insertions(+), 4 deletions(-)\n> \n> diff --git a/include/libcamera/internal/control_serializer.h b/include/libcamera/internal/control_serializer.h\n> index 8a63ae44a13e..79d6eff2a940 100644\n> --- a/include/libcamera/internal/control_serializer.h\n> +++ b/include/libcamera/internal/control_serializer.h\n> @@ -49,7 +49,8 @@ private:\n>   \n>   \tControlValue loadControlValue(ByteStreamBuffer &buffer,\n>   \t\t\t\t      bool isArray = false, unsigned int count = 1);\n> -\tControlInfo loadControlInfo(ByteStreamBuffer &buffer);\n> +\tControlInfo loadControlInfo(ByteStreamBuffer &buffer,\n> +\t\t\t\t    bool isArray, unsigned int count);\n>   \n>   \tunsigned int serial_;\n>   \tunsigned int serialSeed_;\n> diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp\n> index 050f8512bd52..db3ddaaa2e78 100644\n> --- a/src/libcamera/control_serializer.cpp\n> +++ b/src/libcamera/control_serializer.cpp\n> @@ -397,11 +397,14 @@ ControlValue ControlSerializer::loadControlValue(ByteStreamBuffer &buffer,\n>   \treturn value;\n>   }\n>   \n> -ControlInfo ControlSerializer::loadControlInfo(ByteStreamBuffer &b)\n> +ControlInfo ControlSerializer::loadControlInfo(ByteStreamBuffer &b,\n> +\t\t\t\t\t       bool isArray,\n> +\t\t\t\t\t       unsigned int count)\n>   {\n> +\t/* min and max are scalars */\n>   \tControlValue min = loadControlValue(b);\n>   \tControlValue max = loadControlValue(b);\n> -\tControlValue def = loadControlValue(b);\n> +\tControlValue def = loadControlValue(b, isArray, count);\n>   \n>   \treturn ControlInfo(min, max, def);\n>   }\n> @@ -519,7 +522,7 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &\n>   \t\t}\n>   \n>   \t\t/* Create and store the ControlInfo. */\n> -\t\tctrls.emplace(controlId, loadControlInfo(values));\n> +\t\tctrls.emplace(controlId, loadControlInfo(values, controlId->isArray(), controlId->size()));\n>   \t}\n>   \n>   \t/*","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 14184BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Sep 2025 14:07:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2032969367;\n\tWed, 10 Sep 2025 16:07:18 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B12069357\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Sep 2025 16:07:14 +0200 (CEST)","from [192.168.33.8] (185.221.142.115.nat.pool.zt.hu\n\t[185.221.142.115])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E2069C6F;\n\tWed, 10 Sep 2025 16:05:59 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"gV/OmJ21\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1757513160;\n\tbh=6rBwp+peLAxX6paHH6iOHyOSG0BSV9hU8sY6Vm0iCn0=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=gV/OmJ21MHq70lysF3gfF/WzuweZEMeDdOOJfYjzTimOcmtzk1pgaLzAOuuNHJyVd\n\tg8Y++jwDj9Z5yFGnJ8q5gw6vO1Gj2H9nYgcpJEk5nuTRgHBgfq9+qLicgftxbchce6\n\tCvd6uwvyeC39oGhpaiKAhmHMFr2SjM0PxZtHxI5k=","Message-ID":"<7dde50e4-4d6b-433a-ad4d-7f14cdc201db@ideasonboard.com>","Date":"Wed, 10 Sep 2025 16:07:09 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 1/2] libcamera: control_serializer: Deserialize array\n\tControlInfos","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20250910093539.3216782-1-paul.elder@ideasonboard.com>\n\t<20250910093539.3216782-2-paul.elder@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250910093539.3216782-2-paul.elder@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]