| Index: media/base/video_frame.cc
 | 
| diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
 | 
| index 2009664099cab71b3369acd92068d7e3c8f04cff..b906ee22a64097d0cca59fe2ff230d6b1b60a0e9 100644
 | 
| --- a/media/base/video_frame.cc
 | 
| +++ b/media/base/video_frame.cc
 | 
| @@ -195,35 +195,19 @@ scoped_refptr<VideoFrame> VideoFrame::CreateFrame(VideoPixelFormat format,
 | 
|                                                    const gfx::Rect& visible_rect,
 | 
|                                                    const gfx::Size& natural_size,
 | 
|                                                    base::TimeDelta timestamp) {
 | 
| -  if (!IsYuvPlanar(format)) {
 | 
| -    NOTIMPLEMENTED();
 | 
| -    return nullptr;
 | 
| -  }
 | 
| -
 | 
| -  // Since we're creating a new YUV frame (and allocating memory for it
 | 
| -  // ourselves), we can pad the requested |coded_size| if necessary if the
 | 
| -  // request does not line up on sample boundaries. See discussion at
 | 
| -  // http://crrev.com/1240833003
 | 
| -  const gfx::Size alignment = CommonAlignment(format);
 | 
| -  const gfx::Size new_coded_size =
 | 
| -      gfx::Size(RoundUp(coded_size.width(), alignment.width()),
 | 
| -                RoundUp(coded_size.height(), alignment.height()));
 | 
| -  DCHECK((new_coded_size.width() % alignment.width() == 0) &&
 | 
| -         (new_coded_size.height() % alignment.height() == 0));
 | 
| -
 | 
| -  const StorageType storage = STORAGE_OWNED_MEMORY;
 | 
| -  if (!IsValidConfig(format, storage, new_coded_size, visible_rect,
 | 
| -                     natural_size)) {
 | 
| -    DLOG(ERROR) << __FUNCTION__ << " Invalid config."
 | 
| -                << ConfigToString(format, storage, coded_size, visible_rect,
 | 
| -                                  natural_size);
 | 
| -    return nullptr;
 | 
| -  }
 | 
| +  return CreateFrameInternal(format, coded_size, visible_rect, natural_size,
 | 
| +                             timestamp, false);
 | 
| +}
 | 
|  
 | 
| -  scoped_refptr<VideoFrame> frame(new VideoFrame(
 | 
| -      format, storage, new_coded_size, visible_rect, natural_size, timestamp));
 | 
| -  frame->AllocateYUV();
 | 
| -  return frame;
 | 
| +// static
 | 
| +scoped_refptr<VideoFrame> VideoFrame::CreateZeroInitializedFrame(
 | 
| +    VideoPixelFormat format,
 | 
| +    const gfx::Size& coded_size,
 | 
| +    const gfx::Rect& visible_rect,
 | 
| +    const gfx::Size& natural_size,
 | 
| +    base::TimeDelta timestamp) {
 | 
| +  return CreateFrameInternal(format, coded_size, visible_rect, natural_size,
 | 
| +                             timestamp, true);
 | 
|  }
 | 
|  
 | 
|  // static
 | 
| @@ -897,7 +881,46 @@ VideoFrame::~VideoFrame() {
 | 
|      base::ResetAndReturn(&callback).Run();
 | 
|  }
 | 
|  
 | 
| -void VideoFrame::AllocateYUV() {
 | 
| +// static
 | 
| +scoped_refptr<VideoFrame> VideoFrame::CreateFrameInternal(
 | 
| +    VideoPixelFormat format,
 | 
| +    const gfx::Size& coded_size,
 | 
| +    const gfx::Rect& visible_rect,
 | 
| +    const gfx::Size& natural_size,
 | 
| +    base::TimeDelta timestamp,
 | 
| +    bool zero_initialize_memory) {
 | 
| +  if (!IsYuvPlanar(format)) {
 | 
| +    NOTIMPLEMENTED();
 | 
| +    return nullptr;
 | 
| +  }
 | 
| +
 | 
| +  // Since we're creating a new YUV frame (and allocating memory for it
 | 
| +  // ourselves), we can pad the requested |coded_size| if necessary if the
 | 
| +  // request does not line up on sample boundaries. See discussion at
 | 
| +  // http://crrev.com/1240833003
 | 
| +  const gfx::Size alignment = CommonAlignment(format);
 | 
| +  const gfx::Size new_coded_size =
 | 
| +      gfx::Size(RoundUp(coded_size.width(), alignment.width()),
 | 
| +                RoundUp(coded_size.height(), alignment.height()));
 | 
| +  DCHECK((new_coded_size.width() % alignment.width() == 0) &&
 | 
| +         (new_coded_size.height() % alignment.height() == 0));
 | 
| +
 | 
| +  const StorageType storage = STORAGE_OWNED_MEMORY;
 | 
| +  if (!IsValidConfig(format, storage, new_coded_size, visible_rect,
 | 
| +                     natural_size)) {
 | 
| +    DLOG(ERROR) << __FUNCTION__ << " Invalid config."
 | 
| +                << ConfigToString(format, storage, coded_size, visible_rect,
 | 
| +                                  natural_size);
 | 
| +    return nullptr;
 | 
| +  }
 | 
| +
 | 
| +  scoped_refptr<VideoFrame> frame(new VideoFrame(
 | 
| +      format, storage, new_coded_size, visible_rect, natural_size, timestamp));
 | 
| +  frame->AllocateYUV(zero_initialize_memory);
 | 
| +  return frame;
 | 
| +}
 | 
| +
 | 
| +void VideoFrame::AllocateYUV(bool zero_initialize_memory) {
 | 
|    DCHECK_EQ(storage_type_, STORAGE_OWNED_MEMORY);
 | 
|    static_assert(0 == kYPlane, "y plane data must be index 0");
 | 
|  
 | 
| @@ -923,6 +946,8 @@ void VideoFrame::AllocateYUV() {
 | 
|  
 | 
|    uint8* data = reinterpret_cast<uint8*>(
 | 
|        base::AlignedAlloc(data_size, kFrameAddressAlignment));
 | 
| +  if (zero_initialize_memory)
 | 
| +    memset(data, 0, data_size);
 | 
|  
 | 
|    for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
 | 
|      data_[plane] = data + offset[plane];
 | 
| 
 |