Index: media/base/video_frame.cc |
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc |
index fd4788026434039525f9b5cdfe76c69210af25af..41273b8fa2f497e4762c464d954f07df964a1722 100644 |
--- a/media/base/video_frame.cc |
+++ b/media/base/video_frame.cc |
@@ -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,17 +793,30 @@ 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); |
- return frame; |
+ switch (NumPlanes(format)) { |
+ case 1: |
+ frame->strides_[kYPlane] = RowBytes(kYPlane, format, coded_size.width()); |
+ frame->data_[kYPlane] = data; |
+ return frame; |
+ 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_[kYPlane] = RowBytes(kYPlane, format, coded_size.width()); |
+ frame->data_[kYPlane] = data; |
+ 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(); |
+ return frame; |
+ default: |
+ LOG(DFATAL) << "Invalid number of planes: " << NumPlanes(format) |
+ << " in format: " << VideoPixelFormatToString(format); |
+ return nullptr; |
+ } |
} |
VideoFrame::VideoFrame(VideoPixelFormat format, |
@@ -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; |
} |
} |