From 4a3c50348edb021d0529d350aabcd78cc0c75164 Mon Sep 17 00:00:00 2001 From: Hou Qi Date: Fri, 9 Sep 2022 10:06:51 +0800 Subject: [PATCH 15/17] V4L2VDA: Add V4L2_PIX_FMT_NV12M_8L128 format for amphion Upstream-Status: Inappropriate [NXP specific] --- media/gpu/chromeos/fourcc.cc | 2 ++ media/gpu/chromeos/fourcc.h | 4 ++++ media/gpu/v4l2/generic_v4l2_device.cc | 4 ++++ media/gpu/v4l2/v4l2_video_decode_accelerator.cc | 9 +++++++-- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/media/gpu/chromeos/fourcc.cc b/media/gpu/chromeos/fourcc.cc index 80f392ebf5e41..e8239121d8e96 100644 --- a/media/gpu/chromeos/fourcc.cc +++ b/media/gpu/chromeos/fourcc.cc @@ -26,6 +26,7 @@ absl::optional Fourcc::FromUint32(uint32_t fourcc) { case YM12: case YM21: case YUYV: + case NA12: case NV12: case NV21: case NM12: @@ -149,6 +150,7 @@ VideoPixelFormat Fourcc::ToVideoPixelFormat() const { return PIXEL_FORMAT_YUY2; case NV12: case NM12: + case NA12: return PIXEL_FORMAT_NV12; case NV21: case NM21: diff --git a/media/gpu/chromeos/fourcc.h b/media/gpu/chromeos/fourcc.h index c4b233ac64562..27f1b679435b1 100644 --- a/media/gpu/chromeos/fourcc.h +++ b/media/gpu/chromeos/fourcc.h @@ -68,6 +68,10 @@ class MEDIA_GPU_EXPORT Fourcc { // Maps to PIXEL_FORMAT_NV21, V4L2_PIX_FMT_NV21M. NM21 = ComposeFourcc('N', 'M', '2', '1'), + // Tiled YUV formats, non contiguous planes. + // Maps to V4L2_PIX_FMT_NV12M_8L128. + NA12 = ComposeFourcc('N', 'A', '1', '2'), + // YUV422 single-planar format. // https://linuxtv.org/downloads/v4l-dvb-apis-new/userspace-api/v4l/pixfmt-yuv422p.html // Maps to PIXEL_FORMAT_I422, V4L2_PIX_FMT_YUV422P. diff --git a/media/gpu/v4l2/generic_v4l2_device.cc b/media/gpu/v4l2/generic_v4l2_device.cc index a578768f8d3b1..d7b57d180f7f7 100644 --- a/media/gpu/v4l2/generic_v4l2_device.cc +++ b/media/gpu/v4l2/generic_v4l2_device.cc @@ -46,6 +46,9 @@ using media_gpu_v4l2::InitializeStubs; using media_gpu_v4l2::StubPathMap; #endif +/* Tiled YUV formats, non contiguous planes */ +#define V4L2_PIX_FMT_NV12M_8L128 v4l2_fourcc('N', 'A', '1', '2') /* Y/CbCr 4:2:0 8x128 tiles */ + namespace media { namespace { @@ -54,6 +57,7 @@ uint32_t V4L2PixFmtToDrmFormat(uint32_t format) { switch (format) { case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV12M: + case V4L2_PIX_FMT_NV12M_8L128: return DRM_FORMAT_NV12; case V4L2_PIX_FMT_YUV420: diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc index fba38c4021855..a37efa9a708e8 100644 --- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc @@ -1356,8 +1356,9 @@ void V4L2VideoDecodeAccelerator::Enqueue() { // yet. Also, V4L2VDA calls STREAMOFF and STREAMON after resolution // change. They implicitly send a V4L2_DEC_CMD_STOP and V4L2_DEC_CMD_START // to the decoder. - if (input_queue_->QueuedBuffersCount() > 0) - break; + if (input_queue_->QueuedBuffersCount() > 0) { + // break; + } if (coded_size_.IsEmpty() || !input_queue_->IsStreaming()) { // In these situations, we should call NotifyFlushDone() immediately: @@ -1499,6 +1500,10 @@ bool V4L2VideoDecodeAccelerator::DequeueOutputBuffer() { // Dequeue a completed output (VIDEO_CAPTURE) buffer, and queue to the // completed queue. auto ret = output_queue_->DequeueBuffer(); + if (errno == EPIPE) { + VLOG(1) << "Got eos"; + flush_awaiting_last_output_buffer_ = false; + } if (ret.first == false) { LOG(ERROR) << "Error in Dequeue output buffer"; NOTIFY_ERROR(PLATFORM_FAILURE); -- 2.17.1