From patchwork Thu Feb 4 10:05: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: 11141 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 077AEBD162 for ; Thu, 4 Feb 2021 10:05:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CC23F61433; Thu, 4 Feb 2021 11:05:56 +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="YN5y9JVg"; dkim-atps=neutral Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2788761402 for ; Thu, 4 Feb 2021 11:05:55 +0100 (CET) Received: by mail-pg1-x52c.google.com with SMTP id z21so1756362pgj.4 for ; Thu, 04 Feb 2021 02:05:55 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=7yERyDLtas5GQ4jIrAxedsZX+9qroAgVoDq37BZqW9A=; b=YN5y9JVgKRLIK+mCIKs4cLBRnsYzwCl0pY+lWoAdcRvjaHUz7oo8Mh32bNeTDWu1dZ HoY0VxwFwZj4o03su1Sj5jt/tz3IyiAJNjwstFpcLPAe1cLxBUMowz7ifWwtEkufsuOp dpDlXGYEV6JnxE93SLyIXuiX6ZLmIHIcnnS+8= 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=7yERyDLtas5GQ4jIrAxedsZX+9qroAgVoDq37BZqW9A=; b=Wyb1bw+d5uPGSkM4who3rvePSJK5+j+WWe04cy8cifQB95GG0z/LK17BdEgcFkO/+H AksQlfO+eM2Wzlbr0epiFJ06R9iCiIQeB4yBJ2tWJ4H2GV378icKIXLYpzWpwRt10WKz 9yaflkm/FsOJwoHznHOYGWmXNN4tgVRQ43BB/s6sVwX8p+EEQ+V6hyJndYlLI0bDtMR+ D5JHyjORE5wYf4HCM30OZmlIO9ALat/mSnbIWiHkauY+IThMGbA7h4Jps4ikVSYlQtDy IioO0iN0HZsyTOX9bbpZ4K+KYRE11+FMwOeNakv3p94O5+Uasg82j5DSXR+c5GDTcRfE 3B5g== X-Gm-Message-State: AOAM531O6StcGdbPwFcGfqLUGzSlko4Dn0o6jT9UMrNxkEYiyAcy4cHC cco/FJ7ixwISsMgYecyDg13EWfOOeb5VPkia X-Google-Smtp-Source: ABdhPJxdRs4jbnDDIKlEXJ2lL3HhxyoJWHCL5ELPWnA7PKmO4dSvMwcS5f1sA1PABkEWe1d2R+9//A== X-Received: by 2002:a63:d5e:: with SMTP id 30mr7428446pgn.178.1612433153227; Thu, 04 Feb 2021 02:05:53 -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 j9sm5808418pgb.47.2021.02.04.02.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 02:05:52 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Feb 2021 10:05:38 +0000 Message-Id: <20210204100541.657503-4-hiroh@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210204100541.657503-1-hiroh@chromium.org> References: <20210204100541.657503-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 3/6] android: camera_stream: Pass post processor in configure() 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: , Cc: hanlinchen@chromium.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" CameraStream creates PostProcessor in its constructor and configures the PostProcessor() in its configure(). The existing code hard-codes them for PostProcessorJpeg. It is difficult to generalize the code for other PostProcessor. A client of CameraStream should know what post processor is needed and how to configure it. Therefore, this changes CameraStream::configure() interface to take a post processor. A client of CameraStream creates and configures a post processor before calling configure(). Signed-off-by: Hirokazu Honda --- src/android/camera_device.cpp | 21 ++++++++++++++++++++- src/android/camera_stream.cpp | 31 ++++++++----------------------- src/android/camera_stream.h | 2 +- 3 files changed, 29 insertions(+), 25 deletions(-) -- 2.30.0.365.g02bc693789-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index a50b0ebf..752e17ba 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -8,6 +8,7 @@ #include "camera_device.h" #include "camera_ops.h" #include "post_processor.h" +#include "jpeg/post_processor_jpeg.h" #include #include @@ -1613,7 +1614,25 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) * the Android camera3_stream_t. */ for (CameraStream &cameraStream : streams_) { - ret = cameraStream.configure(); + std::unique_ptr postProcessor; + + if (cameraStream.type() == CameraStream::Type::Internal || + cameraStream.type() == CameraStream::Type::Mapped) { + postProcessor = + std::make_unique(this); + + auto output = cameraStream.configuration(); + output.pixelFormat = formats::MJPEG; + postProcessor->configure(cameraStream.configuration(), + output); + if (ret) { + LOG(HAL, Error) << "Failed to configure " + << "PostProcessorJpeg"; + return ret; + } + } + + ret = cameraStream.configure(std::move(postProcessor)); if (ret) { LOG(HAL, Error) << "Failed to configure camera stream"; return ret; diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 611ec0d1..ed6c5265 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -9,7 +9,7 @@ #include "camera_device.h" #include "camera_metadata.h" -#include "jpeg/post_processor_jpeg.h" +#include "post_processor.h" #include @@ -38,22 +38,13 @@ LOG_DECLARE_CATEGORY(HAL) * and buffer allocation. */ -CameraStream::CameraStream(CameraDevice *const cameraDevice, Type type, - camera3_stream_t *camera3Stream, unsigned int index) +CameraStream::CameraStream(CameraDevice *const cameraDevice, + Type type, camera3_stream_t *camera3Stream, + unsigned int index) : cameraDevice_(cameraDevice), - config_(cameraDevice->cameraConfiguration()), type_(type), - camera3Stream_(camera3Stream), index_(index) + config_(cameraDevice->cameraConfiguration()), + type_(type), camera3Stream_(camera3Stream), index_(index) { - if (type_ == Type::Internal || type_ == Type::Mapped) { - /* - * \todo There might be multiple post-processors. The logic - * which should be instantiated here, is deferred for the - * future. For now, we only have PostProcessorJpeg and that - * is what we instantiate here. - */ - postProcessor_ = std::make_unique(cameraDevice_); - } - if (type == Type::Internal) { allocator_ = std::make_unique(cameraDevice_->camera()); mutex_ = std::make_unique(); @@ -70,15 +61,9 @@ Stream *CameraStream::stream() const return configuration().stream(); } -int CameraStream::configure() +int CameraStream::configure(std::unique_ptr postProcessor) { - if (postProcessor_) { - StreamConfiguration output = configuration(); - output.pixelFormat = formats::MJPEG; - int ret = postProcessor_->configure(configuration(), output); - if (ret) - return ret; - } + postProcessor_ = std::move(postProcessor); if (allocator_) { int ret = allocator_->allocate(stream()); diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index fc242b2a..faafc934 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -118,7 +118,7 @@ public: const libcamera::StreamConfiguration &configuration() const; libcamera::Stream *stream() const; - int configure(); + int configure(std::unique_ptr postProcessor); int process(const libcamera::FrameBuffer &source, libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata,