| Index: media/base/video_frame_impl.cc
|
| diff --git a/media/base/video_frame_impl.cc b/media/base/video_frame_impl.cc
|
| index aabda6c54ed9ccd48baae9fc16975ed53b2b7376..470e297d2abda5f90d70fb53132c8cccd5000c75 100644
|
| --- a/media/base/video_frame_impl.cc
|
| +++ b/media/base/video_frame_impl.cc
|
| @@ -52,6 +52,48 @@ void VideoFrameImpl::CreateEmptyFrame(scoped_refptr<VideoFrame>* frame_out) {
|
| *frame_out = new VideoFrameImpl(VideoSurface::EMPTY, 0, 0);
|
| }
|
|
|
| +// static
|
| +void VideoFrameImpl::CreateBlackFrame(int width, int height,
|
| + scoped_refptr<VideoFrame>* frame_out) {
|
| + DCHECK_GT(width, 0);
|
| + DCHECK_GT(height, 0);
|
| +
|
| + // Create our frame.
|
| + scoped_refptr<VideoFrame> frame;
|
| + const base::TimeDelta kZero;
|
| + VideoFrameImpl::CreateFrame(VideoSurface::YV12, width, height, kZero, kZero,
|
| + &frame);
|
| + DCHECK(frame);
|
| +
|
| + // Now set the data to YUV(0,128,128).
|
| + const uint8 kBlackY = 0x00;
|
| + const uint8 kBlackUV = 0x80;
|
| + VideoSurface surface;
|
| + frame->Lock(&surface);
|
| + DCHECK_EQ(VideoSurface::YV12, surface.format) << "Expected YV12 surface";
|
| +
|
| + // Fill the Y plane.
|
| + for (size_t i = 0; i < surface.height; ++i) {
|
| + memset(surface.data[VideoSurface::kYPlane], kBlackY, surface.width);
|
| + surface.data[VideoSurface::kYPlane]
|
| + += surface.strides[VideoSurface::kYPlane];
|
| + }
|
| +
|
| + // Fill the U and V planes.
|
| + for (size_t i = 0; i < (surface.height / 2); ++i) {
|
| + memset(surface.data[VideoSurface::kUPlane], kBlackUV, surface.width / 2);
|
| + memset(surface.data[VideoSurface::kVPlane], kBlackUV, surface.width / 2);
|
| + surface.data[VideoSurface::kUPlane] +=
|
| + surface.strides[VideoSurface::kUPlane];
|
| + surface.data[VideoSurface::kVPlane] +=
|
| + surface.strides[VideoSurface::kVPlane];
|
| + }
|
| + frame->Unlock();
|
| +
|
| + // Success!
|
| + *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)));
|
|
|