[{"id":13219,"web_url":"https://patchwork.libcamera.org/comment/13219/","msgid":"<4f8ae975-6650-a799-44bc-b2949c9a59d7@ideasonboard.com>","date":"2020-10-15T19:32:29","subject":"Re: [libcamera-devel] [PATCH 2/3] android: jpeg: Port to\n\tPostProcessor interface","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Umang,\n\nOn 15/10/2020 18:14, Umang Jain wrote:\n> Port the CameraStream's JPEG-encoding bits to PostProcessorJpeg.\n> This encapsulates the encoder and EXIF generation code into the\n> PostProcessorJpeg layer and removes these specifics related to JPEG,\n> from the CameraStream itself.\n\nFantastic, getting all the JPEG specifics out of CameraStream is really\ngood.\n\n> \n> Signed-off-by: Umang Jain <email@uajain.com>\n> ---\n>  src/android/camera_device.cpp            |   1 +\n>  src/android/camera_stream.cpp            |  77 ++++------------\n>  src/android/camera_stream.h              |   4 +-\n>  src/android/jpeg/encoder_libjpeg.cpp     |   2 +-\n>  src/android/jpeg/post_processor_jpeg.cpp | 110 +++++++++++++++++++++++\n>  src/android/jpeg/post_processor_jpeg.h   |  36 ++++++++\n>  src/android/meson.build                  |   1 +\n>  7 files changed, 169 insertions(+), 62 deletions(-)\n>  create mode 100644 src/android/jpeg/post_processor_jpeg.cpp\n>  create mode 100644 src/android/jpeg/post_processor_jpeg.h\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index c29fcb4..d6a8acb 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -7,6 +7,7 @@\n>  \n>  #include \"camera_device.h\"\n>  #include \"camera_ops.h\"\n> +#include \"post_processor.h\"\n>  \n>  #include <sys/mman.h>\n>  #include <tuple>\n> diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\n> index eac1480..2a0ba16 100644\n> --- a/src/android/camera_stream.cpp\n> +++ b/src/android/camera_stream.cpp\n> @@ -9,9 +9,9 @@\n>  \n>  #include \"camera_device.h\"\n>  #include \"camera_metadata.h\"\n> -#include \"jpeg/encoder.h\"\n> -#include \"jpeg/encoder_libjpeg.h\"\n> -#include \"jpeg/exif.h\"\n> +#include \"jpeg/post_processor_jpeg.h\"\n> +\n> +#include <libcamera/formats.h>\n>  \n>  using namespace libcamera;\n>  \n> @@ -24,8 +24,15 @@ CameraStream::CameraStream(CameraDevice *cameraDevice, Type type,\n>  {\n>  \tconfig_ = cameraDevice_->cameraConfiguration();\n>  \n> -\tif (type_ == Type::Internal || type_ == Type::Mapped)\n> -\t\tencoder_ = std::make_unique<EncoderLibJpeg>();\n> +\tif (type_ == Type::Internal || type_ == Type::Mapped) {\n> +\t\t/*\n> +\t\t * \\todo There might be multiple post-processors. The logic\n> +\t\t * which should be instantiated here, is deferred for future.\n> +\t\t * For now, we only have PostProcessorJpeg and that is what we\n> +\t\t * will instantiate here.\n> +\t\t */\n> +\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n\nAgreed, we can leave it to the next PostProcessor to decide how we\ncreate these. We've got one - this is it ;-)\n\nI anticipate we might also have to chain them together too, so we'll\nneed to figure out how to handle multiple PostProcessors feeding into\neach other without turning into a full gstreamer-esque pipeline.\n\n(For instance, we'll have a Format Convertor to take YUYV->NV12, and\nthen an Encoder to take NV12->MJPEG for UVC pipelines)\n\n> +\t}\n>  \n>  \tif (type == Type::Internal) {\n>  \t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n> @@ -45,8 +52,10 @@ Stream *CameraStream::stream() const\n>  \n>  int CameraStream::configure()\n>  {\n> -\tif (encoder_) {\n> -\t\tint ret = encoder_->configure(configuration());\n> +\tif (postProcessor_) {\n> +\t\tStreamConfiguration output = configuration();\n> +\t\toutput.pixelFormat == formats::MJPEG;\n> +\t\tint ret = postProcessor_->configure(configuration(), output);\n>  \t\tif (ret)\n>  \t\t\treturn ret;\n>  \t}\n> @@ -69,60 +78,10 @@ int CameraStream::configure()\n>  int CameraStream::process(const libcamera::FrameBuffer &source,\n>  \t\t\t  MappedCamera3Buffer *dest, CameraMetadata *metadata)\n>  {\n> -\tif (!encoder_)\n> +\tif (!postProcessor_)\n>  \t\treturn 0;\n>  \n> -\t/* Set EXIF metadata for various tags. */\n> -\tExif exif;\n> -\t/* \\todo Set Make and Model from external vendor tags. */\n> -\texif.setMake(\"libcamera\");\n> -\texif.setModel(\"cameraModel\");\n> -\texif.setOrientation(cameraDevice_->orientation());\n> -\texif.setSize(configuration().size);\n> -\t/*\n> -\t * We set the frame's EXIF timestamp as the time of encode.\n> -\t * Since the precision we need for EXIF timestamp is only one\n> -\t * second, it is good enough.\n> -\t */\n> -\texif.setTimestamp(std::time(nullptr));\n> -\tif (exif.generate() != 0)\n> -\t\tLOG(HAL, Error) << \"Failed to generate valid EXIF data\";\n> -\n> -\tint jpeg_size = encoder_->encode(&source, dest->maps()[0], exif.data());\n> -\tif (jpeg_size < 0) {\n> -\t\tLOG(HAL, Error) << \"Failed to encode stream image\";\n> -\t\treturn jpeg_size;\n> -\t}\n> -\n> -\t/*\n> -\t * Fill in the JPEG blob header.\n> -\t *\n> -\t * The mapped size of the buffer is being returned as\n> -\t * substantially larger than the requested JPEG_MAX_SIZE\n> -\t * (which is referenced from maxJpegBufferSize_). Utilise\n> -\t * this static size to ensure the correct offset of the blob is\n> -\t * determined.\n> -\t *\n> -\t * \\todo Investigate if the buffer size mismatch is an issue or\n> -\t * expected behaviour.\n> -\t */\n> -\tuint8_t *resultPtr = dest->maps()[0].data() +\n> -\t\t\t     cameraDevice_->maxJpegBufferSize() -\n> -\t\t\t     sizeof(struct camera3_jpeg_blob);\n> -\tauto *blob = reinterpret_cast<struct camera3_jpeg_blob *>(resultPtr);\n> -\tblob->jpeg_blob_id = CAMERA3_JPEG_BLOB_ID;\n> -\tblob->jpeg_size = jpeg_size;\n> -\n> -\t/* Update the JPEG result Metadata. */\n> -\tmetadata->addEntry(ANDROID_JPEG_SIZE, &jpeg_size, 1);\n> -\n> -\tconst uint32_t jpeg_quality = 95;\n> -\tmetadata->addEntry(ANDROID_JPEG_QUALITY, &jpeg_quality, 1);\n> -\n> -\tconst uint32_t jpeg_orientation = 0;\n> -\tmetadata->addEntry(ANDROID_JPEG_ORIENTATION, &jpeg_orientation, 1);\n> -> -\treturn 0;\n> +\treturn postProcessor_->process(&source, dest->maps()[0], metadata);\n\nI wonder if we should move this to the point that calls\nCameraStream::process() directly ... but equally, if we have multiple\npost-processors we might have to do more operations here ... so that\nmakes me think we should keep this function for now..\n\n\n>  }\n>  \n>  FrameBuffer *CameraStream::getBuffer()\n> diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\n> index 8df0101..c55d90b 100644\n> --- a/src/android/camera_stream.h\n> +++ b/src/android/camera_stream.h\n> @@ -19,10 +19,10 @@\n>  #include <libcamera/geometry.h>\n>  #include <libcamera/pixel_format.h>\n>  \n> -class Encoder;\n>  class CameraDevice;\n>  class CameraMetadata;\n>  class MappedCamera3Buffer;\n> +class PostProcessor;\n>  \n>  class CameraStream\n>  {\n> @@ -135,7 +135,6 @@ private:\n>  \t */\n>  \tunsigned int index_;\n>  \n> -\tstd::unique_ptr<Encoder> encoder_;\n>  \tstd::unique_ptr<libcamera::FrameBufferAllocator> allocator_;\n>  \tstd::vector<libcamera::FrameBuffer *> buffers_;\n>  \t/*\n> @@ -143,6 +142,7 @@ private:\n>  \t * an std::vector in CameraDevice.\n>  \t */\n>  \t std::unique_ptr<std::mutex> mutex_;\n\nHaha, Maybe I would have had the nitpick-fix patch first ;-) It really\nstands out here - but either way is fine.\n\n\n> +\tstd::unique_ptr<PostProcessor> postProcessor_;\n>  };\n>  \n>  #endif /* __ANDROID_CAMERA_STREAM__ */\n> diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp\n> index a77f5b2..8995ba5 100644\n> --- a/src/android/jpeg/encoder_libjpeg.cpp\n> +++ b/src/android/jpeg/encoder_libjpeg.cpp\n> @@ -25,7 +25,7 @@\n>  \n>  using namespace libcamera;\n>  \n> -LOG_DEFINE_CATEGORY(JPEG)\n> +LOG_DECLARE_CATEGORY(JPEG);\n>  \n>  namespace {\n>  \n> diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\n> new file mode 100644\n> index 0000000..d1ec95b\n> --- /dev/null\n> +++ b/src/android/jpeg/post_processor_jpeg.cpp\n> @@ -0,0 +1,110 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2020, Google Inc.\n> + *\n> + * post_processor_jpeg.cpp - JPEG Post Processor\n> + */\n> +\n> +#include \"post_processor_jpeg.h\"\n> +\n> +#include \"../camera_device.h\"\n> +#include \"../camera_metadata.h\"\n> +#include \"encoder_libjpeg.h\"\n> +#include \"exif.h\"\n> +\n> +#include <libcamera/formats.h>\n> +\n> +#include \"libcamera/internal/log.h\"\n> +\n> +using namespace libcamera;\n> +\n> +LOG_DEFINE_CATEGORY(JPEG);\n\nI'm wondering if we should separate the categories for the JPEG encoder,\nand the PostProcessor layers - but I think it's all JPEG related, so\nkeeping fewer LOG_CATEGORY's is probably better, so I think I'm happy\nwith this.\n\n\n> +\n> +PostProcessorJpeg::PostProcessorJpeg(CameraDevice *device)\n> +\t: cameraDevice_(device)\n> +{\n> +}\n> +\n> +int PostProcessorJpeg::configure(const StreamConfiguration &inCfg,\n> +\t\t\t\t const StreamConfiguration &outCfg)\n> +{\n> +\tint ret = 0;\n> +\n> +\tif (inCfg.size != outCfg.size) {\n> +\t\tLOG(JPEG, Error) << \"Mismatch of input and output stream sizes\";\n> +\t\treturn -1;\n\nWe could use (negative) errno values here.\n\neither:\n\nEXDEV 18 Invalid cross-device link\nor\nEINVAL 22 Invalid argument\n\n\n> +\t}\n> +\n> +\tif (outCfg.pixelFormat != formats::MJPEG) {\n> +\t\tLOG(JPEG, Error) << \"Output stream pixel format is not JPEG\";\n> +\t\treturn -1;\n\nSame here of course.\n\n> +\t}\n> +\n> +\tstreamSize_ = outCfg.size;\n> +\tencoder_ = std::make_unique<EncoderLibJpeg>();\n\nWe could also create the encoder_ during construction, but wherever it\nhappens, later there will have to be a factory/condition to decide\nwhether to create the libjpeg encoder, or the hardware accellerated one,\nso I don't mind it being here at the moment... however...\n\n\n> +\n> +\tif (encoder_)\n> +\t\tret = encoder_->configure(inCfg);\n> +\n\nYou need to initialise ret to an error value, above as here it will\nreturn success if the encoder was not created.\n\n> +\treturn ret;\n> +}\n> +\n> +int PostProcessorJpeg::process(const libcamera::FrameBuffer *source,\n> +\t\t\t       const libcamera::Span<uint8_t> &destination,\n> +\t\t\t       CameraMetadata *metadata)\n> +{\n> +\tif (!encoder_)\n> +\t\treturn 0;\n> +\n> +\t/* Set EXIF metadata for various tags. */\n> +\tExif exif;\n> +\t/* \\todo Set Make and Model from external vendor tags. */\n> +\texif.setMake(\"libcamera\");\n> +\texif.setModel(\"cameraModel\");\n> +\texif.setOrientation(cameraDevice_->orientation());\n> +\texif.setSize(streamSize_);\n> +\t/*\n> +\t * We set the frame's EXIF timestamp as the time of encode.\n> +\t * Since the precision we need for EXIF timestamp is only one\n> +\t * second, it is good enough.\n> +\t */\n> +\texif.setTimestamp(std::time(nullptr));\n> +\tif (exif.generate() != 0)\n> +\t\tLOG(JPEG, Error) << \"Failed to generate valid EXIF data\";\n> +\n> +\tint jpeg_size = encoder_->encode(source, destination, exif.data());\n> +\tif (jpeg_size < 0) {\n> +\t\tLOG(JPEG, Error) << \"Failed to encode stream image\";\n> +\t\treturn jpeg_size;\n> +\t}\n> +\n> +\t/*\n> +\t * Fill in the JPEG blob header.\n> +\t *\n> +\t * The mapped size of the buffer is being returned as\n> +\t * substantially larger than the requested JPEG_MAX_SIZE\n> +\t * (which is referenced from maxJpegBufferSize_). Utilise\n> +\t * this static size to ensure the correct offset of the blob is\n> +\t * determined.\n> +\t *\n> +\t * \\todo Investigate if the buffer size mismatch is an issue or\n> +\t * expected behaviour.\n> +\t */\n> +\tuint8_t *resultPtr = destination.data() +\n> +\t\t\t     cameraDevice_->maxJpegBufferSize() -\n> +\t\t\t     sizeof(struct camera3_jpeg_blob);\n> +\tauto *blob = reinterpret_cast<struct camera3_jpeg_blob *>(resultPtr);\n> +\tblob->jpeg_blob_id = CAMERA3_JPEG_BLOB_ID;\n> +\tblob->jpeg_size = jpeg_size;\n> +\n> +\t/* Update the JPEG result Metadata. */\n> +\tmetadata->addEntry(ANDROID_JPEG_SIZE, &jpeg_size, 1);\n> +\n> +\tconst uint32_t jpeg_quality = 95;\n> +\tmetadata->addEntry(ANDROID_JPEG_QUALITY, &jpeg_quality, 1);\n> +\n> +\tconst uint32_t jpeg_orientation = 0;\n> +\tmetadata->addEntry(ANDROID_JPEG_ORIENTATION, &jpeg_orientation, 1);\n> +\n> +\treturn 0;\n> +}\n> diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h\n> new file mode 100644\n> index 0000000..72aca9b\n> --- /dev/null\n> +++ b/src/android/jpeg/post_processor_jpeg.h\n> @@ -0,0 +1,36 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2020, Google Inc.\n> + *\n> + * post_processor_jpeg.h - JPEG Post Processor\n> + */\n> +#ifndef __ANDROID_POST_PROCESSOR_JPEG_H__\n> +#define __ANDROID_POST_PROCESSOR_JPEG_H__\n> +\n> +#include \"../post_processor.h\"\n> +#include \"libcamera/internal/buffer.h\"\n> +\n> +#include <libcamera/geometry.h>\n> +\n> +class Encoder;\n> +class CameraDevice;\n> +\n> +class PostProcessorJpeg : public PostProcessor\n> +{\n> +public:\n> +\tPostProcessorJpeg(CameraDevice *device);\n> +\n> +\tint configure(const libcamera::StreamConfiguration &incfg,\n> +\t\t      const libcamera::StreamConfiguration &outcfg) override;\n> +\tint process(const libcamera::FrameBuffer *source,\n> +\t\t    const libcamera::Span<uint8_t> &destination,\n> +\t\t    CameraMetadata *metadata) override;\n> +\n> +\n\nThere's an extra blank line here.\n\nWith negative errno values in  PostProcessorJpeg::configure, and the ret\nin that function handled correctly if the encoder isn't created:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> +private:\n> +\tCameraDevice *cameraDevice_;\n> +\tstd::unique_ptr<Encoder> encoder_;\n> +\tlibcamera::Size streamSize_;\n> +};\n> +\n> +#endif /* __ANDROID_POST_PROCESSOR_JPEG_H__ */\n> diff --git a/src/android/meson.build b/src/android/meson.build\n> index 802bb89..eacd544 100644\n> --- a/src/android/meson.build\n> +++ b/src/android/meson.build\n> @@ -23,6 +23,7 @@ android_hal_sources = files([\n>      'camera_stream.cpp',\n>      'jpeg/encoder_libjpeg.cpp',\n>      'jpeg/exif.cpp',\n> +    'jpeg/post_processor_jpeg.cpp',\n>  ])\n>  \n>  android_camera_metadata_sources = files([\n>","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 178ADBE174\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Oct 2020 19:32:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9984E60E8D;\n\tThu, 15 Oct 2020 21:32:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 19B66605BF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Oct 2020 21:32:33 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7025D556;\n\tThu, 15 Oct 2020 21:32:32 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ECIm1Hon\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1602790352;\n\tbh=ZUCief10sXSDMLFH5kIZI3JqCepk1Jg0gJpwNLufYYQ=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=ECIm1HonLqnuFOvPNGYzqxdRQbWJ8aSdBQW1IntKYgg3vIh0vgmyMUDwYZfbrMtOh\n\tLy7NRryaxOOGs52IEGq6/+YwAjY9Tj+1Wo3RvsZ/fa6gS0Yl41N459ok02PRJDNC5m\n\tlfPHMy5ovQjQw/8i4d70FsLV0PSFF8qO9Z9h4tfc=","To":"Umang Jain <email@uajain.com>, libcamera-devel@lists.libcamera.org","References":"<20201015171457.75678-1-email@uajain.com>\n\t<20201015171457.75678-3-email@uajain.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\t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\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<4f8ae975-6650-a799-44bc-b2949c9a59d7@ideasonboard.com>","Date":"Thu, 15 Oct 2020 20:32:29 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<20201015171457.75678-3-email@uajain.com>","Content-Language":"en-GB","Subject":"Re: [libcamera-devel] [PATCH 2/3] android: jpeg: Port to\n\tPostProcessor interface","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>","Reply-To":"kieran.bingham@ideasonboard.com","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>"}},{"id":13232,"web_url":"https://patchwork.libcamera.org/comment/13232/","msgid":"<20201016045716.GB14324@pendragon.ideasonboard.com>","date":"2020-10-16T04:57:16","subject":"Re: [libcamera-devel] [PATCH 2/3] android: jpeg: Port to\n\tPostProcessor interface","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\nOn Thu, Oct 15, 2020 at 08:32:29PM +0100, Kieran Bingham wrote:\n> On 15/10/2020 18:14, Umang Jain wrote:\n> > Port the CameraStream's JPEG-encoding bits to PostProcessorJpeg.\n> > This encapsulates the encoder and EXIF generation code into the\n> > PostProcessorJpeg layer and removes these specifics related to JPEG,\n> > from the CameraStream itself.\n> \n> Fantastic, getting all the JPEG specifics out of CameraStream is really\n> good.\n\nYes, it looks much better.\n\n> > Signed-off-by: Umang Jain <email@uajain.com>\n> > ---\n> >  src/android/camera_device.cpp            |   1 +\n> >  src/android/camera_stream.cpp            |  77 ++++------------\n> >  src/android/camera_stream.h              |   4 +-\n> >  src/android/jpeg/encoder_libjpeg.cpp     |   2 +-\n> >  src/android/jpeg/post_processor_jpeg.cpp | 110 +++++++++++++++++++++++\n> >  src/android/jpeg/post_processor_jpeg.h   |  36 ++++++++\n> >  src/android/meson.build                  |   1 +\n> >  7 files changed, 169 insertions(+), 62 deletions(-)\n> >  create mode 100644 src/android/jpeg/post_processor_jpeg.cpp\n> >  create mode 100644 src/android/jpeg/post_processor_jpeg.h\n> > \n> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> > index c29fcb4..d6a8acb 100644\n> > --- a/src/android/camera_device.cpp\n> > +++ b/src/android/camera_device.cpp\n> > @@ -7,6 +7,7 @@\n> >  \n> >  #include \"camera_device.h\"\n> >  #include \"camera_ops.h\"\n> > +#include \"post_processor.h\"\n> >  \n> >  #include <sys/mman.h>\n> >  #include <tuple>\n> > diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\n> > index eac1480..2a0ba16 100644\n> > --- a/src/android/camera_stream.cpp\n> > +++ b/src/android/camera_stream.cpp\n> > @@ -9,9 +9,9 @@\n> >  \n> >  #include \"camera_device.h\"\n> >  #include \"camera_metadata.h\"\n> > -#include \"jpeg/encoder.h\"\n> > -#include \"jpeg/encoder_libjpeg.h\"\n> > -#include \"jpeg/exif.h\"\n> > +#include \"jpeg/post_processor_jpeg.h\"\n> > +\n> > +#include <libcamera/formats.h>\n> >  \n> >  using namespace libcamera;\n> >  \n> > @@ -24,8 +24,15 @@ CameraStream::CameraStream(CameraDevice *cameraDevice, Type type,\n> >  {\n> >  \tconfig_ = cameraDevice_->cameraConfiguration();\n> >  \n> > -\tif (type_ == Type::Internal || type_ == Type::Mapped)\n> > -\t\tencoder_ = std::make_unique<EncoderLibJpeg>();\n> > +\tif (type_ == Type::Internal || type_ == Type::Mapped) {\n> > +\t\t/*\n> > +\t\t * \\todo There might be multiple post-processors. The logic\n> > +\t\t * which should be instantiated here, is deferred for future.\n\ns/, is deferred for future/ is deferred to the future/\n\n> > +\t\t * For now, we only have PostProcessorJpeg and that is what we\n> > +\t\t * will instantiate here.\n\ns/will //\n\n> > +\t\t */\n> > +\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n> \n> Agreed, we can leave it to the next PostProcessor to decide how we\n> create these. We've got one - this is it ;-)\n> \n> I anticipate we might also have to chain them together too, so we'll\n> need to figure out how to handle multiple PostProcessors feeding into\n> each other without turning into a full gstreamer-esque pipeline.\n\ngstreamer is exactly what came to my mind :-) It's tempting to make it\noverengineered, but let's try to keep it simple.\n\n> (For instance, we'll have a Format Convertor to take YUYV->NV12, and\n> then an Encoder to take NV12->MJPEG for UVC pipelines)\n\nIt would probably be more efficient to support encoding JPEG from YUYV\nthough. And we'll also need an MJPEG -> YUV/NV12 decompressor as webcams\noften provide higher resolutions and frame rates in MJPEG. Anyway,\nthat's for later.\n\n> > +\t}\n> >  \n> >  \tif (type == Type::Internal) {\n> >  \t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n> > @@ -45,8 +52,10 @@ Stream *CameraStream::stream() const\n> >  \n> >  int CameraStream::configure()\n> >  {\n> > -\tif (encoder_) {\n> > -\t\tint ret = encoder_->configure(configuration());\n> > +\tif (postProcessor_) {\n> > +\t\tStreamConfiguration output = configuration();\n> > +\t\toutput.pixelFormat == formats::MJPEG;\n\ns/==/=/\n\n> > +\t\tint ret = postProcessor_->configure(configuration(), output);\n> >  \t\tif (ret)\n> >  \t\t\treturn ret;\n> >  \t}\n> > @@ -69,60 +78,10 @@ int CameraStream::configure()\n> >  int CameraStream::process(const libcamera::FrameBuffer &source,\n> >  \t\t\t  MappedCamera3Buffer *dest, CameraMetadata *metadata)\n> >  {\n> > -\tif (!encoder_)\n> > +\tif (!postProcessor_)\n> >  \t\treturn 0;\n> >  \n> > -\t/* Set EXIF metadata for various tags. */\n> > -\tExif exif;\n> > -\t/* \\todo Set Make and Model from external vendor tags. */\n> > -\texif.setMake(\"libcamera\");\n> > -\texif.setModel(\"cameraModel\");\n> > -\texif.setOrientation(cameraDevice_->orientation());\n> > -\texif.setSize(configuration().size);\n> > -\t/*\n> > -\t * We set the frame's EXIF timestamp as the time of encode.\n> > -\t * Since the precision we need for EXIF timestamp is only one\n> > -\t * second, it is good enough.\n> > -\t */\n> > -\texif.setTimestamp(std::time(nullptr));\n> > -\tif (exif.generate() != 0)\n> > -\t\tLOG(HAL, Error) << \"Failed to generate valid EXIF data\";\n> > -\n> > -\tint jpeg_size = encoder_->encode(&source, dest->maps()[0], exif.data());\n> > -\tif (jpeg_size < 0) {\n> > -\t\tLOG(HAL, Error) << \"Failed to encode stream image\";\n> > -\t\treturn jpeg_size;\n> > -\t}\n> > -\n> > -\t/*\n> > -\t * Fill in the JPEG blob header.\n> > -\t *\n> > -\t * The mapped size of the buffer is being returned as\n> > -\t * substantially larger than the requested JPEG_MAX_SIZE\n> > -\t * (which is referenced from maxJpegBufferSize_). Utilise\n> > -\t * this static size to ensure the correct offset of the blob is\n> > -\t * determined.\n> > -\t *\n> > -\t * \\todo Investigate if the buffer size mismatch is an issue or\n> > -\t * expected behaviour.\n> > -\t */\n> > -\tuint8_t *resultPtr = dest->maps()[0].data() +\n> > -\t\t\t     cameraDevice_->maxJpegBufferSize() -\n> > -\t\t\t     sizeof(struct camera3_jpeg_blob);\n> > -\tauto *blob = reinterpret_cast<struct camera3_jpeg_blob *>(resultPtr);\n> > -\tblob->jpeg_blob_id = CAMERA3_JPEG_BLOB_ID;\n> > -\tblob->jpeg_size = jpeg_size;\n> > -\n> > -\t/* Update the JPEG result Metadata. */\n> > -\tmetadata->addEntry(ANDROID_JPEG_SIZE, &jpeg_size, 1);\n> > -\n> > -\tconst uint32_t jpeg_quality = 95;\n> > -\tmetadata->addEntry(ANDROID_JPEG_QUALITY, &jpeg_quality, 1);\n> > -\n> > -\tconst uint32_t jpeg_orientation = 0;\n> > -\tmetadata->addEntry(ANDROID_JPEG_ORIENTATION, &jpeg_orientation, 1);\n> > -> -\treturn 0;\n> > +\treturn postProcessor_->process(&source, dest->maps()[0], metadata);\n> \n> I wonder if we should move this to the point that calls\n> CameraStream::process() directly ... but equally, if we have multiple\n> post-processors we might have to do more operations here ... so that\n> makes me think we should keep this function for now..\n\nI'd keep it for now.\n\n> >  }\n> >  \n> >  FrameBuffer *CameraStream::getBuffer()\n> > diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\n> > index 8df0101..c55d90b 100644\n> > --- a/src/android/camera_stream.h\n> > +++ b/src/android/camera_stream.h\n> > @@ -19,10 +19,10 @@\n> >  #include <libcamera/geometry.h>\n> >  #include <libcamera/pixel_format.h>\n> >  \n> > -class Encoder;\n> >  class CameraDevice;\n> >  class CameraMetadata;\n> >  class MappedCamera3Buffer;\n> > +class PostProcessor;\n> >  \n> >  class CameraStream\n> >  {\n> > @@ -135,7 +135,6 @@ private:\n> >  \t */\n> >  \tunsigned int index_;\n> >  \n> > -\tstd::unique_ptr<Encoder> encoder_;\n> >  \tstd::unique_ptr<libcamera::FrameBufferAllocator> allocator_;\n> >  \tstd::vector<libcamera::FrameBuffer *> buffers_;\n> >  \t/*\n> > @@ -143,6 +142,7 @@ private:\n> >  \t * an std::vector in CameraDevice.\n> >  \t */\n> >  \t std::unique_ptr<std::mutex> mutex_;\n> \n> Haha, Maybe I would have had the nitpick-fix patch first ;-) It really\n> stands out here - but either way is fine.\n\nI've just pushed it to the master branch :-)\n\n> > +\tstd::unique_ptr<PostProcessor> postProcessor_;\n> >  };\n> >  \n> >  #endif /* __ANDROID_CAMERA_STREAM__ */\n> > diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp\n> > index a77f5b2..8995ba5 100644\n> > --- a/src/android/jpeg/encoder_libjpeg.cpp\n> > +++ b/src/android/jpeg/encoder_libjpeg.cpp\n> > @@ -25,7 +25,7 @@\n> >  \n> >  using namespace libcamera;\n> >  \n> > -LOG_DEFINE_CATEGORY(JPEG)\n> > +LOG_DECLARE_CATEGORY(JPEG);\n> >  \n> >  namespace {\n> >  \n> > diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\n> > new file mode 100644\n> > index 0000000..d1ec95b\n> > --- /dev/null\n> > +++ b/src/android/jpeg/post_processor_jpeg.cpp\n> > @@ -0,0 +1,110 @@\n> > +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> > +/*\n> > + * Copyright (C) 2020, Google Inc.\n> > + *\n> > + * post_processor_jpeg.cpp - JPEG Post Processor\n> > + */\n> > +\n> > +#include \"post_processor_jpeg.h\"\n> > +\n> > +#include \"../camera_device.h\"\n> > +#include \"../camera_metadata.h\"\n> > +#include \"encoder_libjpeg.h\"\n> > +#include \"exif.h\"\n> > +\n> > +#include <libcamera/formats.h>\n> > +\n> > +#include \"libcamera/internal/log.h\"\n> > +\n> > +using namespace libcamera;\n> > +\n> > +LOG_DEFINE_CATEGORY(JPEG);\n> \n> I'm wondering if we should separate the categories for the JPEG encoder,\n> and the PostProcessor layers - but I think it's all JPEG related, so\n> keeping fewer LOG_CATEGORY's is probably better, so I think I'm happy\n> with this.\n> \n> > +\n> > +PostProcessorJpeg::PostProcessorJpeg(CameraDevice *device)\n> > +\t: cameraDevice_(device)\n> > +{\n> > +}\n> > +\n> > +int PostProcessorJpeg::configure(const StreamConfiguration &inCfg,\n> > +\t\t\t\t const StreamConfiguration &outCfg)\n> > +{\n> > +\tint ret = 0;\n> > +\n> > +\tif (inCfg.size != outCfg.size) {\n> > +\t\tLOG(JPEG, Error) << \"Mismatch of input and output stream sizes\";\n> > +\t\treturn -1;\n> \n> We could use (negative) errno values here.\n> \n> either:\n> \n> EXDEV 18 Invalid cross-device link\n> or\n> EINVAL 22 Invalid argument\n> \n> > +\t}\n> > +\n> > +\tif (outCfg.pixelFormat != formats::MJPEG) {\n> > +\t\tLOG(JPEG, Error) << \"Output stream pixel format is not JPEG\";\n> > +\t\treturn -1;\n> \n> Same here of course.\n> \n> > +\t}\n> > +\n> > +\tstreamSize_ = outCfg.size;\n> > +\tencoder_ = std::make_unique<EncoderLibJpeg>();\n> \n> We could also create the encoder_ during construction, but wherever it\n> happens, later there will have to be a factory/condition to decide\n> whether to create the libjpeg encoder, or the hardware accellerated one,\n> so I don't mind it being here at the moment... however...\n> \n> > +\n> > +\tif (encoder_)\n> > +\t\tret = encoder_->configure(inCfg);\n> > +\n> \n> You need to initialise ret to an error value, above as here it will\n> return success if the encoder was not created.\n\nstd::make_unique<>() will never return null, will it ? Shouldn't the\ncheck just be dropped ?\n\n> > +\treturn ret;\n> > +}\n> > +\n> > +int PostProcessorJpeg::process(const libcamera::FrameBuffer *source,\n> > +\t\t\t       const libcamera::Span<uint8_t> &destination,\n> > +\t\t\t       CameraMetadata *metadata)\n> > +{\n> > +\tif (!encoder_)\n> > +\t\treturn 0;\n> > +\n> > +\t/* Set EXIF metadata for various tags. */\n> > +\tExif exif;\n> > +\t/* \\todo Set Make and Model from external vendor tags. */\n> > +\texif.setMake(\"libcamera\");\n> > +\texif.setModel(\"cameraModel\");\n> > +\texif.setOrientation(cameraDevice_->orientation());\n> > +\texif.setSize(streamSize_);\n> > +\t/*\n> > +\t * We set the frame's EXIF timestamp as the time of encode.\n> > +\t * Since the precision we need for EXIF timestamp is only one\n> > +\t * second, it is good enough.\n> > +\t */\n> > +\texif.setTimestamp(std::time(nullptr));\n> > +\tif (exif.generate() != 0)\n> > +\t\tLOG(JPEG, Error) << \"Failed to generate valid EXIF data\";\n> > +\n> > +\tint jpeg_size = encoder_->encode(source, destination, exif.data());\n> > +\tif (jpeg_size < 0) {\n> > +\t\tLOG(JPEG, Error) << \"Failed to encode stream image\";\n> > +\t\treturn jpeg_size;\n> > +\t}\n> > +\n> > +\t/*\n> > +\t * Fill in the JPEG blob header.\n> > +\t *\n> > +\t * The mapped size of the buffer is being returned as\n> > +\t * substantially larger than the requested JPEG_MAX_SIZE\n> > +\t * (which is referenced from maxJpegBufferSize_). Utilise\n> > +\t * this static size to ensure the correct offset of the blob is\n> > +\t * determined.\n> > +\t *\n> > +\t * \\todo Investigate if the buffer size mismatch is an issue or\n> > +\t * expected behaviour.\n> > +\t */\n> > +\tuint8_t *resultPtr = destination.data() +\n> > +\t\t\t     cameraDevice_->maxJpegBufferSize() -\n> > +\t\t\t     sizeof(struct camera3_jpeg_blob);\n> > +\tauto *blob = reinterpret_cast<struct camera3_jpeg_blob *>(resultPtr);\n> > +\tblob->jpeg_blob_id = CAMERA3_JPEG_BLOB_ID;\n> > +\tblob->jpeg_size = jpeg_size;\n> > +\n> > +\t/* Update the JPEG result Metadata. */\n> > +\tmetadata->addEntry(ANDROID_JPEG_SIZE, &jpeg_size, 1);\n> > +\n> > +\tconst uint32_t jpeg_quality = 95;\n> > +\tmetadata->addEntry(ANDROID_JPEG_QUALITY, &jpeg_quality, 1);\n> > +\n> > +\tconst uint32_t jpeg_orientation = 0;\n> > +\tmetadata->addEntry(ANDROID_JPEG_ORIENTATION, &jpeg_orientation, 1);\n> > +\n> > +\treturn 0;\n> > +}\n> > diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h\n> > new file mode 100644\n> > index 0000000..72aca9b\n> > --- /dev/null\n> > +++ b/src/android/jpeg/post_processor_jpeg.h\n> > @@ -0,0 +1,36 @@\n> > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > +/*\n> > + * Copyright (C) 2020, Google Inc.\n> > + *\n> > + * post_processor_jpeg.h - JPEG Post Processor\n> > + */\n> > +#ifndef __ANDROID_POST_PROCESSOR_JPEG_H__\n> > +#define __ANDROID_POST_PROCESSOR_JPEG_H__\n> > +\n> > +#include \"../post_processor.h\"\n> > +#include \"libcamera/internal/buffer.h\"\n\nThis header...\n\n> > +\n> > +#include <libcamera/geometry.h>\n> > +\n\n... should go here.\n\n> > +class Encoder;\n> > +class CameraDevice;\n> > +\n> > +class PostProcessorJpeg : public PostProcessor\n> > +{\n> > +public:\n> > +\tPostProcessorJpeg(CameraDevice *device);\n> > +\n> > +\tint configure(const libcamera::StreamConfiguration &incfg,\n> > +\t\t      const libcamera::StreamConfiguration &outcfg) override;\n> > +\tint process(const libcamera::FrameBuffer *source,\n> > +\t\t    const libcamera::Span<uint8_t> &destination,\n> > +\t\t    CameraMetadata *metadata) override;\n> > +\n> > +\n> \n> There's an extra blank line here.\n> \n> With negative errno values in  PostProcessorJpeg::configure, and the ret\n> in that function handled correctly if the encoder isn't created:\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > +private:\n> > +\tCameraDevice *cameraDevice_;\n> > +\tstd::unique_ptr<Encoder> encoder_;\n> > +\tlibcamera::Size streamSize_;\n> > +};\n> > +\n> > +#endif /* __ANDROID_POST_PROCESSOR_JPEG_H__ */\n> > diff --git a/src/android/meson.build b/src/android/meson.build\n> > index 802bb89..eacd544 100644\n> > --- a/src/android/meson.build\n> > +++ b/src/android/meson.build\n> > @@ -23,6 +23,7 @@ android_hal_sources = files([\n> >      'camera_stream.cpp',\n> >      'jpeg/encoder_libjpeg.cpp',\n> >      'jpeg/exif.cpp',\n> > +    'jpeg/post_processor_jpeg.cpp',\n> >  ])\n> >  \n> >  android_camera_metadata_sources = files([","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 A32BBBE174\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 16 Oct 2020 04:58:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 40C2860E36;\n\tFri, 16 Oct 2020 06:58:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 92BD660354\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 16 Oct 2020 06:58:03 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 017FC528;\n\tFri, 16 Oct 2020 06:58:02 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"KcjPLyyR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1602824283;\n\tbh=op1Ea9XCak7rKND/pl5OECly0/Sn5KTqc1ua6i7u0zI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=KcjPLyyRTD63FkRt1OBaDPeYznwtdt55VLaBWY2Avek29dk71542wyzT8bGxrU7Cr\n\t5fMKrl9P9U0KKZT/54ZSadHogCFykCVrprdiz0tMd/tI7dX/bP98Pw0HB6aeRHBaqo\n\tW5qUoFAVxEM3iG+yKqmtxKzfie9G682drdj6IY6E=","Date":"Fri, 16 Oct 2020 07:57:16 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <email@uajain.com>","Message-ID":"<20201016045716.GB14324@pendragon.ideasonboard.com>","References":"<20201015171457.75678-1-email@uajain.com>\n\t<20201015171457.75678-3-email@uajain.com>\n\t<4f8ae975-6650-a799-44bc-b2949c9a59d7@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<4f8ae975-6650-a799-44bc-b2949c9a59d7@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/3] android: jpeg: Port to\n\tPostProcessor interface","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>","Cc":"libcamera-devel@lists.libcamera.org","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>"}}]