From patchwork Wed Feb 8 03:33:15 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: 18262 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 AD677BEFBE for ; Wed, 8 Feb 2023 03:33:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 60869625E3; Wed, 8 Feb 2023 04:33:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675827211; bh=nxQH6Fnf5tBxut2vw18X01WtPIl2E0cii2wz2Jf/Um4=; 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=prXhUb5kDJXz/rGncXmEON16ZyL2V1gRsBFThLIgd3KKz8FGzwG/FpSz+/0jj1Hjh 4ywTuYCMckt5gkBszzw1sDXNYAUnB+7TyQaqXH90lHDbCVPtDOHBT4267MbA4KEch9 m1KxNdsWOGi7+GCfxDJ4fREtIbbjskw2OudNPm4T8aLPTebT6SZH71b13XNswV/lMY v7JJ8BBY1ozOIaW+3gTo/25zGXWlnLaZWOwyQOxgMb3gam5Qnd1dH9x4FGH1pa3l0i rA4UJtLYOi57xl2CffM4ygnuCDc45Nfm7UqWqHFvOwQivRsqkWZkvwjYKupJwTay2D +EwDoiAREieVQ== Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 834DE603B8 for ; Wed, 8 Feb 2023 04:33:27 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="eR9sNZLc"; dkim-atps=neutral Received: by mail-pj1-x1029.google.com with SMTP id c10-20020a17090a1d0a00b0022e63a94799so956473pjd.2 for ; Tue, 07 Feb 2023 19:33:27 -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=skPLhBnh3iLkI1XSxbHLlMVG/RIJVEbJWy1VZEFkv5k=; b=eR9sNZLc3Pci1i+5nAJUKp6IMtLL6mmh7fs96nxWUbe+z0Zw4OVx7rjYWEuuPXJ744 wycRT9Lih+SMumFGnHMo0vTWUA73fcaymZFhh1A/7ZxGRpJn9dWq2kWAfErAv0dFlJVN FquZMbSov5ONLUsPzB9B6U6O3W/VrMdIFTrKI= 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=skPLhBnh3iLkI1XSxbHLlMVG/RIJVEbJWy1VZEFkv5k=; b=o/WjIi08JkRVTWsMTlBtG0ZyK4A9x/abVzD6ZRk8Ig4cdUcBelWWFSJlJ7nfFZbUwH ZZTNvs7O1wX7SouP5INFDD+uFPO1mdu7vKdiPEZXC4tzE5eBQaznQipL+j1c+KEIJ0gW CwE/OO20jN5Ukn0yk9cuIIWEwBJ99i3s+cM8L96hNmUe+5JsiNBJzrwfMOGao4KK+ap4 ByFC9Fr6lEZ4D0QFh4iPuFSnkEv4hvWgXIjKlDHTIix/ONGeB30zqe4sg+dB38YlWcKC r1UgWTBVbFh3kOQgajaQvp32PLJCUtWd/m5To7T6Dc1C0yemGg1oMjDWZIiivoGqtwte KbPA== X-Gm-Message-State: AO0yUKUJtpBbdU8GlIcbXPY/tLSaq6X+KIxyUmZeocqcgdGZJUH57yBx 1XBal3RAF83A09ubZNBYBkvmioo3L2ufHGFE X-Google-Smtp-Source: AK7set9pHY4IlquhrjWGH1dNJRVIjmJLgFnfFKW2xoUSMMqD8obO3Hmm+9d1Mm+1O8d0I4JEEuLggQ== X-Received: by 2002:a17:902:ce86:b0:199:1375:279c with SMTP id f6-20020a170902ce8600b001991375279cmr5793585plg.69.1675827205703; Tue, 07 Feb 2023 19:33:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 19:33:25 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Feb 2023 03:33:15 +0000 Message-Id: <20230208033319.1361109-2-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 1/5] libcamera: framebuffer: Allow inheritance of FrameBuffer 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 add buffer_handle_t access in android, this patch allows inheritance of FrameBuffer to add a derived class in android. Signed-off-by: Harvey Yang Reviewed-by: Laurent Pinchart Reviewed-by: Han-Lin Chen Signed-off-by: Laurent Pinchart --- include/libcamera/framebuffer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 69553999..61244829 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -46,7 +46,7 @@ private: std::vector planes_; }; -class FrameBuffer final : public Extensible +class FrameBuffer : public Extensible { LIBCAMERA_DECLARE_PRIVATE() @@ -60,6 +60,7 @@ public: FrameBuffer(const std::vector &planes, unsigned int cookie = 0); FrameBuffer(std::unique_ptr d); + virtual ~FrameBuffer() {} const std::vector &planes() const; Request *request() const; From patchwork Wed Feb 8 03:33:16 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: 18263 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 A6938C324D for ; Wed, 8 Feb 2023 03:33:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CF90F62602; Wed, 8 Feb 2023 04:33:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675827211; bh=kfXCe6d0JENl0nWbN5zN6XjCdC6VmPsDqnb6LpuILsw=; 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=Wdv0y0Kfo+7Ogefn3JqBsZl8kQujwSC/g9uCdGRsEFPYMYHaSuzzZIvlMikVnqfHK SHBUD4486Y2iZY6itbs/8ELgs50NUlx9stgKQhXoMwRkb5tB8mpF/oH1PN6cc85CQ9 4fP9lkV0ELNCM7VAIP2YsDHiOXAd476SAIvp4YhBu6YmvQvm9f5cOMIR8j8svdiGD6 hhjX7dBOnQgj5JrBkvIQcUzQ+qFJ4OaDemkBDLKqJGnWnJVg7+xlNKJkwCcPMe5EdC DodlIazxtNHTvcI8qL8jvd5/AsZjq482Jl15qCIpmbtoun2sqYvSaxR9E1ANfH3C+C pBVeyxqdRnApw== Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A2FE8603B8 for ; Wed, 8 Feb 2023 04:33:28 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="TPIvGXMX"; dkim-atps=neutral Received: by mail-pl1-x62a.google.com with SMTP id w5so7841818plg.8 for ; Tue, 07 Feb 2023 19:33:28 -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=z/t7H/Omk/nheHrPMv8hRot19I4ehunO7Rb/xDqKUhE=; b=TPIvGXMXcadtvb5NTgh/TEUkqyqO/zp+QjTZy3NhMlRtPIcZ4Yo3CNwFq+OZTryJS6 L3cgB2GMHMcPTphy4vob57YKkc0F6DVAbA5xcU6guUovzICJwQoputlxp+vpDdjxZ8BP Vo+V/mfXLAfqom1WZQiBhpkCelFpYAArmO+2U= 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=z/t7H/Omk/nheHrPMv8hRot19I4ehunO7Rb/xDqKUhE=; b=X9TRrlkISUYl51EYRglkv2OUYo07zurk+oX2lrlv2gwpXP3XvOyllL3cf1TSfCO9FE Z1zM1bByPF/bfTCywuSfkP4DuopATZ6aTuiEkWghWuu/ZotHXEVIUuWicWJfa40NtgFh UoW/eXE+KEhaBjlTDKT66n7ic4CeBOhG334JSRjk/f//QL9KS2A+2ziG5S7dYVAdU8Xn 2HqJaSiySU17sg3kJDBofw+jjvGYC8rHkMCLDyXYmy6zovg82iw5JAKDTr723m4l3T8F PL37kvjwaCnanRAkkh7JKAvOf6jyQCO3+Dp4XYRA7G64CFa4uISVaWQUA2nRoYU6qpo3 VjkQ== X-Gm-Message-State: AO0yUKUCEOdRKvq8umkdsKp5lws39DoUwpHiqOiVnUvUSg5W+kdTs+63 mGqh2dIkYwrySCGLKA76nsq5JURi214Uf/Ny X-Google-Smtp-Source: AK7set85Cdk3HUWAI9d4Kk00jonkpU5dXflWL+w+iNXTnBawtj6Tuq2SimcDoQpMZ7WeCl/SHFm6BQ== X-Received: by 2002:a17:902:dac7:b0:193:678:df13 with SMTP id q7-20020a170902dac700b001930678df13mr7043782plx.36.1675827207000; Tue, 07 Feb 2023 19:33:27 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 19:33:26 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Feb 2023 03:33:16 +0000 Message-Id: <20230208033319.1361109-3-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 2/5] android: framebuffer: Add HALFrameBuffer and replace FrameBuffer 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 HALFrameBuffer is derived from FrameBuffer with access to buffer_handle_t, which is needed for JEA usage. Signed-off-by: Harvey Yang Reviewed-by: Laurent Pinchart Reviewed-by: Han-Lin Chen Signed-off-by: Laurent Pinchart --- src/android/camera_device.cpp | 5 ++-- src/android/camera_device.h | 3 ++- src/android/camera_request.h | 3 ++- src/android/frame_buffer_allocator.h | 7 ++--- src/android/hal_framebuffer.cpp | 22 ++++++++++++++++ src/android/hal_framebuffer.h | 26 +++++++++++++++++++ src/android/meson.build | 1 + .../mm/cros_frame_buffer_allocator.cpp | 9 ++++--- .../mm/generic_frame_buffer_allocator.cpp | 11 +++++--- 9 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 src/android/hal_framebuffer.cpp create mode 100644 src/android/hal_framebuffer.h diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index b20e389b..1f7ce440 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -30,6 +30,7 @@ #include "camera_hal_config.h" #include "camera_ops.h" #include "camera_request.h" +#include "hal_framebuffer.h" using namespace libcamera; @@ -771,7 +772,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) return 0; } -std::unique_ptr +std::unique_ptr CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer, PixelFormat pixelFormat, const Size &size) { @@ -794,7 +795,7 @@ CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer, planes[i].length = buf.size(i); } - return std::make_unique(planes); + return std::make_unique(planes, camera3buffer); } int CameraDevice::processControls(Camera3RequestDescriptor *descriptor) diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 64050416..43ee0159 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -29,6 +29,7 @@ #include "camera_capabilities.h" #include "camera_metadata.h" #include "camera_stream.h" +#include "hal_framebuffer.h" #include "jpeg/encoder.h" class Camera3RequestDescriptor; @@ -83,7 +84,7 @@ private: void stop() LIBCAMERA_TSA_EXCLUDES(stateMutex_); - std::unique_ptr + std::unique_ptr createFrameBuffer(const buffer_handle_t camera3buffer, libcamera::PixelFormat pixelFormat, const libcamera::Size &size); diff --git a/src/android/camera_request.h b/src/android/camera_request.h index 37b6ae32..20aba79d 100644 --- a/src/android/camera_request.h +++ b/src/android/camera_request.h @@ -21,6 +21,7 @@ #include #include "camera_metadata.h" +#include "hal_framebuffer.h" class CameraBuffer; class CameraStream; @@ -44,7 +45,7 @@ public: CameraStream *stream; buffer_handle_t *camera3Buffer; - std::unique_ptr frameBuffer; + std::unique_ptr frameBuffer; libcamera::UniqueFD fence; Status status = Status::Success; libcamera::FrameBuffer *internalBuffer = nullptr; diff --git a/src/android/frame_buffer_allocator.h b/src/android/frame_buffer_allocator.h index 5d2eeda1..e5c94922 100644 --- a/src/android/frame_buffer_allocator.h +++ b/src/android/frame_buffer_allocator.h @@ -13,9 +13,10 @@ #include #include -#include #include +#include "hal_framebuffer.h" + class CameraDevice; class PlatformFrameBufferAllocator : libcamera::Extensible @@ -31,7 +32,7 @@ public: * Note: The returned FrameBuffer needs to be destroyed before * PlatformFrameBufferAllocator is destroyed. */ - std::unique_ptr allocate( + std::unique_ptr allocate( int halPixelFormat, const libcamera::Size &size, uint32_t usage); }; @@ -44,7 +45,7 @@ PlatformFrameBufferAllocator::PlatformFrameBufferAllocator( \ PlatformFrameBufferAllocator::~PlatformFrameBufferAllocator() \ { \ } \ -std::unique_ptr \ +std::unique_ptr \ PlatformFrameBufferAllocator::allocate(int halPixelFormat, \ const libcamera::Size &size, \ uint32_t usage) \ diff --git a/src/android/hal_framebuffer.cpp b/src/android/hal_framebuffer.cpp new file mode 100644 index 00000000..3f3d1ed1 --- /dev/null +++ b/src/android/hal_framebuffer.cpp @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * hal_framebuffer.cpp - HAL Frame Buffer Handling + */ + +#include "hal_framebuffer.h" + +#include + +HALFrameBuffer::HALFrameBuffer(std::unique_ptr d, + buffer_handle_t handle) + : FrameBuffer(std::move(d)), handle_(handle) +{ +} + +HALFrameBuffer::HALFrameBuffer(const std::vector &planes, + buffer_handle_t handle) + : FrameBuffer(planes), handle_(handle) +{ +} diff --git a/src/android/hal_framebuffer.h b/src/android/hal_framebuffer.h new file mode 100644 index 00000000..dc96a7e1 --- /dev/null +++ b/src/android/hal_framebuffer.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * hal_framebuffer.h - HAL Frame Buffer Handling + */ + +#pragma once + +#include "libcamera/internal/framebuffer.h" + +#include + +class HALFrameBuffer final : public libcamera::FrameBuffer +{ +public: + HALFrameBuffer(std::unique_ptr d, + buffer_handle_t handle); + HALFrameBuffer(const std::vector &planes, + buffer_handle_t handle); + + buffer_handle_t handle() const { return handle_; } + +private: + buffer_handle_t handle_; +}; diff --git a/src/android/meson.build b/src/android/meson.build index 1bba54de..b543c143 100644 --- a/src/android/meson.build +++ b/src/android/meson.build @@ -46,6 +46,7 @@ android_hal_sources = files([ 'camera_ops.cpp', 'camera_request.cpp', 'camera_stream.cpp', + 'hal_framebuffer.cpp', 'jpeg/encoder_libjpeg.cpp', 'jpeg/exif.cpp', 'jpeg/post_processor_jpeg.cpp', diff --git a/src/android/mm/cros_frame_buffer_allocator.cpp b/src/android/mm/cros_frame_buffer_allocator.cpp index 0665c77b..0a5c59f2 100644 --- a/src/android/mm/cros_frame_buffer_allocator.cpp +++ b/src/android/mm/cros_frame_buffer_allocator.cpp @@ -16,6 +16,7 @@ #include "../camera_device.h" #include "../frame_buffer_allocator.h" +#include "../hal_framebuffer.h" #include "cros-camera/camera_buffer_manager.h" using namespace libcamera; @@ -48,11 +49,11 @@ public: { } - std::unique_ptr + std::unique_ptr allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage); }; -std::unique_ptr +std::unique_ptr PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage) @@ -81,8 +82,8 @@ PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat, plane.length = cros::CameraBufferManager::GetPlaneSize(handle, i); } - return std::make_unique( - std::make_unique(std::move(scopedHandle), planes)); + return std::make_unique( + std::make_unique(std::move(scopedHandle), planes), handle); } PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp index 956623df..3750e1bf 100644 --- a/src/android/mm/generic_frame_buffer_allocator.cpp +++ b/src/android/mm/generic_frame_buffer_allocator.cpp @@ -20,6 +20,7 @@ #include "../camera_device.h" #include "../frame_buffer_allocator.h" +#include "../hal_framebuffer.h" using namespace libcamera; @@ -79,7 +80,7 @@ public: ~Private() override; - std::unique_ptr + std::unique_ptr allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage); private: @@ -94,7 +95,7 @@ PlatformFrameBufferAllocator::Private::~Private() gralloc_close(allocDevice_); } -std::unique_ptr +std::unique_ptr PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage) @@ -137,8 +138,10 @@ PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat, offset += planeSize; } - return std::make_unique( - std::make_unique(allocDevice_, handle, planes)); + return std::make_unique( + std::make_unique( + allocDevice_, handle, planes), + handle); } PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION From patchwork Wed Feb 8 03:33:17 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: 18264 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 7F65DBEFBE 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 56C7562605; 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=is26u44qZbTYnYWCbGDxhYeIbkonuhjVeavboSCbDyY=; 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=J0FzgIulbBRdSr/YROHPVMLh0eo2Qon/B912ZsrDAJGf2bPdWZLTtk/CmNz9T9/mD Hj0t9hu+hD/xi0qmCSVkDsQicHOqp98otjza65ByE3Rky0imGT/60aZTuutESXQDHf KB/ZqzCzSBWH65C91P6CpnErGMzWiDuelfir8D6rb36g3UDnX51d/CQ8XjAm3Bt6+d SWFJWlnqVh7OySlNF5k3RlDeicgqLIQdyqseqo47mtxOni/qLf3FJjF5eoKZH8v0yN 3cGTln+GJWxn+KqETCg39xSHj9A8Rnv6ARYeROfOcPaAWnge6W+MGvGLf3K2nEVR/u PRpC3CSim+Mxg== 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 D1185603B8 for ; Wed, 8 Feb 2023 04:33:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="D3129vmY"; dkim-atps=neutral Received: by mail-pj1-x102c.google.com with SMTP id gj9-20020a17090b108900b0023114156d36so498732pjb.4 for ; Tue, 07 Feb 2023 19:33:29 -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=gqT1DdXhAd7kSzHtFnM8/ldJvPrYwTgmzmRjeiHsmuU=; b=D3129vmYZO7LJCesHzl+5MakHqlrZWDf18rK2NMUtpZGq0i1s+Auz0h7GRWy56s61o Q5zRug3YerZxoAbxA7T4d5nr1jmXLJXaE0Vrt/ZMtu1snyEeAMTwGMXZ93JPVpYVOYAX Kq7Qa/ANjH+BQv0aSMEgt9Ye6PpycK3l9YdTI= 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=gqT1DdXhAd7kSzHtFnM8/ldJvPrYwTgmzmRjeiHsmuU=; b=WbCofbE7guvZIJYEONCGbwaapTNcUziWaBoVzJcfuppCQ6552vlH3s35pI3+cFaW2b 4kHQmLFtuZNRxQ+yGRWuy5lubMUtury/wXXM+Ig6ItHf6eIFF8KsxJhcOvDCfmbuuZi4 i5VNPLNhE4F3V5YIu4K4hpCQpsqNP3OIoZ9yPFNvHvDXrun4UkbeorpcFmuqQV1dL4Rl z7UmDgm5cZ7FNkInXGCiCmVJouksxtFesuQe8WOK8Wv3qr0CME+bOy1/pqmiyUeRUmHb CYCTOYBmld6z9RyEuSjiGBGvX9JmbSYN/x3mzUQqQ8e/HPQTD9gnFRyJW8dfiZnPQ5wn 19+w== X-Gm-Message-State: AO0yUKV1rUHKU9uhPGEOZ8etmBxgMPtLQNGmIQyRKMV4HNo8/usWVujl QKfQt47hYo361T0vhVp0oNW6wFZD7Zc4tHd+ X-Google-Smtp-Source: AK7set+NsQUDMFrFhdhxHIEBGURHZOzb8swSRBlw/epqq0BKDZErxSj1VnULH7x1e0YNLdmBDC8zVA== X-Received: by 2002:a17:903:1104:b0:196:6ec4:52db with SMTP id n4-20020a170903110400b001966ec452dbmr6847406plh.51.1675827208253; Tue, 07 Feb 2023 19:33:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 19:33:28 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Feb 2023 03:33:17 +0000 Message-Id: <20230208033319.1361109-4-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 3/5] android: jpeg: Add meson.build in src/android/jpeg 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 further control sources in jpeg to build based on the platform, this patch adds meson.build in src/android/jpeg directory. Signed-off-by: Harvey Yang Reviewed-by: Laurent Pinchart Reviewed-by: Han-Lin Chen Signed-off-by: Laurent Pinchart --- src/android/jpeg/meson.build | 8 ++++++++ src/android/meson.build | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 src/android/jpeg/meson.build diff --git a/src/android/jpeg/meson.build b/src/android/jpeg/meson.build new file mode 100644 index 00000000..08397a87 --- /dev/null +++ b/src/android/jpeg/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: CC0-1.0 + +android_hal_sources += files([ + 'encoder_libjpeg.cpp', + 'exif.cpp', + 'post_processor_jpeg.cpp', + 'thumbnailer.cpp' +]) diff --git a/src/android/meson.build b/src/android/meson.build index b543c143..68646120 100644 --- a/src/android/meson.build +++ b/src/android/meson.build @@ -47,16 +47,13 @@ android_hal_sources = files([ 'camera_request.cpp', 'camera_stream.cpp', 'hal_framebuffer.cpp', - 'jpeg/encoder_libjpeg.cpp', - 'jpeg/exif.cpp', - 'jpeg/post_processor_jpeg.cpp', - 'jpeg/thumbnailer.cpp', 'yuv/post_processor_yuv.cpp' ]) android_cpp_args = [] subdir('cros') +subdir('jpeg') subdir('mm') android_camera_metadata_sources = files([ 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); From patchwork Wed Feb 8 03:33:19 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: 18266 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 EB7BBC324D for ; Wed, 8 Feb 2023 03:33:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 85566625FF; Wed, 8 Feb 2023 04:33:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675827215; bh=8heM0wgJp2Nb8ziqYzQ/6brIKwImR7elaz4ft9BL748=; 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=eBMN8YRdzOlQEikk10QOqES056aL5T8uyrHphsT4l1wi5MWEP8w+m4zE7m1c+6WgC Up6IdQgGoqzfNvjUBgAkHDRFWL4TmUFshw2NkOgvtoU2+LyWV0DUieOx94X5W4Do2m dDnx7dz1NtBn6wvcvTMbSoihlSleFoZlOrAjessdRcsbuuNIV2lrDtehOXXW+fBidP 1nt/O478u5maa2AD67RJpH0pNGNF5t0vSUGybT+7tw6/FhIQPvZp8McuRhWjIBYT+F K9z00vGfZUsWfiw1IbIt4s3BRpOsqRtk9jVmEgTNIHORBKs1ZS8fWZQEKvP8N20E7t L96t7lJAQ9Z8Q== Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 801D6625FD for ; Wed, 8 Feb 2023 04:33:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PtFaoL8P"; dkim-atps=neutral Received: by mail-pl1-x62a.google.com with SMTP id w5so7841934plg.8 for ; Tue, 07 Feb 2023 19:33:31 -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=nZnf86n3l5NZDFZUhXa66wE+AHBO/uzfnPJ6GMpQuUk=; b=PtFaoL8Pv4u9LFR83qjPmGK1CVIPmPq4FHnHj05aEMxwK0oOGm3xH7hXbW+ajgCWQ3 nOjPjjAXOVuKHiEtj02XvduZCv6vlOi25zAE5QYt1+5ekbZaVWSQv4LsbSQAZYSmMQ8J 9aLRw5mY3lzF8hb+B60UrTVPfNFtx3nek1WEg= 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=nZnf86n3l5NZDFZUhXa66wE+AHBO/uzfnPJ6GMpQuUk=; b=hXe40ogO409kBHxnHs1uNOd+++LfwaR1hI+iCSx7bCmG8zYcKAu+txfquWUCvYIB6q MKz7AuGkAX6b5aCkRZwuf4vCqWAAFZEN2qFe4I8p3dyihpHMlDv5F1h23g94crYI1yqX jpElJsRw8RnswmT/6IqqJJjk57zvFuYTaDqnAK4l1xxO5q40u6MHfglr8MDst7qZTxZW VW5FSlka3k8v4yq2L24v+YE7dhdvmqudEWFMvcbDlTw7pp1DkPaAg9sLrzp5ANJ4d+Ft QbjRk9808CAVMp+GthsMKC0eC0NC8deQ3e9bTxncsilbjhIPXYyrjsZfKtiOwhdnYzGu NlmA== X-Gm-Message-State: AO0yUKUaQttX4ItvwE7h/rSRxkNCseEfIYkYEToU79r8DcK9UTxoAzHf otjDJ0s5P56dwfKYgXQrq43Z07sm9gThITay X-Google-Smtp-Source: AK7set/SemJ9mRb8HP7T4qdIM4ANI+IhibVIEfFGOM32sTw0UX+RsxN3lFzRFGZ28UFLK+PtUaaMUQ== X-Received: by 2002:a17:902:e0d4:b0:199:cf2:4bea with SMTP id e20-20020a170902e0d400b001990cf24beamr4526841pla.66.1675827210836; Tue, 07 Feb 2023 19:33:30 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 19:33:30 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Feb 2023 03:33:19 +0000 Message-Id: <20230208033319.1361109-6-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 5/5] android: jpeg: Add JEA implementation 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 This patch adds JEA implementation to replace libjpeg in CrOS platform, where hardware accelerator is available. Signed-off-by: Harvey Yang --- src/android/cros/camera3_hal.cpp | 4 +- src/android/cros_mojo_token.h | 12 +++++ src/android/jpeg/encoder_jea.cpp | 56 ++++++++++++++++++++++++ src/android/jpeg/encoder_jea.h | 31 +++++++++++++ src/android/jpeg/meson.build | 10 ++++- src/android/jpeg/post_processor_jpeg.cpp | 8 ++++ 6 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 src/android/cros_mojo_token.h create mode 100644 src/android/jpeg/encoder_jea.cpp create mode 100644 src/android/jpeg/encoder_jea.h diff --git a/src/android/cros/camera3_hal.cpp b/src/android/cros/camera3_hal.cpp index fb863b5f..71acb441 100644 --- a/src/android/cros/camera3_hal.cpp +++ b/src/android/cros/camera3_hal.cpp @@ -8,9 +8,11 @@ #include #include "../camera_hal_manager.h" +#include "../cros_mojo_token.h" -static void set_up([[maybe_unused]] cros::CameraMojoChannelManagerToken *token) +static void set_up(cros::CameraMojoChannelManagerToken *token) { + gCrosMojoToken = token; } static void tear_down() diff --git a/src/android/cros_mojo_token.h b/src/android/cros_mojo_token.h new file mode 100644 index 00000000..043c752a --- /dev/null +++ b/src/android/cros_mojo_token.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * cros_mojo_token.h - cros-specific mojo token + */ + +#pragma once + +#include + +inline cros::CameraMojoChannelManagerToken *gCrosMojoToken = nullptr; diff --git a/src/android/jpeg/encoder_jea.cpp b/src/android/jpeg/encoder_jea.cpp new file mode 100644 index 00000000..7880a6bd --- /dev/null +++ b/src/android/jpeg/encoder_jea.cpp @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * encoder_jea.cpp - JPEG encoding using CrOS JEA + */ + +#include "encoder_jea.h" + +#include "libcamera/internal/mapped_framebuffer.h" + +#include + +#include "../cros_mojo_token.h" +#include "../hal_framebuffer.h" + +EncoderJea::EncoderJea() = default; + +EncoderJea::~EncoderJea() = default; + +int EncoderJea::configure(const libcamera::StreamConfiguration &cfg) +{ + size_ = cfg.size; + + if (jpegCompressor_) + return 0; + + if (gCrosMojoToken == nullptr) + return -ENOTSUP; + + jpegCompressor_ = cros::JpegCompressor::GetInstance(gCrosMojoToken); + + return 0; +} + +int EncoderJea::encode(Camera3RequestDescriptor::StreamBuffer *buffer, + libcamera::Span exifData, + unsigned int quality) +{ + if (!jpegCompressor_) + return -ENOTSUP; + + uint32_t outDataSize = 0; + const HALFrameBuffer *fb = + dynamic_cast(buffer->srcBuffer); + + if (!jpegCompressor_->CompressImageFromHandle(fb->handle(), + *buffer->camera3Buffer, + size_.width, size_.height, + quality, exifData.data(), + exifData.size(), + &outDataSize)) + return -EBUSY; + + return outDataSize; +} diff --git a/src/android/jpeg/encoder_jea.h b/src/android/jpeg/encoder_jea.h new file mode 100644 index 00000000..ffe9df27 --- /dev/null +++ b/src/android/jpeg/encoder_jea.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * encoder_jea.h - JPEG encoding using CrOS JEA + */ + +#pragma once + +#include + +#include + +#include "encoder.h" + +class EncoderJea : public Encoder +{ +public: + EncoderJea(); + ~EncoderJea(); + + int configure(const libcamera::StreamConfiguration &cfg) override; + int encode(Camera3RequestDescriptor::StreamBuffer *buffer, + libcamera::Span exifData, + unsigned int quality) override; + +private: + libcamera::Size size_; + + std::unique_ptr jpegCompressor_; +}; diff --git a/src/android/jpeg/meson.build b/src/android/jpeg/meson.build index 08397a87..9162576b 100644 --- a/src/android/jpeg/meson.build +++ b/src/android/jpeg/meson.build @@ -1,8 +1,14 @@ # SPDX-License-Identifier: CC0-1.0 android_hal_sources += files([ - 'encoder_libjpeg.cpp', 'exif.cpp', + 'encoder_libjpeg.cpp', + 'thumbnailer.cpp', 'post_processor_jpeg.cpp', - 'thumbnailer.cpp' ]) + +platform = get_option('android_platform') +if platform == 'cros' + android_hal_sources += files(['encoder_jea.cpp']) + android_deps += [dependency('libcros_camera')] +endif diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 3e676eb4..40261652 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -12,7 +12,11 @@ #include "../camera_device.h" #include "../camera_metadata.h" #include "../camera_request.h" +#if defined(OS_CHROMEOS) +#include "encoder_jea.h" +#else /* !defined(OS_CHROMEOS) */ #include "encoder_libjpeg.h" +#endif #include "exif.h" #include @@ -46,7 +50,11 @@ int PostProcessorJpeg::configure(const StreamConfiguration &inCfg, thumbnailer_.configure(inCfg.size, inCfg.pixelFormat); +#if defined(OS_CHROMEOS) + encoder_ = std::make_unique(); +#else /* !defined(OS_CHROMEOS) */ encoder_ = std::make_unique(); +#endif return encoder_->configure(inCfg); }