Patch Detail
Show a patch.
GET /api/patches/15717/?format=api
{ "id": 15717, "url": "https://patchwork.libcamera.org/api/patches/15717/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15717/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20220426090029.1350103-5-chenghaoyang@chromium.org>", "date": "2022-04-26T09:00:29", "name": "[libcamera-devel,v2,4/4] Add JEA implementation", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "c2d3ff9f5b44c0c35faf1f28ed4af3b1704e3b90", "submitter": { "id": 117, "url": "https://patchwork.libcamera.org/api/people/117/?format=api", "name": "Cheng-Hao Yang", "email": "chenghaoyang@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/15717/mbox/", "series": [ { "id": 3070, "url": "https://patchwork.libcamera.org/api/series/3070/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3070", "date": "2022-04-26T09:00:25", "name": "Add CrOS JEA implementation", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3070/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15717/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15717/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 01F6EC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Apr 2022 09:01:24 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A6C1265646;\n\tTue, 26 Apr 2022 11:01:24 +0200 (CEST)", "from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com\n\t[IPv6:2607:f8b0:4864:20::62e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 057666564A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Apr 2022 11:01:22 +0200 (CEST)", "by mail-pl1-x62e.google.com with SMTP id j8so29590357pll.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Apr 2022 02:01:21 -0700 (PDT)", "from chenghaoyang.c.googlers.com.com\n\t(93.135.240.35.bc.googleusercontent.com. [35.240.135.93])\n\tby smtp.gmail.com with ESMTPSA id\n\tc18-20020a056a000ad200b004cdccd3da08sm15449379pfl.44.2022.04.26.02.01.18\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 26 Apr 2022 02:01:19 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1650963684;\n\tbh=dswS/+WU+hkvYSavCWp/tI3Nf271PIWebq8iR/wSXDQ=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Yzp0DvdA1grYNc0sRQXNE1BORjhDmqVRmmg58byJqP/tJvFl0CfnTXkuQ1oK4PEUO\n\tl2C3sULFV/CG2KdokiDTvEnAWGIjlu/auhCkTudCi39kmKz3cV2KYi5IhSJNvbc2cz\n\tbcooPH50kiDRTHtdIDBW9xj496bsrbEbm98Nm3bDIAib8UyfoUV8df05iMRPGoOptu\n\teGtuqxhYCVNqLxv4y9+Yl8Kq8vn8U2Sb+HE2xm00Y1dLTQuzBwJAdJ62Okm/nKwR7m\n\tBlrFVYOBlCjQ6E5RLzf9LFnzkucgibYfFamno3hXoeU5c4dCaE8qSYF60IvGnosU4G\n\tdEP7S5pMwUTNQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=MBshtqQ99ek/TRqscza57RyezIU9PbOSy/UhkdgflZk=;\n\tb=h5+/FHol7fetLFjGiwURwzgLsEJ4yum6XSBUx3TWmCTCm8mTrx2RHa5YBNBBMmBQAk\n\tEgRZAGE5bXrTM0YsKKA8WJBHW6GpQ+rj98METoW06dS6oJnbYaNA0arfeTZfZmjScApq\n\tUubqUJ//zUlD7hOLLmM2pq1vuBSzilwbfe3Kk=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"h5+/FHol\"; \n\tdkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=MBshtqQ99ek/TRqscza57RyezIU9PbOSy/UhkdgflZk=;\n\tb=2X4p/DbGjtUg/54UkuR9ZzWbK4g1BG6QxqTuyTn9KcjGa9U/6tovabNHitbuw8KY2t\n\t+marNqZSxuYDFzVfeWSKKbLQ2cYd6QjWHug9Ju9aACAEpi7jgE44j9gMkIV7ISdPWVBq\n\tDfDq0Cp8c/jvRZdoIEHjkL5r2gDJRPZABl/4twJy5H7uVDBAwi6mwrGKwc2l6bMi1Xu1\n\tmElqy+70XTpF70l6VXFmzAb8WQ5Sns5QuoUUYFrz0F4vP3EXi6gINcpkWl2ahZp6CEVk\n\t+4N2k6pHXi/WPDiFru0NODiSe1uMZafUrMo0DmSJL4g0qTgHeL5LNRG6/J+pkbIClIHR\n\t8F3Q==", "X-Gm-Message-State": "AOAM533HXV85e8y/UthqFWcSrMjgVtU2Qhc5IJ37guaivBMdacYC+z8V\n\tgMAV6TkmRopBwer7CDYV/bdYJZjBF2Ow9tAr", "X-Google-Smtp-Source": "ABdhPJxkFK1ZQb9BhxG0Dh/PmEaXtAGzrIXpoFk1DOAFRdrUDkCWy22L3t9ri2Fbwr5ICQNF7994PQ==", "X-Received": "by 2002:a17:902:a981:b0:156:52b2:40d6 with SMTP id\n\tbh1-20020a170902a98100b0015652b240d6mr22529031plb.34.1650963680038; \n\tTue, 26 Apr 2022 02:01:20 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 26 Apr 2022 09:00:29 +0000", "Message-Id": "<20220426090029.1350103-5-chenghaoyang@chromium.org>", "X-Mailer": "git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog", "In-Reply-To": "<20220426090029.1350103-1-chenghaoyang@chromium.org>", "References": "<20220426090029.1350103-1-chenghaoyang@chromium.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 4/4] Add JEA implementation", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "From": "Harvey Yang via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Harvey Yang <chenghaoyang@chromium.org>", "Cc": "Harvey Yang <chenghaoyang@chromium.org>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "This CL adds JEA implementation to replace Lib Jpeg in cros platform,\nwhere HW accelerator is available.\n---\n src/android/cros/camera3_hal.cpp | 3 +\n src/android/jpeg/cros_post_processor_jpeg.cpp | 14 ++++\n src/android/jpeg/encoder_jea.cpp | 82 +++++++++++++++++++\n src/android/jpeg/encoder_jea.h | 35 ++++++++\n src/android/jpeg/meson.build | 13 ++-\n 5 files changed, 144 insertions(+), 3 deletions(-)\n create mode 100644 src/android/jpeg/cros_post_processor_jpeg.cpp\n create mode 100644 src/android/jpeg/encoder_jea.cpp\n create mode 100644 src/android/jpeg/encoder_jea.h", "diff": "diff --git a/src/android/cros/camera3_hal.cpp b/src/android/cros/camera3_hal.cpp\nindex fb863b5f..ea5577f0 100644\n--- a/src/android/cros/camera3_hal.cpp\n+++ b/src/android/cros/camera3_hal.cpp\n@@ -9,8 +9,11 @@\n \n #include \"../camera_hal_manager.h\"\n \n+cros::CameraMojoChannelManagerToken *g_cros_camera_token = nullptr;\n+\n static void set_up([[maybe_unused]] cros::CameraMojoChannelManagerToken *token)\n {\n+\tg_cros_camera_token = token;\n }\n \n static void tear_down()\ndiff --git a/src/android/jpeg/cros_post_processor_jpeg.cpp b/src/android/jpeg/cros_post_processor_jpeg.cpp\nnew file mode 100644\nindex 00000000..7020f0d0\n--- /dev/null\n+++ b/src/android/jpeg/cros_post_processor_jpeg.cpp\n@@ -0,0 +1,14 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Google Inc.\n+ *\n+ * cros_post_processor_jpeg.cpp - CrOS JPEG Post Processor\n+ */\n+\n+#include \"encoder_jea.h\"\n+#include \"post_processor_jpeg.h\"\n+\n+void PostProcessorJpeg::SetEncoder()\n+{\n+\tencoder_ = std::make_unique<EncoderJea>();\n+}\ndiff --git a/src/android/jpeg/encoder_jea.cpp b/src/android/jpeg/encoder_jea.cpp\nnew file mode 100644\nindex 00000000..838e8647\n--- /dev/null\n+++ b/src/android/jpeg/encoder_jea.cpp\n@@ -0,0 +1,82 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Google Inc.\n+ *\n+ * encoder_jea.cpp - JPEG encoding using CrOS JEA\n+ */\n+\n+#include \"encoder_jea.h\"\n+\n+#include <libcamera/base/log.h>\n+\n+#include \"libcamera/internal/mapped_framebuffer.h\"\n+\n+#include <cros-camera/camera_mojo_channel_manager_token.h>\n+\n+#include \"../android_framebuffer.h\"\n+\n+extern cros::CameraMojoChannelManagerToken *g_cros_camera_token;\n+\n+EncoderJea::EncoderJea() = default;\n+\n+EncoderJea::~EncoderJea() = default;\n+\n+int EncoderJea::configure(const libcamera::StreamConfiguration &cfg)\n+{\n+\tsize_ = cfg.size;\n+\n+\tif (jpeg_compressor_.get())\n+\t\treturn 0;\n+\n+\tif (g_cros_camera_token == nullptr)\n+\t\treturn -ENOTSUP;\n+\n+\tjpeg_compressor_ = cros::JpegCompressor::GetInstance(g_cros_camera_token);\n+\n+\treturn 0;\n+}\n+\n+int EncoderJea::encode(Camera3RequestDescriptor::StreamBuffer *streamBuffer,\n+\t\t libcamera::Span<const uint8_t> exifData,\n+\t\t unsigned int quality)\n+{\n+\tif (!jpeg_compressor_.get())\n+\t\treturn -1;\n+\n+\tuint32_t out_data_size = 0;\n+\n+\tif (!jpeg_compressor_->CompressImageFromHandle(\n+\t\t dynamic_cast<const AndroidFrameBuffer *>(\n+\t\t\t streamBuffer->srcBuffer)\n+\t\t\t ->getHandle(),\n+\t\t *streamBuffer->camera3Buffer, size_.width, size_.height, quality,\n+\t\t exifData.data(), exifData.size(), &out_data_size)) {\n+\t\treturn -1;\n+\t}\n+\n+\treturn out_data_size;\n+}\n+\n+int EncoderJea::generateThumbnail(const libcamera::FrameBuffer &source,\n+\t\t\t\t const libcamera::Size &targetSize,\n+\t\t\t\t unsigned int quality,\n+\t\t\t\t std::vector<unsigned char> *thumbnail)\n+{\n+\tif (!jpeg_compressor_.get())\n+\t\treturn -1;\n+\n+\tlibcamera::MappedFrameBuffer frame(&source, libcamera::MappedFrameBuffer::MapFlag::Read);\n+\n+\tif (frame.planes().empty())\n+\t\treturn 0;\n+\n+\tuint32_t out_data_size = 0;\n+\n+\tif (!jpeg_compressor_->GenerateThumbnail(frame.planes()[0].data(),\n+\t\t\t\t\t\t size_.width, size_.height, targetSize.width, targetSize.height,\n+\t\t\t\t\t\t quality, thumbnail->size(), thumbnail->data(), &out_data_size)) {\n+\t\treturn -1;\n+\t}\n+\n+\treturn out_data_size;\n+}\ndiff --git a/src/android/jpeg/encoder_jea.h b/src/android/jpeg/encoder_jea.h\nnew file mode 100644\nindex 00000000..d5c9f1f7\n--- /dev/null\n+++ b/src/android/jpeg/encoder_jea.h\n@@ -0,0 +1,35 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Google Inc.\n+ *\n+ * encoder_jea.h - JPEG encoding using CrOS JEA\n+ */\n+\n+#pragma once\n+\n+#include <libcamera/geometry.h>\n+\n+#include <cros-camera/jpeg_compressor.h>\n+\n+#include \"encoder.h\"\n+\n+class EncoderJea : public Encoder\n+{\n+public:\n+\tEncoderJea();\n+\t~EncoderJea();\n+\n+\tint configure(const libcamera::StreamConfiguration &cfg) override;\n+\tint encode(Camera3RequestDescriptor::StreamBuffer *streamBuffer,\n+\t\t libcamera::Span<const uint8_t> exifData,\n+\t\t unsigned int quality) override;\n+\tint generateThumbnail(const libcamera::FrameBuffer &source,\n+\t\t\t const libcamera::Size &targetSize,\n+\t\t\t unsigned int quality,\n+\t\t\t std::vector<unsigned char> *thumbnail) override;\n+\n+private:\n+\tlibcamera::Size size_;\n+\n+\tstd::unique_ptr<cros::JpegCompressor> jpeg_compressor_;\n+};\ndiff --git a/src/android/jpeg/meson.build b/src/android/jpeg/meson.build\nindex 94522dc0..8606acc4 100644\n--- a/src/android/jpeg/meson.build\n+++ b/src/android/jpeg/meson.build\n@@ -4,6 +4,13 @@ android_hal_sources += files([\n 'exif.cpp',\n 'post_processor_jpeg.cpp'])\n \n-android_hal_sources += files(['encoder_libjpeg.cpp',\n- 'generic_post_processor_jpeg.cpp',\n- 'thumbnailer.cpp'])\n+platform = get_option('android_platform')\n+if platform == 'generic'\n+ android_hal_sources += files(['encoder_libjpeg.cpp',\n+ 'generic_post_processor_jpeg.cpp',\n+ 'thumbnailer.cpp'])\n+elif platform == 'cros'\n+ android_hal_sources += files(['cros_post_processor_jpeg.cpp',\n+ 'encoder_jea.cpp'])\n+ android_deps += [dependency('libcros_camera')]\n+endif\n", "prefixes": [ "libcamera-devel", "v2", "4/4" ] }