[{"id":24187,"web_url":"https://patchwork.libcamera.org/comment/24187/","msgid":"<CAEmqJPoAEyop3=_a1=g8RRRrcao8WvnY-Swm-=Us45e_nFKRDQ@mail.gmail.com>","date":"2022-07-27T12:40:15","subject":"Re: [libcamera-devel] [PATCH v7 14/14] ipa: raspberrypi: agc: Use\n\tYamlObject::getList()","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\n\nOn Wed, 27 Jul 2022 at 03:38, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> Replace the manual implementation of the readList() functions with\n> YamlObject::getList().\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n\nThis is a nice improvement!\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\n> ---\n>  src/ipa/raspberrypi/controller/rpi/agc.cpp | 43 +++++++---------------\n>  1 file changed, 13 insertions(+), 30 deletions(-)\n>\n> diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n> b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n> index 9fd339c6904e..b8eb5bc605a1 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n> @@ -5,6 +5,7 @@\n>   * agc.cpp - AGC/AEC control algorithm\n>   */\n>\n> +#include <algorithm>\n>  #include <map>\n>  #include <tuple>\n>\n> @@ -71,44 +72,26 @@ readMeteringModes(std::map<std::string,\n> AgcMeteringMode> &metering_modes,\n>         return { 0, first };\n>  }\n>\n> -static int readList(std::vector<double> &list,\n> -                   const libcamera::YamlObject &params)\n> -{\n> -       for (const auto &p : params.asList()) {\n> -               auto value = p.get<double>();\n> -               if (!value)\n> -                       return -EINVAL;\n> -               list.push_back(*value);\n> -       }\n> -\n> -       return list.size();\n> -}\n> -\n> -static int readList(std::vector<Duration> &list,\n> -                   const libcamera::YamlObject &params)\n> -{\n> -       for (const auto &p : params.asList()) {\n> -               auto value = p.get<double>();\n> -               if (!value)\n> -                       return -EINVAL;\n> -               list.push_back(*value * 1us);\n> -       }\n> -\n> -       return list.size();\n> -}\n> -\n>  int AgcExposureMode::read(const libcamera::YamlObject &params)\n>  {\n> -       int numShutters = readList(shutter, params[\"shutter\"]);\n> -       int numAgs = readList(gain, params[\"gain\"]);\n> +       auto value = params[\"shutter\"].getList<double>();\n> +       if (!value)\n> +               return -EINVAL;\n> +       std::transform(value->begin(), value->end(),\n> std::back_inserter(shutter),\n> +                      [](double v) { return v * 1us; });\n>\n> -       if (numShutters < 2 || numAgs < 2) {\n> +       value = params[\"gain\"].getList<double>();\n> +       if (!value)\n> +               return -EINVAL;\n> +       gain = std::move(*value);\n> +\n> +       if (shutter.size() < 2 || gain.size() < 2) {\n>                 LOG(RPiAgc, Error)\n>                         << \"AgcExposureMode: must have at least two\n> entries in exposure profile\";\n>                 return -EINVAL;\n>         }\n>\n> -       if (numShutters != numAgs) {\n> +       if (shutter.size() != gain.size()) {\n>                 LOG(RPiAgc, Error)\n>                         << \"AgcExposureMode: expect same number of\n> exposure and gain entries in exposure profile\";\n>                 return -EINVAL;\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n>","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 895A5C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Jul 2022 12:40:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DC21763311;\n\tWed, 27 Jul 2022 14:40:32 +0200 (CEST)","from mail-lj1-x231.google.com (mail-lj1-x231.google.com\n\t[IPv6:2a00:1450:4864:20::231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7AADD63309\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 14:40:31 +0200 (CEST)","by mail-lj1-x231.google.com with SMTP id e11so19688202ljl.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 05:40:31 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658925632;\n\tbh=0Qp19XwWscvUaO27jPTwnriiijV7wxaT2trcG2U30Wk=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=jS2ZRadLkrRPfdbWYx2LKE1EW8uPdEDsWwJKil6BOiJUWLYiHhowZhgeK45trKxl5\n\tDC9YIgGoQ5xBqdRknWHllbQsMNwVvscHOPo4aTsgi1eOlJt6xFtJbfwQjkP6O2Y9gK\n\tMz8FEFyqindX8MhgzzD7PDykZYsCiQYxZhs9VJXBJ27FCM06amFxubp5fzpz62uCLG\n\tYNwHqy6f92kmRT2J+WM4Lr2civM4BRgxJhSiACKauAdUJkx3vZpndW9gShmsFA3lVd\n\t8DUrksIY44e3AuI0ezqwkyoXcnTOJQ4BHdIqVUAO85UoUqBDj95phcgSZoq9h1FVpx\n\tN37CqNcOksDRw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=sLn/HJ+A4BDvmBVl5/u7p1N9KTtmTO2JpSAfRN8Ke5I=;\n\tb=fkyEGRkmBue0KyCe4ro3G4Fb8rK/AInNlOVoxBQ5mZocWZT2wRKutIX2PG/j5F9vEr\n\tNOAorn1m7OWYH7FRojz/y26wzHSFCwFR4pnJUEyN0+RT6N+my/AWbDMNZNyLWQ4VtC1K\n\tPHXcJJie/h18rUDoSYUnLlFgera8cE+q9fsGIsbfDqoMOdH4Sso3bbBbC9pZzT1wiWan\n\tzhLGdy6cKhXN585DOk3VsZ1m62YlNZ+345haFW6aMHy/fNh/8ZyjQkHCGBtXyDiNjkP2\n\t7BET5iu1UdGnxrV2887snpgINk+lk2UOdRJlnrv4FeorPU9dvg1gOT01/O53ywYEU75r\n\t70YA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"fkyEGRkm\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=sLn/HJ+A4BDvmBVl5/u7p1N9KTtmTO2JpSAfRN8Ke5I=;\n\tb=2wAPspqbjo+ouEmyH7TKwcS3M3/7UxhZayTCvZSv1vJDJPvU62VGrnUn8lKg4R02lz\n\tWpOo3Uo8aXpCa4FnuyutaByb+ha5bTZww4fultHYvhAO7V1hVw+FENXIgBBpGrkAE5LY\n\tPuULi+P1Nty94s22w531WMAIicqVUncZXy9Ko4hfHbkszC58ZFepWRJ0UCQn7Y6lm/TX\n\tI5XberoGWZ3Qy7U/6GPKaofTEvjFzgb3yC8/52UfENcpS8XNkA+d+uAPd+BaRmjU2FDV\n\tmGpAH64d33uE/j5P/uMf5QvoMS7fBoTRzHxeNY8WmSMgFV5nfkNmnS+9YWf3Nq6pCiO8\n\tlnVQ==","X-Gm-Message-State":"AJIora8zX+LCoaWmRunDnLIZJ2h1Ih/EyLjfwSHIdSb7LyjjkP2XrUX6\n\tUbx02TbEzLYjPuHjPq2J027hm8Go9qvlOaq0WAJTPw==","X-Google-Smtp-Source":"AGRyM1unh2LGpmvgPnu7bvvwHoEBVYIp2rDwfO3d2RWq8Pol8qWg/zleOHWUwBMbZ0YCauew8l5o8+m9+87dvLT4Ec0=","X-Received":"by 2002:a2e:6101:0:b0:25d:eb9d:4c79 with SMTP id\n\tv1-20020a2e6101000000b0025deb9d4c79mr7623981ljb.354.1658925630735;\n\tWed, 27 Jul 2022 05:40:30 -0700 (PDT)","MIME-Version":"1.0","References":"<20220727023816.30008-1-laurent.pinchart@ideasonboard.com>\n\t<20220727023816.30008-15-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20220727023816.30008-15-laurent.pinchart@ideasonboard.com>","Date":"Wed, 27 Jul 2022 13:40:15 +0100","Message-ID":"<CAEmqJPoAEyop3=_a1=g8RRRrcao8WvnY-Swm-=Us45e_nFKRDQ@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"000000000000edda8705e4c8b851\"","Subject":"Re: [libcamera-devel] [PATCH v7 14/14] ipa: raspberrypi: agc: Use\n\tYamlObject::getList()","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]