From patchwork Thu Apr 28 09:55:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 15747 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 5F04EC3256 for ; Thu, 28 Apr 2022 09:56:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1FA3265657; Thu, 28 Apr 2022 11:56:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1651139766; bh=29NvjNNGYmp4T2wEstIfpQt73wZ5u1ezQfoHG255vRE=; 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=tzj3TwSVDCeZSEzCabm3mYCB5qB36zXDumapquwLZ2bOml3/CmWdUVSQ1/w5GrciA qOoScNNldkhT0nsENII3mFP8DUa47JH9SKV7VlF1vysIFkcJscNpNZcum2sY5TvLgZ sN8IUunSWzPCeL568H92ocbZdfS1g78wzf43z+LIf8RkjZN91kXmo/gyZkfGSQsExj BpPICbK4FY2q48Mjsj2IfVtyIdpRhbHvz1/UusCGhb5vrlGXf7mJsdNeJ1cDcPGxWf alzdY6kIOH7kbN9BUgl6ccVScTqqr3mJvYycHQt5xghms27KPvJQF+71LxjdjEYXIf i1FJhwlhgXmpQ== Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9FEB065643 for ; Thu, 28 Apr 2022 11:56:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Cjz+owoy"; dkim-atps=neutral Received: by mail-pl1-x62e.google.com with SMTP id n18so3900306plg.5 for ; Thu, 28 Apr 2022 02:56:03 -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=WjtlR5sTJO49edn+9TX/1f+nmLNOmaXlAscT0oLbJpM=; b=Cjz+owoyPrF45cRDmgzlgRXv/hQDLJ9enzBKJhpnO5pMWu8ztBupwxOhtdxc6EhopV Tovhu+9gDECpVlve8a1XOl5BRJTDQ90AhYcjB2s4e44lhGqZf3h/NI/05nBCF6WTRVtI 8GefPFVXgzV1r7FKeE8MtLZzo7iwcMbd5iNmo= 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=WjtlR5sTJO49edn+9TX/1f+nmLNOmaXlAscT0oLbJpM=; b=Klt4ob7w889wptCPg8jPxD6orDZ0rlmoiTrUwuI6MQaUhbgif1SL7bwX8/azoigu/p A83l58bResVJ5uvqXuqRpgrI1xG/S0QxluofxQw05a0LC/XjYavA2zQKSYnme7O0pOSL GfwSuDQtMcbu8465yVlb+jcVuiGT75TmUBBMW+RAS3z/YOZ5upl6AGEGvcPGYFGQ5BkZ s4JCKRuT3sYQuK/WwRVqBj+DS4isF4gDA9ISuwj6bgSRL0m1KOsza2VQTH6umjPSE3Kr R8SFyc3vgwikHK96/YHQ2BMW8pkHC5BlagO7Sk4Eq4JV+g8n2u6TjBF+NxHI1s8fjzxE XPvw== X-Gm-Message-State: AOAM531Ctlzs8tArx59j/3awkPDPLZ3fyiFVuyD8/4dxcHEYqANI3q1F 4IMTF9SJ1+iLlC/rx1ANkPRNw4OhgeMqO2NR X-Google-Smtp-Source: ABdhPJzyiQJPLj4aVDXCI6iAwM7D/Jl1zCwDdfEgb8wsGYmJKu19aUxrT0bxbF5Bd1J3bTBY4iG45Q== X-Received: by 2002:a17:902:9307:b0:154:78ba:ed40 with SMTP id bc7-20020a170902930700b0015478baed40mr33303613plb.92.1651139761860; Thu, 28 Apr 2022 02:56:01 -0700 (PDT) Received: from chenghaoyang.c.googlers.com.com (93.135.240.35.bc.googleusercontent.com. [35.240.135.93]) by smtp.gmail.com with ESMTPSA id x6-20020a17090a46c600b001d960eaed66sm5861256pjg.42.2022.04.28.02.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 02:56:01 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Apr 2022 09:55:43 +0000 Message-Id: <20220428095544.2795980-6-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog In-Reply-To: <20220428095544.2795980-1-chenghaoyang@chromium.org> References: <20220428095544.2795980-1-chenghaoyang@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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" 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 e76947d7..9237fa12 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 d9a20b67..2ec0a311 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) @@ -189,6 +191,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, diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h index 7b6131a4..5d94df3a 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( @@ -38,6 +37,10 @@ private: int configureEncoder(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 332ce1ca..ed85bd48 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);