From patchwork Fri Sep 15 07:57:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 19008 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D3A78C3260 for ; Fri, 15 Sep 2023 07:57:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 456AC6291C; Fri, 15 Sep 2023 09:57:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1694764652; bh=Gmyz+JFbdgJxh5sAYtlji1fX/uQaXkb+Fc2zUb8qSPM=; h=Date:References:In-Reply-To:To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=t4vGyKs8nN/RmYolPeyDjcHv4B5jkdcuVfAmSS7o/kz4Lk29ZYyL85vYu/ekoOqKw CxruRGOwZtASKV7fJc96kgelSKRTJRlgjzVvv+qRnqXYs3Qu1uJ+aUoyHZ9LQ2+6se Elz2Z3g9tbtrY6Os5XVNR3E1OvqnaX1gKDPylNHHAgmET2EG6jnqQGnstVn/KnaBgN +8HPASxpSgsZbo+mZPZmkBI5B+wGjcDMIssile/BlU8OgS9ZvVXoFScL/he6MiEyyt do+w3P6ao8GE8qnXHpOvbWYqpsO8OwiktDlZZR3ImeDR394e+7sBTU+WS36FcYEtAc d1NwGE8pywKRg== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4578A62911 for ; Fri, 15 Sep 2023 09:57:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="npbt+OKi"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-404773f2501so10197855e9.0 for ; Fri, 15 Sep 2023 00:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1694764649; x=1695369449; darn=lists.libcamera.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vZTpit9hOwhOaXXsmkIT8ZLwPgPwB4u4Lnyf5QP21iw=; b=npbt+OKiRvslG9ezoG8pHHS2mjP6ED1hiHLCkuarfIy3Fa3zlouy+LqHSYuvCumSoy /7DbmuSt8q/CJ6OQ3dkmxNusc0e20M02QoRvowIMLA4Mi3KRpdipJlWOA0zRBGRjLo7L sEICo27dLWj/OvM2yEbZrqhTrBAsrwuwy1K9WfkVqrmb+82ZBfsLnVHfvraGOkxZbKa/ S7L3+9myUQLdGV+0BWnM2g74nWKUhRqk7Crq2wn0SdofaXqGNXL0LwvZmrdPO2Uqnr62 CGFBhPNZzkBeyBVo5vXGoswupXAERlksO3y5H3x8snDpCCVgouaZYRyJqOYqXQsx7XGQ 1DCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694764649; x=1695369449; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vZTpit9hOwhOaXXsmkIT8ZLwPgPwB4u4Lnyf5QP21iw=; b=C4L3SfKq5SiPLsmIbrvsxUKTHoR07T8wDjpb1BAUu1gGKW9U1ZBhoDQVA1et/vty4h pSZ/ajExS9JoRyQtYm4FsW3MXIKG8W039a+Rol5bsJIqeZrlaT/RLkDhIrZVthC3BKCc koW18zkgjNBcl0nkgWE5Bo3msA2u9lF3V5chSSUvt/654MBQwxmugMerPf24EBJEqwv6 jW8knKE1yIu+izMNGIWH2Tq2IOZFVeJBTpo6d7w3WRc8fCfTNIW8bNEhzc+pcYXGAqde UKBGj2QkTMG9h9/XS72DkrWPCMhoUuHeF35fVZYMfM4L06JbnF5JcBVCAp3/QnrNdkun 7HiQ== X-Gm-Message-State: AOJu0YxEcN3mbeOvxIOsdK1wifK2rrQ3iWjqRnO0QE+DIKLy3ov2BKex PA0kueWxOdXNJiQ70JTU38peDQ== X-Google-Smtp-Source: AGHT+IEHF4VshMwkLrBmR5lEmGo/34nPonQBdXtP86jwoLsGjlpUIeoQIgi2rxvhPNAjAqCjWfkn6g== X-Received: by 2002:adf:a303:0:b0:31f:f84e:f63e with SMTP id c3-20020adfa303000000b0031ff84ef63emr305113wrb.54.1694764648864; Fri, 15 Sep 2023 00:57:28 -0700 (PDT) Received: from [192.168.1.20] ([2a01:cb19:8704:be00:4f55:bd9d:611a:6c8e]) by smtp.gmail.com with ESMTPSA id m2-20020a056000174200b0031fe9a47a87sm2506942wrf.112.2023.09.15.00.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 00:57:28 -0700 (PDT) Date: Fri, 15 Sep 2023 09:57:26 +0200 MIME-Version: 1.0 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 plane for size check X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mattijs Korpershoek via libcamera-devel From: Mattijs Korpershoek Reply-To: Mattijs Korpershoek Cc: Guillaume La Roque Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" PostProcessorYuv assumption is that only formats::NV12 is supported for source and destination pixelFormat. Because of this, we don't loop on each plane when size checking, but we always assume a 2 plane buffer. To prepare for adding more YUV formats such as YUYV, loop over the planes instead of using an if. No functional change, besides the logs only printing the first faulty plane length. Signed-off-by: Mattijs Korpershoek Reviewed-by: Jacopo Mondi --- src/android/yuv/post_processor_yuv.cpp | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp index 9631c9617154..d58090db14ee 100644 --- a/src/android/yuv/post_processor_yuv.cpp +++ b/src/android/yuv/post_processor_yuv.cpp @@ -101,27 +101,27 @@ bool PostProcessorYuv::isValidBuffers(const FrameBuffer &source, return false; } - if (source.planes()[0].length < sourceLength_[0] || - source.planes()[1].length < sourceLength_[1]) { - LOG(YUV, Error) - << "The source planes lengths are too small, actual size: {" - << source.planes()[0].length << ", " - << source.planes()[1].length - << "}, expected size: {" - << sourceLength_[0] << ", " - << sourceLength_[1] << "}"; - return false; + for (unsigned int i = 0; i < 2; i++) { + if (source.planes()[i].length < sourceLength_[i]) { + LOG(YUV, Error) + << "The source planes lengths are too small, " + << "actual size[" << i << "]=" + << source.planes()[i].length + << ", expected size[" << i << "]=" + << sourceLength_[i]; + return false; + } } - if (destination.plane(0).size() < destinationLength_[0] || - destination.plane(1).size() < destinationLength_[1]) { - LOG(YUV, Error) - << "The destination planes lengths are too small, actual size: {" - << destination.plane(0).size() << ", " - << destination.plane(1).size() - << "}, expected size: {" - << sourceLength_[0] << ", " - << sourceLength_[1] << "}"; - return false; + for (unsigned int i = 0; i < 2; i++) { + if (destination.plane(i).size() < destinationLength_[i]) { + LOG(YUV, Error) + << "The destination planes lengths are too small, " + << "actual size[" << i << "]=" + << destination.plane(i).size() + << ", expected size[" << i << "]=" + << sourceLength_[i]; + return false; + } } return true;