From patchwork Wed Dec 14 09:33:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 18007 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 326FABDE6B for ; Wed, 14 Dec 2022 09:33:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D7D976336F; Wed, 14 Dec 2022 10:33:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1671010425; bh=ErYqdVqhpoIWvbfYMXa+CbV5cQYoYhOzBhpewCex/m4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=NHqDZskY12GUYOoR4P+uPUkJt7/G9bXosX3LDtCd/QKCu7wfJkBdrqs7zQv1t9GYo T72Hv33exRrY7NMUmFuHruRV/MWqA1WC70999/FGHh393C/gCKO0loxfbjzDCMFRs+ K1XU8fgMrfFw+ucIaBzBVZV8GLE1NFk9TVzwHWNm0NLKg3KTN0n6m/Zbp5OpTK9CYq VoMUWIO3gnvkl6PZlYleF9eHRMXLmVZLYMDORRi8iCI/xCxBMFXYTSFfYL04+MduLT gbcHSo7rvXj3N/qf7gZB2o8V/eVakV/yU0cR/KwG5j4Xpl8ak+Ylh+auEg1mJy06CF 8zL1FvFdF+SpA== Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7C1D563354 for ; Wed, 14 Dec 2022 10:33:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="P22vYc12"; dkim-atps=neutral Received: by mail-pf1-x431.google.com with SMTP id c13so4034127pfp.5 for ; Wed, 14 Dec 2022 01:33:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CIUd5dIW+pI9vncdTZ/Ndg5zNWGbOMPW6DkXVoCZ9fs=; b=P22vYc12tNyzMa96G5KqFVK0/9aShLHGaN77uir3sUDemS86T9PQ+DYHweZrxz4tW+ nWLS9uZ1oYOc5bspRitbFCmAZ0ukMf4OgZgzPFpIh9jmvniCK3oz+MZZ71PERDgTAvR/ ck6t0NNzpe+aNqb0Ldf9htH3AZ71I3Eyb+uto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CIUd5dIW+pI9vncdTZ/Ndg5zNWGbOMPW6DkXVoCZ9fs=; b=T536iwseWzRoWArKImAzeMmYfCAUdwGcDPz5xYYKYT8we4aC34a8MVzzXyPEs6/zoL QtFjXv37nlTZdUjU0kzGZz66LECCKOk/jPS2BUjFbXy5fPPNsPcapLS5sdFwE5oW2WDZ tFH8bpCmOxX9yT2w9EP7FbDPN7XQvCmBtm2WrnvTeUoQa/vcFJi1M1cHPEyJgEm4HhUb sWBBMTlwUiwsnOJIivbeR27+6xabgSML0qIioboZyN9hi9qUdzoOUMrnIwKg7NUYIrvM CvwyJTo3Al1ubxceXU0rdU78voHcGsEtZEcMajmsW2CZfYiSqLcpHAjQhB4TrQ0z19J7 8TIA== X-Gm-Message-State: ANoB5pnowwa3xT5dFAWxNzu2vCY4sT7ln4LuA9EIdJxszYiUIHbpxLjE K95zVKjfn8akxELaBke9JWdL3OeshHirrxYV X-Google-Smtp-Source: AA0mqf77AKt91V2l9Qmt+86ma6CxOW6asst5g2GS2besj7UoMmt7N1AG99x25J9MY3932apqJ1us5g== X-Received: by 2002:aa7:8e4c:0:b0:56b:7b9f:5cb6 with SMTP id d12-20020aa78e4c000000b0056b7b9f5cb6mr24251268pfr.19.1671010421924; Wed, 14 Dec 2022 01:33:41 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (46.165.189.35.bc.googleusercontent.com. [35.189.165.46]) by smtp.gmail.com with ESMTPSA id d206-20020a621dd7000000b0056bc742d21esm9331190pfd.176.2022.12.14.01.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 01:33:41 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Wed, 14 Dec 2022 09:33:29 +0000 Message-Id: <20221214093330.3345421-7-chenghaoyang@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog In-Reply-To: <20221214093330.3345421-1-chenghaoyang@google.com> References: <20221214093330.3345421-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 6/7] Pass StreamBuffer to Encoder::encoder 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: , X-Patchwork-Original-From: Harvey Yang via libcamera-devel From: Cheng-Hao Yang Reply-To: Harvey Yang Cc: Harvey Yang Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Harvey Yang To prepare for the JEA encoder in the following patches, StreamBuffer is passed to Encoder::encoder, which contains the original FrameBuffer and Span |destination|. Signed-off-by: Harvey Yang Reviewed-by: Laurent Pinchart Reviewed-by: Han-Lin Chen Reviewed-by: Laurent Pinchart --- src/android/jpeg/encoder.h | 5 +++-- src/android/jpeg/encoder_libjpeg.cpp | 11 +++++++---- src/android/jpeg/encoder_libjpeg.h | 3 +-- src/android/jpeg/post_processor_jpeg.cpp | 3 +-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h index 5f9ef890..14b1ab45 100644 --- a/src/android/jpeg/encoder.h +++ b/src/android/jpeg/encoder.h @@ -12,14 +12,15 @@ #include #include +#include "../camera_request.h" + class Encoder { public: virtual ~Encoder() = default; virtual int configure(const libcamera::StreamConfiguration &cfg) = 0; - virtual int encode(const libcamera::FrameBuffer &source, - libcamera::Span destination, + virtual int encode(Camera3RequestDescriptor::StreamBuffer *streamBuffer, libcamera::Span exifData, unsigned int quality) = 0; virtual void generateThumbnail(const libcamera::FrameBuffer &source, diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp index cc5f37be..8bbba6e0 100644 --- a/src/android/jpeg/encoder_libjpeg.cpp +++ b/src/android/jpeg/encoder_libjpeg.cpp @@ -24,6 +24,8 @@ #include "libcamera/internal/formats.h" #include "libcamera/internal/mapped_framebuffer.h" +#include "../camera_buffer.h" + using namespace libcamera; LOG_DECLARE_CATEGORY(JPEG) @@ -187,17 +189,18 @@ void EncoderLibJpeg::Encoder::compressNV(const std::vector> &plane } } -int EncoderLibJpeg::encode(const FrameBuffer &source, Span dest, - Span exifData, unsigned int quality) +int EncoderLibJpeg::encode(Camera3RequestDescriptor::StreamBuffer *streamBuffer, + libcamera::Span exifData, + unsigned int quality) { - MappedFrameBuffer frame(&source, MappedFrameBuffer::MapFlag::Read); + MappedFrameBuffer frame(streamBuffer->srcBuffer, MappedFrameBuffer::MapFlag::Read); if (!frame.isValid()) { LOG(JPEG, Error) << "Failed to map FrameBuffer : " << strerror(frame.error()); return frame.error(); } - return captureEncoder_.encode(frame.planes(), dest, exifData, quality); + return captureEncoder_.encode(frame.planes(), streamBuffer->dstBuffer->plane(0), exifData, quality); } void EncoderLibJpeg::generateThumbnail(const libcamera::FrameBuffer &source, diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h index fa077b8d..f4bf99ba 100644 --- a/src/android/jpeg/encoder_libjpeg.h +++ b/src/android/jpeg/encoder_libjpeg.h @@ -24,8 +24,7 @@ public: ~EncoderLibJpeg(); int configure(const libcamera::StreamConfiguration &cfg) override; - int encode(const libcamera::FrameBuffer &source, - libcamera::Span destination, + int encode(Camera3RequestDescriptor::StreamBuffer *streamBuffer, libcamera::Span exifData, unsigned int quality) override; void generateThumbnail(const libcamera::FrameBuffer &source, diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 69b18a2e..918ab492 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -146,8 +146,7 @@ void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBu const uint8_t quality = ret ? *entry.data.u8 : 95; resultMetadata->addEntry(ANDROID_JPEG_QUALITY, quality); - int jpeg_size = encoder_->encode(source, destination->plane(0), - exif.data(), quality); + int jpeg_size = encoder_->encode(streamBuffer, exif.data(), quality); if (jpeg_size < 0) { LOG(JPEG, Error) << "Failed to encode stream image"; processComplete.emit(streamBuffer, PostProcessor::Status::Error);