| Index: media/base/video_frame.cc
|
| diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
|
| index 3e2164e6eb1189430e93a1a9a08b6c8ebd88396c..a7eeb1e53799c00a0d551814acb9d26995f74887 100644
|
| --- a/media/base/video_frame.cc
|
| +++ b/media/base/video_frame.cc
|
| @@ -47,6 +47,29 @@ void VideoFrame::CreateFrame(VideoFrame::Format format,
|
| *frame_out = alloc_worked ? frame : NULL;
|
| }
|
|
|
| +void VideoFrame::CreateFrameExternal(VideoFrame::Format format,
|
| + size_t width,
|
| + size_t height,
|
| + uint8* const data[kMaxPlanes],
|
| + const int32 strides[kMaxPlanes],
|
| + base::TimeDelta timestamp,
|
| + base::TimeDelta duration,
|
| + scoped_refptr<VideoFrame>* frame_out) {
|
| + DCHECK(frame_out);
|
| + scoped_refptr<VideoFrame> frame =
|
| + new VideoFrame(VideoFrame::TYPE_SYSTEM_MEMORY, format, width, height);
|
| + if (frame) {
|
| + frame->SetTimestamp(timestamp);
|
| + frame->SetDuration(duration);
|
| + frame->external_memory_ = true;
|
| + for (size_t i = 0; i < kMaxPlanes; ++i) {
|
| + frame->data_[i] = data[i];
|
| + frame->strides_[i] = strides[i];
|
| + }
|
| + }
|
| + *frame_out = frame;
|
| +}
|
| +
|
| // static
|
| void VideoFrame::CreateEmptyFrame(scoped_refptr<VideoFrame>* frame_out) {
|
| *frame_out = new VideoFrame(VideoFrame::TYPE_SYSTEM_MEMORY,
|
| @@ -179,6 +202,7 @@ VideoFrame::VideoFrame(VideoFrame::BufferType type,
|
| planes_ = 0;
|
| memset(&strides_, 0, sizeof(strides_));
|
| memset(&data_, 0, sizeof(data_));
|
| + external_memory_ = false;
|
| private_buffer_ = NULL;
|
| }
|
|
|
| @@ -186,7 +210,8 @@ VideoFrame::~VideoFrame() {
|
| // In multi-plane allocations, only a single block of memory is allocated
|
| // on the heap, and other |data| pointers point inside the same, single block
|
| // so just delete index 0.
|
| - delete[] data_[0];
|
| + if (!external_memory_)
|
| + delete[] data_[0];
|
| }
|
|
|
| bool VideoFrame::IsEndOfStream() const {
|
|
|