{"id":19008,"url":"https://patchwork.libcamera.org/api/patches/19008/?format=json","web_url":"https://patchwork.libcamera.org/patch/19008/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230915-libyuv-convert-v1-2-1e5bcf68adac@baylibre.com>","date":"2023-09-15T07:57:26","name":"[libcamera-devel,RFC,2/7] android: yuv: loop over each plane for size check","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f622f49c38b8f510614ad180b9a1c6f8055a8b2e","submitter":{"id":153,"url":"https://patchwork.libcamera.org/api/people/153/?format=json","name":"Mattijs Korpershoek","email":"mkorpershoek@baylibre.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19008/mbox/","series":[{"id":4023,"url":"https://patchwork.libcamera.org/api/series/4023/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4023","date":"2023-09-15T07:57:24","name":"android: add YUYV->NV12 conversion via libyuv","version":1,"mbox":"https://patchwork.libcamera.org/series/4023/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19008/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19008/checks/","tags":{},"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 D3A78C3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Sep 2023 07:57:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 456AC6291C;\n\tFri, 15 Sep 2023 09:57:32 +0200 (CEST)","from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4578A62911\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Sep 2023 09:57:29 +0200 (CEST)","by mail-wm1-x32e.google.com with SMTP id\n\t5b1f17b1804b1-404773f2501so10197855e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Sep 2023 00:57:29 -0700 (PDT)","from [192.168.1.20] ([2a01:cb19:8704:be00:4f55:bd9d:611a:6c8e])\n\tby smtp.gmail.com with ESMTPSA id\n\tm2-20020a056000174200b0031fe9a47a87sm2506942wrf.112.2023.09.15.00.57.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 15 Sep 2023 00:57:28 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1694764652;\n\tbh=Gmyz+JFbdgJxh5sAYtlji1fX/uQaXkb+Fc2zUb8qSPM=;\n\th=Date:References:In-Reply-To:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=t4vGyKs8nN/RmYolPeyDjcHv4B5jkdcuVfAmSS7o/kz4Lk29ZYyL85vYu/ekoOqKw\n\tCxruRGOwZtASKV7fJc96kgelSKRTJRlgjzVvv+qRnqXYs3Qu1uJ+aUoyHZ9LQ2+6se\n\tElz2Z3g9tbtrY6Os5XVNR3E1OvqnaX1gKDPylNHHAgmET2EG6jnqQGnstVn/KnaBgN\n\t+8HPASxpSgsZbo+mZPZmkBI5B+wGjcDMIssile/BlU8OgS9ZvVXoFScL/he6MiEyyt\n\tdo+w3P6ao8GE8qnXHpOvbWYqpsO8OwiktDlZZR3ImeDR394e+7sBTU+WS36FcYEtAc\n\td1NwGE8pywKRg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1694764649;\n\tx=1695369449; darn=lists.libcamera.org; \n\th=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n\t:mime-version:subject:date:from:from:to:cc:subject:date:message-id\n\t:reply-to; bh=vZTpit9hOwhOaXXsmkIT8ZLwPgPwB4u4Lnyf5QP21iw=;\n\tb=npbt+OKiRvslG9ezoG8pHHS2mjP6ED1hiHLCkuarfIy3Fa3zlouy+LqHSYuvCumSoy\n\t/7DbmuSt8q/CJ6OQ3dkmxNusc0e20M02QoRvowIMLA4Mi3KRpdipJlWOA0zRBGRjLo7L\n\tsEICo27dLWj/OvM2yEbZrqhTrBAsrwuwy1K9WfkVqrmb+82ZBfsLnVHfvraGOkxZbKa/\n\tS7L3+9myUQLdGV+0BWnM2g74nWKUhRqk7Crq2wn0SdofaXqGNXL0LwvZmrdPO2Uqnr62\n\tCGFBhPNZzkBeyBVo5vXGoswupXAERlksO3y5H3x8snDpCCVgouaZYRyJqOYqXQsx7XGQ\n\t1DCA=="],"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=\"npbt+OKi\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1694764649; x=1695369449;\n\th=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n\t:mime-version:subject:date:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=vZTpit9hOwhOaXXsmkIT8ZLwPgPwB4u4Lnyf5QP21iw=;\n\tb=C4L3SfKq5SiPLsmIbrvsxUKTHoR07T8wDjpb1BAUu1gGKW9U1ZBhoDQVA1et/vty4h\n\tpSZ/ajExS9JoRyQtYm4FsW3MXIKG8W039a+Rol5bsJIqeZrlaT/RLkDhIrZVthC3BKCc\n\tkoW18zkgjNBcl0nkgWE5Bo3msA2u9lF3V5chSSUvt/654MBQwxmugMerPf24EBJEqwv6\n\tjW8knKE1yIu+izMNGIWH2Tq2IOZFVeJBTpo6d7w3WRc8fCfTNIW8bNEhzc+pcYXGAqde\n\tUKBGj2QkTMG9h9/XS72DkrWPCMhoUuHeF35fVZYMfM4L06JbnF5JcBVCAp3/QnrNdkun\n\t7HiQ==","X-Gm-Message-State":"AOJu0YxEcN3mbeOvxIOsdK1wifK2rrQ3iWjqRnO0QE+DIKLy3ov2BKex\n\tPA0kueWxOdXNJiQ70JTU38peDQ==","X-Google-Smtp-Source":"AGHT+IEHF4VshMwkLrBmR5lEmGo/34nPonQBdXtP86jwoLsGjlpUIeoQIgi2rxvhPNAjAqCjWfkn6g==","X-Received":"by 2002:adf:a303:0:b0:31f:f84e:f63e with SMTP id\n\tc3-20020adfa303000000b0031ff84ef63emr305113wrb.54.1694764648864; \n\tFri, 15 Sep 2023 00:57:28 -0700 (PDT)","Date":"Fri, 15 Sep 2023 09:57:26 +0200","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20230915-libyuv-convert-v1-2-1e5bcf68adac@baylibre.com>","References":"<20230915-libyuv-convert-v1-0-1e5bcf68adac@baylibre.com>","In-Reply-To":"<20230915-libyuv-convert-v1-0-1e5bcf68adac@baylibre.com>","To":"libcamera-devel@lists.libcamera.org","X-Mailer":"b4 0.12.4-dev-6aa5d","Subject":"[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":"Guillaume La Roque <glaroque@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"PostProcessorYuv assumption is that only formats::NV12 is supported\nfor source and destination pixelFormat.\n\nBecause of this, we don't loop on each plane when size checking, but we\nalways assume a 2 plane buffer.\n\nTo prepare for adding more YUV formats such as YUYV, loop over the\nplanes instead of using an if.\n\nNo functional change, besides the logs only printing the first faulty\nplane length.\n\nSigned-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(-)","diff":"diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp\nindex 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+\t\t\treturn false;\n+\t\t}\n \t}\n \n \treturn true;\n","prefixes":["libcamera-devel","RFC","2/7"]}