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

Unified Diff: media/base/video_frame.cc

Issue 2398463003: 16 bit capture and GPU&CPU memory buffer support.
Patch Set: fixes. Created 4 years, 2 months 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
« no previous file with comments | « media/base/video_frame.h ('k') | media/capture/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_frame.cc
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index 62b347dca3f953bff4e5184d3b21de374f0ec6c2..5ce090990aad673bf0d9fdbacad9e149ed8376ff 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -166,7 +166,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;
@@ -214,6 +214,31 @@ scoped_refptr<VideoFrame> VideoFrame::WrapExternalSharedMemory(
}
// static
+scoped_refptr<VideoFrame> VideoFrame::WrapExternalGpuMemoryBuffer(
+ VideoPixelFormat format,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size,
+ uint8_t* data,
+ const gfx::GpuMemoryBufferHandle& handle,
+ base::TimeDelta timestamp) {
+ const StorageType storage = STORAGE_GPU_MEMORY_BUFFERS;
+ if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) {
+ LOG(DFATAL) << __func__ << " Invalid config."
+ << ConfigToString(format, storage, coded_size, visible_rect,
+ natural_size);
+ return nullptr;
+ }
+
+ scoped_refptr<VideoFrame> frame(new VideoFrame(
+ format, storage, coded_size, visible_rect, natural_size, timestamp));
+ frame->strides_[0] = coded_size.width() * BytesPerElement(format, 0);
+ frame->data_[0] = data;
+ frame->gpu_memory_buffer_handles_.push_back(handle);
+ return frame;
+}
+
+// static
scoped_refptr<VideoFrame> VideoFrame::WrapExternalYuvData(
VideoPixelFormat format,
const gfx::Size& coded_size,
@@ -623,6 +648,24 @@ void VideoFrame::HashFrameForTesting(base::MD5Context* context,
}
}
+// static
+gfx::BufferFormat VideoFrame::BufferFormat(VideoPixelFormat format) {
+ switch (format) {
+ case PIXEL_FORMAT_I420:
+ case PIXEL_FORMAT_Y8:
+ return gfx::BufferFormat::R_8;
+ case PIXEL_FORMAT_NV12:
+ return gfx::BufferFormat::YUV_420_BIPLANAR;
+ case PIXEL_FORMAT_UYVY:
+ return gfx::BufferFormat::UYVY_422;
+ case PIXEL_FORMAT_Y16:
+ return gfx::BufferFormat::RG_88;
+ default:
+ NOTREACHED();
+ return gfx::BufferFormat::BGRA_8888;
+ }
+}
+
bool VideoFrame::IsMappable() const {
return IsStorageTypeMappable(storage_type_);
}
@@ -818,8 +861,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;
}
@@ -840,6 +884,13 @@ scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage(
frame = new VideoFrame(format, storage_type, coded_size, visible_rect,
natural_size, timestamp);
}
+ if (format == PIXEL_FORMAT_Y16) {
+ DCHECK_EQ(NumPlanes(format), 1U);
+ 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
@@ -1020,6 +1071,8 @@ gfx::Size VideoFrame::SampleSize(VideoPixelFormat format, size_t plane) {
case PIXEL_FORMAT_YUV444P9:
case PIXEL_FORMAT_YUV444P10:
case PIXEL_FORMAT_YUV444P12:
+ case PIXEL_FORMAT_Y8:
+ case PIXEL_FORMAT_Y16:
return gfx::Size(1, 1);
case PIXEL_FORMAT_YV16:
@@ -1047,8 +1100,6 @@ gfx::Size VideoFrame::SampleSize(VideoPixelFormat format, size_t plane) {
case PIXEL_FORMAT_RGB24:
case PIXEL_FORMAT_RGB32:
case PIXEL_FORMAT_MJPEG:
- case PIXEL_FORMAT_Y8:
- case PIXEL_FORMAT_Y16:
break;
}
}
« no previous file with comments | « media/base/video_frame.h ('k') | media/capture/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698