diff options
author | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-22 16:57:14 +0000 |
---|---|---|
committer | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-22 16:57:14 +0000 |
commit | fd98f105b85f074a1b6adb2b6ab37d2e36ffbc92 (patch) | |
tree | 824720ab2dea3ce4f63f316fb270f5bed86d721a /media/base | |
parent | 7509874518456dc2b495eed8256bef6da77ae59b (diff) | |
download | chromium_src-fd98f105b85f074a1b6adb2b6ab37d2e36ffbc92.zip chromium_src-fd98f105b85f074a1b6adb2b6ab37d2e36ffbc92.tar.gz chromium_src-fd98f105b85f074a1b6adb2b6ab37d2e36ffbc92.tar.bz2 |
media: preparation for recycle buffer.
1. add ffmpeg_video_allocator.cc/h
2. add omx_bufferheader type and av_frame type of video_frame.
please see http://codereview.chromium.org/2992002/show
for full commit. this is used to split that change to reviewable size of changelist.
Review URL: http://codereview.chromium.org/3006001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53348 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/video_frame.cc | 29 | ||||
-rw-r--r-- | media/base/video_frame.h | 17 | ||||
-rw-r--r-- | media/base/video_frame_unittest.cc | 26 |
3 files changed, 16 insertions, 56 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index 857af70..e7da94e 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc @@ -50,21 +50,26 @@ void VideoFrame::CreateFrame(VideoFrame::Format format, *frame_out = alloc_worked ? frame : NULL; } -void VideoFrame::CreateFrameExternal(VideoFrame::Format format, +void VideoFrame::CreateFrameExternal(SurfaceType type, + Format format, size_t width, size_t height, + size_t planes, uint8* const data[kMaxPlanes], const int32 strides[kMaxPlanes], base::TimeDelta timestamp, base::TimeDelta duration, + void* private_buffer, scoped_refptr<VideoFrame>* frame_out) { DCHECK(frame_out); scoped_refptr<VideoFrame> frame = - new VideoFrame(VideoFrame::TYPE_SYSTEM_MEMORY, format, width, height); + new VideoFrame(type, format, width, height); if (frame) { frame->SetTimestamp(timestamp); frame->SetDuration(duration); frame->external_memory_ = true; + frame->planes_ = planes; + frame->private_buffer_ = private_buffer; for (size_t i = 0; i < kMaxPlanes; ++i) { frame->data_[i] = data[i]; frame->strides_[i] = strides[i]; @@ -117,26 +122,6 @@ void VideoFrame::CreateBlackFrame(int width, int height, *frame_out = frame; } -// static -void VideoFrame::CreatePrivateFrame(VideoFrame::SurfaceType type, - VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, - void* private_buffer, - scoped_refptr<VideoFrame>* frame_out) { - DCHECK(frame_out); - scoped_refptr<VideoFrame> frame = - new VideoFrame(type, format, width, height); - if (frame) { - frame->SetTimestamp(timestamp); - frame->SetDuration(duration); - frame->private_buffer_ = private_buffer; - } - *frame_out = frame; -} - static inline size_t RoundUp(size_t value, size_t alignment) { // Check that |alignment| is a power of 2. DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); diff --git a/media/base/video_frame.h b/media/base/video_frame.h index ddf6644..a135bdf 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h @@ -39,7 +39,7 @@ class VideoFrame : public StreamSample { enum SurfaceType { TYPE_SYSTEM_MEMORY, - TYPE_OMX_BUFFER_HEAD, + TYPE_OMXBUFFERHEAD, TYPE_EGL_IMAGE, }; @@ -56,13 +56,16 @@ class VideoFrame : public StreamSample { // Creates a new frame with given parameters. Buffers for the frame are // provided externally. Reference to the buffers and strides are copied // from |data| and |strides| respectively. - static void CreateFrameExternal(Format format, + static void CreateFrameExternal(SurfaceType type, + Format format, size_t width, size_t height, + size_t planes, uint8* const data[kMaxPlanes], const int32 strides[kMaxPlanes], base::TimeDelta timestamp, base::TimeDelta duration, + void* private_buffer, scoped_refptr<VideoFrame>* frame_out); // Creates a frame with format equals to VideoFrame::EMPTY, width, height @@ -74,16 +77,6 @@ class VideoFrame : public StreamSample { static void CreateBlackFrame(int width, int height, scoped_refptr<VideoFrame>* frame_out); - // Creates a new frame of |type| with given parameters. - static void CreatePrivateFrame(VideoFrame::SurfaceType type, - VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, - void* private_buffer, - scoped_refptr<VideoFrame>* frame_out); - virtual SurfaceType type() const { return type_; } Format format() const { return format_; } diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc index df407b5..633ccc0 100644 --- a/media/base/video_frame_unittest.cc +++ b/media/base/video_frame_unittest.cc @@ -176,35 +176,17 @@ TEST(VideoFrame, CreateBlackFrame) { } } -TEST(VideoFrame, CreatePrivateFrame) { - void* private_buffer = NULL; - const base::TimeDelta kTimestampA = base::TimeDelta::FromMicroseconds(1337); - const base::TimeDelta kDurationA = base::TimeDelta::FromMicroseconds(1667); - - // Create an EGL Frame. - scoped_refptr<media::VideoFrame> frame; - VideoFrame::CreatePrivateFrame(media::VideoFrame::TYPE_EGL_IMAGE, - media::VideoFrame::RGBA, 0, 0, - kTimestampA, kDurationA, - private_buffer, &frame); - ASSERT_TRUE(frame); - - // Test |frame| properties. - EXPECT_EQ(media::VideoFrame::TYPE_EGL_IMAGE, frame->type()); - EXPECT_EQ(media::VideoFrame::RGBA, frame->format()); - EXPECT_EQ(private_buffer, frame->private_buffer()); - EXPECT_EQ(NULL, frame->data(VideoFrame::kYPlane)); -} - TEST(VideoFram, CreateExternalFrame) { scoped_array<uint8> memory(new uint8[1]); scoped_refptr<media::VideoFrame> frame; uint8* data[3] = {memory.get(), NULL, NULL}; int strides[3] = {1, 0, 0}; - VideoFrame::CreateFrameExternal(media::VideoFrame::RGB32, 0, 0, + VideoFrame::CreateFrameExternal(media::VideoFrame::TYPE_SYSTEM_MEMORY, + media::VideoFrame::RGB32, 0, 0, 3, data, strides, - base::TimeDelta(), base::TimeDelta(), &frame); + base::TimeDelta(), base::TimeDelta(), + NULL, &frame); ASSERT_TRUE(frame); // Test frame properties. |