From patchwork Thu Jan 21 10:15:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 10918 X-Patchwork-Delegate: paul.elder@ideasonboard.com 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 4614AC0F2A for ; Thu, 21 Jan 2021 10:16:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0E3F1681DB; Thu, 21 Jan 2021 11:16:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="f1kl0s6Z"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 86728681BF for ; Thu, 21 Jan 2021 11:16:13 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1317250E; Thu, 21 Jan 2021 11:16:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1611224173; bh=F/tN+HFLOCrpsc36gpPO2GSxl8oIkGUu1Uzx1eMt0PY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f1kl0s6Zy4ubzYKguFA0mr5PrcncH/gh3n86GvjdwI+t1MN+ZVeBIeTADVVlM14oc pxGKCytpozv1ADx1L7gxXaX+f8DQ685bCyR+x7JYfCWirdz7korpButL+OylA1Qv+5 0ogRSVp7/1RrquzXIfmhDNC++M4fzVsUjz4ooGdc= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 21 Jan 2021 19:15:46 +0900 Message-Id: <20210121101549.134574-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210121101549.134574-1-paul.elder@ideasonboard.com> References: <20210121101549.134574-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/9] android: jpeg: Factor out thumbnailer configuration 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" Move configuration of the thumbnailer into a function so that it can be called later in post-processing if a different size thumbnail is requested. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- New in v2 --- src/android/jpeg/post_processor_jpeg.cpp | 26 ++++++++++++++++-------- src/android/jpeg/post_processor_jpeg.h | 2 ++ src/android/jpeg/thumbnailer.h | 1 + 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 436a50f8..0c1226ad 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -25,6 +25,21 @@ PostProcessorJpeg::PostProcessorJpeg(CameraDevice *const device) { } +int PostProcessorJpeg::configureThumbnailer(const Size &size, + const PixelFormat &pixelFormat) +{ + thumbnailer_.configure(size, pixelFormat); + StreamConfiguration thCfg; + thCfg.size = thumbnailer_.size(); + thCfg.pixelFormat = pixelFormat; + if (thumbnailEncoder_.configure(thCfg) != 0) { + LOG(JPEG, Error) << "Failed to configure thumbnail encoder"; + return -EINVAL; + } + + return 0; +} + int PostProcessorJpeg::configure(const StreamConfiguration &inCfg, const StreamConfiguration &outCfg) { @@ -40,16 +55,11 @@ int PostProcessorJpeg::configure(const StreamConfiguration &inCfg, streamSize_ = outCfg.size; - thumbnailer_.configure(inCfg.size, inCfg.pixelFormat); - StreamConfiguration thCfg = inCfg; - thCfg.size = thumbnailer_.size(); - if (thumbnailEncoder_.configure(thCfg) != 0) { - LOG(JPEG, Error) << "Failed to configure thumbnail encoder"; - return -EINVAL; - } + int ret = configureThumbnailer(inCfg.size, inCfg.pixelFormat); + if (ret) + return ret; encoder_ = std::make_unique(); - return encoder_->configure(inCfg); } diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h index 5afa831c..c545c29c 100644 --- a/src/android/jpeg/post_processor_jpeg.h +++ b/src/android/jpeg/post_processor_jpeg.h @@ -31,6 +31,8 @@ public: private: void generateThumbnail(const libcamera::FrameBuffer &source, std::vector *thumbnail); + int configureThumbnailer(const libcamera::Size &size, + const libcamera::PixelFormat &pixelFormat); CameraDevice *const cameraDevice_; std::unique_ptr encoder_; diff --git a/src/android/jpeg/thumbnailer.h b/src/android/jpeg/thumbnailer.h index 98f11833..f393db47 100644 --- a/src/android/jpeg/thumbnailer.h +++ b/src/android/jpeg/thumbnailer.h @@ -22,6 +22,7 @@ public: void createThumbnail(const libcamera::FrameBuffer &source, std::vector *dest); const libcamera::Size &size() const { return targetSize_; } + const libcamera::PixelFormat &pixelFormat() const { return pixelFormat_; } private: libcamera::Size computeThumbnailSize() const;