| OLD | NEW |
| 1 // Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 1 // Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
| 4 // that can be found in the LICENSE file in the root of the source | 4 // that can be found in the LICENSE file in the root of the source |
| 5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
| 8 | 8 |
| 9 #ifndef MKVPARSER_HPP | 9 #ifndef MKVPARSER_HPP |
| 10 #define MKVPARSER_HPP | 10 #define MKVPARSER_HPP |
| 11 | 11 |
| 12 #include <cstddef> |
| 13 #include <cstdio> |
| 12 #include <cstdlib> | 14 #include <cstdlib> |
| 13 #include <cstdio> | |
| 14 #include <cstddef> | |
| 15 | 15 |
| 16 namespace mkvparser { | 16 namespace mkvparser { |
| 17 | 17 |
| 18 const int E_PARSE_FAILED = -1; |
| 18 const int E_FILE_FORMAT_INVALID = -2; | 19 const int E_FILE_FORMAT_INVALID = -2; |
| 19 const int E_BUFFER_NOT_FULL = -3; | 20 const int E_BUFFER_NOT_FULL = -3; |
| 20 | 21 |
| 21 class IMkvReader { | 22 class IMkvReader { |
| 22 public: | 23 public: |
| 23 virtual int Read(long long pos, long len, unsigned char* buf) = 0; | 24 virtual int Read(long long pos, long len, unsigned char* buf) = 0; |
| 24 virtual int Length(long long* total, long long* available) = 0; | 25 virtual int Length(long long* total, long long* available) = 0; |
| 25 | 26 |
| 26 protected: | 27 protected: |
| 27 virtual ~IMkvReader(); | 28 virtual ~IMkvReader(); |
| 28 }; | 29 }; |
| 29 | 30 |
| 31 template<typename Type> Type* SafeArrayAlloc(unsigned long long num_elements, |
| 32 unsigned long long element_size); |
| 30 long long GetUIntLength(IMkvReader*, long long, long&); | 33 long long GetUIntLength(IMkvReader*, long long, long&); |
| 31 long long ReadUInt(IMkvReader*, long long, long&); | 34 long long ReadUInt(IMkvReader*, long long, long&); |
| 35 long long ReadID(IMkvReader* pReader, long long pos, long& len); |
| 32 long long UnserializeUInt(IMkvReader*, long long pos, long long size); | 36 long long UnserializeUInt(IMkvReader*, long long pos, long long size); |
| 33 | 37 |
| 34 long UnserializeFloat(IMkvReader*, long long pos, long long size, double&); | 38 long UnserializeFloat(IMkvReader*, long long pos, long long size, double&); |
| 35 long UnserializeInt(IMkvReader*, long long pos, long long size, | 39 long UnserializeInt(IMkvReader*, long long pos, long long size, |
| 36 long long& result); | 40 long long& result); |
| 37 | 41 |
| 38 long UnserializeString(IMkvReader*, long long pos, long long size, char*& str); | 42 long UnserializeString(IMkvReader*, long long pos, long long size, char*& str); |
| 39 | 43 |
| 40 long ParseElementHeader(IMkvReader* pReader, | 44 long ParseElementHeader(IMkvReader* pReader, |
| 41 long long& pos, // consume id and size fields | 45 long long& pos, // consume id and size fields |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 const BlockEntry* GetBlock(const CuePoint*, | 830 const BlockEntry* GetBlock(const CuePoint*, |
| 827 const CuePoint::TrackPosition*) const; | 831 const CuePoint::TrackPosition*) const; |
| 828 | 832 |
| 829 bool LoadCuePoint() const; | 833 bool LoadCuePoint() const; |
| 830 long GetCount() const; // loaded only | 834 long GetCount() const; // loaded only |
| 831 // long GetTotal() const; //loaded + preloaded | 835 // long GetTotal() const; //loaded + preloaded |
| 832 bool DoneParsing() const; | 836 bool DoneParsing() const; |
| 833 | 837 |
| 834 private: | 838 private: |
| 835 bool Init() const; | 839 bool Init() const; |
| 836 void PreloadCuePoint(long&, long long) const; | 840 bool PreloadCuePoint(long&, long long) const; |
| 837 | 841 |
| 838 mutable CuePoint** m_cue_points; | 842 mutable CuePoint** m_cue_points; |
| 839 mutable long m_count; | 843 mutable long m_count; |
| 840 mutable long m_preload_count; | 844 mutable long m_preload_count; |
| 841 mutable long long m_pos; | 845 mutable long long m_pos; |
| 842 }; | 846 }; |
| 843 | 847 |
| 844 class Cluster { | 848 class Cluster { |
| 845 friend class Segment; | 849 friend class Segment; |
| 846 | 850 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 Tags* m_pTags; | 996 Tags* m_pTags; |
| 993 Cluster** m_clusters; | 997 Cluster** m_clusters; |
| 994 long m_clusterCount; // number of entries for which m_index >= 0 | 998 long m_clusterCount; // number of entries for which m_index >= 0 |
| 995 long m_clusterPreloadCount; // number of entries for which m_index < 0 | 999 long m_clusterPreloadCount; // number of entries for which m_index < 0 |
| 996 long m_clusterSize; // array size | 1000 long m_clusterSize; // array size |
| 997 | 1001 |
| 998 long DoLoadCluster(long long&, long&); | 1002 long DoLoadCluster(long long&, long&); |
| 999 long DoLoadClusterUnknownSize(long long&, long&); | 1003 long DoLoadClusterUnknownSize(long long&, long&); |
| 1000 long DoParseNext(const Cluster*&, long long&, long&); | 1004 long DoParseNext(const Cluster*&, long long&, long&); |
| 1001 | 1005 |
| 1002 void AppendCluster(Cluster*); | 1006 bool AppendCluster(Cluster*); |
| 1003 void PreloadCluster(Cluster*, ptrdiff_t); | 1007 bool PreloadCluster(Cluster*, ptrdiff_t); |
| 1004 | 1008 |
| 1005 // void ParseSeekHead(long long pos, long long size); | 1009 // void ParseSeekHead(long long pos, long long size); |
| 1006 // void ParseSeekEntry(long long pos, long long size); | 1010 // void ParseSeekEntry(long long pos, long long size); |
| 1007 // void ParseCues(long long); | 1011 // void ParseCues(long long); |
| 1008 | 1012 |
| 1009 const BlockEntry* GetBlock(const CuePoint&, const CuePoint::TrackPosition&); | 1013 const BlockEntry* GetBlock(const CuePoint&, const CuePoint::TrackPosition&); |
| 1010 }; | 1014 }; |
| 1011 | 1015 |
| 1012 } // end namespace mkvparser | 1016 } // end namespace mkvparser |
| 1013 | 1017 |
| 1014 inline long mkvparser::Segment::LoadCluster() { | 1018 inline long mkvparser::Segment::LoadCluster() { |
| 1015 long long pos; | 1019 long long pos; |
| 1016 long size; | 1020 long size; |
| 1017 | 1021 |
| 1018 return LoadCluster(pos, size); | 1022 return LoadCluster(pos, size); |
| 1019 } | 1023 } |
| 1020 | 1024 |
| 1021 #endif // MKVPARSER_HPP | 1025 #endif // MKVPARSER_HPP |
| OLD | NEW |