From patchwork Thu Jan 28 01:13:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11034 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 19304BD808 for ; Thu, 28 Jan 2021 01:14:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 91A7368374; Thu, 28 Jan 2021 02:14:00 +0100 (CET) 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="aKi7Owpo"; 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 9A4AA60308 for ; Thu, 28 Jan 2021 02:13:59 +0100 (CET) Received: by mail-pl1-x629.google.com with SMTP id s15so2381227plr.9 for ; Wed, 27 Jan 2021 17:13:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LV90NSM8M8tB06QknQg/zmzlmudY4l+0sEattC6Jz0U=; b=aKi7Owpoj6dtN6vMMq0OuoWqYXbrQMNeO3qzE/e5pOxn2pMxPP1CILOnXXMeUenoYI zvTEW3V6yE7zh4m+l+/MvQ+CcmMnR5uThe+CbLApBz0zRYPyjcv3h86HNqkiHSu38Zlj IO8RavCwGr/ROPrZwbDvtkaKHIfXHiRNM7B6c= 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:mime-version :content-transfer-encoding; bh=LV90NSM8M8tB06QknQg/zmzlmudY4l+0sEattC6Jz0U=; b=aLEzhbscv5O7Kf0rSb37tc1+mSSMWjzRTO1CLl+pDUc30x5BJTCYNi4gyVBQka+gqd saWmY3jUrDaHyNYZ3R4nhR8+rFq2MJ2JgoEI2h3/cmCL6iW/45ihlCn4/pYhYHw2/qVZ UFRGU4znAURVeQQRbPhfqejypit0xdxRND+4iUb5bjzmiHVj4o/tziTSE8VZqgzaTFh3 atP1aTWITJXG/9obxnMNT7V6Avn66y5RnYesgvLKiqPHzJ7POf2msRnGYhUt0srqPnpK DXNRaG4OW17TH+UesaQdQGOWPoGtvZcOE66SSjpmnLL+kjGB1rWhapddIvjk+W1aDoDM L0pQ== X-Gm-Message-State: AOAM532Y0mkayjXIjUJwWaJKUH25KTuWVTdrmdlh09Ry+Cd64tEhHrKI jJRD3Qp3BLXhRaPf8OZmpPePWpekRQVsASxO X-Google-Smtp-Source: ABdhPJy2Fj+Vlq1mvna12G9beYtti6ylEAD8JvLVNzqF0JmvmkwR9xp8cRB3WjUAUr7c0/uBzy2UUg== X-Received: by 2002:a17:90a:760b:: with SMTP id s11mr8389533pjk.187.1611796437298; Wed, 27 Jan 2021 17:13:57 -0800 (PST) Received: from hiroh.c.googlers.com.com (128.141.236.35.bc.googleusercontent.com. [35.236.141.128]) by smtp.gmail.com with ESMTPSA id br21sm3331103pjb.9.2021.01.27.17.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jan 2021 17:13:56 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Jan 2021 01:13:49 +0000 Message-Id: <20210128011351.2495050-1-hiroh@chromium.org> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/2] android: post_processor: Change the type destination in process() 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 type of the destination buffer in PostProcessor::process() is libcamera::Span. libcamera::Span is used for one dimension buffer (e.g. blob buffer). The destination can be multiple dimensions buffer (e.g. yuv frame). Therefore, this changes the type of the destination buffer to MappedFrameBuffer. Signed-off-by: Hirokazu Honda Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/android/camera_stream.cpp | 4 ++-- src/android/camera_stream.h | 6 ++++-- src/android/jpeg/post_processor_jpeg.cpp | 6 +++--- src/android/jpeg/post_processor_jpeg.h | 2 +- src/android/post_processor.h | 7 ++++--- 5 files changed, 14 insertions(+), 11 deletions(-) -- 2.30.0.280.ga3ce27912f-goog diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 4c8020e5..611ec0d1 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -96,14 +96,14 @@ int CameraStream::configure() } int CameraStream::process(const libcamera::FrameBuffer &source, - MappedCamera3Buffer *dest, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) { if (!postProcessor_) return 0; - return postProcessor_->process(source, dest->maps()[0], + return postProcessor_->process(source, destination, requestMetadata, resultMetadata); } diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index 298ffbf6..73bac0ba 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -19,9 +19,10 @@ #include #include +#include + class CameraDevice; class CameraMetadata; -class MappedCamera3Buffer; class PostProcessor; class CameraStream @@ -119,9 +120,10 @@ public: int configure(); int process(const libcamera::FrameBuffer &source, - MappedCamera3Buffer *dest, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata); + libcamera::FrameBuffer *getBuffer(); void putBuffer(libcamera::FrameBuffer *buffer); diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index cac0087b..74e81c6f 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -83,7 +83,7 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source, } int PostProcessorJpeg::process(const FrameBuffer &source, - Span destination, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) { @@ -171,8 +171,8 @@ int PostProcessorJpeg::process(const FrameBuffer &source, ret = requestMetadata.getEntry(ANDROID_JPEG_QUALITY, &entry); const uint8_t quality = ret ? *entry.data.u8 : 95; resultMetadata->addEntry(ANDROID_JPEG_QUALITY, &quality, 1); + int jpeg_size = encoder_->encode(source, destination->maps()[0], exif.data(), quality); - int jpeg_size = encoder_->encode(source, destination, exif.data(), quality); if (jpeg_size < 0) { LOG(JPEG, Error) << "Failed to encode stream image"; return jpeg_size; @@ -190,7 +190,7 @@ int PostProcessorJpeg::process(const FrameBuffer &source, * \todo Investigate if the buffer size mismatch is an issue or * expected behaviour. */ - uint8_t *resultPtr = destination.data() + + uint8_t *resultPtr = destination->maps()[0].data() + cameraDevice_->maxJpegBufferSize() - sizeof(struct camera3_jpeg_blob); auto *blob = reinterpret_cast(resultPtr); diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h index d2dfa450..7689de73 100644 --- a/src/android/jpeg/post_processor_jpeg.h +++ b/src/android/jpeg/post_processor_jpeg.h @@ -25,7 +25,7 @@ public: int configure(const libcamera::StreamConfiguration &incfg, const libcamera::StreamConfiguration &outcfg) override; int process(const libcamera::FrameBuffer &source, - libcamera::Span destination, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) override; diff --git a/src/android/post_processor.h b/src/android/post_processor.h index bda93bb4..f5c99f03 100644 --- a/src/android/post_processor.h +++ b/src/android/post_processor.h @@ -8,9 +8,10 @@ #define __ANDROID_POST_PROCESSOR_H__ #include -#include #include +#include + class CameraMetadata; class PostProcessor @@ -21,9 +22,9 @@ public: virtual int configure(const libcamera::StreamConfiguration &inCfg, const libcamera::StreamConfiguration &outCfg) = 0; virtual int process(const libcamera::FrameBuffer &source, - libcamera::Span destination, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, - CameraMetadata *resultMetadata) = 0; + CameraMetadata *metadata) = 0; }; #endif /* __ANDROID_POST_PROCESSOR_H__ */