| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 switch (format) { | 191 switch (format) { |
| 192 case VideoFrame::NATIVE_TEXTURE: | 192 case VideoFrame::NATIVE_TEXTURE: |
| 193 #if defined(GOOGLE_TV) | 193 #if defined(GOOGLE_TV) |
| 194 case VideoFrame::HOLE: | 194 case VideoFrame::HOLE: |
| 195 #endif | 195 #endif |
| 196 return 0; | 196 return 0; |
| 197 case VideoFrame::RGB32: | 197 case VideoFrame::RGB32: |
| 198 return 1; | 198 return 1; |
| 199 case VideoFrame::YV12: | 199 case VideoFrame::YV12: |
| 200 case VideoFrame::YV16: | 200 case VideoFrame::YV16: |
| 201 case VideoFrame::I420: |
| 201 return 3; | 202 return 3; |
| 202 case VideoFrame::YV12A: | 203 case VideoFrame::YV12A: |
| 203 return 4; | 204 return 4; |
| 204 case VideoFrame::EMPTY: | 205 case VideoFrame::EMPTY: |
| 205 case VideoFrame::I420: | |
| 206 case VideoFrame::INVALID: | 206 case VideoFrame::INVALID: |
| 207 break; | 207 break; |
| 208 } | 208 } |
| 209 NOTREACHED() << "Unsupported video frame format: " << format; | 209 NOTREACHED() << "Unsupported video frame format: " << format; |
| 210 return 0; | 210 return 0; |
| 211 } | 211 } |
| 212 | 212 |
| 213 static inline size_t RoundUp(size_t value, size_t alignment) { | 213 static inline size_t RoundUp(size_t value, size_t alignment) { |
| 214 // Check that |alignment| is a power of 2. | 214 // Check that |alignment| is a power of 2. |
| 215 DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); | 215 DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 344 } |
| 345 | 345 |
| 346 int VideoFrame::rows(size_t plane) const { | 346 int VideoFrame::rows(size_t plane) const { |
| 347 DCHECK(IsValidPlane(plane)); | 347 DCHECK(IsValidPlane(plane)); |
| 348 int height = coded_size_.height(); | 348 int height = coded_size_.height(); |
| 349 switch (format_) { | 349 switch (format_) { |
| 350 case RGB32: | 350 case RGB32: |
| 351 case YV16: | 351 case YV16: |
| 352 return height; | 352 return height; |
| 353 | 353 |
| 354 case YV12A: |
| 355 if (plane == kAPlane) |
| 356 return height; |
| 357 // fallthrough. |
| 354 case YV12: | 358 case YV12: |
| 355 case YV12A: | 359 case I420: |
| 356 if (plane == kYPlane || plane == kAPlane) | 360 if (plane == kYPlane) |
| 357 return height; | 361 return height; |
| 358 return RoundUp(height, 2) / 2; | 362 return RoundUp(height, 2) / 2; |
| 359 | 363 |
| 360 default: | 364 default: |
| 361 break; | 365 break; |
| 362 } | 366 } |
| 363 | 367 |
| 364 // Intentionally leave out non-production formats. | 368 // Intentionally leave out non-production formats. |
| 365 NOTREACHED() << "Unsupported video frame format: " << format_; | 369 NOTREACHED() << "Unsupported video frame format: " << format_; |
| 366 return 0; | 370 return 0; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 : mailbox_(mailbox), | 413 : mailbox_(mailbox), |
| 410 sync_point_(sync_point), | 414 sync_point_(sync_point), |
| 411 release_callback_(release_callback) {} | 415 release_callback_(release_callback) {} |
| 412 | 416 |
| 413 VideoFrame::MailboxHolder::~MailboxHolder() { | 417 VideoFrame::MailboxHolder::~MailboxHolder() { |
| 414 if (!release_callback_.is_null()) | 418 if (!release_callback_.is_null()) |
| 415 release_callback_.Run(sync_point_); | 419 release_callback_.Run(sync_point_); |
| 416 } | 420 } |
| 417 | 421 |
| 418 } // namespace media | 422 } // namespace media |
| OLD | NEW |