From patchwork Mon Aug 16 04:31:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13362 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 82D29BD87D for ; Mon, 16 Aug 2021 04:31:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4B838688C4; Mon, 16 Aug 2021 06:31:56 +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="kFho54l7"; dkim-atps=neutral Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 74AC56888C for ; Mon, 16 Aug 2021 06:31:53 +0200 (CEST) Received: by mail-pl1-x629.google.com with SMTP id q2so19363503plr.11 for ; Sun, 15 Aug 2021 21:31:53 -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=73f5QDjSVO9zhfCjdBruDhBrJUzuMAxKbVfRDfFAGRI=; b=kFho54l72yWrhKew1OD+0Z+4mRuQLh8R2xWj1e/yTH4AxvzYMKp0Wtete7ZgRNT7QI CMBV/XDux2r0KnofVii3NV1uqJGSbpgYNOfqyARaL0vgRgiXlbGevrZE4s/8Q0t0qx4h UykzEY2jf3gl+KLuY3UBfqYy2ZKVRtBy38mVk= 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=73f5QDjSVO9zhfCjdBruDhBrJUzuMAxKbVfRDfFAGRI=; b=mCPOPpxEDl2IsIdNdZGROUMTOZG6EaXcjt+fEmx1h1GrAwVzo+7yEAcctyy8R/1JDT U5oQZWm6T9FboJNSKGnsPeUbgj3FtuaaiPBZYJgfB+yycOWFJieOiKM2VInknqSuQh+A hkk7mka0+1sM3kZ7AqIT8Bi2W7qi+0ntgOGeZgD5J4AK+GW3iTiWNQdPEjfX7wg3ewQe +scvkPJ994Hpnl1BnEeH2l2KX1/UyFB1gFbXw8BgUKS5U0S8uJpoYt3EmH60JjAqb8Jc xAi3GcK1h+1TA6P575HST0zXOQIKrUTc6nvFtvHBgH0LEvgy4GpiM5Sh3PEk1UX2b/hR FJPg== X-Gm-Message-State: AOAM532NbYQaxQ9B5TOHSPx+fS0iRtxThTZv1x9ZGevZ+NtzCDzO0NAQ 1MtBNti2dGa5rwjVLY3QhxdHcap//dxlXw== X-Google-Smtp-Source: ABdhPJwdDf18lvQ/3rVXL44IRX8OsSbO8Zq5bEzGFqjLDr6Thp+s0LVoMbzEy8XL4ZVKSlT0p7Z7qQ== X-Received: by 2002:a65:5a0d:: with SMTP id y13mr14047046pgs.22.1629088311783; Sun, 15 Aug 2021 21:31:51 -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.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Aug 2021 21:31:51 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 16 Aug 2021 13:31:32 +0900 Message-Id: <20210816043138.957984-5-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 04/10] cam: file_sink: Use offset in mapping FrameBuffer 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" This fixes the way of mapping FrameBuffer in FrameSink by using offset. Signed-off-by: Hirokazu Honda --- src/cam/file_sink.cpp | 5 ++++- src/cam/file_sink.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cam/file_sink.cpp b/src/cam/file_sink.cpp index 2d30694a..92b2d53d 100644 --- a/src/cam/file_sink.cpp +++ b/src/cam/file_sink.cpp @@ -51,12 +51,15 @@ int FileSink::configure(const libcamera::CameraConfiguration &config) void FileSink::mapBuffer(FrameBuffer *buffer) { + /* \todo use MappedFrameBuffer. */ for (const FrameBuffer::Plane &plane : buffer->planes()) { void *memory = mmap(NULL, plane.length, PROT_READ, MAP_SHARED, plane.fd.fd(), 0); mappedBuffers_[plane.fd.fd()] = std::make_pair(memory, plane.length); + planeData_[plane.fd.fd()] = + static_cast(memory) + plane.offset; } } @@ -102,7 +105,7 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer) const FrameBuffer::Plane &plane = buffer->planes()[i]; const FrameMetadata::Plane &meta = buffer->metadata().planes[i]; - void *data = mappedBuffers_[plane.fd.fd()].first; + void *data = planeData_[plane.fd.fd()]; unsigned int length = std::min(meta.bytesused, plane.length); if (meta.bytesused > plane.length) diff --git a/src/cam/file_sink.h b/src/cam/file_sink.h index c3eb230a..d236d6d8 100644 --- a/src/cam/file_sink.h +++ b/src/cam/file_sink.h @@ -33,6 +33,7 @@ private: std::map streamNames_; std::string pattern_; std::map> mappedBuffers_; + std::map planeData_; }; #endif /* __CAM_FILE_SINK_H__ */