From patchwork Wed Jun 22 12:37:05 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: 16315 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 242F6BE173 for ; Wed, 22 Jun 2022 12:37:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D97BF65638; Wed, 22 Jun 2022 14:37:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655901453; bh=mGlCwGwC2Tp3XWmgWLv41jgNhgsHJMstwCRgfl1zO0M=; 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=E/T7ylWG/fWTo0phHBR2cB7thg+m+8LX+lCQZxk/AOlOrt6kIN3gKbkwTdY6VkIhp FgmaCynClFCMAdznXj6E77QvsRXWDxtI5ti7RGqpCG2jQh9S5FgUcXlSrDaeLMw125 9Bqubb6jWR61WejdupgXBMOgVf3B2w5VcZXubw/dr91Obr63uApubluk+GcFZmOEXF Mbc3UgfTAIhcv8DnMlPkhERmrbTGCNHNPAGtkUm7s4cvoTQ9GI1dweGhFO+LJ0zkrP Fo939pPnI6PmT3RCozADCsqloP0sZzL2fKYtD2B7SevEK3yTcwkUL6pc0vt1+TE9FC nB5GX9Mwo45XQ== 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 B9F93633A7 for ; Wed, 22 Jun 2022 14:37:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="iDZ157Pn"; dkim-atps=neutral Received: by mail-pf1-x431.google.com with SMTP id p14so10299623pfh.6 for ; Wed, 22 Jun 2022 05:37:32 -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=0BLlbRlkKi+qUNRpBngyDWy4oL4WYowVOHPmHfeu/qc=; b=iDZ157Pn7ajJMdFASJcTGyS6KiALaZ689IMRmB1XalWi50CY/vj5/ww16L8hSzg1Oi bYTrZ7xDlNitxrCAakcr0WgxxqPHEULkRUq2AEeyhY+QlZRsPzuOfAgWZaSRTc/arHV7 O/vXAGSTrPOxRFeCnjxeR8HX5nvWAIfhxGtJs= 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=0BLlbRlkKi+qUNRpBngyDWy4oL4WYowVOHPmHfeu/qc=; b=vzDuB4dggF1lbyyVbK0TIChrmSpoKHTwsxHfFDrPU0OI7SDX4GcPTQyOs7vaOvO23x RNPcAplIDKBUvknGbVxoM2RqGPd09EspvaxUocd8mvFekW1ZQ9mxNJGuGTLt6y8+Ln5+ N/olDYhw4zVFF74WwY1heO+G7yYtE9nHAtiuZ2/nJHhjV1hZNsyW5JaZ6Zhbz6i1CYZc JZFwAHmqQkw2Ku1qrMuJJ7ZNVu4nc15gnoxAf7aue/Bg5AoDEBwG4T5TCoMjciNMsuiY 2N+hOyA+jRB4/hpikwV25Gl39b1RUbF0jtnqoZD/EkEefvRNYvqwB/UOlAzQtFN9n4dG p/yA== X-Gm-Message-State: AJIora/+nnmf5lyhSaW+EwqV9qPAAiZj9LsfQVSE70nr6t3v83HNOQUw Ve+A8rNY11JEcdmjD0iL8bWPfZT8WaLtig== X-Google-Smtp-Source: AGRyM1sqIbL3uqr98/BKXd3qIl/1Cr/9cCnfaLkMo03J7ZXvhGgKd2Gp9JdPKTLFRatY090WeGVyRw== X-Received: by 2002:a05:6a00:996:b0:505:b6d2:abc8 with SMTP id u22-20020a056a00099600b00505b6d2abc8mr35265989pfg.11.1655901450837; Wed, 22 Jun 2022 05:37:30 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (21.160.199.104.bc.googleusercontent.com. [104.199.160.21]) by smtp.gmail.com with ESMTPSA id j3-20020a170903024300b0016378bfeb90sm12684038plh.227.2022.06.22.05.37.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 05:37:28 -0700 (PDT) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Wed, 22 Jun 2022 12:37:05 +0000 Message-Id: <20220622123706.2946976-6-chenghaoyang@google.com> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622123706.2946976-1-chenghaoyang@google.com> References: <20220622123706.2946976-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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: 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 --- 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);