[libcamera-devel] [PATCH v2 6/9] android: jpeg: Factor out thumbnailer configuration

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Jan 21 21:36:43 CET 2021


Hi Paul,

Thank you for the patch.

On Thu, Jan 21, 2021 at 07:15:46PM +0900, Paul Elder wrote:
> Move configuration of the thumbnailer into a function so that it can be
> called later in post-processing if a different size thumbnail is
> requested.
> 
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
> New in v2
> ---
>  src/android/jpeg/post_processor_jpeg.cpp | 26 ++++++++++++++++--------
>  src/android/jpeg/post_processor_jpeg.h   |  2 ++
>  src/android/jpeg/thumbnailer.h           |  1 +
>  3 files changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp
> index 436a50f8..0c1226ad 100644
> --- a/src/android/jpeg/post_processor_jpeg.cpp
> +++ b/src/android/jpeg/post_processor_jpeg.cpp
> @@ -25,6 +25,21 @@ PostProcessorJpeg::PostProcessorJpeg(CameraDevice *const device)
>  {
>  }
>  
> +int PostProcessorJpeg::configureThumbnailer(const Size &size,
> +					    const PixelFormat &pixelFormat)
> +{
> +	thumbnailer_.configure(size, pixelFormat);
> +	StreamConfiguration thCfg;
> +	thCfg.size = thumbnailer_.size();
> +	thCfg.pixelFormat = pixelFormat;
> +	if (thumbnailEncoder_.configure(thCfg) != 0) {
> +		LOG(JPEG, Error) << "Failed to configure thumbnail encoder";
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
>  int PostProcessorJpeg::configure(const StreamConfiguration &inCfg,
>  				 const StreamConfiguration &outCfg)
>  {
> @@ -40,16 +55,11 @@ int PostProcessorJpeg::configure(const StreamConfiguration &inCfg,
>  
>  	streamSize_ = outCfg.size;
>  
> -	thumbnailer_.configure(inCfg.size, inCfg.pixelFormat);
> -	StreamConfiguration thCfg = inCfg;
> -	thCfg.size = thumbnailer_.size();
> -	if (thumbnailEncoder_.configure(thCfg) != 0) {
> -		LOG(JPEG, Error) << "Failed to configure thumbnail encoder";
> -		return -EINVAL;
> -	}
> +	int ret = configureThumbnailer(inCfg.size, inCfg.pixelFormat);
> +	if (ret)
> +		return ret;
>  
>  	encoder_ = std::make_unique<EncoderLibJpeg>();
> -
>  	return encoder_->configure(inCfg);
>  }
>  
> diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h
> index 5afa831c..c545c29c 100644
> --- a/src/android/jpeg/post_processor_jpeg.h
> +++ b/src/android/jpeg/post_processor_jpeg.h
> @@ -31,6 +31,8 @@ public:
>  private:
>  	void generateThumbnail(const libcamera::FrameBuffer &source,
>  			       std::vector<unsigned char> *thumbnail);
> +	int configureThumbnailer(const libcamera::Size &size,
> +				 const libcamera::PixelFormat &pixelFormat);
>  
>  	CameraDevice *const cameraDevice_;
>  	std::unique_ptr<Encoder> encoder_;
> diff --git a/src/android/jpeg/thumbnailer.h b/src/android/jpeg/thumbnailer.h
> index 98f11833..f393db47 100644
> --- a/src/android/jpeg/thumbnailer.h
> +++ b/src/android/jpeg/thumbnailer.h
> @@ -22,6 +22,7 @@ public:
>  	void createThumbnail(const libcamera::FrameBuffer &source,
>  			     std::vector<unsigned char> *dest);
>  	const libcamera::Size &size() const { return targetSize_; }
> +	const libcamera::PixelFormat &pixelFormat() const { return pixelFormat_; }
>  
>  private:
>  	libcamera::Size computeThumbnailSize() const;

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list