Index: media/base/video_frame.cc |
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc |
index fd4788026434039525f9b5cdfe76c69210af25af..0c02e641ba700dd0700ae945b7ca86b26d732832 100644 |
--- a/media/base/video_frame.cc |
+++ b/media/base/video_frame.cc |
@@ -163,7 +163,7 @@ scoped_refptr<VideoFrame> VideoFrame::WrapNativeTextures( |
base::TimeDelta timestamp) { |
if (format != PIXEL_FORMAT_ARGB && format != PIXEL_FORMAT_XRGB && |
format != PIXEL_FORMAT_UYVY && format != PIXEL_FORMAT_NV12 && |
- format != PIXEL_FORMAT_I420) { |
+ format != PIXEL_FORMAT_I420 && format != PIXEL_FORMAT_Y16) { |
LOG(DFATAL) << "Unsupported pixel format supported, got " |
<< VideoPixelFormatToString(format); |
return nullptr; |
@@ -770,8 +770,9 @@ scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( |
// TODO(miu): This function should support any pixel format. |
// http://crbug.com/555909 |
- if (format != PIXEL_FORMAT_I420) { |
- LOG(DFATAL) << "Only PIXEL_FORMAT_I420 format supported: " |
+ if (format != PIXEL_FORMAT_I420 && format != PIXEL_FORMAT_Y16) { |
+ LOG(DFATAL) << "Only PIXEL_FORMAT_I420 and PIXEL_FORMAT_Y16 formats are" |
+ "supported: " |
<< VideoPixelFormatToString(format); |
return nullptr; |
} |
@@ -792,16 +793,29 @@ scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( |
frame = new VideoFrame(format, storage_type, coded_size, visible_rect, |
natural_size, timestamp); |
} |
- frame->strides_[kYPlane] = coded_size.width(); |
- // TODO(miu): This always rounds widths down, whereas VideoFrame::RowBytes() |
- // always rounds up. This inconsistency must be resolved. Perhaps a |
- // CommonAlignment() check should be made in IsValidConfig()? |
- // http://crbug.com/555909 |
- frame->strides_[kUPlane] = coded_size.width() / 2; |
- frame->strides_[kVPlane] = coded_size.width() / 2; |
- frame->data_[kYPlane] = data; |
- frame->data_[kUPlane] = data + coded_size.GetArea(); |
- frame->data_[kVPlane] = data + (coded_size.GetArea() * 5 / 4); |
+ switch (NumPlanes(format)) { |
+ case 0: |
+ case 2: |
+ case 4: |
+ NOTREACHED(); |
+ break; |
+ case 3: |
+ DCHECK_EQ(format, PIXEL_FORMAT_I420); |
+ // TODO(miu): This always rounds widths down, whereas |
+ // VideoFrame::RowBytes() always rounds up. This inconsistency must be |
+ // resolved. Perhaps a CommonAlignment() check should be made in |
+ // IsValidConfig()? |
+ // http://crbug.com/555909 |
+ frame->strides_[kVPlane] = coded_size.width() / 2; |
+ frame->data_[kVPlane] = data + (coded_size.GetArea() * 5 / 4); |
+ frame->strides_[kUPlane] = coded_size.width() / 2; |
+ frame->data_[kUPlane] = data + coded_size.GetArea(); |
+ // Fall through. |
+ case 1: |
+ frame->strides_[kYPlane] = RowBytes(kYPlane, format, coded_size.width()); |
+ frame->data_[kYPlane] = data; |
+ return frame; |
+ } |
return frame; |
} |
@@ -972,6 +986,7 @@ gfx::Size VideoFrame::SampleSize(VideoPixelFormat format, size_t plane) { |
case PIXEL_FORMAT_YUV444P9: |
case PIXEL_FORMAT_YUV444P10: |
case PIXEL_FORMAT_YUV444P12: |
+ case PIXEL_FORMAT_Y16: |
return gfx::Size(1, 1); |
case PIXEL_FORMAT_YV16: |
@@ -1000,7 +1015,6 @@ gfx::Size VideoFrame::SampleSize(VideoPixelFormat format, size_t plane) { |
case PIXEL_FORMAT_RGB32: |
case PIXEL_FORMAT_MJPEG: |
case PIXEL_FORMAT_Y8: |
- case PIXEL_FORMAT_Y16: |
break; |
} |
} |