From patchwork Mon Aug 16 04:31:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13368 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 14AEDBD87D for ; Mon, 16 Aug 2021 04:32:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BA984688A2; Mon, 16 Aug 2021 06:32:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="n+En1NwB"; dkim-atps=neutral Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BBCCD68894 for ; Mon, 16 Aug 2021 06:32:03 +0200 (CEST) Received: by mail-pj1-x102d.google.com with SMTP id u13-20020a17090abb0db0290177e1d9b3f7so30424397pjr.1 for ; Sun, 15 Aug 2021 21:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T0dHkJ+PNUMoZsj2N4CcOXDLrqClbhhh/k1FY/GiBJ4=; b=n+En1NwBdcH4TcPaMwrSbLNjbPZ7eHu5aquTG1xyL87Alq2AyAfq6VIKenL2dRFAQi fujSyt1idViZxifcccws3ejuPsn2x8NiGOTiSjgsg7FWVfyQt10kwHyPXLFuKOI+MZn8 6DLyqH6WK1qyinAXMxm6v0s1y/cp0XizzKuGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T0dHkJ+PNUMoZsj2N4CcOXDLrqClbhhh/k1FY/GiBJ4=; b=tic79EACsHlOI7QsD4WX6LzWU5e7eAWs3a/gmFr/tJavZ9cOF9g3Py1QEvQLUQmZmQ oC/s+jbMiY/C1ocPQxC72u1E3bFpKq0adlE7fNUbK587+5m2y9wguPKZo3cjN6Lgeq+w YuXa9tFmslT8V4nvc+HONmU8BlrbSkbSrQBLFxfj/DOAPGwHhb8zYkuFVyPp5xl0a2kn 8TchJdFkrjyztQP8YX2+DUz45LxVkcR6++q/h3ZQII054s5xdeaaOU4CxWLnseUzb2Zt gMWY7X/BE+5D7oprIhHwjziLaqqbwogk3QVm0R1V6qiuZUF/qS5EgE4L7/QKsVgBiDJK AaAg== X-Gm-Message-State: AOAM533Wpuq8BcSzJ7FshRjzQ+l/t06u7PRWkLlBS7up/BHiHJnZMm1h C5XgMCEHvaMI2N9lCt0ilqtDVIMC1Lyr/Q== X-Google-Smtp-Source: ABdhPJyIbuE9t6aeZQu06o+X2h+vnUq44B/CC7xAWI3oOnHCX7F7G9PmG5tUl2yjnW288PcM/xOXCg== X-Received: by 2002:aa7:8e4e:0:b029:3e0:28db:d73b with SMTP id d14-20020aa78e4e0000b02903e028dbd73bmr14309318pfr.8.1629088322111; Sun, 15 Aug 2021 21:32:02 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:6f5f:1479:a6ab:4229]) by smtp.gmail.com with ESMTPSA id u10sm2767417pgj.48.2021.08.15.21.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Aug 2021 21:32:01 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 16 Aug 2021 13:31:38 +0900 Message-Id: <20210816043138.957984-11-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.rc1.237.g0d66db33f3-goog In-Reply-To: <20210816043138.957984-1-hiroh@chromium.org> References: <20210816043138.957984-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 10/10] libcamera: framebuffer: Add assertion to detect offset is unfilled 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The offset variable is introduced to FrameBuffer::Plane. In order to detect that the plane is used while the offset is not set, this adds the assertion to FrameBuffer::planes(). It should be removed in the future. Signed-off-by: Hirokazu Honda --- include/libcamera/framebuffer.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 5de3c744..79541557 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -7,6 +7,8 @@ #ifndef __LIBCAMERA_FRAMEBUFFER_H__ #define __LIBCAMERA_FRAMEBUFFER_H__ +#include +#include #include #include @@ -41,14 +43,21 @@ class FrameBuffer final : public Extensible public: struct Plane { + static constexpr unsigned int kInvalidOffset = std::numeric_limits::max(); FileDescriptor fd; - unsigned int offset; + unsigned int offset = kInvalidOffset; unsigned int length; }; FrameBuffer(const std::vector &planes, unsigned int cookie = 0); - const std::vector &planes() const { return planes_; } + const std::vector &planes() const + { + /* \todo remove this assert. */ + for (const auto &plane : planes_) + assert(plane.offset != Plane::kInvalidOffset); + return planes_; + } Request *request() const; const FrameMetadata &metadata() const { return metadata_; }