[{"id":27845,"web_url":"https://patchwork.libcamera.org/comment/27845/","msgid":"<aqsp6ugn4d5vacqgnd4oi6zxcj5ayzsw6vh67bt7z55ab4ormb@wfgektf3izex>","date":"2023-09-22T10:56:16","subject":"Re: [libcamera-devel] [PATCH RFC 2/7] android: yuv: loop over each\n\tplane for size check","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Mattijs\n\nOn Fri, Sep 15, 2023 at 09:57:26AM +0200, Mattijs Korpershoek via libcamera-devel wrote:\n> PostProcessorYuv assumption is that only formats::NV12 is supported\n> for source and destination pixelFormat.\n>\n> Because of this, we don't loop on each plane when size checking, but we\n> always assume a 2 plane buffer.\n>\n> To prepare for adding more YUV formats such as YUYV, loop over the\n> planes instead of using an if.\n>\n> No functional change, besides the logs only printing the first faulty\n> plane length.\n>\n> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n> ---\n>  src/android/yuv/post_processor_yuv.cpp | 40 +++++++++++++++++-----------------\n>  1 file changed, 20 insertions(+), 20 deletions(-)\n>\n> diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp\n> index 9631c9617154..d58090db14ee 100644\n> --- a/src/android/yuv/post_processor_yuv.cpp\n> +++ b/src/android/yuv/post_processor_yuv.cpp\n> @@ -101,27 +101,27 @@ bool PostProcessorYuv::isValidBuffers(const FrameBuffer &source,\n>  \t\treturn false;\n>  \t}\n>\n> -\tif (source.planes()[0].length < sourceLength_[0] ||\n> -\t    source.planes()[1].length < sourceLength_[1]) {\n> -\t\tLOG(YUV, Error)\n> -\t\t\t<< \"The source planes lengths are too small, actual size: {\"\n> -\t\t\t<< source.planes()[0].length << \", \"\n> -\t\t\t<< source.planes()[1].length\n> -\t\t\t<< \"}, expected size: {\"\n> -\t\t\t<< sourceLength_[0] << \", \"\n> -\t\t\t<< sourceLength_[1] << \"}\";\n> -\t\treturn false;\n> +\tfor (unsigned int i = 0; i < 2; i++) {\n> +\t\tif (source.planes()[i].length < sourceLength_[i]) {\n> +\t\t\tLOG(YUV, Error)\n> +\t\t\t\t<< \"The source planes lengths are too small, \"\n> +\t\t\t\t<< \"actual size[\" << i << \"]=\"\n> +\t\t\t\t<< source.planes()[i].length\n> +\t\t\t\t<< \", expected size[\" << i << \"]=\"\n> +\t\t\t\t<< sourceLength_[i];\n> +\t\t\treturn false;\n> +\t\t}\n>  \t}\n> -\tif (destination.plane(0).size() < destinationLength_[0] ||\n> -\t    destination.plane(1).size() < destinationLength_[1]) {\n> -\t\tLOG(YUV, Error)\n> -\t\t\t<< \"The destination planes lengths are too small, actual size: {\"\n> -\t\t\t<< destination.plane(0).size() << \", \"\n> -\t\t\t<< destination.plane(1).size()\n> -\t\t\t<< \"}, expected size: {\"\n> -\t\t\t<< sourceLength_[0] << \", \"\n> -\t\t\t<< sourceLength_[1] << \"}\";\n> -\t\treturn false;\n> +\tfor (unsigned int i = 0; i < 2; i++) {\n> +\t\tif (destination.plane(i).size() < destinationLength_[i]) {\n> +\t\t\tLOG(YUV, Error)\n> +\t\t\t\t<< \"The destination planes lengths are too small, \"\n> +\t\t\t\t<< \"actual size[\" << i << \"]=\"\n> +\t\t\t\t<< destination.plane(i).size()\n> +\t\t\t\t<< \", expected size[\" << i << \"]=\"\n> +\t\t\t\t<< sourceLength_[i];\n\nThis should be destinationLength_[i]\n\nWith this fixed\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\n> +\t\t\treturn false;\n> +\t\t}\n>  \t}\n>\n>  \treturn true;\n>\n> --\n> 2.41.0\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 29F18C326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 22 Sep 2023 10:56:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8F6A862931;\n\tFri, 22 Sep 2023 12:56:21 +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 CC9136291F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Sep 2023 12:56:19 +0200 (CEST)","from ideasonboard.com (93-46-82-201.ip106.fastwebnet.it\n\t[93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AC2CC891;\n\tFri, 22 Sep 2023 12:54:41 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695380181;\n\tbh=YAkWddSWoso3E0s9D8GaPReYG4h8xKoNK7AZhhRI/4c=;\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=JctolsbVpiQhEACM3uPp1mj0j1zri2ZZBtmRNMOyYlgblpYwh7nkrG2nDrgHntBS9\n\tYlmr2+PsdP8euo2N21KGnteFHTKhvXO6ma1Zr2x9iorMc2tWwL78PxYt4OzIPIaYJx\n\tiiQ5VZv1p2No6ACdQJS4OzZvAkFySmrgzzuEU6+hH9/xBftD3gXYK1RScbhya5mr+W\n\tDYlEY9HJap0Fz0RS1qVW9WtT9fh3+nuY4+S24UHu5V6LTX/FEubBVNc3mB8yzx+Bj2\n\tAVIlgFrA5JVUEL0VnvKWp1aU5ol4jZ3Zo76sPFIBc+CAU9vVhiOPRpSjtRdZPxPrSu\n\t8hZ/PHQ1kJtnw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1695380081;\n\tbh=YAkWddSWoso3E0s9D8GaPReYG4h8xKoNK7AZhhRI/4c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=TPbvZphp1ep7UVHA82Rb8OHOwLHplnbN2ButOrVaahcYaBaMFo1ViV8lQXDtcMzrZ\n\tVWjlapwPKu29TJSV3zF3uWCQRpyVt3nJ19FAjVy0QZmPXfuycYw9VHwgADmicla2/m\n\ta2hbSfoHqc69u7deT5gjW1mqWCUL+VQ1jYWm+BTI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"TPbvZphp\"; dkim-atps=neutral","Date":"Fri, 22 Sep 2023 12:56:16 +0200","To":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","Message-ID":"<aqsp6ugn4d5vacqgnd4oi6zxcj5ayzsw6vh67bt7z55ab4ormb@wfgektf3izex>","References":"<20230915-libyuv-convert-v1-0-1e5bcf68adac@baylibre.com>\n\t<20230915-libyuv-convert-v1-2-1e5bcf68adac@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230915-libyuv-convert-v1-2-1e5bcf68adac@baylibre.com>","Subject":"Re: [libcamera-devel] [PATCH RFC 2/7] android: yuv: loop over each\n\tplane for size check","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tGuillaume La Roque <glaroque@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":27852,"web_url":"https://patchwork.libcamera.org/comment/27852/","msgid":"<87fs33ix4d.fsf@baylibre.com>","date":"2023-09-24T12:17:22","subject":"Re: [libcamera-devel] [PATCH RFC 2/7] android: yuv: loop over each\n\tplane for size check","submitter":{"id":153,"url":"https://patchwork.libcamera.org/api/people/153/","name":"Mattijs Korpershoek","email":"mkorpershoek@baylibre.com"},"content":"Hi Jacopo,\n\nThank you for your review.\n\nOn ven., sept. 22, 2023 at 12:56, Jacopo Mondi <jacopo.mondi@ideasonboard.com> wrote:\n\n> Hi Mattijs\n>\n> On Fri, Sep 15, 2023 at 09:57:26AM +0200, Mattijs Korpershoek via libcamera-devel wrote:\n>> PostProcessorYuv assumption is that only formats::NV12 is supported\n>> for source and destination pixelFormat.\n>>\n>> Because of this, we don't loop on each plane when size checking, but we\n>> always assume a 2 plane buffer.\n>>\n>> To prepare for adding more YUV formats such as YUYV, loop over the\n>> planes instead of using an if.\n>>\n>> No functional change, besides the logs only printing the first faulty\n>> plane length.\n>>\n>> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n>> ---\n>>  src/android/yuv/post_processor_yuv.cpp | 40 +++++++++++++++++-----------------\n>>  1 file changed, 20 insertions(+), 20 deletions(-)\n>>\n>> diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp\n>> index 9631c9617154..d58090db14ee 100644\n>> --- a/src/android/yuv/post_processor_yuv.cpp\n>> +++ b/src/android/yuv/post_processor_yuv.cpp\n>> @@ -101,27 +101,27 @@ bool PostProcessorYuv::isValidBuffers(const FrameBuffer &source,\n>>  \t\treturn false;\n>>  \t}\n>>\n>> -\tif (source.planes()[0].length < sourceLength_[0] ||\n>> -\t    source.planes()[1].length < sourceLength_[1]) {\n>> -\t\tLOG(YUV, Error)\n>> -\t\t\t<< \"The source planes lengths are too small, actual size: {\"\n>> -\t\t\t<< source.planes()[0].length << \", \"\n>> -\t\t\t<< source.planes()[1].length\n>> -\t\t\t<< \"}, expected size: {\"\n>> -\t\t\t<< sourceLength_[0] << \", \"\n>> -\t\t\t<< sourceLength_[1] << \"}\";\n>> -\t\treturn false;\n>> +\tfor (unsigned int i = 0; i < 2; i++) {\n>> +\t\tif (source.planes()[i].length < sourceLength_[i]) {\n>> +\t\t\tLOG(YUV, Error)\n>> +\t\t\t\t<< \"The source planes lengths are too small, \"\n>> +\t\t\t\t<< \"actual size[\" << i << \"]=\"\n>> +\t\t\t\t<< source.planes()[i].length\n>> +\t\t\t\t<< \", expected size[\" << i << \"]=\"\n>> +\t\t\t\t<< sourceLength_[i];\n>> +\t\t\treturn false;\n>> +\t\t}\n>>  \t}\n>> -\tif (destination.plane(0).size() < destinationLength_[0] ||\n>> -\t    destination.plane(1).size() < destinationLength_[1]) {\n>> -\t\tLOG(YUV, Error)\n>> -\t\t\t<< \"The destination planes lengths are too small, actual size: {\"\n>> -\t\t\t<< destination.plane(0).size() << \", \"\n>> -\t\t\t<< destination.plane(1).size()\n>> -\t\t\t<< \"}, expected size: {\"\n>> -\t\t\t<< sourceLength_[0] << \", \"\n>> -\t\t\t<< sourceLength_[1] << \"}\";\n>> -\t\treturn false;\n>> +\tfor (unsigned int i = 0; i < 2; i++) {\n>> +\t\tif (destination.plane(i).size() < destinationLength_[i]) {\n>> +\t\t\tLOG(YUV, Error)\n>> +\t\t\t\t<< \"The destination planes lengths are too small, \"\n>> +\t\t\t\t<< \"actual size[\" << i << \"]=\"\n>> +\t\t\t\t<< destination.plane(i).size()\n>> +\t\t\t\t<< \", expected size[\" << i << \"]=\"\n>> +\t\t\t\t<< sourceLength_[i];\n>\n> This should be destinationLength_[i]\n>\n> With this fixed\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nWill fix for v2 and apply your reviewed tag.\n\n>\n>> +\t\t\treturn false;\n>> +\t\t}\n>>  \t}\n>>\n>>  \treturn true;\n>>\n>> --\n>> 2.41.0\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 2D04CC326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 24 Sep 2023 12:17:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 72B9862944;\n\tSun, 24 Sep 2023 14:17:30 +0200 (CEST)","from mail-ed1-x529.google.com (mail-ed1-x529.google.com\n\t[IPv6:2a00:1450:4864:20::529])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D6DD262916\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 24 Sep 2023 14:17:28 +0200 (CEST)","by mail-ed1-x529.google.com with SMTP id\n\t4fb4d7f45d1cf-52fe27898e9so5502879a12.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 24 Sep 2023 05:17:28 -0700 (PDT)","from localhost ([89.207.171.157]) by smtp.gmail.com with ESMTPSA id\n\tn26-20020a056402061a00b005313c60165asm4355486edv.77.2023.09.24.05.17.27\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 24 Sep 2023 05:17:27 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695557850;\n\tbh=wYFhLaSHl0eAZAqd6sOibDlVIoa2aZey8Z6oMADHCYU=;\n\th=To:In-Reply-To:References:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=eDlGGLn1qocINOx4/akBxSkgfMARbezAurDjs6OHiiPoO5C0jTxkpWsB4rHCaWen1\n\tCLIfEXR+vwqEOAPtegDMNgfEJoiKHptEVqvyRwcwIbwtnmwrXkMyfEmXRo/ZyjPPFh\n\t7AaKOo56eOIbZPPxnuuwJWWyBs6niNB27RS+glkXY8U76A0LufieFxD+LstojDrZKc\n\t9i2gc/dyvKxpT9bTdLR/AzCJ7Ejy8rypy6+O8X3FKrkBDP30Ni448D+q7jP5h/bBmI\n\t+9mri8ycTirINQuPhmwKE89eYng7qFeBy8W0/BZGRu7zNk/DfH+bHMPd2jQBnNZ45s\n\tWlWXOw51gv11w==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695557848;\n\tx=1696162648; darn=lists.libcamera.org; \n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=auc3PaY6oDZkd0/xIEjjbV6GtGmc/fqBW7dLx6YOgCU=;\n\tb=MmXn7mucUAt4ik0vq1lZimwk1PT+9hCATLPzFVI3AmKFCLupcTV4COwLAgKQXXLYql\n\tf1sUWh2f5P0i0dLx3hx63VhRLoYMshV/2lTFH5+C8JTehTYjFph0EeQUGHBS8eDV8hev\n\t4EssUDowvkNKXsvyABd+TqqZr/0/G4kh8KJUdl7H9wcQcA4d0xoiF+AjyWZrRnETTp53\n\tuXKbRV3kPe0g10Vbizc/vg4j5JKTlnZVXGVhyXkNHSk9uMjnGdk+qX6prVy79PaEuZZ+\n\tZV1gVBn54SGoXvAN3tjudu0PZXfvWxFU4YDDfNIqWNUMo10N4++yBG5uevBokVXM1Xw+\n\tVpww=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20230601.gappssmtp.com\n\theader.i=@baylibre-com.20230601.gappssmtp.com header.b=\"MmXn7muc\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1695557848; x=1696162648;\n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; \n\tbh=auc3PaY6oDZkd0/xIEjjbV6GtGmc/fqBW7dLx6YOgCU=;\n\tb=kX9KdmJUSLnmD/Sm5l9gsdnY4q4r9Z2yCiP8faeRoxJBuNPFj0LXm6Qti2DH9sG1tD\n\tuLJ/2i28t7SeolRq94DZkXrBZeVH4l1BDyRosxK3J1nCLTqaWA5sYc+s6ocMG2G74jYF\n\tqLUi7GTQAG8GeIa2AjPHfL5mmd/4fvjBxQEi+8PJCoM0Se+bhLJh5+ewYRto+HYtgHiE\n\tTkSNpnIgZN0hGeVeWMFPG4lZvNJtdoXKYsbiepINFVQ39acVFioecOIZrPsTe2BEtNfk\n\tTnPynRaeTlXrOrO2AGJie5cUFqcUE95E8TrdVxSzNjSn800HgeWbSpNPYX8YFg9JlPNg\n\tI1xg==","X-Gm-Message-State":"AOJu0YxfScdivSmLkKMrnemF3CQZQSFGC6P5t6YhC67Ma7NkKU5Fmdxt\n\tuhQav58YlmC8nDtkCAxqqtDPww==","X-Google-Smtp-Source":"AGHT+IFgzB83gTTguS3JpFeBD18RjUClV41+wyPNpUaWNWlvaU7GupzVw8ZyTMMXPhdWo5NB5RcRkg==","X-Received":"by 2002:aa7:c98b:0:b0:532:ac24:5c00 with SMTP id\n\tc11-20020aa7c98b000000b00532ac245c00mr3038366edt.40.1695557848011; \n\tSun, 24 Sep 2023 05:17:28 -0700 (PDT)","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","In-Reply-To":"<aqsp6ugn4d5vacqgnd4oi6zxcj5ayzsw6vh67bt7z55ab4ormb@wfgektf3izex>","References":"<20230915-libyuv-convert-v1-0-1e5bcf68adac@baylibre.com>\n\t<20230915-libyuv-convert-v1-2-1e5bcf68adac@baylibre.com>\n\t<aqsp6ugn4d5vacqgnd4oi6zxcj5ayzsw6vh67bt7z55ab4ormb@wfgektf3izex>","Date":"Sun, 24 Sep 2023 14:17:22 +0200","Message-ID":"<87fs33ix4d.fsf@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain","Subject":"Re: [libcamera-devel] [PATCH RFC 2/7] android: yuv: loop over each\n\tplane for size check","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":"Mattijs Korpershoek via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tGuillaume La Roque <glaroque@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":27858,"web_url":"https://patchwork.libcamera.org/comment/27858/","msgid":"<20230924132744.GQ19112@pendragon.ideasonboard.com>","date":"2023-09-24T13:27:44","subject":"Re: [libcamera-devel] [PATCH RFC 2/7] android: yuv: loop over each\n\tplane for size check","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Sun, Sep 24, 2023 at 02:17:22PM +0200, Mattijs Korpershoek via libcamera-devel wrote:\n> On ven., sept. 22, 2023 at 12:56, Jacopo Mondi wrote:\n> > On Fri, Sep 15, 2023 at 09:57:26AM +0200, Mattijs Korpershoek via libcamera-devel wrote:\n> >> PostProcessorYuv assumption is that only formats::NV12 is supported\n> >> for source and destination pixelFormat.\n> >>\n> >> Because of this, we don't loop on each plane when size checking, but we\n> >> always assume a 2 plane buffer.\n> >>\n> >> To prepare for adding more YUV formats such as YUYV, loop over the\n> >> planes instead of using an if.\n> >>\n> >> No functional change, besides the logs only printing the first faulty\n> >> plane length.\n> >>\n> >> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n> >> ---\n> >>  src/android/yuv/post_processor_yuv.cpp | 40 +++++++++++++++++-----------------\n> >>  1 file changed, 20 insertions(+), 20 deletions(-)\n> >>\n> >> diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp\n> >> index 9631c9617154..d58090db14ee 100644\n> >> --- a/src/android/yuv/post_processor_yuv.cpp\n> >> +++ b/src/android/yuv/post_processor_yuv.cpp\n> >> @@ -101,27 +101,27 @@ bool PostProcessorYuv::isValidBuffers(const FrameBuffer &source,\n> >>  \t\treturn false;\n> >>  \t}\n> >>\n> >> -\tif (source.planes()[0].length < sourceLength_[0] ||\n> >> -\t    source.planes()[1].length < sourceLength_[1]) {\n> >> -\t\tLOG(YUV, Error)\n> >> -\t\t\t<< \"The source planes lengths are too small, actual size: {\"\n> >> -\t\t\t<< source.planes()[0].length << \", \"\n> >> -\t\t\t<< source.planes()[1].length\n> >> -\t\t\t<< \"}, expected size: {\"\n> >> -\t\t\t<< sourceLength_[0] << \", \"\n> >> -\t\t\t<< sourceLength_[1] << \"}\";\n> >> -\t\treturn false;\n> >> +\tfor (unsigned int i = 0; i < 2; i++) {\n\nI would replace 2 with source.planes().size() here.\n\n> >> +\t\tif (source.planes()[i].length < sourceLength_[i]) {\n> >> +\t\t\tLOG(YUV, Error)\n> >> +\t\t\t\t<< \"The source planes lengths are too small, \"\n> >> +\t\t\t\t<< \"actual size[\" << i << \"]=\"\n> >> +\t\t\t\t<< source.planes()[i].length\n> >> +\t\t\t\t<< \", expected size[\" << i << \"]=\"\n> >> +\t\t\t\t<< sourceLength_[i];\n\nYou can avoid printing i twice:\n\n\t\t\tLOG(YUV, Error)\n\t\t\t\t<< \"Source plane \" << i << \" is too small, \"\n\t\t\t\t<< \"actual size=\" << source.planes()[i].length\n\t\t\t\t<< \", expected size=\" << sourceLength_[i];\n\n> >> +\t\t\treturn false;\n> >> +\t\t}\n> >>  \t}\n\nTo do it the C++ way,\n\n\tfor (const auto &[i, plane] : utils::enumerate(source.planes())) {\n\t\tif (plane.length < sourceLength_[i]) {\n\t\t\tLOG(YUV, Error)\n\t\t\t\t<< \"Source plane \" << i << \" is too small, \"\n\t\t\t\t<< \"actual size=\" << source.planes()[i].length\n\t\t\t\t<< \", expected size=\" << sourceLength_[i];\n\t\t\treturn false;\n\t\t}\n\t}\n\n> >> -\tif (destination.plane(0).size() < destinationLength_[0] ||\n> >> -\t    destination.plane(1).size() < destinationLength_[1]) {\n> >> -\t\tLOG(YUV, Error)\n> >> -\t\t\t<< \"The destination planes lengths are too small, actual size: {\"\n> >> -\t\t\t<< destination.plane(0).size() << \", \"\n> >> -\t\t\t<< destination.plane(1).size()\n> >> -\t\t\t<< \"}, expected size: {\"\n> >> -\t\t\t<< sourceLength_[0] << \", \"\n> >> -\t\t\t<< sourceLength_[1] << \"}\";\n> >> -\t\treturn false;\n\nBlank line please.\n\n> >> +\tfor (unsigned int i = 0; i < 2; i++) {\n> >> +\t\tif (destination.plane(i).size() < destinationLength_[i]) {\n> >> +\t\t\tLOG(YUV, Error)\n> >> +\t\t\t\t<< \"The destination planes lengths are too small, \"\n> >> +\t\t\t\t<< \"actual size[\" << i << \"]=\"\n> >> +\t\t\t\t<< destination.plane(i).size()\n> >> +\t\t\t\t<< \", expected size[\" << i << \"]=\"\n> >> +\t\t\t\t<< sourceLength_[i];\n> >\n> > This should be destinationLength_[i]\n> >\n> > With this fixed\n> > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n> Will fix for v2 and apply your reviewed tag.\n> \n> >> +\t\t\treturn false;\n> >> +\t\t}\n> >>  \t}\n\nSimilar comments here as above.\n\n> >>\n> >>  \treturn true;\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 F2A96BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 24 Sep 2023 13:27:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 57B8262945;\n\tSun, 24 Sep 2023 15:27:34 +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 D414D62931\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 24 Sep 2023 15:27:32 +0200 (CEST)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 19AED128D;\n\tSun, 24 Sep 2023 15:25:53 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695562054;\n\tbh=fsJRfLNxAmy02RVo91WntLmQwTpxlurXVAztFIEKPQQ=;\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=JmL1OAZNjstgj+nP+PjLfFMOTFUH8c881w2WYtwmYLmItxrxTz82c7QR13k1M0Jds\n\tLlnKg8Fq/iOoRQABObWKOsRAE7gYACBmzJ9l+uYXxhNh4798OYurTVGRggD5vJ80hw\n\tK39F8DZGyax6hqZAwvSmDLo94/+PUyfrR9Ery3Gsmi6JFkuTolYRfIH3860FZzb4/d\n\t0VE2uDzvtkqgvSOA9A/p3WogPzdMUNVks1ok/XLKIqWeek0qKDcFF6zBPEkmUT4wlX\n\tGGoEaNniEaDhdpaiANB+Pc/irjZ8kuCUcfSGoXqt6ZdkSZcZJUx17kYaZLnFCt/Rdn\n\tZ9tfy1r2s/m9Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1695561953;\n\tbh=fsJRfLNxAmy02RVo91WntLmQwTpxlurXVAztFIEKPQQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=CkwuiIkFBF9eHYMDH0niLmIU1O8uYaa+FGup0ZsI8DTKCkj+hqM521yZMjTC9IAk+\n\tia9XQcKEZtAFg+1fmmHqe+0RDwPnm6MBwOIIHfzO2bIl45u1d/hMkbxJXrwO5IwzEC\n\tsUXqz/fbCuvUsuxcrblAm3KOmQfFDVPrTUWLvBvI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"CkwuiIkF\"; dkim-atps=neutral","Date":"Sun, 24 Sep 2023 16:27:44 +0300","To":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","Message-ID":"<20230924132744.GQ19112@pendragon.ideasonboard.com>","References":"<20230915-libyuv-convert-v1-0-1e5bcf68adac@baylibre.com>\n\t<20230915-libyuv-convert-v1-2-1e5bcf68adac@baylibre.com>\n\t<aqsp6ugn4d5vacqgnd4oi6zxcj5ayzsw6vh67bt7z55ab4ormb@wfgektf3izex>\n\t<87fs33ix4d.fsf@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<87fs33ix4d.fsf@baylibre.com>","Subject":"Re: [libcamera-devel] [PATCH RFC 2/7] android: yuv: loop over each\n\tplane for size check","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":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org,\n\tGuillaume La Roque <glaroque@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]