Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Unified Diff: media/base/video_frame.cc

Issue 2428263004: 16 bpp video stream capture, render and createImageBitmap(video) using (CPU) shared memory buffers (Closed)
Patch Set: Split webrtc_depth_capture_browsertest. Thanks phoglund@, Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
}

Powered by Google App Engine
This is Rietveld 408576698