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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 bool VideoFrame::IsValidPlane(size_t plane, VideoFrame::Format format) { | 738 bool VideoFrame::IsValidPlane(size_t plane, VideoFrame::Format format) { |
739 return (plane < NumPlanes(format)); | 739 return (plane < NumPlanes(format)); |
740 } | 740 } |
741 | 741 |
742 int VideoFrame::stride(size_t plane) const { | 742 int VideoFrame::stride(size_t plane) const { |
743 DCHECK(IsValidPlane(plane, format_)); | 743 DCHECK(IsValidPlane(plane, format_)); |
744 return strides_[plane]; | 744 return strides_[plane]; |
745 } | 745 } |
746 | 746 |
747 // static | 747 // static |
748 int VideoFrame::RowBytes(size_t plane, VideoFrame::Format format, int width) { | 748 size_t VideoFrame::RowBytes(size_t plane, VideoFrame::Format format, |
| 749 int width) { |
749 DCHECK(IsValidPlane(plane, format)); | 750 DCHECK(IsValidPlane(plane, format)); |
750 switch (format) { | 751 switch (format) { |
751 case VideoFrame::YV24: | 752 case VideoFrame::YV24: |
752 switch (plane) { | 753 switch (plane) { |
753 case kYPlane: | 754 case kYPlane: |
754 case kUPlane: | 755 case kUPlane: |
755 case kVPlane: | 756 case kVPlane: |
756 return width; | 757 return width; |
757 default: | 758 default: |
758 break; | 759 break; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 } | 803 } |
803 NOTREACHED() << "Unsupported video frame format/plane: " << format << "/" | 804 NOTREACHED() << "Unsupported video frame format/plane: " << format << "/" |
804 << plane; | 805 << plane; |
805 return 0; | 806 return 0; |
806 } | 807 } |
807 | 808 |
808 int VideoFrame::row_bytes(size_t plane) const { | 809 int VideoFrame::row_bytes(size_t plane) const { |
809 return RowBytes(plane, format_, coded_size_.width()); | 810 return RowBytes(plane, format_, coded_size_.width()); |
810 } | 811 } |
811 | 812 |
812 int VideoFrame::rows(size_t plane) const { | 813 // static |
813 DCHECK(IsValidPlane(plane, format_)); | 814 size_t VideoFrame::Rows(size_t plane, VideoFrame::Format format, int height) { |
814 int height = coded_size_.height(); | 815 DCHECK(IsValidPlane(plane, format)); |
815 switch (format_) { | 816 switch (format) { |
816 case VideoFrame::YV24: | 817 case VideoFrame::YV24: |
817 case VideoFrame::YV16: | 818 case VideoFrame::YV16: |
818 switch (plane) { | 819 switch (plane) { |
819 case kYPlane: | 820 case kYPlane: |
820 case kUPlane: | 821 case kUPlane: |
821 case kVPlane: | 822 case kVPlane: |
822 return height; | 823 return height; |
823 default: | 824 default: |
824 break; | 825 break; |
825 } | 826 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 break; | 860 break; |
860 } | 861 } |
861 break; | 862 break; |
862 case VideoFrame::UNKNOWN: | 863 case VideoFrame::UNKNOWN: |
863 #if defined(VIDEO_HOLE) | 864 #if defined(VIDEO_HOLE) |
864 case VideoFrame::HOLE: | 865 case VideoFrame::HOLE: |
865 #endif // defined(VIDEO_HOLE) | 866 #endif // defined(VIDEO_HOLE) |
866 case VideoFrame::NATIVE_TEXTURE: | 867 case VideoFrame::NATIVE_TEXTURE: |
867 break; | 868 break; |
868 } | 869 } |
869 NOTREACHED() << "Unsupported video frame format/plane: " | 870 NOTREACHED() << "Unsupported video frame format/plane: " << format << "/" |
870 << format_ << "/" << plane; | 871 << plane; |
871 return 0; | 872 return 0; |
872 } | 873 } |
873 | 874 |
| 875 int VideoFrame::rows(size_t plane) const { |
| 876 return Rows(plane, format_, coded_size_.height()); |
| 877 } |
| 878 |
874 uint8* VideoFrame::data(size_t plane) const { | 879 uint8* VideoFrame::data(size_t plane) const { |
875 DCHECK(IsValidPlane(plane, format_)); | 880 DCHECK(IsValidPlane(plane, format_)); |
876 return data_[plane]; | 881 return data_[plane]; |
877 } | 882 } |
878 | 883 |
879 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const { | 884 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const { |
880 DCHECK_EQ(format_, NATIVE_TEXTURE); | 885 DCHECK_EQ(format_, NATIVE_TEXTURE); |
881 return mailbox_holder_.get(); | 886 return mailbox_holder_.get(); |
882 } | 887 } |
883 | 888 |
(...skipping 30 matching lines...) Expand all Loading... |
914 break; | 919 break; |
915 for (int row = 0; row < rows(plane); ++row) { | 920 for (int row = 0; row < rows(plane); ++row) { |
916 base::MD5Update(context, base::StringPiece( | 921 base::MD5Update(context, base::StringPiece( |
917 reinterpret_cast<char*>(data(plane) + stride(plane) * row), | 922 reinterpret_cast<char*>(data(plane) + stride(plane) * row), |
918 row_bytes(plane))); | 923 row_bytes(plane))); |
919 } | 924 } |
920 } | 925 } |
921 } | 926 } |
922 | 927 |
923 } // namespace media | 928 } // namespace media |
OLD | NEW |