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 18 matching lines...) Expand all Loading... | |
29 VideoFrame::Format format, | 29 VideoFrame::Format format, |
30 const gfx::Size& coded_size, | 30 const gfx::Size& coded_size, |
31 const gfx::Rect& visible_rect, | 31 const gfx::Rect& visible_rect, |
32 const gfx::Size& natural_size, | 32 const gfx::Size& natural_size, |
33 base::TimeDelta timestamp) { | 33 base::TimeDelta timestamp) { |
34 // Since we're creating a new YUV frame (and allocating memory for it | 34 // Since we're creating a new YUV frame (and allocating memory for it |
35 // ourselves), we can pad the requested |coded_size| if necessary if the | 35 // ourselves), we can pad the requested |coded_size| if necessary if the |
36 // request does not line up on sample boundaries. | 36 // request does not line up on sample boundaries. |
37 gfx::Size new_coded_size(coded_size); | 37 gfx::Size new_coded_size(coded_size); |
38 switch (format) { | 38 switch (format) { |
39 case VideoFrame::I444: | |
40 break; | |
39 case VideoFrame::YV12: | 41 case VideoFrame::YV12: |
40 case VideoFrame::YV12A: | 42 case VideoFrame::YV12A: |
41 case VideoFrame::I420: | 43 case VideoFrame::I420: |
42 case VideoFrame::YV12J: | 44 case VideoFrame::YV12J: |
43 new_coded_size.set_height((new_coded_size.height() + 1) / 2 * 2); | 45 new_coded_size.set_height((new_coded_size.height() + 1) / 2 * 2); |
44 // Fallthrough. | 46 // Fallthrough. |
45 case VideoFrame::YV16: | 47 case VideoFrame::YV16: |
46 new_coded_size.set_width((new_coded_size.width() + 1) / 2 * 2); | 48 new_coded_size.set_width((new_coded_size.width() + 1) / 2 * 2); |
47 break; | 49 break; |
48 default: | 50 default: |
(...skipping 29 matching lines...) Expand all Loading... | |
78 #if defined(VIDEO_HOLE) | 80 #if defined(VIDEO_HOLE) |
79 case VideoFrame::HOLE: | 81 case VideoFrame::HOLE: |
80 return "HOLE"; | 82 return "HOLE"; |
81 #endif // defined(VIDEO_HOLE) | 83 #endif // defined(VIDEO_HOLE) |
82 case VideoFrame::YV12A: | 84 case VideoFrame::YV12A: |
83 return "YV12A"; | 85 return "YV12A"; |
84 case VideoFrame::YV12J: | 86 case VideoFrame::YV12J: |
85 return "YV12J"; | 87 return "YV12J"; |
86 case VideoFrame::NV12: | 88 case VideoFrame::NV12: |
87 return "NV12"; | 89 return "NV12"; |
90 case VideoFrame::I444: | |
91 return "I444"; | |
88 } | 92 } |
89 NOTREACHED() << "Invalid videoframe format provided: " << format; | 93 NOTREACHED() << "Invalid videoframe format provided: " << format; |
90 return ""; | 94 return ""; |
91 } | 95 } |
92 | 96 |
93 // static | 97 // static |
94 bool VideoFrame::IsValidConfig(VideoFrame::Format format, | 98 bool VideoFrame::IsValidConfig(VideoFrame::Format format, |
95 const gfx::Size& coded_size, | 99 const gfx::Size& coded_size, |
96 const gfx::Rect& visible_rect, | 100 const gfx::Rect& visible_rect, |
97 const gfx::Size& natural_size) { | 101 const gfx::Size& natural_size) { |
98 // Check maximum limits for all formats. | 102 // Check maximum limits for all formats. |
99 if (coded_size.GetArea() > limits::kMaxCanvas || | 103 if (coded_size.GetArea() > limits::kMaxCanvas || |
100 coded_size.width() > limits::kMaxDimension || | 104 coded_size.width() > limits::kMaxDimension || |
101 coded_size.height() > limits::kMaxDimension || | 105 coded_size.height() > limits::kMaxDimension || |
102 visible_rect.x() < 0 || visible_rect.y() < 0 || | 106 visible_rect.x() < 0 || visible_rect.y() < 0 || |
103 visible_rect.right() > coded_size.width() || | 107 visible_rect.right() > coded_size.width() || |
104 visible_rect.bottom() > coded_size.height() || | 108 visible_rect.bottom() > coded_size.height() || |
105 natural_size.GetArea() > limits::kMaxCanvas || | 109 natural_size.GetArea() > limits::kMaxCanvas || |
106 natural_size.width() > limits::kMaxDimension || | 110 natural_size.width() > limits::kMaxDimension || |
107 natural_size.height() > limits::kMaxDimension) | 111 natural_size.height() > limits::kMaxDimension) |
108 return false; | 112 return false; |
109 | 113 |
110 // Check format-specific width/height requirements. | 114 // Check format-specific width/height requirements. |
111 switch (format) { | 115 switch (format) { |
112 case VideoFrame::UNKNOWN: | 116 case VideoFrame::UNKNOWN: |
113 return (coded_size.IsEmpty() && visible_rect.IsEmpty() && | 117 return (coded_size.IsEmpty() && visible_rect.IsEmpty() && |
114 natural_size.IsEmpty()); | 118 natural_size.IsEmpty()); |
119 case VideoFrame::I444: | |
120 break; | |
115 case VideoFrame::YV12: | 121 case VideoFrame::YV12: |
116 case VideoFrame::YV12J: | 122 case VideoFrame::YV12J: |
117 case VideoFrame::I420: | 123 case VideoFrame::I420: |
118 case VideoFrame::YV12A: | 124 case VideoFrame::YV12A: |
119 case VideoFrame::NV12: | 125 case VideoFrame::NV12: |
120 // YUV formats have width/height requirements due to chroma subsampling. | 126 // Subsampled YUV formats have width/height requirements. |
121 if (static_cast<size_t>(coded_size.height()) < | 127 if (static_cast<size_t>(coded_size.height()) < |
122 RoundUp(visible_rect.bottom(), 2)) | 128 RoundUp(visible_rect.bottom(), 2)) |
123 return false; | 129 return false; |
124 // Fallthrough. | 130 // Fallthrough. |
125 case VideoFrame::YV16: | 131 case VideoFrame::YV16: |
126 if (static_cast<size_t>(coded_size.width()) < | 132 if (static_cast<size_t>(coded_size.width()) < |
127 RoundUp(visible_rect.right(), 2)) | 133 RoundUp(visible_rect.right(), 2)) |
128 return false; | 134 return false; |
129 break; | 135 break; |
130 case VideoFrame::NATIVE_TEXTURE: | 136 case VideoFrame::NATIVE_TEXTURE: |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 #if defined(VIDEO_HOLE) | 389 #if defined(VIDEO_HOLE) |
384 case VideoFrame::HOLE: | 390 case VideoFrame::HOLE: |
385 #endif // defined(VIDEO_HOLE) | 391 #endif // defined(VIDEO_HOLE) |
386 return 0; | 392 return 0; |
387 case VideoFrame::NV12: | 393 case VideoFrame::NV12: |
388 return 2; | 394 return 2; |
389 case VideoFrame::YV12: | 395 case VideoFrame::YV12: |
390 case VideoFrame::YV16: | 396 case VideoFrame::YV16: |
391 case VideoFrame::I420: | 397 case VideoFrame::I420: |
392 case VideoFrame::YV12J: | 398 case VideoFrame::YV12J: |
399 case VideoFrame::I444: | |
393 return 3; | 400 return 3; |
394 case VideoFrame::YV12A: | 401 case VideoFrame::YV12A: |
395 return 4; | 402 return 4; |
396 case VideoFrame::UNKNOWN: | 403 case VideoFrame::UNKNOWN: |
397 break; | 404 break; |
398 } | 405 } |
399 NOTREACHED() << "Unsupported video frame format: " << format; | 406 NOTREACHED() << "Unsupported video frame format: " << format; |
400 return 0; | 407 return 0; |
401 } | 408 } |
402 | 409 |
403 | 410 |
404 // static | 411 // static |
405 size_t VideoFrame::AllocationSize(Format format, const gfx::Size& coded_size) { | 412 size_t VideoFrame::AllocationSize(Format format, const gfx::Size& coded_size) { |
406 size_t total = 0; | 413 size_t total = 0; |
407 for (size_t i = 0; i < NumPlanes(format); ++i) | 414 for (size_t i = 0; i < NumPlanes(format); ++i) |
408 total += PlaneAllocationSize(format, i, coded_size); | 415 total += PlaneAllocationSize(format, i, coded_size); |
409 return total; | 416 return total; |
410 } | 417 } |
411 | 418 |
412 // static | 419 // static |
413 gfx::Size VideoFrame::PlaneSize(Format format, | 420 gfx::Size VideoFrame::PlaneSize(Format format, |
414 size_t plane, | 421 size_t plane, |
415 const gfx::Size& coded_size) { | 422 const gfx::Size& coded_size) { |
423 // Align to multiple-of-two size overall. This ensures that non-subsampled | |
424 // planes can be addressed by pixel with the same scaling as the subsampled | |
425 // planes. | |
416 const int width = RoundUp(coded_size.width(), 2); | 426 const int width = RoundUp(coded_size.width(), 2); |
417 const int height = RoundUp(coded_size.height(), 2); | 427 const int height = RoundUp(coded_size.height(), 2); |
418 switch (format) { | 428 switch (format) { |
429 case VideoFrame::I444: | |
430 switch (plane) { | |
431 case VideoFrame::kYPlane: | |
432 case VideoFrame::kUPlane: | |
433 case VideoFrame::kVPlane: | |
434 return gfx::Size(width, height); | |
435 default: | |
436 break; | |
437 } | |
438 break; | |
419 case VideoFrame::YV12: | 439 case VideoFrame::YV12: |
420 case VideoFrame::YV12J: | 440 case VideoFrame::YV12J: |
421 case VideoFrame::I420: { | 441 case VideoFrame::I420: |
422 switch (plane) { | 442 switch (plane) { |
423 case VideoFrame::kYPlane: | 443 case VideoFrame::kYPlane: |
424 return gfx::Size(width, height); | 444 return gfx::Size(width, height); |
425 case VideoFrame::kUPlane: | 445 case VideoFrame::kUPlane: |
426 case VideoFrame::kVPlane: | 446 case VideoFrame::kVPlane: |
427 return gfx::Size(width / 2, height / 2); | 447 return gfx::Size(width / 2, height / 2); |
428 default: | 448 default: |
429 break; | 449 break; |
430 } | 450 } |
431 } | 451 break; |
432 case VideoFrame::YV12A: { | 452 case VideoFrame::YV12A: |
433 switch (plane) { | 453 switch (plane) { |
434 case VideoFrame::kYPlane: | 454 case VideoFrame::kYPlane: |
435 case VideoFrame::kAPlane: | 455 case VideoFrame::kAPlane: |
436 return gfx::Size(width, height); | 456 return gfx::Size(width, height); |
437 case VideoFrame::kUPlane: | 457 case VideoFrame::kUPlane: |
438 case VideoFrame::kVPlane: | 458 case VideoFrame::kVPlane: |
439 return gfx::Size(width / 2, height / 2); | 459 return gfx::Size(width / 2, height / 2); |
440 default: | 460 default: |
441 break; | 461 break; |
442 } | 462 } |
443 } | 463 break; |
444 case VideoFrame::YV16: { | 464 case VideoFrame::YV16: |
445 switch (plane) { | 465 switch (plane) { |
446 case VideoFrame::kYPlane: | 466 case VideoFrame::kYPlane: |
447 return gfx::Size(width, height); | 467 return gfx::Size(width, height); |
448 case VideoFrame::kUPlane: | 468 case VideoFrame::kUPlane: |
449 case VideoFrame::kVPlane: | 469 case VideoFrame::kVPlane: |
450 return gfx::Size(width / 2, height); | 470 return gfx::Size(width / 2, height); |
451 default: | 471 default: |
452 break; | 472 break; |
453 } | 473 } |
454 } | 474 break; |
455 case VideoFrame::NV12: { | 475 case VideoFrame::NV12: |
456 switch (plane) { | 476 switch (plane) { |
457 case VideoFrame::kYPlane: | 477 case VideoFrame::kYPlane: |
458 return gfx::Size(width, height); | 478 return gfx::Size(width, height); |
459 case VideoFrame::kUVPlane: | 479 case VideoFrame::kUVPlane: |
460 return gfx::Size(width, height / 2); | 480 return gfx::Size(width, height / 2); |
461 default: | 481 default: |
462 break; | 482 break; |
463 } | 483 } |
464 } | 484 break; |
465 case VideoFrame::UNKNOWN: | 485 case VideoFrame::UNKNOWN: |
466 case VideoFrame::NATIVE_TEXTURE: | 486 case VideoFrame::NATIVE_TEXTURE: |
467 #if defined(VIDEO_HOLE) | 487 #if defined(VIDEO_HOLE) |
468 case VideoFrame::HOLE: | 488 case VideoFrame::HOLE: |
469 #endif // defined(VIDEO_HOLE) | 489 #endif // defined(VIDEO_HOLE) |
470 break; | 490 break; |
471 } | 491 } |
472 NOTREACHED() << "Unsupported video frame format/plane: " | 492 NOTREACHED() << "Unsupported video frame format/plane: " |
473 << format << "/" << plane; | 493 << format << "/" << plane; |
474 return gfx::Size(); | 494 return gfx::Size(); |
475 } | 495 } |
476 | 496 |
477 size_t VideoFrame::PlaneAllocationSize(Format format, | 497 size_t VideoFrame::PlaneAllocationSize(Format format, |
478 size_t plane, | 498 size_t plane, |
479 const gfx::Size& coded_size) { | 499 const gfx::Size& coded_size) { |
480 // VideoFrame formats are (so far) all YUV and 1 byte per sample. | 500 // VideoFrame formats are (so far) all YUV and 1 byte per sample. |
481 return PlaneSize(format, plane, coded_size).GetArea(); | 501 return PlaneSize(format, plane, coded_size).GetArea(); |
482 } | 502 } |
483 | 503 |
484 // static | 504 // static |
485 int VideoFrame::PlaneHorizontalBitsPerPixel(Format format, size_t plane) { | 505 int VideoFrame::PlaneHorizontalBitsPerPixel(Format format, size_t plane) { |
486 switch (format) { | 506 switch (format) { |
487 case VideoFrame::YV12A: | 507 case VideoFrame::I444: |
488 if (plane == kAPlane) | 508 switch (plane) { |
489 return 8; | 509 case kYPlane: |
490 // fallthrough | 510 case kUPlane: |
511 case kVPlane: | |
512 return 8; | |
513 default: | |
514 break; | |
515 } | |
516 break; | |
491 case VideoFrame::YV12: | 517 case VideoFrame::YV12: |
492 case VideoFrame::YV16: | 518 case VideoFrame::YV16: |
493 case VideoFrame::I420: | 519 case VideoFrame::I420: |
494 case VideoFrame::YV12J: { | 520 case VideoFrame::YV12J: |
495 switch (plane) { | 521 switch (plane) { |
496 case kYPlane: | 522 case kYPlane: |
497 return 8; | 523 return 8; |
498 case kUPlane: | 524 case kUPlane: |
499 case kVPlane: | 525 case kVPlane: |
500 return 2; | 526 return 2; |
501 default: | 527 default: |
502 break; | 528 break; |
503 } | 529 } |
504 } | 530 break; |
505 | 531 case VideoFrame::YV12A: |
506 case VideoFrame::NV12: { | 532 switch (plane) { |
533 case kYPlane: | |
534 case kAPlane: | |
535 return 8; | |
536 case kUPlane: | |
537 case kVPlane: | |
538 return 2; | |
539 default: | |
540 break; | |
541 } | |
542 break; | |
543 case VideoFrame::NV12: | |
507 switch (plane) { | 544 switch (plane) { |
508 case kYPlane: | 545 case kYPlane: |
509 return 8; | 546 return 8; |
510 case kUVPlane: | 547 case kUVPlane: |
511 return 4; | 548 return 4; |
512 default: | 549 default: |
513 break; | 550 break; |
514 } | 551 } |
515 } | 552 break; |
516 default: | 553 default: |
scherkus (not reviewing)
2014/05/22 23:45:11
can you replace the default cases w/ the other for
sandersd (OOO until July 31)
2014/05/23 00:45:22
Done.
| |
517 break; | 554 break; |
518 } | 555 } |
519 | 556 NOTREACHED() << "Unsupported video frame format/plane: " |
520 NOTREACHED() << "Unsupported video frame format: " << format; | 557 << format << "/" << plane; |
521 return 0; | 558 return 0; |
522 } | 559 } |
523 | 560 |
524 // Release data allocated by AllocateYUV(). | 561 // Release data allocated by AllocateYUV(). |
525 static void ReleaseData(uint8* data) { | 562 static void ReleaseData(uint8* data) { |
526 DCHECK(data); | 563 DCHECK(data); |
527 base::AlignedFree(data); | 564 base::AlignedFree(data); |
528 } | 565 } |
529 | 566 |
530 void VideoFrame::AllocateYUV() { | 567 void VideoFrame::AllocateYUV() { |
531 DCHECK(format_ == VideoFrame::YV12 || format_ == VideoFrame::YV16 || | 568 DCHECK(format_ == VideoFrame::YV12 || format_ == VideoFrame::YV16 || |
532 format_ == VideoFrame::YV12A || format_ == VideoFrame::I420 || | 569 format_ == VideoFrame::YV12A || format_ == VideoFrame::I420 || |
533 format_ == VideoFrame::YV12J); | 570 format_ == VideoFrame::YV12J || format_ == VideoFrame::I444); |
534 // Align Y rows at least at 16 byte boundaries. The stride for both | 571 // Align Y rows at least at 16 byte boundaries. The stride for both |
535 // YV12 and YV16 is 1/2 of the stride of Y. For YV12, every row of bytes for | 572 // YV12 and YV16 is 1/2 of the stride of Y. For YV12, every row of bytes for |
536 // U and V applies to two rows of Y (one byte of UV for 4 bytes of Y), so in | 573 // U and V applies to two rows of Y (one byte of UV for 4 bytes of Y), so in |
537 // the case of YV12 the strides are identical for the same width surface, but | 574 // the case of YV12 the strides are identical for the same width surface, but |
538 // the number of bytes allocated for YV12 is 1/2 the amount for U & V as | 575 // the number of bytes allocated for YV12 is 1/2 the amount for U & V as |
539 // YV16. We also round the height of the surface allocated to be an even | 576 // YV16. We also round the height of the surface allocated to be an even |
540 // number to avoid any potential of faulting by code that attempts to access | 577 // number to avoid any potential of faulting by code that attempts to access |
541 // the Y values of the final row, but assumes that the last row of U & V | 578 // the Y values of the final row, but assumes that the last row of U & V |
542 // applies to a full two rows of Y. YV12A is the same as YV12, but with an | 579 // applies to a full two rows of Y. YV12A is the same as YV12, but with an |
543 // additional alpha plane that has the same size and alignment as the Y plane. | 580 // additional alpha plane that has the same size and alignment as the Y plane. |
544 | |
545 size_t y_stride = RoundUp(row_bytes(VideoFrame::kYPlane), | 581 size_t y_stride = RoundUp(row_bytes(VideoFrame::kYPlane), |
546 kFrameSizeAlignment); | 582 kFrameSizeAlignment); |
547 size_t uv_stride = RoundUp(row_bytes(VideoFrame::kUPlane), | 583 size_t uv_stride = RoundUp(row_bytes(VideoFrame::kUPlane), |
548 kFrameSizeAlignment); | 584 kFrameSizeAlignment); |
585 | |
549 // The *2 here is because some formats (e.g. h264) allow interlaced coding, | 586 // The *2 here is because some formats (e.g. h264) allow interlaced coding, |
550 // and then the size needs to be a multiple of two macroblocks (vertically). | 587 // and then the size needs to be a multiple of two macroblocks (vertically). |
551 // See libavcodec/utils.c:avcodec_align_dimensions2(). | 588 // See libavcodec/utils.c:avcodec_align_dimensions2(). |
552 size_t y_height = RoundUp(coded_size_.height(), kFrameSizeAlignment * 2); | 589 size_t y_height = RoundUp(coded_size_.height(), kFrameSizeAlignment * 2); |
553 size_t uv_height = | 590 size_t uv_height = |
554 (format_ == VideoFrame::YV12 || format_ == VideoFrame::YV12A || | 591 (format_ == VideoFrame::YV12 || format_ == VideoFrame::YV12A || |
555 format_ == VideoFrame::I420) | 592 format_ == VideoFrame::I420) |
556 ? y_height / 2 | 593 ? y_height / 2 |
557 : y_height; | 594 : y_height; |
558 size_t y_bytes = y_height * y_stride; | 595 size_t y_bytes = y_height * y_stride; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 } | 657 } |
621 | 658 |
622 int VideoFrame::stride(size_t plane) const { | 659 int VideoFrame::stride(size_t plane) const { |
623 DCHECK(IsValidPlane(plane)); | 660 DCHECK(IsValidPlane(plane)); |
624 return strides_[plane]; | 661 return strides_[plane]; |
625 } | 662 } |
626 | 663 |
627 int VideoFrame::row_bytes(size_t plane) const { | 664 int VideoFrame::row_bytes(size_t plane) const { |
628 DCHECK(IsValidPlane(plane)); | 665 DCHECK(IsValidPlane(plane)); |
629 int width = coded_size_.width(); | 666 int width = coded_size_.width(); |
667 // Intentionally leave out non-production formats. | |
630 switch (format_) { | 668 switch (format_) { |
631 // Planar, 8bpp. | 669 case I444: |
632 case YV12A: | 670 switch (plane) { |
633 if (plane == kAPlane) | 671 case kYPlane: |
634 return width; | 672 case kUPlane: |
635 // Fallthrough. | 673 case kVPlane: |
674 return width; | |
675 default: | |
676 break; | |
677 } | |
678 break; | |
636 case YV12: | 679 case YV12: |
637 case YV16: | 680 case YV16: |
638 case I420: | 681 case I420: |
639 case YV12J: | 682 case YV12J: |
640 if (plane == kYPlane) | 683 switch (plane) { |
641 return width; | 684 case kYPlane: |
642 else if (plane <= kVPlane) | 685 return width; |
643 return RoundUp(width, 2) / 2; | 686 case kUPlane: |
687 case kVPlane: | |
688 return RoundUp(width, 2) / 2; | |
689 default: | |
690 break; | |
691 } | |
644 break; | 692 break; |
645 | 693 case YV12A: |
694 switch (plane) { | |
695 case kYPlane: | |
696 case kAPlane: | |
697 return width; | |
698 case kUPlane: | |
699 case kVPlane: | |
700 return RoundUp(width, 2) / 2; | |
701 default: | |
702 break; | |
703 } | |
704 break; | |
646 case NV12: | 705 case NV12: |
647 if (plane <= kUVPlane) | 706 switch (plane) { |
648 return width; | 707 case kYPlane: |
708 case kUVPlane: | |
709 return width; | |
710 default: | |
711 break; | |
712 } | |
649 break; | 713 break; |
650 | |
651 default: | 714 default: |
scherkus (not reviewing)
2014/05/22 23:45:11
ditto -- and remove the comment about intentionall
sandersd (OOO until July 31)
2014/05/23 00:45:22
Done.
| |
652 break; | 715 break; |
653 } | 716 } |
654 | 717 NOTREACHED() << "Unsupported video frame format/plane: " |
655 // Intentionally leave out non-production formats. | 718 << format_ << "/" << plane; |
656 NOTREACHED() << "Unsupported video frame format: " << format_; | |
657 return 0; | 719 return 0; |
658 } | 720 } |
659 | 721 |
660 int VideoFrame::rows(size_t plane) const { | 722 int VideoFrame::rows(size_t plane) const { |
661 DCHECK(IsValidPlane(plane)); | 723 DCHECK(IsValidPlane(plane)); |
662 int height = coded_size_.height(); | 724 int height = coded_size_.height(); |
725 // Intentionally leave out non-production formats. | |
663 switch (format_) { | 726 switch (format_) { |
727 case I444: | |
664 case YV16: | 728 case YV16: |
665 return height; | 729 switch (plane) { |
666 | 730 case kYPlane: |
667 case YV12A: | 731 case kUPlane: |
668 if (plane == kAPlane) | 732 case kVPlane: |
669 return height; | 733 return height; |
670 // Fallthrough. | 734 default: |
735 break; | |
736 } | |
737 break; | |
671 case YV12: | 738 case YV12: |
672 case YV12J: | 739 case YV12J: |
673 case I420: | 740 case I420: |
674 if (plane == kYPlane) | 741 switch (plane) { |
675 return height; | 742 case kYPlane: |
676 else if (plane <= kVPlane) | 743 return height; |
677 return RoundUp(height, 2) / 2; | 744 case kUPlane: |
745 case kVPlane: | |
746 return RoundUp(height, 2) / 2; | |
747 default: | |
748 break; | |
749 } | |
678 break; | 750 break; |
679 | 751 case YV12A: |
752 switch (plane) { | |
753 case kYPlane: | |
754 case kAPlane: | |
755 return height; | |
756 case kUPlane: | |
757 case kVPlane: | |
758 return RoundUp(height, 2) / 2; | |
759 default: | |
760 break; | |
761 } | |
762 break; | |
680 case NV12: | 763 case NV12: |
681 if (plane == kYPlane) | 764 switch (plane) { |
682 return height; | 765 case kYPlane: |
683 else if (plane == kUVPlane) | 766 return height; |
684 return RoundUp(height, 2) / 2; | 767 case kUVPlane: |
768 return RoundUp(height, 2) / 2; | |
769 default: | |
770 break; | |
771 } | |
685 break; | 772 break; |
686 | |
687 default: | 773 default: |
scherkus (not reviewing)
2014/05/22 23:45:11
ditto
sandersd (OOO until July 31)
2014/05/23 00:45:22
Done.
| |
688 break; | 774 break; |
689 } | 775 } |
690 | 776 NOTREACHED() << "Unsupported video frame format/plane: " |
691 // Intentionally leave out non-production formats. | 777 << format_ << "/" << plane; |
692 NOTREACHED() << "Unsupported video frame format: " << format_; | |
693 return 0; | 778 return 0; |
694 } | 779 } |
695 | 780 |
696 uint8* VideoFrame::data(size_t plane) const { | 781 uint8* VideoFrame::data(size_t plane) const { |
697 DCHECK(IsValidPlane(plane)); | 782 DCHECK(IsValidPlane(plane)); |
698 return data_[plane]; | 783 return data_[plane]; |
699 } | 784 } |
700 | 785 |
701 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const { | 786 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const { |
702 DCHECK_EQ(format_, NATIVE_TEXTURE); | 787 DCHECK_EQ(format_, NATIVE_TEXTURE); |
(...skipping 24 matching lines...) Expand all Loading... | |
727 break; | 812 break; |
728 for (int row = 0; row < rows(plane); ++row) { | 813 for (int row = 0; row < rows(plane); ++row) { |
729 base::MD5Update(context, base::StringPiece( | 814 base::MD5Update(context, base::StringPiece( |
730 reinterpret_cast<char*>(data(plane) + stride(plane) * row), | 815 reinterpret_cast<char*>(data(plane) + stride(plane) * row), |
731 row_bytes(plane))); | 816 row_bytes(plane))); |
732 } | 817 } |
733 } | 818 } |
734 } | 819 } |
735 | 820 |
736 } // namespace media | 821 } // namespace media |
OLD | NEW |