Index: media/video/gpu_memory_buffer_video_frame_pool.cc |
diff --git a/media/video/gpu_memory_buffer_video_frame_pool.cc b/media/video/gpu_memory_buffer_video_frame_pool.cc |
index d75f7aaa690b4b5a2442be1d1797cb642a86eb92..8608f6a84ff23eca9930994ad4bfbd43ee136afe 100644 |
--- a/media/video/gpu_memory_buffer_video_frame_pool.cc |
+++ b/media/video/gpu_memory_buffer_video_frame_pool.cc |
@@ -182,6 +182,9 @@ gfx::BufferFormat GpuMemoryBufferFormat( |
case GpuVideoAcceleratorFactories::OutputFormat::UYVY: |
DCHECK_EQ(0u, plane); |
return gfx::BufferFormat::UYVY_422; |
+ case GpuVideoAcceleratorFactories::OutputFormat::YUYV: |
+ DCHECK_EQ(0u, plane); |
+ return gfx::BufferFormat::YUYV_422; |
case GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED: |
NOTREACHED(); |
break; |
@@ -202,6 +205,7 @@ unsigned ImageInternalFormat(GpuVideoAcceleratorFactories::OutputFormat format, |
DCHECK_LE(plane, 1u); |
return GL_RGB_YCBCR_420V_CHROMIUM; |
case GpuVideoAcceleratorFactories::OutputFormat::UYVY: |
+ case GpuVideoAcceleratorFactories::OutputFormat::YUYV: |
DCHECK_EQ(0u, plane); |
return GL_RGB_YCBCR_422_CHROMIUM; |
case GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED: |
@@ -216,6 +220,7 @@ size_t PlanesPerCopy(GpuVideoAcceleratorFactories::OutputFormat format) { |
switch (format) { |
case GpuVideoAcceleratorFactories::OutputFormat::I420: |
case GpuVideoAcceleratorFactories::OutputFormat::UYVY: |
+ case GpuVideoAcceleratorFactories::OutputFormat::YUYV: |
return 1; |
case GpuVideoAcceleratorFactories::OutputFormat::NV12_DUAL_GMB: |
case GpuVideoAcceleratorFactories::OutputFormat::NV12_SINGLE_GMB: |
@@ -237,6 +242,8 @@ VideoPixelFormat VideoFormat( |
return PIXEL_FORMAT_NV12; |
case GpuVideoAcceleratorFactories::OutputFormat::UYVY: |
return PIXEL_FORMAT_UYVY; |
+ case GpuVideoAcceleratorFactories::OutputFormat::YUYV: |
+ return PIXEL_FORMAT_YUY2; |
case GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED: |
NOTREACHED(); |
break; |
@@ -353,6 +360,34 @@ void CopyRowsToUYVYBuffer(int first_row, |
done.Run(); |
} |
+void CopyRowsToYUYVBuffer(int first_row, |
+ int rows, |
+ int width, |
+ const scoped_refptr<VideoFrame>& source_frame, |
+ uint8_t* output, |
+ int dest_stride, |
+ const base::Closure& done) { |
+ TRACE_EVENT2("media", "CopyRowsToYUYVBuffer", "bytes_per_row", width * 2, |
+ "rows", rows); |
+ if (output) { |
+ DCHECK_NE(dest_stride, 0); |
+ DCHECK_LE(width, std::abs(dest_stride / 2)); |
+ DCHECK_EQ(0, first_row % 2); |
+ libyuv::I420ToYUY2( |
+ source_frame->visible_data(VideoFrame::kYPlane) + |
+ first_row * source_frame->stride(VideoFrame::kYPlane), |
+ source_frame->stride(VideoFrame::kYPlane), |
+ source_frame->visible_data(VideoFrame::kUPlane) + |
+ first_row / 2 * source_frame->stride(VideoFrame::kUPlane), |
+ source_frame->stride(VideoFrame::kUPlane), |
+ source_frame->visible_data(VideoFrame::kVPlane) + |
+ first_row / 2 * source_frame->stride(VideoFrame::kVPlane), |
+ source_frame->stride(VideoFrame::kVPlane), |
+ output + first_row * dest_stride, dest_stride, width, rows); |
+ } |
+ done.Run(); |
+} |
+ |
gfx::Size CodedSize(const scoped_refptr<VideoFrame>& video_frame, |
GpuVideoAcceleratorFactories::OutputFormat output_format) { |
DCHECK(gfx::Rect(video_frame->coded_size()) |
@@ -367,7 +402,9 @@ gfx::Size CodedSize(const scoped_refptr<VideoFrame>& video_frame, |
output = gfx::Size((video_frame->visible_rect().width() + 1) & ~1, |
(video_frame->visible_rect().height() + 1) & ~1); |
break; |
+ |
case GpuVideoAcceleratorFactories::OutputFormat::UYVY: |
+ case GpuVideoAcceleratorFactories::OutputFormat::YUYV: |
output = gfx::Size((video_frame->visible_rect().width() + 1) & ~1, |
video_frame->visible_rect().height()); |
break; |
@@ -591,6 +628,14 @@ void GpuMemoryBufferVideoFramePool::PoolImpl::CopyVideoFrameToGpuMemoryBuffers( |
static_cast<uint8_t*>(buffer->memory(0)), |
buffer->stride(0), barrier)); |
break; |
+ case GpuVideoAcceleratorFactories::OutputFormat::YUYV: |
+ worker_task_runner_->PostTask( |
+ FROM_HERE, base::Bind(&CopyRowsToYUYVBuffer, row, rows_to_copy, |
+ coded_size.width(), video_frame, |
+ static_cast<uint8_t*>(buffer->memory(0)), |
+ buffer->stride(0), barrier)); |
+ break; |
+ |
case GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED: |
NOTREACHED(); |
} |
@@ -679,6 +724,10 @@ void GpuMemoryBufferVideoFramePool::PoolImpl:: |
case GpuVideoAcceleratorFactories::OutputFormat::UYVY: |
allow_overlay = true; |
break; |
+ case GpuVideoAcceleratorFactories::OutputFormat::YUYV: |
+ // IA ChromeOS doesn't support overlay for YUYV GPU_READ_CPU_READ_WRITE |
+ // plane. |
+ break; |
default: |
break; |
} |