Show a patch.

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

{
    "id": 10158,
    "url": "https://patchwork.libcamera.org/api/patches/10158/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10158/",
    "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": "<20201021080806.46636-2-email@uajain.com>",
    "date": "2020-10-21T08:08:05",
    "name": "[libcamera-devel,RFC,1/2] android: jpeg: encoder_libjpeg Allow encoding raw frame bytes",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "da48e3c11d5688c50546da59bd26934de1c20c6f",
    "submitter": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/people/1/?format=api",
        "name": "Umang Jain",
        "email": "email@uajain.com"
    },
    "delegate": {
        "id": 12,
        "url": "https://patchwork.libcamera.org/api/users/12/?format=api",
        "username": "uajain",
        "first_name": "Umang",
        "last_name": "Jain",
        "email": "umang.jain@ideasonboard.com"
    },
    "mbox": "https://patchwork.libcamera.org/patch/10158/mbox/",
    "series": [
        {
            "id": 1397,
            "url": "https://patchwork.libcamera.org/api/series/1397/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1397",
            "date": "2020-10-21T08:08:04",
            "name": "andriod: Basic NV12 thumbnailer",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1397/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10158/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10158/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 12DD1C3D3C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 08:08:20 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D3A32610B6;\n\tWed, 21 Oct 2020 10:08:19 +0200 (CEST)",
            "from mail.uajain.com (static.126.159.217.95.clients.your-server.de\n\t[95.217.159.126])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1DF2A610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 10:08:18 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"taApur+1\"; dkim-atps=neutral",
        "From": "Umang Jain <email@uajain.com>",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail;\n\tt=1603267697; bh=X7zxhOa5JXahgqrLkw2Bdm3RCeCrIrqS6RA00dk0QZI=;\n\th=From:To:Cc:Subject:In-Reply-To:References;\n\tb=taApur+1qN+Bk4F31gIk3NiIkoJQeYAKIkR308z3yByEO3t1pdTAFuLrHYWKVKyoc\n\trlYmcERr8Riz5DH2+IWC8SnWnoFE/xQk6HxEWlVuG5cKVDWYAhzTGWSzuiQW4Ouas8\n\tug+L6QgABF6E5/w4hPp5r2Du0Rx2vYqKlt4UMxhb6GcAD6daUaa8gaHsCgZCukfoid\n\t1sxf3q6L3nJSy6EkWM2opGyA3XdzXxwehIoxSPC848r1pa+KFP7hEaPo2l3HpRqpZI\n\tdhLeXn1Of3UG3Nmu0LbEiAcYUa9E7g9QY19A65fgO8xT7caN6O7bPVdLhSrkRVsVTQ\n\tKZYcujSAkAj+A==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 21 Oct 2020 13:38:05 +0530",
        "Message-Id": "<20201021080806.46636-2-email@uajain.com>",
        "In-Reply-To": "<20201021080806.46636-1-email@uajain.com>",
        "References": "<20201021080806.46636-1-email@uajain.com>",
        "Mime-Version": "1.0",
        "Subject": "[libcamera-devel] [RFC PATCH 1/2] android: jpeg: encoder_libjpeg\n\tAllow encoding raw frame bytes",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Allow encoding frame which are directly handed over to the encoder\nvia a span or vector i.e. a raw frame bytes. Introduce an overloaded\nEncoderLibJpeg::encode() with libcamera::Span source parameter to\nachieve this functionality. This makes the libjpeg-encoder a bit\nflexible for use case such as compressing a thumbnail generated for\nExif.\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n src/android/jpeg/encoder_libjpeg.cpp | 37 +++++++++++++++++-----------\n src/android/jpeg/encoder_libjpeg.h   |  7 ++++--\n 2 files changed, 28 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp\nindex f11e004..bfaf9d5 100644\n--- a/src/android/jpeg/encoder_libjpeg.cpp\n+++ b/src/android/jpeg/encoder_libjpeg.cpp\n@@ -104,9 +104,9 @@ int EncoderLibJpeg::configure(const StreamConfiguration &cfg)\n \treturn 0;\n }\n \n-void EncoderLibJpeg::compressRGB(const libcamera::MappedBuffer *frame)\n+void EncoderLibJpeg::compressRGB(const libcamera::Span<uint8_t> &frame)\n {\n-\tunsigned char *src = static_cast<unsigned char *>(frame->maps()[0].data());\n+\tunsigned char *src = static_cast<unsigned char *>(frame.data());\n \t/* \\todo Stride information should come from buffer configuration. */\n \tunsigned int stride = pixelFormatInfo_->stride(compress_.image_width, 0);\n \n@@ -122,7 +122,7 @@ void EncoderLibJpeg::compressRGB(const libcamera::MappedBuffer *frame)\n  * Compress the incoming buffer from a supported NV format.\n  * This naively unpacks the semi-planar NV12 to a YUV888 format for libjpeg.\n  */\n-void EncoderLibJpeg::compressNV(const libcamera::MappedBuffer *frame)\n+void EncoderLibJpeg::compressNV(const libcamera::Span<uint8_t> &frame)\n {\n \tuint8_t tmprowbuf[compress_.image_width * 3];\n \n@@ -144,7 +144,7 @@ void EncoderLibJpeg::compressNV(const libcamera::MappedBuffer *frame)\n \tunsigned int cb_pos = nvSwap_ ? 1 : 0;\n \tunsigned int cr_pos = nvSwap_ ? 0 : 1;\n \n-\tconst unsigned char *src = static_cast<unsigned char *>(frame->maps()[0].data());\n+\tconst unsigned char *src = static_cast<unsigned char *>(frame.data());\n \tconst unsigned char *src_c = src + y_stride * compress_.image_height;\n \n \tJSAMPROW row_pointer[1];\n@@ -179,17 +179,10 @@ void EncoderLibJpeg::compressNV(const libcamera::MappedBuffer *frame)\n \t}\n }\n \n-int EncoderLibJpeg::encode(const FrameBuffer *source,\n+int EncoderLibJpeg::encode(const libcamera::Span<uint8_t> &frame,\n \t\t\t   const libcamera::Span<uint8_t> &dest,\n \t\t\t   const libcamera::Span<const uint8_t> &exifData)\n {\n-\tMappedFrameBuffer frame(source, PROT_READ);\n-\tif (!frame.isValid()) {\n-\t\tLOG(JPEG, Error) << \"Failed to map FrameBuffer : \"\n-\t\t\t\t << strerror(frame.error());\n-\t\treturn frame.error();\n-\t}\n-\n \tunsigned char *destination = dest.data();\n \tunsigned long size = dest.size();\n \n@@ -215,11 +208,27 @@ int EncoderLibJpeg::encode(const FrameBuffer *source,\n \t\t\t << \"x\" << compress_.image_height;\n \n \tif (nv_)\n-\t\tcompressNV(&frame);\n+\t\tcompressNV(frame);\n \telse\n-\t\tcompressRGB(&frame);\n+\t\tcompressRGB(frame);\n \n \tjpeg_finish_compress(&compress_);\n \n \treturn size;\n }\n+\n+int EncoderLibJpeg::encode(const FrameBuffer *source,\n+\t\t\t   const libcamera::Span<uint8_t> &dest,\n+\t\t\t   const libcamera::Span<const uint8_t> &exifData)\n+{\n+\tMappedFrameBuffer frame(source, PROT_READ);\n+\tif (!frame.isValid()) {\n+\t\tLOG(JPEG, Error) << \"Failed to map FrameBuffer : \"\n+\t\t\t\t << strerror(frame.error());\n+\t\treturn frame.error();\n+\t}\n+\n+\tlibcamera::Span<uint8_t> src = frame.maps()[0];\n+\n+\treturn encode(src, dest, exifData);\n+}\ndiff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h\nindex 934caef..bf2e512 100644\n--- a/src/android/jpeg/encoder_libjpeg.h\n+++ b/src/android/jpeg/encoder_libjpeg.h\n@@ -21,13 +21,16 @@ public:\n \t~EncoderLibJpeg();\n \n \tint configure(const libcamera::StreamConfiguration &cfg) override;\n+\tint encode(const libcamera::Span<uint8_t> &frames,\n+\t\t   const libcamera::Span<uint8_t> &destination,\n+\t\t   const libcamera::Span<const uint8_t> &exifData);\n \tint encode(const libcamera::FrameBuffer *source,\n \t\t   const libcamera::Span<uint8_t> &destination,\n \t\t   const libcamera::Span<const uint8_t> &exifData) override;\n \n private:\n-\tvoid compressRGB(const libcamera::MappedBuffer *frame);\n-\tvoid compressNV(const libcamera::MappedBuffer *frame);\n+\tvoid compressRGB(const libcamera::Span<uint8_t> &frame);\n+\tvoid compressNV(const libcamera::Span<uint8_t> &frame);\n \n \tstruct jpeg_compress_struct compress_;\n \tstruct jpeg_error_mgr jerr_;\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "1/2"
    ]
}