{"id":16652,"url":"https://patchwork.libcamera.org/api/patches/16652/?format=json","web_url":"https://patchwork.libcamera.org/patch/16652/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220715143822.672321-6-chenghaoyang@google.com>","date":"2022-07-15T14:38:21","name":"[libcamera-devel,v6,5/6] Pass StreamBuffer to Encoder::encoder","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d690f2658593922e8f95c26f6227773d0768c054","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/people/117/?format=json","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16652/mbox/","series":[{"id":3290,"url":"https://patchwork.libcamera.org/api/series/3290/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3290","date":"2022-07-15T14:38:16","name":"Add CrOS JEA implementation","version":6,"mbox":"https://patchwork.libcamera.org/series/3290/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16652/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16652/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 09CF2BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Jul 2022 14:38:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BEC1063323;\n\tFri, 15 Jul 2022 16:38:38 +0200 (CEST)","from mail-pl1-x633.google.com (mail-pl1-x633.google.com\n\t[IPv6:2607:f8b0:4864:20::633])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3338863314\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 16:38:37 +0200 (CEST)","by mail-pl1-x633.google.com with SMTP id w7so3387252ply.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 07:38:37 -0700 (PDT)","from chenghaoyang-low.c.googlers.com.com\n\t(208.158.221.35.bc.googleusercontent.com. [35.221.158.208])\n\tby smtp.gmail.com with ESMTPSA id\n\tf15-20020aa7968f000000b00528c22fbb45sm3972782pfk.141.2022.07.15.07.38.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 15 Jul 2022 07:38:34 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657895918;\n\tbh=hQa8WRuP5e9bgD2QWc7olwSVRjpi725avTwwpIqeT5E=;\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=zHa5hgomvfgmxIZr8g/IGUA58jt2ApIjhFXftRRHvVIeS6X7OvHIxnWuQ0621Vwc5\n\tV4AS0NqoNaf7IAcnEMRNtwCPqffmDLbMFPzMLYXz2U5x38Xv4kqEX4taBgSLL/+qmT\n\txhCYxKUClAXE7fA2oid7weAjcg06Z0O1tXXH7OE8w/34DMw+4HADGOkNtKLUhdHt7X\n\tG1XyYqt/Ce2Be6cbeVlrWeI0zGvOz2dVhiq50vmEE61B7fMiSdcj2nvtuU2VX3ZdnH\n\trvCIzphBFcCg+bIly2P3SILRHZCBueREsIP1Lo92OEGQsSkZ/hZhNH3FgcqhrBW0ny\n\tCh4G4ybyHOmcw==","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=ii+FPsv/XZLZ2VlFspzT14QmUpMBQRSpGB3GPYL3Lss=;\n\tb=PampK83W+XTn2jShIbBg5cp0W8E60n8jB1W0F/XdKeVlXOrV+2HoulnJiXtoE0JAck\n\tUJpA7NUfOMwoI54x6cgIQn5j+BBOrzrGMYIQtsY6oKJTUF0Zp2cEh2N4qcNHNSaapoFs\n\taEEyt3C4HJUDzMi8cbHbUmlF0qF5D3xAC4SnA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"PampK83W\"; \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=ii+FPsv/XZLZ2VlFspzT14QmUpMBQRSpGB3GPYL3Lss=;\n\tb=dn8b9U65P5lc5KwQbMr9uVklsUKcrDbT/CEHvkXnQaf7NcC+3e16u0pb+4yx4aLcBn\n\thSZu/zNwCB8Hap+GsgLuOtlQGqh5gvXMeP3cc0p0dLKvhPVrAULF9SilR7yAmkqIaO4T\n\taYgpjCJa6c68eavmLvFk9Dimu2EPitA7VNwScfxWw04RP/ETw1BYIIhlTDhKT2Xj2tuh\n\teP6DSZeYKu9BwHtFhQAPfDej1d4cs7vUm7Z+lHhYOluhoXCMmkFB5FNX+2Gq/ucYzMSc\n\t7O5BFMV25hcSssDzUNoGj81oZCrR5PPL/i5rOTPVU0kuKb1j9mJP3UF+AZNsUu4ZNO6S\n\tN5vw==","X-Gm-Message-State":"AJIora9bDmbduAANMOE09wewuwF74pc4SqUgIXlOlKiqu3XXCW0wV/aS\n\t8FLy+wIyrxSxg5YBrv/sckkSCr2ZDdZiAQ==","X-Google-Smtp-Source":"AGRyM1uSeJs03FaRp5Om/f8QbRDMuJQ2yRZ2ECZxmruKfd3HnLAiShMjEimzNdyuKFzOOSwf/jPmsA==","X-Received":"by 2002:a17:90a:ba97:b0:1ef:91ab:de1e with SMTP id\n\tt23-20020a17090aba9700b001ef91abde1emr16128645pjr.237.1657895915375; \n\tFri, 15 Jul 2022 07:38:35 -0700 (PDT)","X-Google-Original-From":"Harvey Yang <chenghaoyang@google.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 15 Jul 2022 14:38:21 +0000","Message-Id":"<20220715143822.672321-6-chenghaoyang@google.com>","X-Mailer":"git-send-email 2.37.0.170.g444d1eabd0-goog","In-Reply-To":"<20220715143822.672321-1-chenghaoyang@google.com>","References":"<20220715143822.672321-1-chenghaoyang@google.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v6 5/6] Pass StreamBuffer to\n\tEncoder::encoder","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":"From: Harvey Yang <chenghaoyang@chromium.org>\n\nTo prepare for the JEA encoder in the following patches, StreamBuffer is\npassed to Encoder::encoder, which contains the original FrameBuffer and\nSpan |destination|.\n\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n src/android/jpeg/encoder.h               |  5 +++--\n src/android/jpeg/encoder_libjpeg.cpp     | 11 +++++++++++\n src/android/jpeg/encoder_libjpeg.h       |  7 +++++--\n src/android/jpeg/post_processor_jpeg.cpp |  3 +--\n 4 files changed, 20 insertions(+), 6 deletions(-)","diff":"diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h\nindex 7dc1ee27..eeff87b1 100644\n--- a/src/android/jpeg/encoder.h\n+++ b/src/android/jpeg/encoder.h\n@@ -12,14 +12,15 @@\n #include <libcamera/framebuffer.h>\n #include <libcamera/stream.h>\n \n+#include \"../camera_request.h\"\n+\n class Encoder\n {\n public:\n \tvirtual ~Encoder() = default;\n \n \tvirtual int configure(const libcamera::StreamConfiguration &cfg) = 0;\n-\tvirtual int encode(const libcamera::FrameBuffer &source,\n-\t\t\t   libcamera::Span<uint8_t> destination,\n+\tvirtual int encode(Camera3RequestDescriptor::StreamBuffer *streamBuffer,\n \t\t\t   libcamera::Span<const uint8_t> exifData,\n \t\t\t   unsigned int quality) = 0;\n \tvirtual int generateThumbnail(\ndiff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp\nindex e0aca821..b61453f8 100644\n--- a/src/android/jpeg/encoder_libjpeg.cpp\n+++ b/src/android/jpeg/encoder_libjpeg.cpp\n@@ -24,6 +24,8 @@\n #include \"libcamera/internal/formats.h\"\n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n+#include \"../camera_buffer.h\"\n+\n using namespace libcamera;\n \n LOG_DECLARE_CATEGORY(JPEG)\n@@ -192,6 +194,15 @@ void EncoderLibJpeg::compressNV(const std::vector<Span<uint8_t>> &planes)\n \t}\n }\n \n+int EncoderLibJpeg::encode(Camera3RequestDescriptor::StreamBuffer *streamBuffer,\n+\t\t\t   libcamera::Span<const uint8_t> exifData,\n+\t\t\t   unsigned int quality)\n+{\n+\treturn encode(*streamBuffer->srcBuffer,\n+\t\t      streamBuffer->dstBuffer.get()->plane(0), exifData,\n+\t\t      quality);\n+}\n+\n int EncoderLibJpeg::generateThumbnail(const libcamera::FrameBuffer &source,\n \t\t\t\t      const libcamera::Size &targetSize,\n \t\t\t\t      unsigned int quality,\ndiff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h\nindex 1ec2ba13..6e9b65d4 100644\n--- a/src/android/jpeg/encoder_libjpeg.h\n+++ b/src/android/jpeg/encoder_libjpeg.h\n@@ -24,8 +24,7 @@ public:\n \t~EncoderLibJpeg();\n \n \tint configure(const libcamera::StreamConfiguration &cfg) override;\n-\tint encode(const libcamera::FrameBuffer &source,\n-\t\t   libcamera::Span<uint8_t> destination,\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(\n@@ -44,6 +43,10 @@ private:\n \t\t\t     libcamera::PixelFormat pixelFormat,\n \t\t\t     libcamera::Size size);\n \n+\tint encode(const libcamera::FrameBuffer &source,\n+\t\t   libcamera::Span<uint8_t> destination,\n+\t\t   libcamera::Span<const uint8_t> exifData,\n+\t\t   unsigned int quality);\n \tint encode(const std::vector<libcamera::Span<uint8_t>> &planes,\n \t\t   libcamera::Span<uint8_t> destination,\n \t\t   libcamera::Span<const uint8_t> exifData,\ndiff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex 233cdedb..a1555048 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -146,8 +146,7 @@ void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBu\n \tconst uint8_t quality = ret ? *entry.data.u8 : 95;\n \tresultMetadata->addEntry(ANDROID_JPEG_QUALITY, quality);\n \n-\tint jpeg_size = encoder_->encode(source, destination->plane(0),\n-\t\t\t\t\t exif.data(), quality);\n+\tint jpeg_size = encoder_->encode(streamBuffer, exif.data(), quality);\n \tif (jpeg_size < 0) {\n \t\tLOG(JPEG, Error) << \"Failed to encode stream image\";\n \t\tprocessComplete.emit(streamBuffer, PostProcessor::Status::Error);\n","prefixes":["libcamera-devel","v6","5/6"]}