From patchwork Wed Feb 8 03:33:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 18265 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 DD389C329C for ; Wed, 8 Feb 2023 03:33:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E636C62600; Wed, 8 Feb 2023 04:33:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675827212; bh=+1QMbgog0McBeYlDQqZ1rFZC+2X8Dp1lA5jIT8JOnmU=; 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=1h7Stj6htVAcGhpiR6QfPOzHdMk9kp6+f7BbCzNwqUsMjxqWTTXdH+gYVykZ79GDh 0oW5hsBA7d4v0/pzepZwQr4iLmhasf/t6/ciq0pg79P/LB9D0i2l7q0vQPLDWYBOjS elEjGxRzeV0uqiRWnHjxB4GPgQc4ckyT3M2+Iap4w2H/VFTj+gETMDTEvByeUW/60v NtxIiuuz0OmZUvq/fPZtGtG/f39riWzUDjBSiTWo0AzOGYIwL+bvk0TNP3v6UTLFpe t8eGx5BZyquA9v2kAaAI5IjX8lxgmGTCGxF9aEM+NU/MDBWvn3FLEouKxDrp71Ct0L N8sbnokYoZHyg== Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DF98625FD for ; Wed, 8 Feb 2023 04:33:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="RLx6EUhc"; dkim-atps=neutral Received: by mail-pj1-x102c.google.com with SMTP id gj9-20020a17090b108900b0023114156d36so498795pjb.4 for ; Tue, 07 Feb 2023 19:33:30 -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=wOi0iKwB5gRf/Y6naVY3wB0RYT3HDL7p4zqQoBj0Kbw=; b=RLx6EUhckO5zHJHVBeUf+RjojhX1QjRtBA1VM3sScYr+YFE/lPNhcZMRjt/v6OzskZ 9NToK+7pSCnv3IweoaX+OBonRdSsRRlZreSkzqqgm9iUIdf3CUanbl7c456QFyCIHZwU xyKzLlE3b1tSk+PFV2FoRV7I9KDZ9HK9NDeR4= 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=wOi0iKwB5gRf/Y6naVY3wB0RYT3HDL7p4zqQoBj0Kbw=; b=At0UWk6h9Wu/mdL29Z9YlhsjeeZgULsBvllmOtVhcyF0ozrpzFHcH1yk+qlv15R3+b 6q4MHvYOubVFyCL5SEr+cgX8qn5S7cc6AVtnvsvtFOQxsVuQU2YbWK+4PIaqjjuw4AOm qQmDQHjSuqNvVN9YLSL6PwgEjpc+Kw9tOlOWo3DWkFME8BzcoU1mQ+C/cRQl1LaKoIkz 0CZ2F8GYW2DNK04oiHxjlADxAZ8fyelYAbOIj1mUtkPdDY7hg8EBKFE7c8+Vvq5+hgA0 4uuor0eHZHfowCOgprevvKaIHL7s7QAaUE6/eVAszBsae3Ks24ON6wnd+KEmottTLycx YmTw== X-Gm-Message-State: AO0yUKUwFx3ao81zL6TrXPG0W9Pha/RK2KzH+8ZqulVfFuV0QrRH63cF X9i+1QyY6C8KSPeIKyEOxp4Mfc4l0IxUKSoT X-Google-Smtp-Source: AK7set/sdQjao30nyrWtEj6yPogVXvcMiJMOhmAxNt4WAFfUrrewzipv+siSyw3Vb7vOyYSlPvL+9g== X-Received: by 2002:a17:902:7c11:b0:196:6296:60e8 with SMTP id x17-20020a1709027c1100b00196629660e8mr4967342pll.45.1675827209776; Tue, 07 Feb 2023 19:33:29 -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 e9-20020a170902784900b00194c82c2a7bsm9621963pln.224.2023.02.07.19.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 19:33:29 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Feb 2023 03:33:18 +0000 Message-Id: <20230208033319.1361109-5-chenghaoyang@google.com> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230208033319.1361109-1-chenghaoyang@google.com> References: <20230208033319.1361109-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v10 4/5] android: jpeg: 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 support of the JEA encoder in a following commit, which will need to access the buffer_handle_t of the destination buffer, pass the StreamBuffer to the Encoder::encoder() function. As the StreamBuffer contains the source FrameBuffer and the destination Span, drop them from the function arguments and access them directly from the StreamBuffer. Signed-off-by: Harvey Yang Reviewed-by: Laurent Pinchart Reviewed-by: Han-Lin Chen Signed-off-by: Laurent Pinchart --- src/android/jpeg/encoder.h | 5 +++-- src/android/jpeg/encoder_libjpeg.cpp | 13 +++++++++---- src/android/jpeg/encoder_libjpeg.h | 3 +-- src/android/jpeg/post_processor_jpeg.cpp | 3 +-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h index b974d367..31f26895 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 *buffer, libcamera::Span exifData, unsigned int quality) = 0; }; diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp index fd62bd9c..f4e8dfad 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) @@ -178,17 +180,20 @@ void EncoderLibJpeg::compressNV(const std::vector> &planes) } } -int EncoderLibJpeg::encode(const FrameBuffer &source, Span dest, - Span exifData, unsigned int quality) +int EncoderLibJpeg::encode(Camera3RequestDescriptor::StreamBuffer *buffer, + libcamera::Span exifData, + unsigned int quality) { - MappedFrameBuffer frame(&source, MappedFrameBuffer::MapFlag::Read); + MappedFrameBuffer frame(buffer->srcBuffer, + MappedFrameBuffer::MapFlag::Read); if (!frame.isValid()) { LOG(JPEG, Error) << "Failed to map FrameBuffer : " << strerror(frame.error()); return frame.error(); } - return encode(frame.planes(), dest, exifData, quality); + return encode(frame.planes(), buffer->dstBuffer->plane(0), + exifData, quality); } int EncoderLibJpeg::encode(const std::vector> &src, diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h index 1b3ac067..146a6a72 100644 --- a/src/android/jpeg/encoder_libjpeg.h +++ b/src/android/jpeg/encoder_libjpeg.h @@ -22,8 +22,7 @@ public: ~EncoderLibJpeg(); int configure(const libcamera::StreamConfiguration &cfg) override; - int encode(const libcamera::FrameBuffer &source, - libcamera::Span destination, + int encode(Camera3RequestDescriptor::StreamBuffer *buffer, libcamera::Span exifData, unsigned int quality) override; int encode(const std::vector> &planes, diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 0cf56716..3e676eb4 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -194,8 +194,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);