{"id":16315,"url":"https://patchwork.libcamera.org/api/patches/16315/?format=json","web_url":"https://patchwork.libcamera.org/patch/16315/","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":"<20220622123706.2946976-6-chenghaoyang@google.com>","date":"2022-06-22T12:37:05","name":"[libcamera-devel,v5,5/6] Pass StreamBuffer to Encoder::encoder","commit_ref":null,"pull_url":null,"state":"superseded","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/16315/mbox/","series":[{"id":3203,"url":"https://patchwork.libcamera.org/api/series/3203/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3203","date":"2022-06-22T12:37:00","name":"Add CrOS JEA implementation","version":5,"mbox":"https://patchwork.libcamera.org/series/3203/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16315/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16315/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 242F6BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Jun 2022 12:37:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D97BF65638;\n\tWed, 22 Jun 2022 14:37:33 +0200 (CEST)","from mail-pf1-x431.google.com (mail-pf1-x431.google.com\n\t[IPv6:2607:f8b0:4864:20::431])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B9F93633A7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jun 2022 14:37:32 +0200 (CEST)","by mail-pf1-x431.google.com with SMTP id p14so10299623pfh.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jun 2022 05:37:32 -0700 (PDT)","from chenghaoyang-low.c.googlers.com.com\n\t(21.160.199.104.bc.googleusercontent.com. [104.199.160.21])\n\tby smtp.gmail.com with ESMTPSA id\n\tj3-20020a170903024300b0016378bfeb90sm12684038plh.227.2022.06.22.05.37.26\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 22 Jun 2022 05:37:28 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655901453;\n\tbh=mGlCwGwC2Tp3XWmgWLv41jgNhgsHJMstwCRgfl1zO0M=;\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=E/T7ylWG/fWTo0phHBR2cB7thg+m+8LX+lCQZxk/AOlOrt6kIN3gKbkwTdY6VkIhp\n\tFgmaCynClFCMAdznXj6E77QvsRXWDxtI5ti7RGqpCG2jQh9S5FgUcXlSrDaeLMw125\n\t9Bqubb6jWR61WejdupgXBMOgVf3B2w5VcZXubw/dr91Obr63uApubluk+GcFZmOEXF\n\tMbc3UgfTAIhcv8DnMlPkhERmrbTGCNHNPAGtkUm7s4cvoTQ9GI1dweGhFO+LJ0zkrP\n\tFo939pPnI6PmT3RCozADCsqloP0sZzL2fKYtD2B7SevEK3yTcwkUL6pc0vt1+TE9FC\n\tnB5GX9Mwo45XQ==","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=0BLlbRlkKi+qUNRpBngyDWy4oL4WYowVOHPmHfeu/qc=;\n\tb=iDZ157Pn7ajJMdFASJcTGyS6KiALaZ689IMRmB1XalWi50CY/vj5/ww16L8hSzg1Oi\n\tbYTrZ7xDlNitxrCAakcr0WgxxqPHEULkRUq2AEeyhY+QlZRsPzuOfAgWZaSRTc/arHV7\n\tO/vXAGSTrPOxRFeCnjxeR8HX5nvWAIfhxGtJs="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"iDZ157Pn\"; \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=0BLlbRlkKi+qUNRpBngyDWy4oL4WYowVOHPmHfeu/qc=;\n\tb=vzDuB4dggF1lbyyVbK0TIChrmSpoKHTwsxHfFDrPU0OI7SDX4GcPTQyOs7vaOvO23x\n\tRNPcAplIDKBUvknGbVxoM2RqGPd09EspvaxUocd8mvFekW1ZQ9mxNJGuGTLt6y8+Ln5+\n\tN/olDYhw4zVFF74WwY1heO+G7yYtE9nHAtiuZ2/nJHhjV1hZNsyW5JaZ6Zhbz6i1CYZc\n\tJZFwAHmqQkw2Ku1qrMuJJ7ZNVu4nc15gnoxAf7aue/Bg5AoDEBwG4T5TCoMjciNMsuiY\n\t2N+hOyA+jRB4/hpikwV25Gl39b1RUbF0jtnqoZD/EkEefvRNYvqwB/UOlAzQtFN9n4dG\n\tp/yA==","X-Gm-Message-State":"AJIora/+nnmf5lyhSaW+EwqV9qPAAiZj9LsfQVSE70nr6t3v83HNOQUw\n\tVe+A8rNY11JEcdmjD0iL8bWPfZT8WaLtig==","X-Google-Smtp-Source":"AGRyM1sqIbL3uqr98/BKXd3qIl/1Cr/9cCnfaLkMo03J7ZXvhGgKd2Gp9JdPKTLFRatY090WeGVyRw==","X-Received":"by 2002:a05:6a00:996:b0:505:b6d2:abc8 with SMTP id\n\tu22-20020a056a00099600b00505b6d2abc8mr35265989pfg.11.1655901450837; \n\tWed, 22 Jun 2022 05:37:30 -0700 (PDT)","X-Google-Original-From":"Harvey Yang <chenghaoyang@google.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 22 Jun 2022 12:37:05 +0000","Message-Id":"<20220622123706.2946976-6-chenghaoyang@google.com>","X-Mailer":"git-send-email 2.37.0.rc0.104.g0611611a94-goog","In-Reply-To":"<20220622123706.2946976-1-chenghaoyang@google.com>","References":"<20220622123706.2946976-1-chenghaoyang@google.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 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","v5","5/6"]}