diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 22:16:17 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 22:16:17 +0000 |
commit | d4833b74f7042a84c85ffc73b9fdf26f515d9ab8 (patch) | |
tree | ec5ed59bff3827a8dfcbf6d2e88b838ad30bce77 /media/base | |
parent | 3e2694fa1dc6404cc1739bccf865fc71393f0c03 (diff) | |
download | chromium_src-d4833b74f7042a84c85ffc73b9fdf26f515d9ab8.zip chromium_src-d4833b74f7042a84c85ffc73b9fdf26f515d9ab8.tar.gz chromium_src-d4833b74f7042a84c85ffc73b9fdf26f515d9ab8.tar.bz2 |
Refactor webkit_media::VideoRendererImpl into standalone class.
As a follow up to r115583 VideoRendererImpl no longer extends VideoRendererBase and instead is a standalone class whose sole purpose is to paint VideoFrames to SkCanvases.
BUG=28208
Review URL: http://codereview.chromium.org/9024019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117711 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/video_frame.cc | 25 | ||||
-rw-r--r-- | media/base/video_util.cc | 26 | ||||
-rw-r--r-- | media/base/video_util.h | 5 | ||||
-rw-r--r-- | media/base/video_util_unittest.cc | 2 |
4 files changed, 33 insertions, 25 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index 918b3d3..7e7e60c 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc @@ -1,10 +1,11 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "media/base/video_frame.h" #include "base/logging.h" +#include "media/base/video_util.h" namespace media { @@ -79,27 +80,7 @@ scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame(int width, int height) { // Now set the data to YUV(0,128,128). const uint8 kBlackY = 0x00; const uint8 kBlackUV = 0x80; - - // Fill the Y plane. - uint8* y_plane = frame->data(VideoFrame::kYPlane); - for (size_t i = 0; i < frame->height_; ++i) { - memset(y_plane, kBlackY, frame->width_); - y_plane += frame->stride(VideoFrame::kYPlane); - } - - // Fill the U and V planes. - uint8* u_plane = frame->data(VideoFrame::kUPlane); - uint8* v_plane = frame->data(VideoFrame::kVPlane); - int uv_rows = frame->rows(VideoFrame::kUPlane); - int u_row_bytes = frame->row_bytes(VideoFrame::kUPlane); - int v_row_bytes = frame->row_bytes(VideoFrame::kVPlane); - for (size_t i = 0; i < (size_t)uv_rows; ++i) { - memset(u_plane, kBlackUV, u_row_bytes); - memset(v_plane, kBlackUV, v_row_bytes); - u_plane += frame->stride(VideoFrame::kUPlane); - v_plane += frame->stride(VideoFrame::kVPlane); - } - + FillYUV(frame, kBlackY, kBlackUV, kBlackUV); return frame; } diff --git a/media/base/video_util.cc b/media/base/video_util.cc index ed00667..4476e6d 100644 --- a/media/base/video_util.cc +++ b/media/base/video_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -40,4 +40,28 @@ void CopyVPlane(const uint8* source, int stride, int rows, VideoFrame* frame) { CopyPlane(VideoFrame::kVPlane, source, stride, rows, frame); } +void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v) { + // Fill the Y plane. + uint8* y_plane = frame->data(VideoFrame::kYPlane); + int y_rows = frame->rows(VideoFrame::kYPlane); + int y_row_bytes = frame->row_bytes(VideoFrame::kYPlane); + for (int i = 0; i < y_rows; ++i) { + memset(y_plane, y, y_row_bytes); + y_plane += frame->stride(VideoFrame::kYPlane); + } + + // Fill the U and V planes. + uint8* u_plane = frame->data(VideoFrame::kUPlane); + uint8* v_plane = frame->data(VideoFrame::kVPlane); + int uv_rows = frame->rows(VideoFrame::kUPlane); + int u_row_bytes = frame->row_bytes(VideoFrame::kUPlane); + int v_row_bytes = frame->row_bytes(VideoFrame::kVPlane); + for (int i = 0; i < uv_rows; ++i) { + memset(u_plane, u, u_row_bytes); + memset(v_plane, v, v_row_bytes); + u_plane += frame->stride(VideoFrame::kUPlane); + v_plane += frame->stride(VideoFrame::kVPlane); + } +} + } // namespace media diff --git a/media/base/video_util.h b/media/base/video_util.h index 7ffef74..3d21c8c 100644 --- a/media/base/video_util.h +++ b/media/base/video_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,6 +23,9 @@ MEDIA_EXPORT void CopyUPlane(const uint8* source, int stride, int rows, MEDIA_EXPORT void CopyVPlane(const uint8* source, int stride, int rows, VideoFrame* frame); +// Fills |frame| containing YUV data to the given color values. +MEDIA_EXPORT void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v); + } // namespace media #endif // MEDIA_BASE_VIDEO_UTIL_H_ diff --git a/media/base/video_util_unittest.cc b/media/base/video_util_unittest.cc index a869671..df28eb6 100644 --- a/media/base/video_util_unittest.cc +++ b/media/base/video_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. |