OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/container_names.h" | 5 #include "media/base/container_names.h" |
6 | 6 |
7 #include <cctype> | 7 #include <cctype> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 } | 947 } |
948 | 948 |
949 // Additional checks for a MOV/QuickTime/MPEG4 container. | 949 // Additional checks for a MOV/QuickTime/MPEG4 container. |
950 static bool CheckMov(const uint8* buffer, int buffer_size) { | 950 static bool CheckMov(const uint8* buffer, int buffer_size) { |
951 // Reference: ISO/IEC 14496-12:2005(E). | 951 // Reference: ISO/IEC 14496-12:2005(E). |
952 // (http://standards.iso.org/ittf/PubliclyAvailableStandards/c061988_ISO_IEC_1 4496-12_2012.zip) | 952 // (http://standards.iso.org/ittf/PubliclyAvailableStandards/c061988_ISO_IEC_1 4496-12_2012.zip) |
953 RCHECK(buffer_size > 8); | 953 RCHECK(buffer_size > 8); |
954 | 954 |
955 int offset = 0; | 955 int offset = 0; |
956 while (offset + 8 < buffer_size) { | 956 while (offset + 8 < buffer_size) { |
957 int atomsize = Read32(buffer + offset); | 957 uint32 atomsize = Read32(buffer + offset); |
958 uint32 atomtype = Read32(buffer + offset + 4); | 958 uint32 atomtype = Read32(buffer + offset + 4); |
959 // Only need to check for ones that are valid at the top level. | 959 // Only need to check for ones that are valid at the top level. |
960 switch (atomtype) { | 960 switch (atomtype) { |
961 case TAG('f','t','y','p'): | 961 case TAG('f','t','y','p'): |
962 case TAG('p','d','i','n'): | 962 case TAG('p','d','i','n'): |
963 case TAG('m','o','o','v'): | 963 case TAG('m','o','o','v'): |
964 case TAG('m','o','o','f'): | 964 case TAG('m','o','o','f'): |
965 case TAG('m','f','r','a'): | 965 case TAG('m','f','r','a'): |
966 case TAG('m','d','a','t'): | 966 case TAG('m','d','a','t'): |
967 case TAG('f','r','e','e'): | 967 case TAG('f','r','e','e'): |
(...skipping 10 matching lines...) Expand all Loading... | |
978 return false; | 978 return false; |
979 } | 979 } |
980 if (atomsize == 1) { | 980 if (atomsize == 1) { |
981 // Indicates that the length is the next 64bits. | 981 // Indicates that the length is the next 64bits. |
982 if (offset + 16 > buffer_size) | 982 if (offset + 16 > buffer_size) |
983 break; | 983 break; |
984 if (Read32(buffer + offset + 8) != 0) | 984 if (Read32(buffer + offset + 8) != 0) |
985 break; // Offset is way past buffer size. | 985 break; // Offset is way past buffer size. |
986 atomsize = Read32(buffer + offset + 12); | 986 atomsize = Read32(buffer + offset + 12); |
987 } | 987 } |
988 if (atomsize <= 0) | 988 if (atomsize == 0 || atomsize > static_cast<unsigned>(buffer_size)) |
DaleCurtis
2014/10/24 20:51:35
Hmm we don't typically use unsigned, maybe size_t
jrummell
2014/10/24 23:18:29
Done.
| |
989 break; // Indicates the last atom or length too big. | 989 break; // Indicates the last atom or length too big. |
990 offset += atomsize; | 990 offset += atomsize; |
991 } | 991 } |
992 return true; | 992 return true; |
993 } | 993 } |
994 | 994 |
995 enum MPEGVersion { | 995 enum MPEGVersion { |
996 VERSION_25 = 0, | 996 VERSION_25 = 0, |
997 VERSION_RESERVED, | 997 VERSION_RESERVED, |
998 VERSION_2, | 998 VERSION_2, |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1664 if (CheckEac3(buffer + offset, buffer_size - offset)) | 1664 if (CheckEac3(buffer + offset, buffer_size - offset)) |
1665 return CONTAINER_EAC3; | 1665 return CONTAINER_EAC3; |
1666 } | 1666 } |
1667 | 1667 |
1668 return CONTAINER_UNKNOWN; | 1668 return CONTAINER_UNKNOWN; |
1669 } | 1669 } |
1670 | 1670 |
1671 } // namespace container_names | 1671 } // namespace container_names |
1672 | 1672 |
1673 } // namespace media | 1673 } // namespace media |
OLD | NEW |