| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "media/base/video_frame.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 memset(u_plane, kBlackUV, frame->width_ / 2); | 159 memset(u_plane, kBlackUV, frame->width_ / 2); |
| 160 memset(v_plane, kBlackUV, frame->width_ / 2); | 160 memset(v_plane, kBlackUV, frame->width_ / 2); |
| 161 u_plane += frame->stride(VideoFrame::kUPlane); | 161 u_plane += frame->stride(VideoFrame::kUPlane); |
| 162 v_plane += frame->stride(VideoFrame::kVPlane); | 162 v_plane += frame->stride(VideoFrame::kVPlane); |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Success! | 165 // Success! |
| 166 *frame_out = frame; | 166 *frame_out = frame; |
| 167 } | 167 } |
| 168 | 168 |
| 169 VideoFrame::SurfaceType VideoFrame::type() const { |
| 170 return type_; |
| 171 } |
| 172 |
| 169 static inline size_t RoundUp(size_t value, size_t alignment) { | 173 static inline size_t RoundUp(size_t value, size_t alignment) { |
| 170 // Check that |alignment| is a power of 2. | 174 // Check that |alignment| is a power of 2. |
| 171 DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); | 175 DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); |
| 172 return ((value + (alignment - 1)) & ~(alignment-1)); | 176 return ((value + (alignment - 1)) & ~(alignment-1)); |
| 173 } | 177 } |
| 174 | 178 |
| 175 bool VideoFrame::AllocateRGB(size_t bytes_per_pixel) { | 179 bool VideoFrame::AllocateRGB(size_t bytes_per_pixel) { |
| 176 // Round up to align at a 64-bit (8 byte) boundary for each row. This | 180 // Round up to align at a 64-bit (8 byte) boundary for each row. This |
| 177 // is sufficient for MMX reads (movq). | 181 // is sufficient for MMX reads (movq). |
| 178 size_t bytes_per_row = RoundUp(width_ * bytes_per_pixel, 8); | 182 size_t bytes_per_row = RoundUp(width_ * bytes_per_pixel, 8); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // so just delete index 0. | 249 // so just delete index 0. |
| 246 if (!external_memory_) | 250 if (!external_memory_) |
| 247 delete[] data_[0]; | 251 delete[] data_[0]; |
| 248 } | 252 } |
| 249 | 253 |
| 250 bool VideoFrame::IsEndOfStream() const { | 254 bool VideoFrame::IsEndOfStream() const { |
| 251 return format_ == VideoFrame::EMPTY; | 255 return format_ == VideoFrame::EMPTY; |
| 252 } | 256 } |
| 253 | 257 |
| 254 } // namespace media | 258 } // namespace media |
| OLD | NEW |