Show a patch.

GET /api/1.1/patches/15748/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 15748,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/15748/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15748/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20220428095544.2795980-7-chenghaoyang@chromium.org>",
    "date": "2022-04-28T09:55:44",
    "name": "[libcamera-devel,v4,6/6] Add JEA implementation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "6f1f52baff160a2ba3117f10ba350512254cfad7",
    "submitter": {
        "id": 117,
        "url": "https://patchwork.libcamera.org/api/1.1/people/117/?format=api",
        "name": "Cheng-Hao Yang",
        "email": "chenghaoyang@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15748/mbox/",
    "series": [
        {
            "id": 3081,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3081/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3081",
            "date": "2022-04-28T09:55:38",
            "name": "Add CrOS JEA implementation",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/3081/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15748/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15748/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 3FE9DC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Apr 2022 09:56:08 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E361C65656;\n\tThu, 28 Apr 2022 11:56:07 +0200 (CEST)",
            "from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com\n\t[IPv6:2607:f8b0:4864:20::52d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C5D565653\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Apr 2022 11:56:05 +0200 (CEST)",
            "by mail-pg1-x52d.google.com with SMTP id bg9so3564776pgb.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Apr 2022 02:56:05 -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\tx6-20020a17090a46c600b001d960eaed66sm5861256pjg.42.2022.04.28.02.56.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 28 Apr 2022 02:56:03 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1651139767;\n\tbh=BRw4Wct9j1VTPx2+RNeytn5nbghVZT7v4jRSdl1C/Dg=;\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=ghbQdvwhSKen5t2FPccFsbB2SrngsaYBEcVbG+BidOs8wYecNT6onTmaEKQyDuroZ\n\t/g3Mftq49Sc1w2hCgkHmYNO1CaA0RmmsFz24hUTUeyxCE7qIkfjppax2RJMQS+XZwq\n\tmzuIaFMuJg7yU3H8G+0wIjtE1jz7lBMjnZOpZbl041KKUiwTWz282aF4ZBm5Qcbut5\n\tUa7JduRR7P1K3ZkbECGagmane3fBjTsFIgE1ZivKHP3Vkx0qZPSOFDcnv0GpGgRAKp\n\tcBSmBOc3UbN3R+l0o+d+XJgA1TLWG9MbsWz4zIVSJrnNx5Ajr4Tb/lhbzt5UgGReAr\n\t4r6Hv/dASHVLw==",
            "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=DUFmBV0P2o594lCT0mBCgXSzCIAH6p0Rd6yCeEWk0ts=;\n\tb=dAj9MDoSBnoX05Ktu9+POQNvgurGuaoE9C9XdVxSsNWeMOj9wd2W6UPyQ+XaepmsXl\n\tBEHm2w/0YYn+aM6xhcoary7bCurJc62aw7exM7OvWzjWEj8tSpKKzeIvpyNBFcs/qiQj\n\t07myuXrTrHPQ3Nfhcts7pXK4JT7UrtyBdEpEw="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"dAj9MDoS\"; \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=DUFmBV0P2o594lCT0mBCgXSzCIAH6p0Rd6yCeEWk0ts=;\n\tb=Ntx+wjvXvL+qWW/VIY+EOxX5OqRT5bMbYxGtsTYonlo8Hf2ZkOv4xYmBltuzyfO40i\n\tAoDsyZ/3hZ3Y0c/4tw1rHuTf0Wg49XkEhPDr1437ZLnlTRgMb/ggVuRwolDY3YHD6lrk\n\tDluaBBIz6SUKMv15weZY8PFlwvp4Hi22nJOFwQ8vRex/MUOTKuHVcMO4uVhy9EdL4IaR\n\tbcI4mLVh4kDLO4kdHN1U8WZQ78KA+5IUGoo7h+GV3BjOUpBN215XhPqwQIhWhbBa0aTY\n\taxIJ5Mj4AQl7bNIn9kBHZvyDLcOZGajB0LsR0P60khS0quoVB3zybIr/de8Xy8NMPkMd\n\tohvw==",
        "X-Gm-Message-State": "AOAM532cRiHR/42ZtPdg1YIDAVHKIdbUoWM2tLWg3gnnZgiE3Xnokr2n\n\tKhPbE3YPPG1EWIByntrCy7tHAELKwdSV0QG5",
        "X-Google-Smtp-Source": "ABdhPJxyXWEKvlGn0xPEj39vmwqQPCOUhMfZy1WKQJik3YJpDbNcdBGZ2aA+LUUumz2slnho+HCExQ==",
        "X-Received": "by 2002:a05:6a00:15d0:b0:50d:3810:922e with SMTP id\n\to16-20020a056a0015d000b0050d3810922emr22553497pfu.6.1651139763546; \n\tThu, 28 Apr 2022 02:56:03 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 28 Apr 2022 09:55:44 +0000",
        "Message-Id": "<20220428095544.2795980-7-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",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 6/6] 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 patch adds JEA implementation to replace Lib Jpeg in cros platform,\nwhere HW accelerator is available.\n\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n src/android/cros/camera3_hal.cpp         |  2 +\n src/android/cros_mojo_token.h            | 12 ++++\n src/android/jpeg/encoder_jea.cpp         | 81 ++++++++++++++++++++++++\n src/android/jpeg/encoder_jea.h           | 35 ++++++++++\n src/android/jpeg/meson.build             | 12 +++-\n src/android/jpeg/post_processor_jpeg.cpp |  8 +++\n 6 files changed, 148 insertions(+), 2 deletions(-)\n create mode 100644 src/android/cros_mojo_token.h\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..d75afccb 100644\n--- a/src/android/cros/camera3_hal.cpp\n+++ b/src/android/cros/camera3_hal.cpp\n@@ -8,9 +8,11 @@\n #include <cros-camera/cros_camera_hal.h>\n \n #include \"../camera_hal_manager.h\"\n+#include \"../cros_mojo_token.h\"\n \n static void set_up([[maybe_unused]] cros::CameraMojoChannelManagerToken *token)\n {\n+\tgCrosMojoToken = token;\n }\n \n static void tear_down()\ndiff --git a/src/android/cros_mojo_token.h b/src/android/cros_mojo_token.h\nnew file mode 100644\nindex 00000000..043c752a\n--- /dev/null\n+++ b/src/android/cros_mojo_token.h\n@@ -0,0 +1,12 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Google Inc.\n+ *\n+ * cros_mojo_token.h - cros-specific mojo token\n+ */\n+\n+#pragma once\n+\n+#include <cros-camera/cros_camera_hal.h>\n+\n+inline cros::CameraMojoChannelManagerToken *gCrosMojoToken = nullptr;\ndiff --git a/src/android/jpeg/encoder_jea.cpp b/src/android/jpeg/encoder_jea.cpp\nnew file mode 100644\nindex 00000000..8c1bf545\n--- /dev/null\n+++ b/src/android/jpeg/encoder_jea.cpp\n@@ -0,0 +1,81 @@\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 \"../cros_mojo_token.h\"\n+#include \"../hal_framebuffer.h\"\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 (jpegCompressor_)\n+\t\treturn 0;\n+\n+\tif (gCrosMojoToken == nullptr)\n+\t\treturn -ENOTSUP;\n+\n+\tjpegCompressor_ = cros::JpegCompressor::GetInstance(gCrosMojoToken);\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 (!jpegCompressor_)\n+\t\treturn -ENOTSUP;\n+\n+\tuint32_t outDataSize = 0;\n+\tconst HALFrameBuffer *fb = dynamic_cast<const HALFrameBuffer *>(\n+\t\t\tstreamBuffer->srcBuffer);\n+\n+\tif (!jpegCompressor_->CompressImageFromHandle(fb->handle(),\n+\t\t\t\t*streamBuffer->camera3Buffer, size_.width,\n+\t\t\t\tsize_.height, quality, exifData.data(),\n+\t\t\t\texifData.size(), &outDataSize))\n+\t\treturn -EBUSY;\n+\n+\treturn outDataSize;\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 (!jpegCompressor_)\n+\t\treturn -ENOTSUP;\n+\n+\tlibcamera::MappedFrameBuffer frame(&source,\n+\t\t\tlibcamera::MappedFrameBuffer::MapFlag::Read);\n+\n+\tif (frame.planes().empty())\n+\t\treturn -ENODATA;\n+\n+\tuint32_t outDataSize = 0;\n+\n+\tif (!jpegCompressor_->GenerateThumbnail(frame.planes()[0].data(),\n+\t\t\t\tsize_.width, size_.height, targetSize.width,\n+\t\t\t\ttargetSize.height, quality, thumbnail->size(),\n+\t\t\t\tthumbnail->data(), &outDataSize))\n+\t\treturn -EBUSY;\n+\n+\treturn outDataSize;\n+}\ndiff --git a/src/android/jpeg/encoder_jea.h b/src/android/jpeg/encoder_jea.h\nnew file mode 100644\nindex 00000000..2eba31c2\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> jpegCompressor_;\n+};\ndiff --git a/src/android/jpeg/meson.build b/src/android/jpeg/meson.build\nindex 08397a87..d25016b1 100644\n--- a/src/android/jpeg/meson.build\n+++ b/src/android/jpeg/meson.build\n@@ -1,8 +1,16 @@\n # SPDX-License-Identifier: CC0-1.0\n \n android_hal_sources += files([\n-    'encoder_libjpeg.cpp',\n     'exif.cpp',\n     'post_processor_jpeg.cpp',\n-    'thumbnailer.cpp'\n ])\n+\n+platform = get_option('android_platform')\n+if platform == 'generic'\n+    android_hal_sources += files(['encoder_libjpeg.cpp',\n+                                  'thumbnailer.cpp'\n+    ])\n+elif platform == 'cros'\n+    android_hal_sources += files(['encoder_jea.cpp'])\n+    android_deps += [dependency('libcros_camera')]\n+endif\ndiff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex ed85bd48..e38a1a91 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -12,7 +12,11 @@\n #include \"../camera_device.h\"\n #include \"../camera_metadata.h\"\n #include \"../camera_request.h\"\n+#if defined(OS_CHROMEOS)\n+#include \"encoder_jea.h\"\n+#else // !defined(OS_CHROMEOS)\n #include \"encoder_libjpeg.h\"\n+#endif\n #include \"exif.h\"\n \n #include <libcamera/base/log.h>\n@@ -44,7 +48,11 @@ int PostProcessorJpeg::configure(const StreamConfiguration &inCfg,\n \n \tstreamSize_ = outCfg.size;\n \n+#if defined(OS_CHROMEOS)\n+\tencoder_ = std::make_unique<EncoderJea>();\n+#else // !defined(OS_CHROMEOS)\n \tencoder_ = std::make_unique<EncoderLibJpeg>();\n+#endif\n \n \treturn encoder_->configure(inCfg);\n }\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "6/6"
    ]
}