[{"id":11186,"web_url":"https://patchwork.libcamera.org/comment/11186/","msgid":"<ad1b7e18-53f8-f8bb-66d6-5cf3e76b835b@uajain.com>","date":"2020-07-05T07:31:05","subject":"Re: [libcamera-devel] [PATCH] libcamera: Use Size::isNull()","submitter":{"id":1,"url":"https://patchwork.libcamera.org/api/people/1/","name":"Umang Jain","email":"email@uajain.com"},"content":"Hi Laurent,\n\nThanks for the patch.\n\nOn 7/3/20 9:17 PM, Laurent Pinchart wrote:\n> Use the new Size::isNull() function through the code base to replace\n> manual checks. While the new code isn't equivalent, as isNull() checks\n> that both width and height are zero, it catches the same conditions in\n> practice.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Umang Jain <email@uajain.com>\n\n> ---\n>   src/libcamera/pipeline/ipu3/ipu3.cpp     | 2 +-\n>   src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 ++--\n>   test/v4l2_subdevice/test_formats.cpp     | 2 +-\n>   3 files changed, 4 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 00559ce318e1..af51fb2d1718 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -185,7 +185,7 @@ void IPU3CameraConfiguration::adjustStream(StreamConfiguration &cfg, bool scale)\n>   \t\t * Provide a suitable default that matches the sensor aspect\n>   \t\t * ratio.\n>   \t\t */\n> -\t\tif (!cfg.size.width || !cfg.size.height) {\n> +\t\tif (cfg.size.isNull()) {\n>   \t\t\tcfg.size.width = 1280;\n>   \t\t\tcfg.size.height = 1280 * cio2Configuration_.size.height\n>   \t\t\t\t\t/ cio2Configuration_.size.width;\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 3c3f3f3a8049..051d77a68b55 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -506,7 +506,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n>   \t\t\t\t\t    MEDIA_BUS_FMT_SGRBG8_1X8,\n>   \t\t\t\t\t    MEDIA_BUS_FMT_SRGGB8_1X8 },\n>   \t\t\t\t\t  cfg.size);\n> -\tif (!sensorFormat_.size.width || !sensorFormat_.size.height)\n> +\tif (sensorFormat_.size.isNull())\n>   \t\tsensorFormat_.size = sensor->resolution();\n>   \n>   \t/*\n> @@ -517,7 +517,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n>   \t */\n>   \tconst Size size = cfg.size;\n>   \n> -\tif (!cfg.size.width || !cfg.size.height) {\n> +\tif (cfg.size.isNull()) {\n>   \t\tcfg.size.width = 1280;\n>   \t\tcfg.size.height = 1280 * sensorFormat_.size.height\n>   \t\t\t\t/ sensorFormat_.size.width;\n> diff --git a/test/v4l2_subdevice/test_formats.cpp b/test/v4l2_subdevice/test_formats.cpp\n> index 9635c9948946..679f50b62c4d 100644\n> --- a/test/v4l2_subdevice/test_formats.cpp\n> +++ b/test/v4l2_subdevice/test_formats.cpp\n> @@ -67,7 +67,7 @@ int FormatHandlingTest::run()\n>   \t\treturn TestFail;\n>   \t}\n>   \n> -\tif (format.size.width == 0 || format.size.height == 0) {\n> +\tif (format.size.isNull()) {\n>   \t\tcerr << \"Failed to update image format\" << endl;\n>   \t\treturn TestFail;\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 0118DBD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  5 Jul 2020 07:31:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 797F960E0D;\n\tSun,  5 Jul 2020 09:31:09 +0200 (CEST)","from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 46546603AB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  5 Jul 2020 09:31:06 +0200 (CEST)","by filterdrecv-p3iad2-5b55dcd864-m99xc with SMTP id\n\tfilterdrecv-p3iad2-5b55dcd864-m99xc-18-5F0181B9-14\n\t2020-07-05 07:31:05.516353104 +0000 UTC m=+742900.121301315","from mail.uajain.com (unknown)\n\tby ismtpd0001p1maa1.sendgrid.net (SG) with ESMTP\n\tid PmxrAoFwQXCK1P8mmv562g Sun, 05 Jul 2020 07:31:04.789 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"SMBgJpi9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com;\n\th=subject:references:from:mime-version:in-reply-to:to:content-type:\n\tcontent-transfer-encoding;\n\ts=s1; bh=98kHPxULrGnsFNHaT1x9frKedqLJYlG7Vzlj8txtSMY=;\n\tb=SMBgJpi9ee/sW9L+fl2RBSTlnRpIBtfIY5hSEzki9K6F4JcJ77b/Qd5DCF8rGLxKfPV0\n\tWgXQA6vqr3Y12R3b4zTRaoiD35ReYRPEQ+Xf+vfqgdw3JU3hggsTtYx1EAonwWTdKjq0N/\n\titMm1qw6GoU1GwJUjuZzjs1LdYIYBi09I=","References":"<20200703154730.3908-1-laurent.pinchart@ideasonboard.com>","From":"Umang Jain <email@uajain.com>","Message-ID":"<ad1b7e18-53f8-f8bb-66d6-5cf3e76b835b@uajain.com>","Date":"Sun, 05 Jul 2020 07:31:05 +0000 (UTC)","Mime-Version":"1.0","In-Reply-To":"<20200703154730.3908-1-laurent.pinchart@ideasonboard.com>","X-SG-EID":"1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcYDswUgqLHty1lirORaEntVRi6plnwy5vVfP/ZGxabGTCG3hErHJXJ/FJjI6U3DwwpN0fNbYj56KoOJoF5g7svvd3NrYhFsDvdBM5R70yG5wod+LkiVYZy/eeSVqCeW1oaMzf9zOs9PeXmxIz0PtEqw5w/6GjvIEWDwgGNz4yVPMD0rNBNjm5x1nsZrp/Fs6Ck5xBV3ttxfMavpC6IOT7bw==","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH] libcamera: Use Size::isNull()","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>","Content-Transfer-Encoding":"7bit","Content-Type":"text/plain; charset=\"us-ascii\"; Format=\"flowed\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11235,"web_url":"https://patchwork.libcamera.org/comment/11235/","msgid":"<20200707183552.GB3875643@oden.dyn.berto.se>","date":"2020-07-07T18:35:52","subject":"Re: [libcamera-devel] [PATCH] libcamera: Use Size::isNull()","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-07-03 18:47:30 +0300, Laurent Pinchart wrote:\n> Use the new Size::isNull() function through the code base to replace\n> manual checks. While the new code isn't equivalent, as isNull() checks\n> that both width and height are zero, it catches the same conditions in\n> practice.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp     | 2 +-\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 ++--\n>  test/v4l2_subdevice/test_formats.cpp     | 2 +-\n>  3 files changed, 4 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 00559ce318e1..af51fb2d1718 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -185,7 +185,7 @@ void IPU3CameraConfiguration::adjustStream(StreamConfiguration &cfg, bool scale)\n>  \t\t * Provide a suitable default that matches the sensor aspect\n>  \t\t * ratio.\n>  \t\t */\n> -\t\tif (!cfg.size.width || !cfg.size.height) {\n> +\t\tif (cfg.size.isNull()) {\n>  \t\t\tcfg.size.width = 1280;\n>  \t\t\tcfg.size.height = 1280 * cio2Configuration_.size.height\n>  \t\t\t\t\t/ cio2Configuration_.size.width;\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 3c3f3f3a8049..051d77a68b55 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -506,7 +506,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n>  \t\t\t\t\t    MEDIA_BUS_FMT_SGRBG8_1X8,\n>  \t\t\t\t\t    MEDIA_BUS_FMT_SRGGB8_1X8 },\n>  \t\t\t\t\t  cfg.size);\n> -\tif (!sensorFormat_.size.width || !sensorFormat_.size.height)\n> +\tif (sensorFormat_.size.isNull())\n>  \t\tsensorFormat_.size = sensor->resolution();\n>  \n>  \t/*\n> @@ -517,7 +517,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n>  \t */\n>  \tconst Size size = cfg.size;\n>  \n> -\tif (!cfg.size.width || !cfg.size.height) {\n> +\tif (cfg.size.isNull()) {\n>  \t\tcfg.size.width = 1280;\n>  \t\tcfg.size.height = 1280 * sensorFormat_.size.height\n>  \t\t\t\t/ sensorFormat_.size.width;\n> diff --git a/test/v4l2_subdevice/test_formats.cpp b/test/v4l2_subdevice/test_formats.cpp\n> index 9635c9948946..679f50b62c4d 100644\n> --- a/test/v4l2_subdevice/test_formats.cpp\n> +++ b/test/v4l2_subdevice/test_formats.cpp\n> @@ -67,7 +67,7 @@ int FormatHandlingTest::run()\n>  \t\treturn TestFail;\n>  \t}\n>  \n> -\tif (format.size.width == 0 || format.size.height == 0) {\n> +\tif (format.size.isNull()) {\n>  \t\tcerr << \"Failed to update image format\" << endl;\n>  \t\treturn TestFail;\n>  \t}\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 7BA4DBD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Jul 2020 18:35:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BABD661030;\n\tTue,  7 Jul 2020 20:35:56 +0200 (CEST)","from mail-lj1-x242.google.com (mail-lj1-x242.google.com\n\t[IPv6:2a00:1450:4864:20::242])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E0F2E60DFA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Jul 2020 20:35:54 +0200 (CEST)","by mail-lj1-x242.google.com with SMTP id q7so37888470ljm.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 07 Jul 2020 11:35:54 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tz23sm329853ljz.3.2020.07.07.11.35.52\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 07 Jul 2020 11:35:53 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"OM4Ih5NK\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=WJcKE0/GW82ZoAlmk7dC8wHDGXzfDO/KbjJFOXWDev4=;\n\tb=OM4Ih5NKnPwOTmQpUsDYq1GtjxHnTK0Xd+sJQNZQ/B4uFT8KMXYNt+T6Y+8uMoNKwC\n\tThqfae+RM+Lhp8fW0N7ow5a6rvRJ1ONFmIW5hG63s4W8tQk1X8MHQUWcU+wSKYbsj+W/\n\t4COWzGpQPExRTcWz4ltdjvnpuQI0HaZU2hhajfhzR+fBOkOLEcJCabrQzXF1yQsIV5ga\n\twgf9GgvLKyhLq8N8Y3uw/sBrzSYIjnKeloxogFdn08gnt9YVq4EgMTfOmHTZy4Dsg86K\n\t3IN/rR/PCduxrY9aPjzuc5wx01SBIx/n8X4cnJncwpo9aHgKGg54Sl/beKEWqGR4RWqW\n\txU9A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=WJcKE0/GW82ZoAlmk7dC8wHDGXzfDO/KbjJFOXWDev4=;\n\tb=jcvJZ4Hc/KChxbbzdpbNRR5hvXyoaAs4H3WiAt4cx/ZP0hT9hVqbhwSXg7u08uWYdw\n\tKI21qhOD/i7YZvFvpYAMtrHmoBUVzoR2+yTF3/zxJBhBlgybe2M6ssVG5RGRQMswNfL3\n\thbE6fBGTx1OS25rjdL2JRpfR+U+9W0R+Uvnlw4DYtGLmzSQNiJ0kNuqfV5UtFQifFvZC\n\tUdwJ+rgXYh9/OJGKFFKIezxHf+2xWc2BkHA6dNEH4gbGhlNp3BWqy5xxP/EBcnKKfYlt\n\tLM7Ue9vIabYoqixafP8+uHp+DEoYLhzET/jDb22luieFh7yQdkaBV41D+RLkM96P1NKs\n\tFH8w==","X-Gm-Message-State":"AOAM530xzdihDRA1p8BFczUB9L0RDGsOqI4WunuA/9CdJOBzU/25j1fk\n\t9esd9IcsCSjLHffZEZEiSFKsOg==","X-Google-Smtp-Source":"ABdhPJxMqpi2+6KyzOPbPNGVhmZBjkyAdZFJ5zQfQD5lN5lUbZX04qVJfIbPo78Fuin9Mi6Pv0EnyQ==","X-Received":"by 2002:a2e:4812:: with SMTP id\n\tv18mr32173491lja.353.1594146953903; \n\tTue, 07 Jul 2020 11:35:53 -0700 (PDT)","Date":"Tue, 7 Jul 2020 20:35:52 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200707183552.GB3875643@oden.dyn.berto.se>","References":"<20200703154730.3908-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200703154730.3908-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: Use Size::isNull()","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]