From patchwork Fri Jul 15 14:38:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 16652 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 09CF2BE173 for ; Fri, 15 Jul 2022 14:38:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BEC1063323; Fri, 15 Jul 2022 16:38:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657895918; bh=hQa8WRuP5e9bgD2QWc7olwSVRjpi725avTwwpIqeT5E=; 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=zHa5hgomvfgmxIZr8g/IGUA58jt2ApIjhFXftRRHvVIeS6X7OvHIxnWuQ0621Vwc5 V4AS0NqoNaf7IAcnEMRNtwCPqffmDLbMFPzMLYXz2U5x38Xv4kqEX4taBgSLL/+qmT xhCYxKUClAXE7fA2oid7weAjcg06Z0O1tXXH7OE8w/34DMw+4HADGOkNtKLUhdHt7X G1XyYqt/Ce2Be6cbeVlrWeI0zGvOz2dVhiq50vmEE61B7fMiSdcj2nvtuU2VX3ZdnH rvCIzphBFcCg+bIly2P3SILRHZCBueREsIP1Lo92OEGQsSkZ/hZhNH3FgcqhrBW0ny Ch4G4ybyHOmcw== Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3338863314 for ; Fri, 15 Jul 2022 16:38:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PampK83W"; dkim-atps=neutral Received: by mail-pl1-x633.google.com with SMTP id w7so3387252ply.12 for ; Fri, 15 Jul 2022 07:38:37 -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=ii+FPsv/XZLZ2VlFspzT14QmUpMBQRSpGB3GPYL3Lss=; b=PampK83W+XTn2jShIbBg5cp0W8E60n8jB1W0F/XdKeVlXOrV+2HoulnJiXtoE0JAck UJpA7NUfOMwoI54x6cgIQn5j+BBOrzrGMYIQtsY6oKJTUF0Zp2cEh2N4qcNHNSaapoFs aEEyt3C4HJUDzMi8cbHbUmlF0qF5D3xAC4SnA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ii+FPsv/XZLZ2VlFspzT14QmUpMBQRSpGB3GPYL3Lss=; b=dn8b9U65P5lc5KwQbMr9uVklsUKcrDbT/CEHvkXnQaf7NcC+3e16u0pb+4yx4aLcBn hSZu/zNwCB8Hap+GsgLuOtlQGqh5gvXMeP3cc0p0dLKvhPVrAULF9SilR7yAmkqIaO4T aYgpjCJa6c68eavmLvFk9Dimu2EPitA7VNwScfxWw04RP/ETw1BYIIhlTDhKT2Xj2tuh eP6DSZeYKu9BwHtFhQAPfDej1d4cs7vUm7Z+lHhYOluhoXCMmkFB5FNX+2Gq/ucYzMSc 7O5BFMV25hcSssDzUNoGj81oZCrR5PPL/i5rOTPVU0kuKb1j9mJP3UF+AZNsUu4ZNO6S N5vw== X-Gm-Message-State: AJIora9bDmbduAANMOE09wewuwF74pc4SqUgIXlOlKiqu3XXCW0wV/aS 8FLy+wIyrxSxg5YBrv/sckkSCr2ZDdZiAQ== X-Google-Smtp-Source: AGRyM1uSeJs03FaRp5Om/f8QbRDMuJQ2yRZ2ECZxmruKfd3HnLAiShMjEimzNdyuKFzOOSwf/jPmsA== X-Received: by 2002:a17:90a:ba97:b0:1ef:91ab:de1e with SMTP id t23-20020a17090aba9700b001ef91abde1emr16128645pjr.237.1657895915375; Fri, 15 Jul 2022 07:38:35 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (208.158.221.35.bc.googleusercontent.com. [35.221.158.208]) by smtp.gmail.com with ESMTPSA id f15-20020aa7968f000000b00528c22fbb45sm3972782pfk.141.2022.07.15.07.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 07:38:34 -0700 (PDT) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Fri, 15 Jul 2022 14:38:21 +0000 Message-Id: <20220715143822.672321-6-chenghaoyang@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog In-Reply-To: <20220715143822.672321-1-chenghaoyang@google.com> References: <20220715143822.672321-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 5/6] 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: Harvey 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 --- src/android/jpeg/encoder.h | 5 +++-- src/android/jpeg/encoder_libjpeg.cpp | 11 +++++++++++ src/android/jpeg/encoder_libjpeg.h | 7 +++++-- src/android/jpeg/post_processor_jpeg.cpp | 3 +-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h index 7dc1ee27..eeff87b1 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 int generateThumbnail( diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp index e0aca821..b61453f8 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) @@ -192,6 +194,15 @@ void EncoderLibJpeg::compressNV(const std::vector> &planes) } } +int EncoderLibJpeg::encode(Camera3RequestDescriptor::StreamBuffer *streamBuffer, + libcamera::Span exifData, + unsigned int quality) +{ + return encode(*streamBuffer->srcBuffer, + streamBuffer->dstBuffer.get()->plane(0), exifData, + quality); +} + int EncoderLibJpeg::generateThumbnail(const libcamera::FrameBuffer &source, const libcamera::Size &targetSize, unsigned int quality, diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h index 1ec2ba13..6e9b65d4 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; int generateThumbnail( @@ -44,6 +43,10 @@ private: libcamera::PixelFormat pixelFormat, libcamera::Size size); + int encode(const libcamera::FrameBuffer &source, + libcamera::Span destination, + libcamera::Span exifData, + unsigned int quality); int encode(const std::vector> &planes, libcamera::Span destination, libcamera::Span exifData, diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 233cdedb..a1555048 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);