[libcamera-devel] [PATCH v3 06/10] android: camera_stream: Plumb process() with Camera3RequestDescriptor

Hirokazu Honda hiroh at chromium.org
Mon Sep 27 08:32:02 CEST 2021


Hi Umang, thank you for the patch.

On Tue, Sep 21, 2021 at 8:13 PM Jacopo Mondi <jacopo at jmondi.org> wrote:
>
> Hi Umang,
>
> On Mon, Sep 20, 2021 at 11:07:48PM +0530, Umang Jain wrote:
> > Data (or broader context) required for post processing of a camera request
> > is saved via Camera3RequestDescriptor. Instead of passing individual
> > arguments to CameraStream::process(), pass the Camera3RequestDescriptor
> > pointer to it. All the arguments necessary to run the post-processor can
> > be accessed from the descriptor.
> >
> > In subsequent commits, we will prepare the post-processor to run
> > asynchronously. Hence, it will require the Camera3RequestDescriptor
> > pointer to be emitted back in the post-processing completion handler
> > to finally complete the request (i.e. sending the capture results back
> > to the framework).
> >
> > Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

Reviewed-by: Hirokazu Honda <hiroh at chromium.org>
>
> Ah -.-
>
> Sorry for the noise on the previous one then
>
> Should these two patches be squashed then ?
>
> Thanks
>   j
>
> > ---
> >  src/android/camera_device.cpp            | 5 ++---
> >  src/android/camera_stream.cpp            | 5 ++---
> >  src/android/camera_stream.h              | 5 +++--
> >  src/android/jpeg/post_processor_jpeg.cpp | 5 +++--
> >  src/android/jpeg/post_processor_jpeg.h   | 3 +--
> >  src/android/post_processor.h             | 5 +++--
> >  src/android/yuv/post_processor_yuv.cpp   | 3 +--
> >  src/android/yuv/post_processor_yuv.h     | 3 +--
> >  8 files changed, 16 insertions(+), 18 deletions(-)
> >
> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > index 1ae4ac73..fa462368 100644
> > --- a/src/android/camera_device.cpp
> > +++ b/src/android/camera_device.cpp
> > @@ -1150,9 +1150,8 @@ void CameraDevice::requestComplete(Request *request)
> >                       continue;
> >               }
> >
> > -             int ret = cameraStream->process(src, *buffer.buffer,
> > -                                             descriptor->settings_,
> > -                                             descriptor->resultMetadata_.get());
> > +             int ret = cameraStream->process(src, *buffer.buffer, descriptor);
> > +
> >               /*
> >                * Return the FrameBuffer to the CameraStream now that we're
> >                * done processing it.
> > diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp
> > index 0fed5382..d494f5d5 100644
> > --- a/src/android/camera_stream.cpp
> > +++ b/src/android/camera_stream.cpp
> > @@ -100,8 +100,7 @@ int CameraStream::configure()
> >
> >  int CameraStream::process(const FrameBuffer *source,
> >                         buffer_handle_t camera3Dest,
> > -                       const CameraMetadata &requestMetadata,
> > -                       CameraMetadata *resultMetadata)
> > +                       Camera3RequestDescriptor *request)
> >  {
> >       if (!postProcessor_)
> >               return 0;
> > @@ -118,7 +117,7 @@ int CameraStream::process(const FrameBuffer *source,
> >               return -EINVAL;
> >       }
> >
> > -     return postProcessor_->process(source, &dest, requestMetadata, resultMetadata);
> > +     return postProcessor_->process(source, &dest, request);
> >  }
> >
> >  FrameBuffer *CameraStream::getBuffer()
> > diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h
> > index 5c232cb6..68789700 100644
> > --- a/src/android/camera_stream.h
> > +++ b/src/android/camera_stream.h
> > @@ -23,6 +23,8 @@ class CameraDevice;
> >  class CameraMetadata;
> >  class PostProcessor;
> >
> > +struct Camera3RequestDescriptor;
> > +
> >  class CameraStream
> >  {
> >  public:
> > @@ -120,8 +122,7 @@ public:
> >       int configure();
> >       int process(const libcamera::FrameBuffer *source,
> >                   buffer_handle_t camera3Dest,
> > -                 const CameraMetadata &requestMetadata,
> > -                 CameraMetadata *resultMetadata);
> > +                 Camera3RequestDescriptor *request);
> >       libcamera::FrameBuffer *getBuffer();
> >       void putBuffer(libcamera::FrameBuffer *buffer);
> >
> > diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp
> > index cb45f86b..31f68330 100644
> > --- a/src/android/jpeg/post_processor_jpeg.cpp
> > +++ b/src/android/jpeg/post_processor_jpeg.cpp
> > @@ -99,14 +99,15 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer *source,
> >
> >  int PostProcessorJpeg::process(const FrameBuffer *source,
> >                              CameraBuffer *destination,
> > -                            const CameraMetadata &requestMetadata,
> > -                            CameraMetadata *resultMetadata)
> > +                            Camera3RequestDescriptor *request)
> >  {
> >       if (!encoder_)
> >               return 0;
> >
> >       ASSERT(destination->numPlanes() == 1);
> >
> > +     const CameraMetadata &requestMetadata = request->settings_;
> > +     CameraMetadata *resultMetadata = request->resultMetadata_.get();
> >       camera_metadata_ro_entry_t entry;
> >       int ret;
> >
> > diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h
> > index c4b2e9ef..d49c8d2b 100644
> > --- a/src/android/jpeg/post_processor_jpeg.h
> > +++ b/src/android/jpeg/post_processor_jpeg.h
> > @@ -24,8 +24,7 @@ public:
> >                     const libcamera::StreamConfiguration &outcfg) override;
> >       int process(const libcamera::FrameBuffer *source,
> >                   CameraBuffer *destination,
> > -                 const CameraMetadata &requestMetadata,
> > -                 CameraMetadata *resultMetadata) override;
> > +                 Camera3RequestDescriptor *request) override;
> >
> >  private:
> >       void generateThumbnail(const libcamera::FrameBuffer *source,
> > diff --git a/src/android/post_processor.h b/src/android/post_processor.h
> > index 61dfb6d4..bdd6afe7 100644
> > --- a/src/android/post_processor.h
> > +++ b/src/android/post_processor.h
> > @@ -14,6 +14,8 @@
> >
> >  class CameraMetadata;
> >
> > +struct Camera3RequestDescriptor;
> > +
> >  class PostProcessor
> >  {
> >  public:
> > @@ -23,8 +25,7 @@ public:
> >                             const libcamera::StreamConfiguration &outCfg) = 0;
> >       virtual int process(const libcamera::FrameBuffer *source,
> >                           CameraBuffer *destination,
> > -                         const CameraMetadata &requestMetadata,
> > -                         CameraMetadata *resultMetadata) = 0;
> > +                         Camera3RequestDescriptor *request) = 0;
> >  };
> >
> >  #endif /* __ANDROID_POST_PROCESSOR_H__ */
> > diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp
> > index 0a874886..5e18caee 100644
> > --- a/src/android/yuv/post_processor_yuv.cpp
> > +++ b/src/android/yuv/post_processor_yuv.cpp
> > @@ -51,8 +51,7 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg,
> >
> >  int PostProcessorYuv::process(const FrameBuffer *source,
> >                             CameraBuffer *destination,
> > -                           [[maybe_unused]] const CameraMetadata &requestMetadata,
> > -                           [[maybe_unused]] CameraMetadata *metadata)
> > +                           [[maybe_unused]] Camera3RequestDescriptor *request)
> >  {
> >       if (!isValidBuffers(source, *destination))
> >               return -EINVAL;
> > diff --git a/src/android/yuv/post_processor_yuv.h b/src/android/yuv/post_processor_yuv.h
> > index 44a04113..eddd1086 100644
> > --- a/src/android/yuv/post_processor_yuv.h
> > +++ b/src/android/yuv/post_processor_yuv.h
> > @@ -22,8 +22,7 @@ public:
> >                     const libcamera::StreamConfiguration &outcfg) override;
> >       int process(const libcamera::FrameBuffer *source,
> >                   CameraBuffer *destination,
> > -                 const CameraMetadata &requestMetadata,
> > -                 CameraMetadata *metadata) override;
> > +                 Camera3RequestDescriptor *context) override;
> >
> >  private:
> >       bool isValidBuffers(const libcamera::FrameBuffer *source,
> > --
> > 2.31.1
> >


More information about the libcamera-devel mailing list