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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 protected: | 26 protected: |
27 virtual ~IMkvReader(); | 27 virtual ~IMkvReader(); |
28 }; | 28 }; |
29 | 29 |
30 long long GetUIntLength(IMkvReader*, long long, long&); | 30 long long GetUIntLength(IMkvReader*, long long, long&); |
31 long long ReadUInt(IMkvReader*, long long, long&); | 31 long long ReadUInt(IMkvReader*, long long, long&); |
32 long long UnserializeUInt(IMkvReader*, long long pos, long long size); | 32 long long UnserializeUInt(IMkvReader*, long long pos, long long size); |
33 | 33 |
34 long UnserializeFloat(IMkvReader*, long long pos, long long size, double&); | 34 long UnserializeFloat(IMkvReader*, long long pos, long long size, double&); |
35 long UnserializeInt(IMkvReader*, long long pos, long len, long long& result); | 35 long UnserializeInt(IMkvReader*, long long pos, long long size, |
| 36 long long& result); |
36 | 37 |
37 long UnserializeString(IMkvReader*, long long pos, long long size, char*& str); | 38 long UnserializeString(IMkvReader*, long long pos, long long size, char*& str); |
38 | 39 |
39 long ParseElementHeader(IMkvReader* pReader, | 40 long ParseElementHeader(IMkvReader* pReader, |
40 long long& pos, // consume id and size fields | 41 long long& pos, // consume id and size fields |
41 long long stop, // if you know size of element's parent | 42 long long stop, // if you know size of element's parent |
42 long long& id, long long& size); | 43 long long& id, long long& size); |
43 | 44 |
44 bool Match(IMkvReader*, long long&, unsigned long, long long&); | 45 bool Match(IMkvReader*, long long&, unsigned long, long long&); |
45 bool Match(IMkvReader*, long long&, unsigned long, unsigned char*&, size_t&); | 46 bool Match(IMkvReader*, long long&, unsigned long, unsigned char*&, size_t&); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 VideoTrack& operator=(const VideoTrack&); | 392 VideoTrack& operator=(const VideoTrack&); |
392 | 393 |
393 VideoTrack(Segment*, long long element_start, long long element_size); | 394 VideoTrack(Segment*, long long element_start, long long element_size); |
394 | 395 |
395 public: | 396 public: |
396 static long Parse(Segment*, const Info&, long long element_start, | 397 static long Parse(Segment*, const Info&, long long element_start, |
397 long long element_size, VideoTrack*&); | 398 long long element_size, VideoTrack*&); |
398 | 399 |
399 long long GetWidth() const; | 400 long long GetWidth() const; |
400 long long GetHeight() const; | 401 long long GetHeight() const; |
| 402 long long GetDisplayWidth() const; |
| 403 long long GetDisplayHeight() const; |
| 404 long long GetDisplayUnit() const; |
| 405 long long GetStereoMode() const; |
401 double GetFrameRate() const; | 406 double GetFrameRate() const; |
402 | 407 |
403 bool VetEntry(const BlockEntry*) const; | 408 bool VetEntry(const BlockEntry*) const; |
404 long Seek(long long time_ns, const BlockEntry*&) const; | 409 long Seek(long long time_ns, const BlockEntry*&) const; |
405 | 410 |
406 private: | 411 private: |
407 long long m_width; | 412 long long m_width; |
408 long long m_height; | 413 long long m_height; |
| 414 long long m_display_width; |
| 415 long long m_display_height; |
| 416 long long m_display_unit; |
| 417 long long m_stereo_mode; |
| 418 |
409 double m_rate; | 419 double m_rate; |
410 }; | 420 }; |
411 | 421 |
412 class AudioTrack : public Track { | 422 class AudioTrack : public Track { |
413 AudioTrack(const AudioTrack&); | 423 AudioTrack(const AudioTrack&); |
414 AudioTrack& operator=(const AudioTrack&); | 424 AudioTrack& operator=(const AudioTrack&); |
415 | 425 |
416 AudioTrack(Segment*, long long element_start, long long element_size); | 426 AudioTrack(Segment*, long long element_start, long long element_size); |
417 | 427 |
418 public: | 428 public: |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 | 585 |
576 private: | 586 private: |
577 long ParseEdition(long long pos, long long size); | 587 long ParseEdition(long long pos, long long size); |
578 bool ExpandEditionsArray(); | 588 bool ExpandEditionsArray(); |
579 | 589 |
580 Edition* m_editions; | 590 Edition* m_editions; |
581 int m_editions_size; | 591 int m_editions_size; |
582 int m_editions_count; | 592 int m_editions_count; |
583 }; | 593 }; |
584 | 594 |
| 595 class Tags { |
| 596 Tags(const Tags&); |
| 597 Tags& operator=(const Tags&); |
| 598 |
| 599 public: |
| 600 Segment* const m_pSegment; |
| 601 const long long m_start; |
| 602 const long long m_size; |
| 603 const long long m_element_start; |
| 604 const long long m_element_size; |
| 605 |
| 606 Tags(Segment*, long long payload_start, long long payload_size, |
| 607 long long element_start, long long element_size); |
| 608 |
| 609 ~Tags(); |
| 610 |
| 611 long Parse(); |
| 612 |
| 613 class Tag; |
| 614 class SimpleTag; |
| 615 |
| 616 class SimpleTag { |
| 617 friend class Tag; |
| 618 SimpleTag(); |
| 619 SimpleTag(const SimpleTag&); |
| 620 ~SimpleTag(); |
| 621 SimpleTag& operator=(const SimpleTag&); |
| 622 |
| 623 public: |
| 624 const char* GetTagName() const; |
| 625 const char* GetTagString() const; |
| 626 |
| 627 private: |
| 628 void Init(); |
| 629 void ShallowCopy(SimpleTag&) const; |
| 630 void Clear(); |
| 631 long Parse(IMkvReader*, long long pos, long long size); |
| 632 |
| 633 char* m_tag_name; |
| 634 char* m_tag_string; |
| 635 }; |
| 636 |
| 637 class Tag { |
| 638 friend class Tags; |
| 639 Tag(); |
| 640 Tag(const Tag&); |
| 641 ~Tag(); |
| 642 Tag& operator=(const Tag&); |
| 643 |
| 644 public: |
| 645 int GetSimpleTagCount() const; |
| 646 const SimpleTag* GetSimpleTag(int index) const; |
| 647 |
| 648 private: |
| 649 void Init(); |
| 650 void ShallowCopy(Tag&) const; |
| 651 void Clear(); |
| 652 long Parse(IMkvReader*, long long pos, long long size); |
| 653 |
| 654 long ParseSimpleTag(IMkvReader*, long long pos, long long size); |
| 655 bool ExpandSimpleTagsArray(); |
| 656 |
| 657 SimpleTag* m_simple_tags; |
| 658 int m_simple_tags_size; |
| 659 int m_simple_tags_count; |
| 660 }; |
| 661 |
| 662 int GetTagCount() const; |
| 663 const Tag* GetTag(int index) const; |
| 664 |
| 665 private: |
| 666 long ParseTag(long long pos, long long size); |
| 667 bool ExpandTagsArray(); |
| 668 |
| 669 Tag* m_tags; |
| 670 int m_tags_size; |
| 671 int m_tags_count; |
| 672 }; |
| 673 |
585 class SegmentInfo { | 674 class SegmentInfo { |
586 SegmentInfo(const SegmentInfo&); | 675 SegmentInfo(const SegmentInfo&); |
587 SegmentInfo& operator=(const SegmentInfo&); | 676 SegmentInfo& operator=(const SegmentInfo&); |
588 | 677 |
589 public: | 678 public: |
590 Segment* const m_pSegment; | 679 Segment* const m_pSegment; |
591 const long long m_start; | 680 const long long m_start; |
592 const long long m_size; | 681 const long long m_size; |
593 const long long m_element_start; | 682 const long long m_element_start; |
594 const long long m_element_size; | 683 const long long m_element_size; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 CuePoint(long, long long); | 766 CuePoint(long, long long); |
678 ~CuePoint(); | 767 ~CuePoint(); |
679 | 768 |
680 CuePoint(const CuePoint&); | 769 CuePoint(const CuePoint&); |
681 CuePoint& operator=(const CuePoint&); | 770 CuePoint& operator=(const CuePoint&); |
682 | 771 |
683 public: | 772 public: |
684 long long m_element_start; | 773 long long m_element_start; |
685 long long m_element_size; | 774 long long m_element_size; |
686 | 775 |
687 void Load(IMkvReader*); | 776 bool Load(IMkvReader*); |
688 | 777 |
689 long long GetTimeCode() const; // absolute but unscaled | 778 long long GetTimeCode() const; // absolute but unscaled |
690 long long GetTime(const Segment*) const; // absolute and scaled (ns units) | 779 long long GetTime(const Segment*) const; // absolute and scaled (ns units) |
691 | 780 |
692 struct TrackPosition { | 781 struct TrackPosition { |
693 long long m_track; | 782 long long m_track; |
694 long long m_pos; // of cluster | 783 long long m_pos; // of cluster |
695 long long m_block; | 784 long long m_block; |
696 // codec_state //defaults to 0 | 785 // codec_state //defaults to 0 |
697 // reference = clusters containing req'd referenced blocks | 786 // reference = clusters containing req'd referenced blocks |
698 // reftime = timecode of the referenced block | 787 // reftime = timecode of the referenced block |
699 | 788 |
700 void Parse(IMkvReader*, long long, long long); | 789 bool Parse(IMkvReader*, long long, long long); |
701 }; | 790 }; |
702 | 791 |
703 const TrackPosition* Find(const Track*) const; | 792 const TrackPosition* Find(const Track*) const; |
704 | 793 |
705 private: | 794 private: |
706 const long m_index; | 795 const long m_index; |
707 long long m_timecode; | 796 long long m_timecode; |
708 TrackPosition* m_track_positions; | 797 TrackPosition* m_track_positions; |
709 size_t m_track_positions_count; | 798 size_t m_track_positions_count; |
710 }; | 799 }; |
(...skipping 12 matching lines...) Expand all Loading... |
723 Segment* const m_pSegment; | 812 Segment* const m_pSegment; |
724 const long long m_start; | 813 const long long m_start; |
725 const long long m_size; | 814 const long long m_size; |
726 const long long m_element_start; | 815 const long long m_element_start; |
727 const long long m_element_size; | 816 const long long m_element_size; |
728 | 817 |
729 bool Find( // lower bound of time_ns | 818 bool Find( // lower bound of time_ns |
730 long long time_ns, const Track*, const CuePoint*&, | 819 long long time_ns, const Track*, const CuePoint*&, |
731 const CuePoint::TrackPosition*&) const; | 820 const CuePoint::TrackPosition*&) const; |
732 | 821 |
733 #if 0 | |
734 bool FindNext( //upper_bound of time_ns | |
735 long long time_ns, | |
736 const Track*, | |
737 const CuePoint*&, | |
738 const CuePoint::TrackPosition*&) const; | |
739 #endif | |
740 | |
741 const CuePoint* GetFirst() const; | 822 const CuePoint* GetFirst() const; |
742 const CuePoint* GetLast() const; | 823 const CuePoint* GetLast() const; |
743 const CuePoint* GetNext(const CuePoint*) const; | 824 const CuePoint* GetNext(const CuePoint*) const; |
744 | 825 |
745 const BlockEntry* GetBlock(const CuePoint*, | 826 const BlockEntry* GetBlock(const CuePoint*, |
746 const CuePoint::TrackPosition*) const; | 827 const CuePoint::TrackPosition*) const; |
747 | 828 |
748 bool LoadCuePoint() const; | 829 bool LoadCuePoint() const; |
749 long GetCount() const; // loaded only | 830 long GetCount() const; // loaded only |
750 // long GetTotal() const; //loaded + preloaded | 831 // long GetTotal() const; //loaded + preloaded |
751 bool DoneParsing() const; | 832 bool DoneParsing() const; |
752 | 833 |
753 private: | 834 private: |
754 void Init() const; | 835 bool Init() const; |
755 void PreloadCuePoint(long&, long long) const; | 836 void PreloadCuePoint(long&, long long) const; |
756 | 837 |
757 mutable CuePoint** m_cue_points; | 838 mutable CuePoint** m_cue_points; |
758 mutable long m_count; | 839 mutable long m_count; |
759 mutable long m_preload_count; | 840 mutable long m_preload_count; |
760 mutable long long m_pos; | 841 mutable long long m_pos; |
761 }; | 842 }; |
762 | 843 |
763 class Cluster { | 844 class Cluster { |
764 friend class Segment; | 845 friend class Segment; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 // long long Unparsed() const; | 951 // long long Unparsed() const; |
871 bool DoneParsing() const; | 952 bool DoneParsing() const; |
872 long long ParseHeaders(); // stops when first cluster is found | 953 long long ParseHeaders(); // stops when first cluster is found |
873 // long FindNextCluster(long long& pos, long& size) const; | 954 // long FindNextCluster(long long& pos, long& size) const; |
874 long LoadCluster(long long& pos, long& size); // load one cluster | 955 long LoadCluster(long long& pos, long& size); // load one cluster |
875 long LoadCluster(); | 956 long LoadCluster(); |
876 | 957 |
877 long ParseNext(const Cluster* pCurr, const Cluster*& pNext, long long& pos, | 958 long ParseNext(const Cluster* pCurr, const Cluster*& pNext, long long& pos, |
878 long& size); | 959 long& size); |
879 | 960 |
880 #if 0 | |
881 //This pair parses one cluster, but only changes the state of the | |
882 //segment object when the cluster is actually added to the index. | |
883 long ParseCluster(long long& cluster_pos, long long& new_pos) const; | |
884 bool AddCluster(long long cluster_pos, long long new_pos); | |
885 #endif | |
886 | |
887 const SeekHead* GetSeekHead() const; | 961 const SeekHead* GetSeekHead() const; |
888 const Tracks* GetTracks() const; | 962 const Tracks* GetTracks() const; |
889 const SegmentInfo* GetInfo() const; | 963 const SegmentInfo* GetInfo() const; |
890 const Cues* GetCues() const; | 964 const Cues* GetCues() const; |
891 const Chapters* GetChapters() const; | 965 const Chapters* GetChapters() const; |
| 966 const Tags* GetTags() const; |
892 | 967 |
893 long long GetDuration() const; | 968 long long GetDuration() const; |
894 | 969 |
895 unsigned long GetCount() const; | 970 unsigned long GetCount() const; |
896 const Cluster* GetFirst() const; | 971 const Cluster* GetFirst() const; |
897 const Cluster* GetLast() const; | 972 const Cluster* GetLast() const; |
898 const Cluster* GetNext(const Cluster*); | 973 const Cluster* GetNext(const Cluster*); |
899 | 974 |
900 const Cluster* FindCluster(long long time_nanoseconds) const; | 975 const Cluster* FindCluster(long long time_nanoseconds) const; |
901 // const BlockEntry* Seek(long long time_nanoseconds, const Track*) const; | 976 // const BlockEntry* Seek(long long time_nanoseconds, const Track*) const; |
902 | 977 |
903 const Cluster* FindOrPreloadCluster(long long pos); | 978 const Cluster* FindOrPreloadCluster(long long pos); |
904 | 979 |
905 long ParseCues(long long cues_off, // offset relative to start of segment | 980 long ParseCues(long long cues_off, // offset relative to start of segment |
906 long long& parse_pos, long& parse_len); | 981 long long& parse_pos, long& parse_len); |
907 | 982 |
908 private: | 983 private: |
909 long long m_pos; // absolute file posn; what has been consumed so far | 984 long long m_pos; // absolute file posn; what has been consumed so far |
910 Cluster* m_pUnknownSize; | 985 Cluster* m_pUnknownSize; |
911 | 986 |
912 SeekHead* m_pSeekHead; | 987 SeekHead* m_pSeekHead; |
913 SegmentInfo* m_pInfo; | 988 SegmentInfo* m_pInfo; |
914 Tracks* m_pTracks; | 989 Tracks* m_pTracks; |
915 Cues* m_pCues; | 990 Cues* m_pCues; |
916 Chapters* m_pChapters; | 991 Chapters* m_pChapters; |
| 992 Tags* m_pTags; |
917 Cluster** m_clusters; | 993 Cluster** m_clusters; |
918 long m_clusterCount; // number of entries for which m_index >= 0 | 994 long m_clusterCount; // number of entries for which m_index >= 0 |
919 long m_clusterPreloadCount; // number of entries for which m_index < 0 | 995 long m_clusterPreloadCount; // number of entries for which m_index < 0 |
920 long m_clusterSize; // array size | 996 long m_clusterSize; // array size |
921 | 997 |
922 long DoLoadCluster(long long&, long&); | 998 long DoLoadCluster(long long&, long&); |
923 long DoLoadClusterUnknownSize(long long&, long&); | 999 long DoLoadClusterUnknownSize(long long&, long&); |
924 long DoParseNext(const Cluster*&, long long&, long&); | 1000 long DoParseNext(const Cluster*&, long long&, long&); |
925 | 1001 |
926 void AppendCluster(Cluster*); | 1002 void AppendCluster(Cluster*); |
927 void PreloadCluster(Cluster*, ptrdiff_t); | 1003 void PreloadCluster(Cluster*, ptrdiff_t); |
928 | 1004 |
929 // void ParseSeekHead(long long pos, long long size); | 1005 // void ParseSeekHead(long long pos, long long size); |
930 // void ParseSeekEntry(long long pos, long long size); | 1006 // void ParseSeekEntry(long long pos, long long size); |
931 // void ParseCues(long long); | 1007 // void ParseCues(long long); |
932 | 1008 |
933 const BlockEntry* GetBlock(const CuePoint&, const CuePoint::TrackPosition&); | 1009 const BlockEntry* GetBlock(const CuePoint&, const CuePoint::TrackPosition&); |
934 }; | 1010 }; |
935 | 1011 |
936 } // end namespace mkvparser | 1012 } // end namespace mkvparser |
937 | 1013 |
938 inline long mkvparser::Segment::LoadCluster() { | 1014 inline long mkvparser::Segment::LoadCluster() { |
939 long long pos; | 1015 long long pos; |
940 long size; | 1016 long size; |
941 | 1017 |
942 return LoadCluster(pos, size); | 1018 return LoadCluster(pos, size); |
943 } | 1019 } |
944 | 1020 |
945 #endif // MKVPARSER_HPP | 1021 #endif // MKVPARSER_HPP |
OLD | NEW |