diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 15:53:30 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 15:53:30 +0000 |
commit | 768708171bb6c8dec34509c11460d3bc355a3e81 (patch) | |
tree | 0759c4e4c4fc9bd6d115e5e4ade74f81225756ff /media/base | |
parent | 8f8b6b856f85ec92504ca3e48ea4e0d0886ac7b2 (diff) | |
download | chromium_src-768708171bb6c8dec34509c11460d3bc355a3e81.zip chromium_src-768708171bb6c8dec34509c11460d3bc355a3e81.tar.gz chromium_src-768708171bb6c8dec34509c11460d3bc355a3e81.tar.bz2 |
Added FakeGlVideoDecodeEngine to exercise the IPC protocol for hardware video decoding
There are several things done in this patch:
1. Added FakeGlVideoDecodeEngine
2. Fixed style problem in VideoDecodeEngine and gpu_video_common.h
3. Added route to pass texture from gpu process to WebKit
BUG=53714
TEST=Tree is green
Review URL: http://codereview.chromium.org/3335014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59223 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/video_frame.cc | 68 | ||||
-rw-r--r-- | media/base/video_frame.h | 40 |
2 files changed, 107 insertions, 1 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index b4fb5cf..8e3b245 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc @@ -8,6 +8,25 @@ namespace media { +static size_t GetNumberOfPlanes(VideoFrame::Format format) { + switch (format) { + case VideoFrame::RGB555: + case VideoFrame::RGB565: + case VideoFrame::RGB24: + case VideoFrame::RGB32: + case VideoFrame::RGBA: + case VideoFrame::ASCII: + return VideoFrame::kNumRGBPlanes; + case VideoFrame::YV12: + case VideoFrame::YV16: + return VideoFrame::kNumYUVPlanes; + case VideoFrame::NV12: + return VideoFrame::kNumNV12Planes; + default: + return 0; + } +} + // static void VideoFrame::CreateFrame(VideoFrame::Format format, size_t width, @@ -52,6 +71,7 @@ void VideoFrame::CreateFrame(VideoFrame::Format format, *frame_out = alloc_worked ? frame : NULL; } +// static void VideoFrame::CreateFrameExternal(SurfaceType type, Format format, size_t width, @@ -81,6 +101,52 @@ void VideoFrame::CreateFrameExternal(SurfaceType type, } // static +void VideoFrame::CreateFrameGlTexture(Format format, + size_t width, + size_t height, + GlTexture const textures[kMaxPlanes], + base::TimeDelta timestamp, + base::TimeDelta duration, + scoped_refptr<VideoFrame>* frame_out) { + DCHECK(frame_out); + scoped_refptr<VideoFrame> frame = + new VideoFrame(TYPE_GL_TEXTURE, format, width, height); + if (frame) { + frame->SetTimestamp(timestamp); + frame->SetDuration(duration); + frame->external_memory_ = true; + frame->planes_ = GetNumberOfPlanes(format); + for (size_t i = 0; i < kMaxPlanes; ++i) { + frame->gl_textures_[i] = textures[i]; + } + } + *frame_out = frame; +} + +// static +void VideoFrame::CreateFrameD3dTexture(Format format, + size_t width, + size_t height, + D3dTexture const textures[kMaxPlanes], + base::TimeDelta timestamp, + base::TimeDelta duration, + scoped_refptr<VideoFrame>* frame_out) { + DCHECK(frame_out); + scoped_refptr<VideoFrame> frame = + new VideoFrame(TYPE_D3D_TEXTURE, format, width, height); + if (frame) { + frame->SetTimestamp(timestamp); + frame->SetDuration(duration); + frame->external_memory_ = true; + frame->planes_ = GetNumberOfPlanes(format); + for (size_t i = 0; i < kMaxPlanes; ++i) { + frame->d3d_textures_[i] = textures[i]; + } + } + *frame_out = frame; +} + +// static void VideoFrame::CreateEmptyFrame(scoped_refptr<VideoFrame>* frame_out) { *frame_out = new VideoFrame(VideoFrame::TYPE_SYSTEM_MEMORY, VideoFrame::EMPTY, 0, 0); @@ -192,6 +258,8 @@ VideoFrame::VideoFrame(VideoFrame::SurfaceType type, planes_ = 0; memset(&strides_, 0, sizeof(strides_)); memset(&data_, 0, sizeof(data_)); + memset(&gl_textures_, 0, sizeof(gl_textures_)); + memset(&d3d_textures_, 0, sizeof(d3d_textures_)); external_memory_ = false; private_buffer_ = NULL; } diff --git a/media/base/video_frame.h b/media/base/video_frame.h index 0eb38fb..88c11dd 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h @@ -17,6 +17,7 @@ class VideoFrame : public StreamSample { static const size_t kRGBPlane = 0; static const size_t kNumYUVPlanes = 3; + static const size_t kNumNV12Planes = 2; static const size_t kYPlane = 0; static const size_t kUPlane = 1; static const size_t kVPlane = 2; @@ -50,7 +51,13 @@ class VideoFrame : public StreamSample { TYPE_D3D_TEXTURE, }; - public: + // Defines a new type for GL texture so we don't include OpenGL headers. + typedef unsigned int GlTexture; + + // Defines a new type for D3D texture so we don't include D3D headers and + // don't need to bind to a specific version of D3D. + typedef void* D3dTexture; + // Creates a new frame in system memory with given parameters. Buffers for // the frame are allocated but not initialized. static void CreateFrame(Format format, @@ -75,6 +82,24 @@ class VideoFrame : public StreamSample { void* private_buffer, scoped_refptr<VideoFrame>* frame_out); + // Creates a new frame with GL textures. + static void CreateFrameGlTexture(Format format, + size_t width, + size_t height, + GlTexture const textures[kMaxPlanes], + base::TimeDelta timestamp, + base::TimeDelta duration, + scoped_refptr<VideoFrame>* frame_out); + + // Creates a new frame with D3d textures. + static void CreateFrameD3dTexture(Format format, + size_t width, + size_t height, + D3dTexture const textures[kMaxPlanes], + base::TimeDelta timestamp, + base::TimeDelta duration, + scoped_refptr<VideoFrame>* frame_out); + // Creates a frame with format equals to VideoFrame::EMPTY, width, height // timestamp and duration are all 0. static void CreateEmptyFrame(scoped_refptr<VideoFrame>* frame_out); @@ -98,8 +123,15 @@ class VideoFrame : public StreamSample { // Returns pointer to the buffer for a given plane. The memory is owned by // VideoFrame object and must not be freed by the caller. + // TODO(hclam): Use union together with |gl_texture| and |d3d_texture|. uint8* data(size_t plane) const { return data_[plane]; } + // Returns the GL texture for a given plane. + GlTexture gl_texture(size_t plane) const { return gl_textures_[plane]; } + + // Returns the D3D texture for a given plane. + D3dTexture d3d_texture(size_t plane) const { return d3d_textures_[plane]; } + void* private_buffer() const { return private_buffer_; } // StreamSample interface. @@ -140,6 +172,12 @@ class VideoFrame : public StreamSample { // Array of data pointers to each plane. uint8* data_[kMaxPlanes]; + // Array fo GL textures. + GlTexture gl_textures_[kMaxPlanes]; + + // Array for D3D textures. + D3dTexture d3d_textures_[kMaxPlanes]; + // True of memory referenced by |data_| is provided externally and shouldn't // be deleted. bool external_memory_; |