[{"id":31683,"web_url":"https://patchwork.libcamera.org/comment/31683/","msgid":"<172851583152.532453.2859616700164132587@ping.linuxembedded.co.uk>","date":"2024-10-09T23:17:11","subject":"Re: [PATCH 1/2] libcamera: v4l2: Implement the equality and\n\tinequality operators for V4L2DeviceFormat","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Harvey,\n\nQuoting Harvey Yang (2024-10-09 20:58:50)\n> From: Yunke Cao <yunkec@chromium.org>\n> \n> The comparators allow us to compare format directly instead of\n> comparing each field.\n> \n\nI haven't seen how this will get used yet, but it seems reasonable on\nit's own.\n\nPerhaps add some unit tests to test/v4l2_videodevice/formats.cpp ?\n\n> Signed-off-by: Yunke Cao <yunkec@chromium.org>\n> Co-developed-by: Han-Lin Chen <hanlinchen@chromium.org>\n> Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>\n> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n> ---\n>  include/libcamera/internal/v4l2_videodevice.h |  6 +++++\n>  src/libcamera/v4l2_videodevice.cpp            | 27 +++++++++++++++++++\n>  2 files changed, 33 insertions(+)\n> \n> diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> index f021c2a01..9f53e37cd 100644\n> --- a/include/libcamera/internal/v4l2_videodevice.h\n> +++ b/include/libcamera/internal/v4l2_videodevice.h\n> @@ -182,6 +182,12 @@ public:\n>         const std::string toString() const;\n>  };\n>  \n> +bool operator==(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs);\n> +static inline bool operator!=(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs)\n> +{\n> +       return !(lhs == rhs);\n> +}\n> +\n>  std::ostream &operator<<(std::ostream &out, const V4L2DeviceFormat &f);\n>  \n>  class V4L2VideoDevice : public V4L2Device\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 14eba0561..1110fb535 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -437,6 +437,33 @@ const std::string V4L2DeviceFormat::toString() const\n>         return ss.str();\n>  }\n>  \n> +/**\n> + * \\brief Compare V4L2DeviceFormat for equality\n> + * \\return True if the two formats are identical, false otherwise\n> + */\n> +bool operator==(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs)\n> +{\n> +       if (!(lhs.fourcc == rhs.fourcc &&\n> +             lhs.size == rhs.size &&\n> +             lhs.colorSpace == rhs.colorSpace &&\n> +             lhs.planesCount == rhs.planesCount))\n> +               return false;\n> +\n> +       for (unsigned int i = 0; i < lhs.planesCount; ++i) {\n> +               if (lhs.planes[i].size != rhs.planes[i].size ||\n> +                   lhs.planes[i].bpl != rhs.planes[i].bpl)\n> +                       return false;\n> +       }\n> +\n> +       return true;\n> +}\n> +\n> +/**\n> + * \\fn bool operator!=(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs)\n> + * \\brief Comparetwo formats for inequality\n\ns/Comparetwo/Compare two/\n\n> + * \\return True if the two formats are not identical, false otherwise\n> + */\n> +\n>  /**\n>   * \\brief Insert a text representation of a V4L2DeviceFormat into an output\n>   * stream\n> -- \n> 2.47.0.rc0.187.ge670bccf7e-goog\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 EE3F8C32DE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Oct 2024 23:17:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 157DA6536C;\n\tThu, 10 Oct 2024 01:17:16 +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 7E277618C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Oct 2024 01:17:14 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BB027226;\n\tThu, 10 Oct 2024 01:15:36 +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=\"bssaod2C\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1728515736;\n\tbh=R/U0H7SH56429OSWnNxgzJ/JdUaSpW8CPSfQQYlTaA8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=bssaod2C/hAjtZbyrE/FgGUeYzGB+TnXcMlllHNanwxqNWytxEYKEfiGeiDxRbD17\n\tmTVru/B1ZmSWBPCrtd19y7av6QyhevolAJ+S1i2+lyePtzqgiv12ENPuJyOAwaE1C/\n\tY7+ANyBYOEf4xQSygfUQI5kDeT7zEze/8uaSNeQg=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241009200142.3213065-2-chenghaoyang@chromium.org>","References":"<20241009200142.3213065-1-chenghaoyang@chromium.org>\n\t<20241009200142.3213065-2-chenghaoyang@chromium.org>","Subject":"Re: [PATCH 1/2] libcamera: v4l2: Implement the equality and\n\tinequality operators for V4L2DeviceFormat","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Yunke Cao <yunkec@chromium.org>, Han-Lin Chen <hanlinchen@chromium.org>, \n\tHarvey Yang <chenghaoyang@chromium.org>","To":"Harvey Yang <chenghaoyang@chromium.org>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 10 Oct 2024 00:17:11 +0100","Message-ID":"<172851583152.532453.2859616700164132587@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":31718,"web_url":"https://patchwork.libcamera.org/comment/31718/","msgid":"<CAEB1ahs=GCqxvT_Fwnri=tkLWby5ioqGAuEnp80cW3XqUar2fA@mail.gmail.com>","date":"2024-10-11T16:37:50","subject":"Re: [PATCH 1/2] libcamera: v4l2: Implement the equality and\n\tinequality operators for V4L2DeviceFormat","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/people/117/","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"content":"Hi Kieran,\n\nOn Thu, Oct 10, 2024 at 7:17 AM Kieran Bingham\n<kieran.bingham@ideasonboard.com> wrote:\n>\n> Hi Harvey,\n>\n> Quoting Harvey Yang (2024-10-09 20:58:50)\n> > From: Yunke Cao <yunkec@chromium.org>\n> >\n> > The comparators allow us to compare format directly instead of\n> > comparing each field.\n> >\n>\n> I haven't seen how this will get used yet, but it seems reasonable on\n> it's own.\n\nIt'll be used here:\nhttps://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/third_party/libcamera/mtkisp7/src/libcamera/pipeline/mtkisp7/imgsys/imgsys.cpp;l=202\n\n>\n> Perhaps add some unit tests to test/v4l2_videodevice/formats.cpp ?\n\nAdded in the next version, while I think I did that pretty ugly... Please\nhelp instruct me how to do that properly :)))\n\nTo prevent the spam, let me provide the version on gitlab for now:\nhttps://gitlab.freedesktop.org/chenghaoyang/libcamera/-/commit/465ce9ce1e14526144a13ef57530310fa9764609\n\n>\n> > Signed-off-by: Yunke Cao <yunkec@chromium.org>\n> > Co-developed-by: Han-Lin Chen <hanlinchen@chromium.org>\n> > Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n> > Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>\n> > Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n> > ---\n> >  include/libcamera/internal/v4l2_videodevice.h |  6 +++++\n> >  src/libcamera/v4l2_videodevice.cpp            | 27 +++++++++++++++++++\n> >  2 files changed, 33 insertions(+)\n> >\n> > diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> > index f021c2a01..9f53e37cd 100644\n> > --- a/include/libcamera/internal/v4l2_videodevice.h\n> > +++ b/include/libcamera/internal/v4l2_videodevice.h\n> > @@ -182,6 +182,12 @@ public:\n> >         const std::string toString() const;\n> >  };\n> >\n> > +bool operator==(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs);\n> > +static inline bool operator!=(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs)\n> > +{\n> > +       return !(lhs == rhs);\n> > +}\n> > +\n> >  std::ostream &operator<<(std::ostream &out, const V4L2DeviceFormat &f);\n> >\n> >  class V4L2VideoDevice : public V4L2Device\n> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > index 14eba0561..1110fb535 100644\n> > --- a/src/libcamera/v4l2_videodevice.cpp\n> > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > @@ -437,6 +437,33 @@ const std::string V4L2DeviceFormat::toString() const\n> >         return ss.str();\n> >  }\n> >\n> > +/**\n> > + * \\brief Compare V4L2DeviceFormat for equality\n> > + * \\return True if the two formats are identical, false otherwise\n> > + */\n> > +bool operator==(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs)\n> > +{\n> > +       if (!(lhs.fourcc == rhs.fourcc &&\n> > +             lhs.size == rhs.size &&\n> > +             lhs.colorSpace == rhs.colorSpace &&\n> > +             lhs.planesCount == rhs.planesCount))\n> > +               return false;\n> > +\n> > +       for (unsigned int i = 0; i < lhs.planesCount; ++i) {\n> > +               if (lhs.planes[i].size != rhs.planes[i].size ||\n> > +                   lhs.planes[i].bpl != rhs.planes[i].bpl)\n> > +                       return false;\n> > +       }\n> > +\n> > +       return true;\n> > +}\n> > +\n> > +/**\n> > + * \\fn bool operator!=(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs)\n> > + * \\brief Comparetwo formats for inequality\n>\n> s/Comparetwo/Compare two/\n\nDone\n\nBR,\nHarvey\n\n\n>\n> > + * \\return True if the two formats are not identical, false otherwise\n> > + */\n> > +\n> >  /**\n> >   * \\brief Insert a text representation of a V4L2DeviceFormat into an output\n> >   * stream\n> > --\n> > 2.47.0.rc0.187.ge670bccf7e-goog\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 47079C326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 11 Oct 2024 16:38:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DBA6C6537A;\n\tFri, 11 Oct 2024 18:38:03 +0200 (CEST)","from mail-lj1-x230.google.com (mail-lj1-x230.google.com\n\t[IPv6:2a00:1450:4864:20::230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3256A6353B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Oct 2024 18:38:02 +0200 (CEST)","by mail-lj1-x230.google.com with SMTP id\n\t38308e7fff4ca-2fac275471dso21381561fa.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Oct 2024 09:38:02 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"TO7rIv9K\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1728664681; x=1729269481;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=uteV0JKVQXJscYFlgjhREr1T73XByZTRz8l1AaWAvTQ=;\n\tb=TO7rIv9KWJ4aUZw5pDmyxJsUCYC2lqXq3k/HmcU4vtHL4xzBp+anyqncIaMUfCgEb4\n\tep9YLRv27BIF53FrjgS5mODcDLrWUrMKsfgZB7px2IyNLkNNhCJbGUFaricRPr36kjxr\n\tvmQP1tFR1csf2gv+8tw16ipz5TGRkmchvS19g=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1728664681; x=1729269481;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=uteV0JKVQXJscYFlgjhREr1T73XByZTRz8l1AaWAvTQ=;\n\tb=YMSj0y+kUdJRX//OiWKTtmnfu+1Mv4T+6dJb/gCAmVbBNC0W6vOrxn38K9Gc6HVgJs\n\twgcGs9shJqEKpE/r4kWrDqiiC3ltE6dMkzixg/ZiPx+sxAldb2bw24xaqPE8E2U1hiQT\n\tUUdegxlVYaIPwfye8mTJrvbmhWLdGnpfw8rIjE29xgKOivLPgOjrJbn8nMR68oKwt0Kv\n\tvEsoIN5pC82UIcEl1O2Q+O2z+Vw222eNtqCpIH9fBC0c2nUe4Shzaa/Os2++fEV5BAyQ\n\tRGhIRz8vSiSuagpmcvOApcrzCPxBQRdzZW975NyqyFIin6bmXpy3jecF9jMvEdOg0vo6\n\tCDzQ==","X-Gm-Message-State":"AOJu0YyONHWy4zQc5PzBiu77MrYimUcsFL0aaU/i9XXEAt08603nQaq6\n\t5P8wrRSv2i0fN6aye+Y1eDqEPgCXBGcf/HHEoFtXOyWoemm6n+VrfqSXilrVrdWuufOHrNsq0zg\n\tLrKv6+mYO08KJLIR/2FrzTyeOjHzy7RcNuxcD","X-Google-Smtp-Source":"AGHT+IGCmFtKF0m36Rmlu/tj36W+oVrzvwWeWHbOUQ+EQh1hYzfmDRE8HySYMiSyMbdZyLKUaTYtFt8nb+Y4koFSo5o=","X-Received":"by 2002:a2e:a581:0:b0:2fa:cfa9:c785 with SMTP id\n\t38308e7fff4ca-2fb30d9f8e0mr12288571fa.5.1728664681359;\n\tFri, 11 Oct 2024 09:38:01 -0700 (PDT)","MIME-Version":"1.0","References":"<20241009200142.3213065-1-chenghaoyang@chromium.org>\n\t<20241009200142.3213065-2-chenghaoyang@chromium.org>\n\t<172851583152.532453.2859616700164132587@ping.linuxembedded.co.uk>","In-Reply-To":"<172851583152.532453.2859616700164132587@ping.linuxembedded.co.uk>","From":"Cheng-Hao Yang <chenghaoyang@chromium.org>","Date":"Sat, 12 Oct 2024 00:37:50 +0800","Message-ID":"<CAEB1ahs=GCqxvT_Fwnri=tkLWby5ioqGAuEnp80cW3XqUar2fA@mail.gmail.com>","Subject":"Re: [PATCH 1/2] libcamera: v4l2: Implement the equality and\n\tinequality operators for V4L2DeviceFormat","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Yunke Cao <yunkec@chromium.org>, \n\tHan-Lin Chen <hanlinchen@chromium.org>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","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>"}}]