[{"id":18909,"web_url":"https://patchwork.libcamera.org/comment/18909/","msgid":"<20210818105600.5nensuvbaaha5zcd@uno.localdomain>","date":"2021-08-18T10:56:00","subject":"Re: [libcamera-devel] [PATCH 1/3] android: camera_stream: Create\n\tpost porcessor in configure()","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Hiro,\n\nOn Thu, Aug 05, 2021 at 10:45:28PM +0900, Hirokazu Honda wrote:\n> CameraStream creates PostProcessor and FrameBufferAllocator in\n> the constructor. CameraStream assumes that a used post processor\n> is JPEG post processor. Since we need to support various post\n> processors, we would rather move the creation to configure() so\n> as to return an error code if no proper post processor is found.\n> This also moves FrameBufferAllocator and Mutex creation for\n> consistency.\n>\n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  src/android/camera_device.h   |  2 ++\n>  src/android/camera_stream.cpp | 35 ++++++++++++++++++-----------------\n>  2 files changed, 20 insertions(+), 17 deletions(-)\n>\n> diff --git a/src/android/camera_device.h b/src/android/camera_device.h\n> index 089a6204..cbc71be4 100644\n> --- a/src/android/camera_device.h\n> +++ b/src/android/camera_device.h\n> @@ -63,6 +63,8 @@ public:\n>  \tint processCaptureRequest(camera3_capture_request_t *request);\n>  \tvoid requestComplete(libcamera::Request *request);\n>\n> +\tlibcamera::PixelFormat toPixelFormat(int format) const;\n> +\n\nWhy I do see this function part of the CameraCapabilities class and\nnot of CameraDevice ? Is this patch missing the\nCameraDevice::toPixelFormat() implementation ?\n\n>  protected:\n>  \tstd::string logPrefix() const override;\n>\n> diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\n> index bf4a7b41..86263403 100644\n> --- a/src/android/camera_stream.cpp\n> +++ b/src/android/camera_stream.cpp\n> @@ -45,20 +45,6 @@ CameraStream::CameraStream(CameraDevice *const cameraDevice,\n>  \t: cameraDevice_(cameraDevice), config_(config), type_(type),\n>  \t  camera3Stream_(camera3Stream), index_(index)\n>  {\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 the\n> -\t\t * future. For now, we only have PostProcessorJpeg and that\n> -\t\t * is what we instantiate here.\n> -\t\t */\n> -\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n> -\t}\n> -\n> -\tif (type == Type::Internal) {\n> -\t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n> -\t\tmutex_ = std::make_unique<std::mutex>();\n> -\t}\n>  }\n>\n>  const StreamConfiguration &CameraStream::configuration() const\n> @@ -73,15 +59,30 @@ Stream *CameraStream::stream() const\n>\n>  int CameraStream::configure()\n>  {\n> -\tif (postProcessor_) {\n> +\tif (type_ == Type::Internal || type_ == Type::Mapped) {\n> +\t\tconst PixelFormat outFormat =\n> +\t\t\tcameraDevice_->toPixelFormat(camera3Stream_->format);\n>  \t\tStreamConfiguration output = configuration();\n> -\t\toutput.pixelFormat = formats::MJPEG;\n> +\t\toutput.pixelFormat = outFormat;\n> +\t\tswitch (outFormat) {\n> +\t\tcase formats::MJPEG:\n> +\t\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n> +\t\t\tbreak;\n> +\n> +\t\tdefault:\n> +\t\t\tLOG(HAL, Error) << \"Unsupported format: \" << outFormat;\n> +\t\t\treturn -EINVAL;\n> +\t\t}\n> +\n>  \t\tint ret = postProcessor_->configure(configuration(), output);\n>  \t\tif (ret)\n>  \t\t\treturn ret;\n>  \t}\n>\n> -\tif (allocator_) {\n> +\tif (type_ == Type::Internal) {\n> +\t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n> +\t\tmutex_ = std::make_unique<std::mutex>();\n> +\n\nWe should probably\n        ASSERT(type_ == Type::Internal)\nin CameraStream::getBuffer() and putBuffer() and remove the\nif (!allocator) check, but that's not required for this series\n\nThanks\n   j\n>  \t\tint ret = allocator_->allocate(stream());\n>  \t\tif (ret < 0)\n>  \t\t\treturn ret;\n> --\n> 2.32.0.554.ge1b32706d8-goog\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 3BF25BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 Aug 2021 10:55:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 91CF568895;\n\tWed, 18 Aug 2021 12:55:14 +0200 (CEST)","from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7184C6888A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Aug 2021 12:55:13 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id B833F24000D;\n\tWed, 18 Aug 2021 10:55:12 +0000 (UTC)"],"Date":"Wed, 18 Aug 2021 12:56:00 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<20210818105600.5nensuvbaaha5zcd@uno.localdomain>","References":"<20210805134530.825065-1-hiroh@chromium.org>\n\t<20210805134530.825065-2-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210805134530.825065-2-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH 1/3] android: camera_stream: Create\n\tpost porcessor in configure()","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","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":18953,"web_url":"https://patchwork.libcamera.org/comment/18953/","msgid":"<CAO5uPHMNVRU2r7ye8uSs0BVuH7wFue6y_-Q991DjAF5EQX1_9g@mail.gmail.com>","date":"2021-08-19T17:40:28","subject":"Re: [libcamera-devel] [PATCH 1/3] android: camera_stream: Create\n\tpost porcessor in configure()","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Jacopo,\n\nOn Wed, Aug 18, 2021 at 7:55 PM Jacopo Mondi <jacopo@jmondi.org> wrote:\n>\n> Hi Hiro,\n>\n> On Thu, Aug 05, 2021 at 10:45:28PM +0900, Hirokazu Honda wrote:\n> > CameraStream creates PostProcessor and FrameBufferAllocator in\n> > the constructor. CameraStream assumes that a used post processor\n> > is JPEG post processor. Since we need to support various post\n> > processors, we would rather move the creation to configure() so\n> > as to return an error code if no proper post processor is found.\n> > This also moves FrameBufferAllocator and Mutex creation for\n> > consistency.\n> >\n> > Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> > ---\n> >  src/android/camera_device.h   |  2 ++\n> >  src/android/camera_stream.cpp | 35 ++++++++++++++++++-----------------\n> >  2 files changed, 20 insertions(+), 17 deletions(-)\n> >\n> > diff --git a/src/android/camera_device.h b/src/android/camera_device.h\n> > index 089a6204..cbc71be4 100644\n> > --- a/src/android/camera_device.h\n> > +++ b/src/android/camera_device.h\n> > @@ -63,6 +63,8 @@ public:\n> >       int processCaptureRequest(camera3_capture_request_t *request);\n> >       void requestComplete(libcamera::Request *request);\n> >\n> > +     libcamera::PixelFormat toPixelFormat(int format) const;\n> > +\n>\n> Why I do see this function part of the CameraCapabilities class and\n> not of CameraDevice ? Is this patch missing the\n> CameraDevice::toPixelFormat() implementation ?\n>\n\nHm, I somehow reverted the change upon uploading unintendedly. Fixed.\n\n> >  protected:\n> >       std::string logPrefix() const override;\n> >\n> > diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\n> > index bf4a7b41..86263403 100644\n> > --- a/src/android/camera_stream.cpp\n> > +++ b/src/android/camera_stream.cpp\n> > @@ -45,20 +45,6 @@ CameraStream::CameraStream(CameraDevice *const cameraDevice,\n> >       : cameraDevice_(cameraDevice), config_(config), type_(type),\n> >         camera3Stream_(camera3Stream), index_(index)\n> >  {\n> > -     if (type_ == Type::Internal || type_ == Type::Mapped) {\n> > -             /*\n> > -              * \\todo There might be multiple post-processors. The logic\n> > -              * which should be instantiated here, is deferred for the\n> > -              * future. For now, we only have PostProcessorJpeg and that\n> > -              * is what we instantiate here.\n> > -              */\n> > -             postProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n> > -     }\n> > -\n> > -     if (type == Type::Internal) {\n> > -             allocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n> > -             mutex_ = std::make_unique<std::mutex>();\n> > -     }\n> >  }\n> >\n> >  const StreamConfiguration &CameraStream::configuration() const\n> > @@ -73,15 +59,30 @@ Stream *CameraStream::stream() const\n> >\n> >  int CameraStream::configure()\n> >  {\n> > -     if (postProcessor_) {\n> > +     if (type_ == Type::Internal || type_ == Type::Mapped) {\n> > +             const PixelFormat outFormat =\n> > +                     cameraDevice_->toPixelFormat(camera3Stream_->format);\n> >               StreamConfiguration output = configuration();\n> > -             output.pixelFormat = formats::MJPEG;\n> > +             output.pixelFormat = outFormat;\n> > +             switch (outFormat) {\n> > +             case formats::MJPEG:\n> > +                     postProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n> > +                     break;\n> > +\n> > +             default:\n> > +                     LOG(HAL, Error) << \"Unsupported format: \" << outFormat;\n> > +                     return -EINVAL;\n> > +             }\n> > +\n> >               int ret = postProcessor_->configure(configuration(), output);\n> >               if (ret)\n> >                       return ret;\n> >       }\n> >\n> > -     if (allocator_) {\n> > +     if (type_ == Type::Internal) {\n> > +             allocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n> > +             mutex_ = std::make_unique<std::mutex>();\n> > +\n>\n> We should probably\n>         ASSERT(type_ == Type::Internal)\n> in CameraStream::getBuffer() and putBuffer() and remove the\n> if (!allocator) check, but that's not required for this series\n>\n\nThanks for the comment. I will do after this series are checked in.\n\nBest,\n-Hiro\n> Thanks\n>    j\n> >               int ret = allocator_->allocate(stream());\n> >               if (ret < 0)\n> >                       return ret;\n> > --\n> > 2.32.0.554.ge1b32706d8-goog\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 93D38BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Aug 2021 17:40:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EFD5A68895;\n\tThu, 19 Aug 2021 19:40:43 +0200 (CEST)","from mail-ed1-x534.google.com (mail-ed1-x534.google.com\n\t[IPv6:2a00:1450:4864:20::534])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D2DC060264\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Aug 2021 19:40:41 +0200 (CEST)","by mail-ed1-x534.google.com with SMTP id dj8so10031284edb.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Aug 2021 10:40:41 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"h1gOZgod\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=4HUeU5KminDxku7LYkGWktwro29F2vv/VyYCgPAwC4o=;\n\tb=h1gOZgodOgdgn62U8wyvRBmJzb4PT620VNTZyU74Ht0NPOX8N2aKReGeKgu87xAzJP\n\t6xeT+oRetm/AJ/vSf3ua/y0EmEWdsXz8jgQ4kPrp4tgGJYHvYeGul5rmw2ii/1ZtffEi\n\tSjfPV/r4cKHZuLNDYHvHnvS5H7Dp+V8K0lUSI=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=4HUeU5KminDxku7LYkGWktwro29F2vv/VyYCgPAwC4o=;\n\tb=H7UZd4mvTyUW8OE1yTqwDcSHztug3E4mfydpO7SrYyibMM86Qe3gPe06n5GcNCvuNK\n\tRGOQgPyoG/VYp92+z5IB+3tyNxx/sfVSIaRopaCGMZfRKsuXwZFR8rd6H6apoG+FyqrG\n\toLXx2EMNESHGx7caTe9e3/RARpjPraCfRadf1eBiSz0Yd0ypsxyU/FFf5GxRbpynVM9h\n\tLP0sO0Aiqb2FBPq9AFQ2KPV7y0UPkYsCWRqgClWt0WukSu2NA648YlqWZptWKQoRKSTf\n\tuj1pffojf7BWhJZ9bXHwYuSKHR6R7w/o9ll8MSFUMubT+zXcVPdpHKxv6dm8HCSpSSHp\n\tYFeg==","X-Gm-Message-State":"AOAM531MuupWoHb10tc6JA+A4AcgWeIvwF32lU42ooO5z7m6uzmCcjRX\n\tEeH9ITkmP0E7u7cTf1TD7M5tJ8E+TdO2dYDH7WRheg==","X-Google-Smtp-Source":"ABdhPJy6RRBtAYHoc8KlRX+VSXumhmLNP618KvOx3Wv72yXsi8HqvyyisY0zqu70XzdjAwZ5dFL2Bd4TOWeZddPL9vs=","X-Received":"by 2002:aa7:c643:: with SMTP id z3mr5125077edr.73.1629394841303; \n\tThu, 19 Aug 2021 10:40:41 -0700 (PDT)","MIME-Version":"1.0","References":"<20210805134530.825065-1-hiroh@chromium.org>\n\t<20210805134530.825065-2-hiroh@chromium.org>\n\t<20210818105600.5nensuvbaaha5zcd@uno.localdomain>","In-Reply-To":"<20210818105600.5nensuvbaaha5zcd@uno.localdomain>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Fri, 20 Aug 2021 02:40:28 +0900","Message-ID":"<CAO5uPHMNVRU2r7ye8uSs0BVuH7wFue6y_-Q991DjAF5EQX1_9g@mail.gmail.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH 1/3] android: camera_stream: Create\n\tpost porcessor in configure()","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 <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]