Compare commits
24 Commits
libwebm-1.
...
libwebm-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
093b78faf2 | ||
|
|
ed90de0d52 | ||
|
|
a01e568293 | ||
|
|
d7ce23a019 | ||
|
|
acf7ddb273 | ||
|
|
fc12207e15 | ||
|
|
c2f6bea0d8 | ||
|
|
16934eb76f | ||
|
|
9c15c0f40b | ||
|
|
43f77d54bd | ||
|
|
aec650fed7 | ||
|
|
024ad97571 | ||
|
|
8f2a2e04d7 | ||
|
|
9105d61514 | ||
|
|
77f61bdd68 | ||
|
|
485b6e8125 | ||
|
|
1d0c804fb9 | ||
|
|
b607880184 | ||
|
|
d2688d316d | ||
|
|
885d2e1ef8 | ||
|
|
1cf3a81c78 | ||
|
|
6efbd56948 | ||
|
|
f56533b30e | ||
|
|
ec2b951a78 |
1705
mkvparser.cpp
1705
mkvparser.cpp
File diff suppressed because it is too large
Load Diff
126
mkvparser.hpp
126
mkvparser.hpp
@@ -80,6 +80,7 @@ public:
|
|||||||
bool IsKey() const;
|
bool IsKey() const;
|
||||||
void SetKey(bool);
|
void SetKey(bool);
|
||||||
|
|
||||||
|
long long GetOffset() const;
|
||||||
long GetSize() const;
|
long GetSize() const;
|
||||||
long Read(IMkvReader*, unsigned char*) const;
|
long Read(IMkvReader*, unsigned char*) const;
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ public:
|
|||||||
virtual Cluster* GetCluster() const = 0;
|
virtual Cluster* GetCluster() const = 0;
|
||||||
virtual size_t GetIndex() const = 0;
|
virtual size_t GetIndex() const = 0;
|
||||||
virtual const Block* GetBlock() const = 0;
|
virtual const Block* GetBlock() const = 0;
|
||||||
virtual bool IsBFrame() const = 0;
|
//virtual bool IsBFrame() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BlockEntry();
|
BlockEntry();
|
||||||
@@ -124,7 +125,7 @@ public:
|
|||||||
Cluster* GetCluster() const;
|
Cluster* GetCluster() const;
|
||||||
size_t GetIndex() const;
|
size_t GetIndex() const;
|
||||||
const Block* GetBlock() const;
|
const Block* GetBlock() const;
|
||||||
bool IsBFrame() const;
|
//bool IsBFrame() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Cluster* const m_pCluster;
|
Cluster* const m_pCluster;
|
||||||
@@ -147,7 +148,7 @@ public:
|
|||||||
Cluster* GetCluster() const;
|
Cluster* GetCluster() const;
|
||||||
size_t GetIndex() const;
|
size_t GetIndex() const;
|
||||||
const Block* GetBlock() const;
|
const Block* GetBlock() const;
|
||||||
bool IsBFrame() const;
|
//bool IsBFrame() const;
|
||||||
|
|
||||||
short GetPrevTimeCode() const; //relative to block's time
|
short GetPrevTimeCode() const; //relative to block's time
|
||||||
short GetNextTimeCode() const; //as above
|
short GetNextTimeCode() const; //as above
|
||||||
@@ -191,6 +192,7 @@ public:
|
|||||||
const char* GetCodecNameAsUTF8() const;
|
const char* GetCodecNameAsUTF8() const;
|
||||||
const char* GetCodecId() const;
|
const char* GetCodecId() const;
|
||||||
const unsigned char* GetCodecPrivate(size_t&) const;
|
const unsigned char* GetCodecPrivate(size_t&) const;
|
||||||
|
bool GetLacing() const;
|
||||||
|
|
||||||
const BlockEntry* GetEOS() const;
|
const BlockEntry* GetEOS() const;
|
||||||
|
|
||||||
@@ -210,7 +212,9 @@ public:
|
|||||||
unsigned char* codecPrivate;
|
unsigned char* codecPrivate;
|
||||||
size_t codecPrivateSize;
|
size_t codecPrivateSize;
|
||||||
char* codecNameAsUTF8;
|
char* codecNameAsUTF8;
|
||||||
|
bool lacing;
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
|
||||||
Info();
|
Info();
|
||||||
void Clear();
|
void Clear();
|
||||||
};
|
};
|
||||||
@@ -333,14 +337,19 @@ private:
|
|||||||
char* m_pTitleAsUTF8;
|
char* m_pTitleAsUTF8;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Cues;
|
||||||
class CuePoint
|
class CuePoint
|
||||||
{
|
{
|
||||||
public:
|
friend class Cues;
|
||||||
CuePoint();
|
|
||||||
|
CuePoint(size_t, long long);
|
||||||
~CuePoint();
|
~CuePoint();
|
||||||
|
|
||||||
void Parse(IMkvReader*, long long start, long long size);
|
CuePoint(const CuePoint&);
|
||||||
|
CuePoint& operator=(const CuePoint&);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Load(IMkvReader*);
|
||||||
|
|
||||||
long long GetTimeCode() const; //absolute but unscaled
|
long long GetTimeCode() const; //absolute but unscaled
|
||||||
long long GetTime(Segment*) const; //absolute and scaled (ns units)
|
long long GetTime(Segment*) const; //absolute and scaled (ns units)
|
||||||
@@ -360,6 +369,7 @@ public:
|
|||||||
const TrackPosition* Find(const Track*) const;
|
const TrackPosition* Find(const Track*) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const size_t m_index;
|
||||||
long long m_timecode;
|
long long m_timecode;
|
||||||
TrackPosition* m_track_positions;
|
TrackPosition* m_track_positions;
|
||||||
size_t m_track_positions_count;
|
size_t m_track_positions_count;
|
||||||
@@ -369,6 +379,11 @@ private:
|
|||||||
|
|
||||||
class Cues
|
class Cues
|
||||||
{
|
{
|
||||||
|
friend class Segment;
|
||||||
|
|
||||||
|
Cues(Segment*, long long start, long long size);
|
||||||
|
~Cues();
|
||||||
|
|
||||||
Cues(const Cues&);
|
Cues(const Cues&);
|
||||||
Cues& operator=(const Cues&);
|
Cues& operator=(const Cues&);
|
||||||
|
|
||||||
@@ -377,24 +392,38 @@ public:
|
|||||||
const long long m_start;
|
const long long m_start;
|
||||||
const long long m_size;
|
const long long m_size;
|
||||||
|
|
||||||
Cues(Segment*, long long start, long long size);
|
|
||||||
~Cues();
|
|
||||||
|
|
||||||
bool Find( //lower bound of time_ns
|
bool Find( //lower bound of time_ns
|
||||||
long long time_ns,
|
long long time_ns,
|
||||||
const Track*,
|
const Track*,
|
||||||
const CuePoint*&,
|
const CuePoint*&,
|
||||||
const CuePoint::TrackPosition*&) const;
|
const CuePoint::TrackPosition*&) const;
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool FindNext( //upper_bound of time_ns
|
bool FindNext( //upper_bound of time_ns
|
||||||
long long time_ns,
|
long long time_ns,
|
||||||
const Track*,
|
const Track*,
|
||||||
const CuePoint*&,
|
const CuePoint*&,
|
||||||
const CuePoint::TrackPosition*&) const;
|
const CuePoint::TrackPosition*&) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const CuePoint* GetFirst() const;
|
||||||
|
const CuePoint* GetLast() const;
|
||||||
|
|
||||||
|
const CuePoint* GetNext(const CuePoint*) const;
|
||||||
|
|
||||||
|
const BlockEntry* GetBlock(
|
||||||
|
const CuePoint*,
|
||||||
|
const CuePoint::TrackPosition*) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CuePoint* m_cue_points;
|
void Init() const;
|
||||||
size_t m_cue_points_count;
|
bool LoadCuePoint() const;
|
||||||
|
void PreloadCuePoint(size_t&, long long) const;
|
||||||
|
|
||||||
|
mutable CuePoint** m_cue_points;
|
||||||
|
mutable size_t m_count;
|
||||||
|
mutable size_t m_preload_count;
|
||||||
|
mutable long long m_pos;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -406,10 +435,9 @@ class Cluster
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Segment* const m_pSegment;
|
Segment* const m_pSegment;
|
||||||
const size_t m_index;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Cluster* Parse(Segment*, size_t, long long off);
|
static Cluster* Parse(Segment*, long, long long off);
|
||||||
|
|
||||||
Cluster(); //EndOfStream
|
Cluster(); //EndOfStream
|
||||||
~Cluster();
|
~Cluster();
|
||||||
@@ -419,6 +447,7 @@ public:
|
|||||||
long long GetTimeCode(); //absolute, but not scaled
|
long long GetTimeCode(); //absolute, but not scaled
|
||||||
long long GetTime(); //absolute, and scaled (nanosecond units)
|
long long GetTime(); //absolute, and scaled (nanosecond units)
|
||||||
long long GetFirstTime(); //time (ns) of first (earliest) block
|
long long GetFirstTime(); //time (ns) of first (earliest) block
|
||||||
|
long long GetLastTime(); //time (ns) of last (latest) block
|
||||||
|
|
||||||
const BlockEntry* GetFirst();
|
const BlockEntry* GetFirst();
|
||||||
const BlockEntry* GetLast();
|
const BlockEntry* GetLast();
|
||||||
@@ -430,15 +459,17 @@ public:
|
|||||||
const BlockEntry* GetMaxKey(const VideoTrack*);
|
const BlockEntry* GetMaxKey(const VideoTrack*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Cluster(Segment*, size_t, long long off);
|
Cluster(Segment*, long, long long off);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//TODO: these should all be private, with public selector functions
|
||||||
|
long m_index;
|
||||||
long long m_pos;
|
long long m_pos;
|
||||||
long long m_size;
|
long long m_size;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long m_timecode;
|
long long m_timecode;
|
||||||
BlockEntry** m_pEntries;
|
BlockEntry** m_entries;
|
||||||
size_t m_entriesCount;
|
size_t m_entriesCount;
|
||||||
|
|
||||||
void Load();
|
void Load();
|
||||||
@@ -451,6 +482,8 @@ private:
|
|||||||
|
|
||||||
class Segment
|
class Segment
|
||||||
{
|
{
|
||||||
|
friend class Cues;
|
||||||
|
|
||||||
Segment(const Segment&);
|
Segment(const Segment&);
|
||||||
Segment& operator=(const Segment&);
|
Segment& operator=(const Segment&);
|
||||||
|
|
||||||
@@ -466,58 +499,55 @@ public:
|
|||||||
static long long CreateInstance(IMkvReader*, long long, Segment*&);
|
static long long CreateInstance(IMkvReader*, long long, Segment*&);
|
||||||
~Segment();
|
~Segment();
|
||||||
|
|
||||||
//for big-bang loading (source filter)
|
long Load(); //loads headers and all clusters
|
||||||
long Load();
|
|
||||||
|
|
||||||
//for incremental loading (splitter)
|
//for incremental loading (splitter)
|
||||||
long long Unparsed() const;
|
long long Unparsed() const;
|
||||||
long long ParseHeaders();
|
long long ParseHeaders(); //stops when first cluster is found
|
||||||
|
long LoadCluster(); //loads one cluster
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
//This pair parses one cluster, but only changes the state of the
|
||||||
|
//segment object when the cluster is actually added to the index.
|
||||||
long ParseCluster(Cluster*&, long long& newpos) const;
|
long ParseCluster(Cluster*&, long long& newpos) const;
|
||||||
bool AddCluster(Cluster*, long long);
|
bool AddCluster(Cluster*, long long);
|
||||||
|
#endif
|
||||||
|
|
||||||
Tracks* GetTracks() const;
|
Tracks* GetTracks() const;
|
||||||
const SegmentInfo* GetInfo() const;
|
const SegmentInfo* GetInfo() const;
|
||||||
long long GetDuration() const;
|
|
||||||
|
|
||||||
//NOTE: this turned out to be too inefficient.
|
|
||||||
//long long Load(long long time_nanoseconds);
|
|
||||||
|
|
||||||
Cluster* GetFirst();
|
|
||||||
Cluster* GetLast();
|
|
||||||
unsigned long GetCount() const;
|
|
||||||
|
|
||||||
Cluster* GetNext(const Cluster*);
|
|
||||||
Cluster* GetCluster(long long time_nanoseconds);
|
|
||||||
|
|
||||||
void GetCluster(
|
|
||||||
long long time_nanoseconds,
|
|
||||||
Track*,
|
|
||||||
Cluster*&,
|
|
||||||
const BlockEntry*&);
|
|
||||||
|
|
||||||
const Cues* GetCues() const;
|
const Cues* GetCues() const;
|
||||||
|
|
||||||
|
long long GetDuration() const;
|
||||||
|
|
||||||
|
unsigned long GetCount() const;
|
||||||
|
Cluster* GetFirst();
|
||||||
|
Cluster* GetLast();
|
||||||
|
Cluster* GetNext(const Cluster*);
|
||||||
|
|
||||||
|
Cluster* FindCluster(long long time_nanoseconds);
|
||||||
|
const BlockEntry* Seek(long long time_nanoseconds, const Track*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
long long m_pos; //absolute file posn; what has been consumed so far
|
long long m_pos; //absolute file posn; what has been consumed so far
|
||||||
SegmentInfo* m_pInfo;
|
SegmentInfo* m_pInfo;
|
||||||
Tracks* m_pTracks;
|
Tracks* m_pTracks;
|
||||||
Cues* m_pCues;
|
Cues* m_pCues;
|
||||||
Cluster** m_clusters;
|
Cluster** m_clusters;
|
||||||
size_t m_clusterCount; //number of entries
|
long m_clusterCount; //number of entries for which m_index >= 0
|
||||||
size_t m_clusterSize; //array size
|
long m_clusterPreloadCount; //number of entries for which m_index < 0
|
||||||
|
long m_clusterSize; //array size
|
||||||
|
|
||||||
void AppendCluster(Cluster*);
|
void AppendCluster(Cluster*);
|
||||||
|
void PreloadCluster(Cluster*, ptrdiff_t);
|
||||||
|
|
||||||
//void ParseSeekHead(long long pos, long long size, size_t*);
|
void ParseSeekHead(long long pos, long long size);
|
||||||
//void ParseSeekEntry(long long pos, long long size, size_t*);
|
void ParseSeekEntry(long long pos, long long size);
|
||||||
//void ParseSecondarySeekHead(long long off, size_t*);
|
void ParseCues(long long);
|
||||||
void ParseCues(long long off);
|
|
||||||
|
|
||||||
bool SearchCues(
|
const BlockEntry* GetBlock(
|
||||||
long long time_ns,
|
const CuePoint&,
|
||||||
Track*,
|
const CuePoint::TrackPosition&);
|
||||||
Cluster*&,
|
|
||||||
const BlockEntry*&);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user