OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/video_frame_impl.h" | 5 #include "media/base/video_frame_impl.h" |
6 | 6 |
7 namespace media { | 7 namespace media { |
8 | 8 |
9 // static | 9 // static |
10 void VideoFrameImpl::CreateFrame(VideoSurface::Format format, | 10 void VideoFrameImpl::CreateFrame(VideoSurface::Format format, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 bool VideoFrameImpl::AllocateRGB(size_t bytes_per_pixel) { | 61 bool VideoFrameImpl::AllocateRGB(size_t bytes_per_pixel) { |
62 // Round up to align at a 64-bit (8 byte) boundary for each row. This | 62 // Round up to align at a 64-bit (8 byte) boundary for each row. This |
63 // is sufficient for MMX reads (movq). | 63 // is sufficient for MMX reads (movq). |
64 size_t bytes_per_row = RoundUp(surface_.width * bytes_per_pixel, 8); | 64 size_t bytes_per_row = RoundUp(surface_.width * bytes_per_pixel, 8); |
65 surface_.planes = VideoSurface::kNumRGBPlanes; | 65 surface_.planes = VideoSurface::kNumRGBPlanes; |
66 surface_.strides[VideoSurface::kRGBPlane] = bytes_per_row; | 66 surface_.strides[VideoSurface::kRGBPlane] = bytes_per_row; |
67 surface_.data[VideoSurface::kRGBPlane] = new uint8[bytes_per_row * | 67 surface_.data[VideoSurface::kRGBPlane] = new uint8[bytes_per_row * |
68 surface_.height]; | 68 surface_.height]; |
69 DCHECK(surface_.data[VideoSurface::kRGBPlane]); | 69 DCHECK(surface_.data[VideoSurface::kRGBPlane]); |
70 DCHECK(!(reinterpret_cast<int>(surface_.data[VideoSurface::kRGBPlane]) & 7)); | 70 DCHECK(!(reinterpret_cast<intptr_t>( |
| 71 surface_.data[VideoSurface::kRGBPlane]) & 7)); |
71 COMPILE_ASSERT(0 == VideoSurface::kRGBPlane, RGB_data_must_be_index_0); | 72 COMPILE_ASSERT(0 == VideoSurface::kRGBPlane, RGB_data_must_be_index_0); |
72 return (NULL != surface_.data[VideoSurface::kRGBPlane]); | 73 return (NULL != surface_.data[VideoSurface::kRGBPlane]); |
73 } | 74 } |
74 | 75 |
75 bool VideoFrameImpl::AllocateYUV() { | 76 bool VideoFrameImpl::AllocateYUV() { |
76 DCHECK(surface_.format == VideoSurface::YV12 || | 77 DCHECK(surface_.format == VideoSurface::YV12 || |
77 surface_.format == VideoSurface::YV16); | 78 surface_.format == VideoSurface::YV16); |
78 // Align Y rows at 32-bit (4 byte) boundaries. The stride for both YV12 and | 79 // Align Y rows at 32-bit (4 byte) boundaries. The stride for both YV12 and |
79 // YV16 is 1/2 of the stride of Y. For YV12, every row of bytes for U and V | 80 // YV16 is 1/2 of the stride of Y. For YV12, every row of bytes for U and V |
80 // applies to two rows of Y (one byte of UV for 4 bytes of Y), so in the | 81 // applies to two rows of Y (one byte of UV for 4 bytes of Y), so in the |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 DCHECK(locked_); | 143 DCHECK(locked_); |
143 DCHECK_NE(surface_.format, VideoSurface::EMPTY); | 144 DCHECK_NE(surface_.format, VideoSurface::EMPTY); |
144 locked_ = false; | 145 locked_ = false; |
145 } | 146 } |
146 | 147 |
147 bool VideoFrameImpl::IsEndOfStream() const { | 148 bool VideoFrameImpl::IsEndOfStream() const { |
148 return surface_.format == VideoSurface::EMPTY; | 149 return surface_.format == VideoSurface::EMPTY; |
149 } | 150 } |
150 | 151 |
151 } // namespace media | 152 } // namespace media |
OLD | NEW |