[libcamera-devel,v4,2/3] android: camera_stream: Support PostProcessorYuv in CameraStream
diff mbox series

Message ID 20210901080302.68525-2-hiroh@chromium.org
State Accepted
Headers show
Series
  • [libcamera-devel,v4,1/3] android: camera_stream: Create post processor in configure()
Related show

Commit Message

Hirokazu Honda Sept. 1, 2021, 8:03 a.m. UTC
CameraStream creates PostProcessorYuv if the destination format
is NV12.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/android/camera_device.cpp |  4 ++--
 src/android/camera_stream.cpp | 14 +++++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index fda77db4..324b997f 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1144,12 +1144,12 @@  void CameraDevice::requestComplete(Request *request)
 		resultMetadata = std::make_unique<CameraMetadata>(0, 0);
 	}
 
-	/* Handle any JPEG compression. */
+	/* Handle post-processing. */
 	for (camera3_stream_buffer_t &buffer : descriptor.buffers_) {
 		CameraStream *cameraStream =
 			static_cast<CameraStream *>(buffer.stream->priv);
 
-		if (cameraStream->camera3Stream().format != HAL_PIXEL_FORMAT_BLOB)
+		if (cameraStream->type() == CameraStream::Type::Direct)
 			continue;
 
 		FrameBuffer *src = request->findBuffer(cameraStream->stream());
diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp
index 3fce29c1..52ebf30a 100644
--- a/src/android/camera_stream.cpp
+++ b/src/android/camera_stream.cpp
@@ -9,13 +9,15 @@ 
 
 #include <sys/mman.h>
 
+#include <libcamera/formats.h>
+
+#include "jpeg/post_processor_jpeg.h"
+#include "yuv/post_processor_yuv.h"
+
 #include "camera_buffer.h"
 #include "camera_capabilities.h"
 #include "camera_device.h"
 #include "camera_metadata.h"
-#include "jpeg/post_processor_jpeg.h"
-
-#include <libcamera/formats.h>
 
 using namespace libcamera;
 
@@ -67,8 +69,14 @@  int CameraStream::configure()
 			cameraDevice_->capabilities()->toPixelFormat(camera3Stream_->format);
 		StreamConfiguration output = configuration();
 		output.pixelFormat = outFormat;
+		output.size.width = camera3Stream_->width;
+		output.size.height = camera3Stream_->height;
 
 		switch (outFormat) {
+		case formats::NV12:
+			postProcessor_ = std::make_unique<PostProcessorYuv>();
+			break;
+
 		case formats::MJPEG:
 			postProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);
 			break;