summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorbradnelson@google.com <bradnelson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-22 17:29:00 +0000
committerbradnelson@google.com <bradnelson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-22 17:29:00 +0000
commit305ddf7c77a2f082499c584ef00b25cad63654cb (patch)
treeeb3da0a7d0f5f4bb45ab1fd986af2590ebb4c3ac /media/base
parentea6089c7c205c2cbfd1470c430bfe16f97e46370 (diff)
downloadchromium_src-305ddf7c77a2f082499c584ef00b25cad63654cb.zip
chromium_src-305ddf7c77a2f082499c584ef00b25cad63654cb.tar.gz
chromium_src-305ddf7c77a2f082499c584ef00b25cad63654cb.tar.bz2
Reverting 53348...
Broke webkit build. BUG=None TEST=Nont TBR=jiesun Review URL: http://codereview.chromium.org/3015018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53352 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/video_frame.cc29
-rw-r--r--media/base/video_frame.h17
-rw-r--r--media/base/video_frame_unittest.cc26
3 files changed, 56 insertions, 16 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index e7da94e..857af70 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -50,26 +50,21 @@ void VideoFrame::CreateFrame(VideoFrame::Format format,
*frame_out = alloc_worked ? frame : NULL;
}
-void VideoFrame::CreateFrameExternal(SurfaceType type,
- Format format,
+void VideoFrame::CreateFrameExternal(VideoFrame::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(type, format, width, height);
+ new VideoFrame(VideoFrame::TYPE_SYSTEM_MEMORY, 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];
@@ -122,6 +117,26 @@ 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 a135bdf..ddf6644 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_OMXBUFFERHEAD,
+ TYPE_OMX_BUFFER_HEAD,
TYPE_EGL_IMAGE,
};
@@ -56,16 +56,13 @@ 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(SurfaceType type,
- Format format,
+ static void CreateFrameExternal(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
@@ -77,6 +74,16 @@ 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 633ccc0..df407b5 100644
--- a/media/base/video_frame_unittest.cc
+++ b/media/base/video_frame_unittest.cc
@@ -176,17 +176,35 @@ 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::TYPE_SYSTEM_MEMORY,
- media::VideoFrame::RGB32, 0, 0, 3,
+ VideoFrame::CreateFrameExternal(media::VideoFrame::RGB32, 0, 0,
data, strides,
- base::TimeDelta(), base::TimeDelta(),
- NULL, &frame);
+ base::TimeDelta(), base::TimeDelta(), &frame);
ASSERT_TRUE(frame);
// Test frame properties.