Chromium Code Reviews| Index: media/base/video_frame.cc |
| diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc |
| index c40c58f000f38861bb00695c7d59cb58fba0c597..735a602a7832932cf70169fc27f708ae13f7ca65 100644 |
| --- a/media/base/video_frame.cc |
| +++ b/media/base/video_frame.cc |
| @@ -75,9 +75,12 @@ scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame(int width, int height) { |
| // Fill the U and V planes. |
| uint8* u_plane = frame->data(VideoFrame::kUPlane); |
| uint8* v_plane = frame->data(VideoFrame::kVPlane); |
| - for (size_t i = 0; i < (frame->height_ / 2); ++i) { |
| - memset(u_plane, kBlackUV, frame->width_ / 2); |
| - memset(v_plane, kBlackUV, frame->width_ / 2); |
| + 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); |
| } |
| @@ -117,12 +120,11 @@ void VideoFrame::AllocateYUV() { |
| // a full two rows of Y. |
| size_t alloc_height = RoundUp(height_, 2); |
|
scherkus (not reviewing)
2011/09/28 17:32:17
want to fix this up to be "y_height" and use rows(
shadi1
2011/09/29 18:31:03
Done.
|
| size_t y_bytes_per_row = RoundUp(width_, 4); |
|
scherkus (not reviewing)
2011/09/28 17:32:17
ditto and maybe rename y_stride to be consistent w
shadi1
2011/09/29 18:31:03
Done.
|
| - size_t uv_stride = RoundUp(y_bytes_per_row / 2, 4); |
| + size_t uv_stride = RoundUp(row_bytes(VideoFrame::kUPlane), 4); |
| + size_t uv_height = RoundUp(rows(VideoFrame::kUPlane), 2); |
| size_t y_bytes = alloc_height * y_bytes_per_row; |
| - size_t uv_bytes = alloc_height * uv_stride; |
| - if (format_ == VideoFrame::YV12) { |
| - uv_bytes /= 2; |
| - } |
| + size_t uv_bytes = uv_height * uv_stride; |
| + |
| uint8* data = new uint8[y_bytes + (uv_bytes * 2) + kFramePadBytes]; |
| planes_ = VideoFrame::kNumYUVPlanes; |
| COMPILE_ASSERT(0 == VideoFrame::kYPlane, y_plane_data_must_be_index_0); |