{"id":15721,"url":"https://patchwork.libcamera.org/api/1.1/patches/15721/?format=json","web_url":"https://patchwork.libcamera.org/patch/15721/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220426091409.1352047-4-chenghaoyang@chromium.org>","date":"2022-04-26T09:14:08","name":"[libcamera-devel,v3,3/4] Rework JPEG encoder API and update PostProcessorJpeg and EncoderLibJpeg","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"28013381f8dacf2b7f96dfbc8b1fc8b6e197415c","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/1.1/people/117/?format=json","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15721/mbox/","series":[{"id":3071,"url":"https://patchwork.libcamera.org/api/1.1/series/3071/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3071","date":"2022-04-26T09:14:05","name":"Add CrOS JEA implementation","version":3,"mbox":"https://patchwork.libcamera.org/series/3071/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15721/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15721/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 A8DE3C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Apr 2022 09:16:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7054165649;\n\tTue, 26 Apr 2022 11:16:19 +0200 (CEST)","from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com\n\t[IPv6:2607:f8b0:4864:20::52f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 84D8C65643\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Apr 2022 11:16:17 +0200 (CEST)","by mail-pg1-x52f.google.com with SMTP id bg9so15575367pgb.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Apr 2022 02:16:17 -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\tw123-20020a623081000000b005056a4d71e3sm14441042pfw.77.2022.04.26.02.16.13\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 26 Apr 2022 02:16:14 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1650964579;\n\tbh=t9eztoBmuA0CjDVwGZ4AOhKORuYwroOYApQmLXpCjV0=;\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=z/8ME2CVerKw4nXn0WBivW+fQrc2j7Brrh0BfmEzvobyBgevF62ur4afg92JbJuu/\n\tBY2BAYuIwxEk/k2L24e1Mhdv27iSFczOQK+5VV5iul/SuE/UbHn559lNGHt2tvAtf0\n\tYCpR+4uAc21R3yBT5SkRKFz45tsWkiJkac6a6OB0T8QmtFgTljA4taztQx1zNKXuUW\n\t6rD/dPHMbnDkJmjSIJYPRDBgtx/2yK/jPgPIXSNPEsTN1xAMTDO7FKr6hiHlM5Mses\n\tQHH6T2qujM9Wrj5b79mZi8vzxmmGeqjLsLTpqruwHR202RMknqY7u/dGM3mwdlROrG\n\t2nf8Llks8BV6Q==","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=TnuFwhiUesDmIAuJNJ0ZvA1fo04LuHXt37R+2ems8BM=;\n\tb=c+qtfw0OZ5+P4GHmCQH4hjQkDB5VWzj5SOjxnXUStH1j38dhU8DjcgPUUXdLj3oEQm\n\tKIsADZIUAVEQY6x3mjxFr4Y4OoK9InCbLtOKtJxJWeoet5mgHD0arJnP8UUFdPvaKmHE\n\tZ+Pa7ehvKt61u3fCakoCozv/L9ZkyjxxntLJQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"c+qtfw0O\"; \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=TnuFwhiUesDmIAuJNJ0ZvA1fo04LuHXt37R+2ems8BM=;\n\tb=laTv/5GlK4NXM3scdqLfhJRNepfbF/uLTGAlsyQHakJWwcqMW9IdvSKh1dlyc3hA/I\n\t8XjhR3uV+Ud/XFqJUKnIByla5E+fK3kUuwuMvzF05aa3nlBLE0mUEcmXqiJkNzhaPucu\n\tpzkcfNZen0Nt/ur6vKfl/ZBoqIflVZ4URp707/fbEGlOx+wkOasjz7mqXLSwpOUf8rbw\n\tku268/IOUsY6xDgs/Q8Sj2iMGTG5GGC8jE4KquNPc3L6dAhv2i8fLR+3kbbItZKwmwZC\n\th+R9ou1qL5ZI50gc0FWD08O5X9H5YrQdpYH1YeBBlpHQiGbv/+v8DU6AOvl2D2m89QN9\n\tLmsw==","X-Gm-Message-State":"AOAM533vtOaRrVJB8+mTm8G06kKsD+EnXaFl9n6xhjaSFdaupWrmcmwv\n\tnRS8QXWDi7NSG+/g/06YMu26zlkYzCM3GRDM","X-Google-Smtp-Source":"ABdhPJy9oB1c/aHGf3j825qA4lSnsFILLpH2w4kNAVyt42Z03auoXiLaXlm16R4/g4frIeecBYumTw==","X-Received":"by 2002:a63:224f:0:b0:399:4a1a:b01f with SMTP id\n\tt15-20020a63224f000000b003994a1ab01fmr19004020pgm.123.1650964575385; \n\tTue, 26 Apr 2022 02:16:15 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 26 Apr 2022 09:14:08 +0000","Message-Id":"<20220426091409.1352047-4-chenghaoyang@chromium.org>","X-Mailer":"git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog","In-Reply-To":"<20220426091409.1352047-1-chenghaoyang@chromium.org>","References":"<20220426091409.1352047-1-chenghaoyang@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 3/4] Rework JPEG encoder API and update\n\tPostProcessorJpeg and EncoderLibJpeg","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":"To add JEA in the next CL, this CL reworks JPEG encoder API and move\nthumbnail encoding code into EncoderLibJpeg's implementation, as JEA\nsupports that as well.\n\nSigned-off-by: Harvey Yang <chenghaoyang at chromium.org>\n---\n src/android/jpeg/encoder.h                    |  9 ++-\n src/android/jpeg/encoder_libjpeg.cpp          | 70 +++++++++++++++++++\n src/android/jpeg/encoder_libjpeg.h            | 21 +++++-\n .../jpeg/generic_post_processor_jpeg.cpp      | 14 ++++\n src/android/jpeg/meson.build                  |  9 +++\n src/android/jpeg/post_processor_jpeg.cpp      | 60 ++--------------\n src/android/jpeg/post_processor_jpeg.h        | 11 +--\n src/android/meson.build                       |  5 +-\n 8 files changed, 128 insertions(+), 71 deletions(-)\n create mode 100644 src/android/jpeg/generic_post_processor_jpeg.cpp\n create mode 100644 src/android/jpeg/meson.build","diff":"diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h\nindex b974d367..6d527d91 100644\n--- a/src/android/jpeg/encoder.h\n+++ b/src/android/jpeg/encoder.h\n@@ -12,14 +12,19 @@\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(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) = 0;\n };\ndiff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp\nindex 21a3b33d..b5591e33 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@@ -82,8 +84,17 @@ EncoderLibJpeg::~EncoderLibJpeg()\n }\n \n int EncoderLibJpeg::configure(const StreamConfiguration &cfg)\n+{\n+\tthumbnailer_.configure(cfg.size, cfg.pixelFormat);\n+\tcfg_ = cfg;\n+\n+\treturn internalConfigure(cfg);\n+}\n+\n+int EncoderLibJpeg::internalConfigure(const StreamConfiguration &cfg)\n {\n \tconst struct JPEGPixelFormatInfo info = findPixelInfo(cfg.pixelFormat);\n+\n \tif (info.colorSpace == JCS_UNKNOWN)\n \t\treturn -ENOTSUP;\n \n@@ -178,6 +189,65 @@ 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+\tinternalConfigure(cfg_);\n+\treturn encode(*streamBuffer->srcBuffer, streamBuffer->dstBuffer.get()->plane(0), exifData, quality);\n+}\n+\n+int EncoderLibJpeg::generateThumbnail(\n+\tconst libcamera::FrameBuffer &source,\n+\tconst libcamera::Size &targetSize,\n+\tunsigned int quality,\n+\tstd::vector<unsigned char> *thumbnail)\n+{\n+\t/* Stores the raw scaled-down thumbnail bytes. */\n+\tstd::vector<unsigned char> rawThumbnail;\n+\n+\tthumbnailer_.createThumbnail(source, targetSize, &rawThumbnail);\n+\n+\tStreamConfiguration thCfg;\n+\tthCfg.size = targetSize;\n+\tthCfg.pixelFormat = thumbnailer_.pixelFormat();\n+\tint ret = internalConfigure(thCfg);\n+\n+\tif (!rawThumbnail.empty() && !ret) {\n+\t\t/*\n+\t\t * \\todo Avoid value-initialization of all elements of the\n+\t\t * vector.\n+\t\t */\n+\t\tthumbnail->resize(rawThumbnail.size());\n+\n+\t\t/*\n+\t\t * Split planes manually as the encoder expects a vector of\n+\t\t * planes.\n+\t\t *\n+\t\t * \\todo Pass a vector of planes directly to\n+\t\t * Thumbnailer::createThumbnailer above and remove the manual\n+\t\t * planes split from here.\n+\t\t */\n+\t\tstd::vector<Span<uint8_t>> thumbnailPlanes;\n+\t\tconst PixelFormatInfo &formatNV12 = PixelFormatInfo::info(formats::NV12);\n+\t\tsize_t yPlaneSize = formatNV12.planeSize(targetSize, 0);\n+\t\tsize_t uvPlaneSize = formatNV12.planeSize(targetSize, 1);\n+\t\tthumbnailPlanes.push_back({ rawThumbnail.data(), yPlaneSize });\n+\t\tthumbnailPlanes.push_back({ rawThumbnail.data() + yPlaneSize, uvPlaneSize });\n+\n+\t\tint jpeg_size = encode(thumbnailPlanes, *thumbnail, {}, quality);\n+\t\tthumbnail->resize(jpeg_size);\n+\n+\t\tLOG(JPEG, Debug)\n+\t\t\t<< \"Thumbnail compress returned \"\n+\t\t\t<< jpeg_size << \" bytes\";\n+\n+\t\treturn jpeg_size;\n+\t}\n+\n+\treturn -1;\n+}\n+\n int EncoderLibJpeg::encode(const FrameBuffer &source, Span<uint8_t> dest,\n \t\t\t   Span<const uint8_t> exifData, unsigned int quality)\n {\ndiff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h\nindex 1b3ac067..56b27bae 100644\n--- a/src/android/jpeg/encoder_libjpeg.h\n+++ b/src/android/jpeg/encoder_libjpeg.h\n@@ -15,6 +15,8 @@\n \n #include <jpeglib.h>\n \n+#include \"thumbnailer.h\"\n+\n class EncoderLibJpeg : public Encoder\n {\n public:\n@@ -22,19 +24,32 @@ public:\n \t~EncoderLibJpeg();\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(\n+\t\tconst libcamera::FrameBuffer &source,\n+\t\tconst libcamera::Size &targetSize,\n+\t\tunsigned int quality,\n+\t\tstd::vector<unsigned char> *thumbnail) override;\n+\n+private:\n+\tint internalConfigure(const libcamera::StreamConfiguration &cfg);\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) override;\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,\n \t\t   unsigned int quality);\n \n-private:\n \tvoid compressRGB(const std::vector<libcamera::Span<uint8_t>> &planes);\n \tvoid compressNV(const std::vector<libcamera::Span<uint8_t>> &planes);\n \n+\tlibcamera::StreamConfiguration cfg_;\n+\n \tstruct jpeg_compress_struct compress_;\n \tstruct jpeg_error_mgr jerr_;\n \n@@ -42,4 +57,6 @@ private:\n \n \tbool nv_;\n \tbool nvSwap_;\n+\n+\tThumbnailer thumbnailer_;\n };\ndiff --git a/src/android/jpeg/generic_post_processor_jpeg.cpp b/src/android/jpeg/generic_post_processor_jpeg.cpp\nnew file mode 100644\nindex 00000000..890f6972\n--- /dev/null\n+++ b/src/android/jpeg/generic_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+ * generic_post_processor_jpeg.cpp - Generic JPEG Post Processor\n+ */\n+\n+#include \"encoder_libjpeg.h\"\n+#include \"post_processor_jpeg.h\"\n+\n+void PostProcessorJpeg::SetEncoder()\n+{\n+\tencoder_ = std::make_unique<EncoderLibJpeg>();\n+}\ndiff --git a/src/android/jpeg/meson.build b/src/android/jpeg/meson.build\nnew file mode 100644\nindex 00000000..94522dc0\n--- /dev/null\n+++ b/src/android/jpeg/meson.build\n@@ -0,0 +1,9 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+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'])\ndiff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex d72ebc3c..7ceba60e 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -9,10 +9,10 @@\n \n #include <chrono>\n \n+#include \"../android_framebuffer.h\"\n #include \"../camera_device.h\"\n #include \"../camera_metadata.h\"\n #include \"../camera_request.h\"\n-#include \"encoder_libjpeg.h\"\n #include \"exif.h\"\n \n #include <libcamera/base/log.h>\n@@ -44,60 +44,11 @@ int PostProcessorJpeg::configure(const StreamConfiguration &inCfg,\n \n \tstreamSize_ = outCfg.size;\n \n-\tthumbnailer_.configure(inCfg.size, inCfg.pixelFormat);\n-\n-\tencoder_ = std::make_unique<EncoderLibJpeg>();\n+\tSetEncoder();\n \n \treturn encoder_->configure(inCfg);\n }\n \n-void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,\n-\t\t\t\t\t  const Size &targetSize,\n-\t\t\t\t\t  unsigned int quality,\n-\t\t\t\t\t  std::vector<unsigned char> *thumbnail)\n-{\n-\t/* Stores the raw scaled-down thumbnail bytes. */\n-\tstd::vector<unsigned char> rawThumbnail;\n-\n-\tthumbnailer_.createThumbnail(source, targetSize, &rawThumbnail);\n-\n-\tStreamConfiguration thCfg;\n-\tthCfg.size = targetSize;\n-\tthCfg.pixelFormat = thumbnailer_.pixelFormat();\n-\tint ret = thumbnailEncoder_.configure(thCfg);\n-\n-\tif (!rawThumbnail.empty() && !ret) {\n-\t\t/*\n-\t\t * \\todo Avoid value-initialization of all elements of the\n-\t\t * vector.\n-\t\t */\n-\t\tthumbnail->resize(rawThumbnail.size());\n-\n-\t\t/*\n-\t\t * Split planes manually as the encoder expects a vector of\n-\t\t * planes.\n-\t\t *\n-\t\t * \\todo Pass a vector of planes directly to\n-\t\t * Thumbnailer::createThumbnailer above and remove the manual\n-\t\t * planes split from here.\n-\t\t */\n-\t\tstd::vector<Span<uint8_t>> thumbnailPlanes;\n-\t\tconst PixelFormatInfo &formatNV12 = PixelFormatInfo::info(formats::NV12);\n-\t\tsize_t yPlaneSize = formatNV12.planeSize(targetSize, 0);\n-\t\tsize_t uvPlaneSize = formatNV12.planeSize(targetSize, 1);\n-\t\tthumbnailPlanes.push_back({ rawThumbnail.data(), yPlaneSize });\n-\t\tthumbnailPlanes.push_back({ rawThumbnail.data() + yPlaneSize, uvPlaneSize });\n-\n-\t\tint jpeg_size = thumbnailEncoder_.encode(thumbnailPlanes,\n-\t\t\t\t\t\t\t *thumbnail, {}, quality);\n-\t\tthumbnail->resize(jpeg_size);\n-\n-\t\tLOG(JPEG, Debug)\n-\t\t\t<< \"Thumbnail compress returned \"\n-\t\t\t<< jpeg_size << \" bytes\";\n-\t}\n-}\n-\n void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBuffer)\n {\n \tASSERT(encoder_);\n@@ -164,8 +115,8 @@ void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBu\n \n \t\tif (thumbnailSize != Size(0, 0)) {\n \t\t\tstd::vector<unsigned char> thumbnail;\n-\t\t\tgenerateThumbnail(source, thumbnailSize, quality, &thumbnail);\n-\t\t\tif (!thumbnail.empty())\n+\t\t\tret = encoder_->generateThumbnail(source, thumbnailSize, quality, &thumbnail);\n+\t\t\tif (ret > 0 && !thumbnail.empty())\n \t\t\t\texif.setThumbnail(thumbnail, Exif::Compression::JPEG);\n \t\t}\n \n@@ -194,8 +145,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);\ndiff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h\nindex 98309b01..a09f8798 100644\n--- a/src/android/jpeg/post_processor_jpeg.h\n+++ b/src/android/jpeg/post_processor_jpeg.h\n@@ -8,11 +8,11 @@\n #pragma once\n \n #include \"../post_processor.h\"\n-#include \"encoder_libjpeg.h\"\n-#include \"thumbnailer.h\"\n \n #include <libcamera/geometry.h>\n \n+#include \"encoder.h\"\n+\n class CameraDevice;\n \n class PostProcessorJpeg : public PostProcessor\n@@ -25,14 +25,9 @@ public:\n \tvoid process(Camera3RequestDescriptor::StreamBuffer *streamBuffer) override;\n \n private:\n-\tvoid 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);\n+\tvoid SetEncoder();\n \n \tCameraDevice *const cameraDevice_;\n \tstd::unique_ptr<Encoder> encoder_;\n \tlibcamera::Size streamSize_;\n-\tEncoderLibJpeg thumbnailEncoder_;\n-\tThumbnailer thumbnailer_;\n };\ndiff --git a/src/android/meson.build b/src/android/meson.build\nindex 27be27bb..026b8b3c 100644\n--- a/src/android/meson.build\n+++ b/src/android/meson.build\n@@ -48,10 +48,6 @@ android_hal_sources = files([\n     'camera_ops.cpp',\n     'camera_request.cpp',\n     'camera_stream.cpp',\n-    'jpeg/encoder_libjpeg.cpp',\n-    'jpeg/exif.cpp',\n-    'jpeg/post_processor_jpeg.cpp',\n-    'jpeg/thumbnailer.cpp',\n     'yuv/post_processor_yuv.cpp'\n ])\n \n@@ -59,6 +55,7 @@ android_cpp_args = []\n \n subdir('cros')\n subdir('mm')\n+subdir('jpeg')\n \n android_camera_metadata_sources = files([\n     'metadata/camera_metadata.c',\n","prefixes":["libcamera-devel","v3","3/4"]}