Index: media/base/video_frame.cc |
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc |
index 66bbe38d5f5492bc55545252b5c6ad44f4637ae9..99a355b511e38f2f5fdd93e31c3a7330ea3b54ce 100644 |
--- a/media/base/video_frame.cc |
+++ b/media/base/video_frame.cc |
@@ -125,7 +125,7 @@ bool VideoFrame::IsValidConfig(VideoPixelFormat format, |
return true; |
// Make sure new formats are properly accounted for in the method. |
- static_assert(PIXEL_FORMAT_MAX == 21, |
+ static_assert(PIXEL_FORMAT_MAX == 22, |
"Added pixel format, please review IsValidConfig()"); |
if (format == PIXEL_FORMAT_UNKNOWN) { |
@@ -514,6 +514,7 @@ size_t VideoFrame::NumPlanes(VideoPixelFormat format) { |
case PIXEL_FORMAT_RGB24: |
case PIXEL_FORMAT_RGB32: |
case PIXEL_FORMAT_MJPEG: |
+ case PIXEL_FORMAT_Y16: |
return 1; |
case PIXEL_FORMAT_NV12: |
case PIXEL_FORMAT_NV21: |
@@ -801,8 +802,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; |
} |
@@ -823,6 +825,15 @@ scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( |
frame = new VideoFrame(format, storage_type, coded_size, visible_rect, |
natural_size, timestamp); |
} |
+ if (format == PIXEL_FORMAT_Y16) { |
+ // TODO(astojilj) Make this code generic for all and move format specifics |
+ // to static methods. |
+ DCHECK_EQ(NumPlanes(format), 1); |
+ const size_t i = 0; |
+ frame->strides_[i] = coded_size.width() * BytesPerElement(format, i); |
+ frame->data_[i] = data; |
+ return frame; |
+ } |
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 |
@@ -1044,6 +1055,7 @@ int VideoFrame::BytesPerElement(VideoPixelFormat format, size_t plane) { |
return 4; |
case PIXEL_FORMAT_RGB24: |
return 3; |
+ case PIXEL_FORMAT_Y16: |
case PIXEL_FORMAT_UYVY: |
case PIXEL_FORMAT_YUY2: |
case PIXEL_FORMAT_YUV420P9: |