Compare commits
14 Commits
libwebm-1.
...
libwebm-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c9f4d11a1 | ||
|
|
95c134ad53 | ||
|
|
7adec5248a | ||
|
|
093b78faf2 | ||
|
|
ed90de0d52 | ||
|
|
a01e568293 | ||
|
|
d7ce23a019 | ||
|
|
acf7ddb273 | ||
|
|
fc12207e15 | ||
|
|
c2f6bea0d8 | ||
|
|
16934eb76f | ||
|
|
9c15c0f40b | ||
|
|
43f77d54bd | ||
|
|
aec650fed7 |
899
mkvparser.cpp
899
mkvparser.cpp
File diff suppressed because it is too large
Load Diff
171
mkvparser.hpp
171
mkvparser.hpp
@@ -73,23 +73,44 @@ public:
|
|||||||
const long long m_size;
|
const long long m_size;
|
||||||
|
|
||||||
Block(long long start, long long size, IMkvReader*);
|
Block(long long start, long long size, IMkvReader*);
|
||||||
|
~Block();
|
||||||
|
|
||||||
long long GetTrackNumber() const;
|
long long GetTrackNumber() const;
|
||||||
long long GetTimeCode(Cluster*) const; //absolute, but not scaled
|
long long GetTimeCode(const Cluster*) const; //absolute, but not scaled
|
||||||
long long GetTime(Cluster*) const; //absolute, and scaled (ns units)
|
long long GetTime(const Cluster*) const; //absolute, and scaled (ns)
|
||||||
bool IsKey() const;
|
bool IsKey() const;
|
||||||
void SetKey(bool);
|
void SetKey(bool);
|
||||||
|
|
||||||
|
int GetFrameCount() const; //to index frames: [0, count)
|
||||||
|
|
||||||
|
struct Frame
|
||||||
|
{
|
||||||
|
long long pos; //absolute offset
|
||||||
|
long len;
|
||||||
|
|
||||||
|
long Read(IMkvReader*, unsigned char*) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
long long GetOffset() const;
|
long long GetOffset() const;
|
||||||
long GetSize() const;
|
long GetSize() const;
|
||||||
long Read(IMkvReader*, unsigned char*) const;
|
long Read(IMkvReader*, unsigned char*) const;
|
||||||
|
#else
|
||||||
|
const Frame& GetFrame(int frame_index) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long m_track; //Track::Number()
|
long long m_track; //Track::Number()
|
||||||
short m_timecode; //relative to cluster
|
short m_timecode; //relative to cluster
|
||||||
unsigned char m_flags;
|
unsigned char m_flags;
|
||||||
|
|
||||||
|
#if 0
|
||||||
long long m_frameOff;
|
long long m_frameOff;
|
||||||
long m_frameSize;
|
long m_frameSize;
|
||||||
|
#else
|
||||||
|
Frame* m_frames;
|
||||||
|
int m_frame_count;
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -102,10 +123,10 @@ class BlockEntry
|
|||||||
public:
|
public:
|
||||||
virtual ~BlockEntry();
|
virtual ~BlockEntry();
|
||||||
virtual bool EOS() const = 0;
|
virtual bool EOS() const = 0;
|
||||||
virtual Cluster* GetCluster() const = 0;
|
virtual const 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();
|
||||||
@@ -122,10 +143,10 @@ public:
|
|||||||
SimpleBlock(Cluster*, size_t, long long start, long long size);
|
SimpleBlock(Cluster*, size_t, long long start, long long size);
|
||||||
|
|
||||||
bool EOS() const;
|
bool EOS() const;
|
||||||
Cluster* GetCluster() const;
|
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;
|
||||||
@@ -145,10 +166,10 @@ public:
|
|||||||
~BlockGroup();
|
~BlockGroup();
|
||||||
|
|
||||||
bool EOS() const;
|
bool EOS() const;
|
||||||
Cluster* GetCluster() const;
|
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
|
||||||
@@ -192,6 +213,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;
|
||||||
|
|
||||||
@@ -211,7 +233,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();
|
||||||
};
|
};
|
||||||
@@ -294,8 +318,8 @@ public:
|
|||||||
Tracks(Segment*, long long start, long long size);
|
Tracks(Segment*, long long start, long long size);
|
||||||
virtual ~Tracks();
|
virtual ~Tracks();
|
||||||
|
|
||||||
Track* GetTrackByNumber(unsigned long tn) const;
|
const Track* GetTrackByNumber(unsigned long tn) const;
|
||||||
Track* GetTrackByIndex(unsigned long idx) const;
|
const Track* GetTrackByIndex(unsigned long idx) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Track** m_trackEntries;
|
Track** m_trackEntries;
|
||||||
@@ -334,18 +358,19 @@ private:
|
|||||||
char* m_pTitleAsUTF8;
|
char* m_pTitleAsUTF8;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Cues;
|
||||||
class CuePoint
|
class CuePoint
|
||||||
{
|
{
|
||||||
|
friend class Cues;
|
||||||
|
|
||||||
|
CuePoint(size_t, long long);
|
||||||
|
~CuePoint();
|
||||||
|
|
||||||
CuePoint(const CuePoint&);
|
CuePoint(const CuePoint&);
|
||||||
CuePoint& operator=(const CuePoint&);
|
CuePoint& operator=(const CuePoint&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CuePoint(long long);
|
void Load(IMkvReader*);
|
||||||
~CuePoint();
|
|
||||||
|
|
||||||
//void Parse(IMkvReader*, long long start, long long size);
|
|
||||||
void Load(IMkvReader*, long long);
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -365,7 +390,7 @@ public:
|
|||||||
const TrackPosition* Find(const Track*) const;
|
const TrackPosition* Find(const Track*) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//long long m_pos;
|
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;
|
||||||
@@ -375,6 +400,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&);
|
||||||
|
|
||||||
@@ -383,9 +413,6 @@ 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*,
|
||||||
@@ -400,29 +427,23 @@ public:
|
|||||||
const CuePoint::TrackPosition*&) const;
|
const CuePoint::TrackPosition*&) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
const CuePoint* GetFirst() const;
|
const CuePoint* GetFirst() const;
|
||||||
const CuePoint* GetLast() const;
|
const CuePoint* GetLast() const;
|
||||||
#endif
|
const CuePoint* GetNext(const CuePoint*) const;
|
||||||
|
|
||||||
bool LoadCuePoint();
|
const BlockEntry* GetBlock(
|
||||||
|
const CuePoint*,
|
||||||
#if 0
|
const CuePoint::TrackPosition*) const;
|
||||||
const CuePoint* LoadCuePoint(
|
|
||||||
long long time_ns,
|
|
||||||
const Track*,
|
|
||||||
const CuePoint::TrackPosition*&) const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init();
|
void Init() const;
|
||||||
void PreloadCuePoint(size_t&, long long);
|
bool LoadCuePoint() const;
|
||||||
|
void PreloadCuePoint(size_t&, long long) const;
|
||||||
|
|
||||||
CuePoint** m_cue_points;
|
mutable CuePoint** m_cue_points;
|
||||||
//size_t m_cue_points_size;
|
mutable size_t m_count;
|
||||||
size_t m_count;
|
mutable size_t m_preload_count;
|
||||||
size_t m_preload_count;
|
mutable long long m_pos;
|
||||||
long long m_pos;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -434,7 +455,6 @@ class Cluster
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Segment* const m_pSegment;
|
Segment* const m_pSegment;
|
||||||
long m_index;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Cluster* Parse(Segment*, long, long long off);
|
static Cluster* Parse(Segment*, long, long long off);
|
||||||
@@ -444,41 +464,46 @@ public:
|
|||||||
|
|
||||||
bool EOS() const;
|
bool EOS() const;
|
||||||
|
|
||||||
long long GetTimeCode(); //absolute, but not scaled
|
long long GetTimeCode() const; //absolute, but not scaled
|
||||||
long long GetTime(); //absolute, and scaled (nanosecond units)
|
long long GetTime() const; //absolute, and scaled (nanosecond units)
|
||||||
long long GetFirstTime(); //time (ns) of first (earliest) block
|
long long GetFirstTime() const; //time (ns) of first (earliest) block
|
||||||
|
long long GetLastTime() const; //time (ns) of last (latest) block
|
||||||
|
|
||||||
const BlockEntry* GetFirst();
|
const BlockEntry* GetFirst() const;
|
||||||
const BlockEntry* GetLast();
|
const BlockEntry* GetLast() const;
|
||||||
const BlockEntry* GetNext(const BlockEntry*) const;
|
const BlockEntry* GetNext(const BlockEntry*) const;
|
||||||
const BlockEntry* GetEntry(const Track*);
|
const BlockEntry* GetEntry(const Track*) const;
|
||||||
const BlockEntry* GetEntry(
|
const BlockEntry* GetEntry(
|
||||||
const CuePoint&,
|
const CuePoint&,
|
||||||
const CuePoint::TrackPosition&);
|
const CuePoint::TrackPosition&) const;
|
||||||
const BlockEntry* GetMaxKey(const VideoTrack*);
|
const BlockEntry* GetMaxKey(const VideoTrack*) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Cluster(Segment*, long, long long off);
|
Cluster(Segment*, long, long long off);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
long long m_pos;
|
//TODO: these should all be private, with public selector functions
|
||||||
long long m_size;
|
long m_index;
|
||||||
|
mutable long long m_pos;
|
||||||
|
mutable long long m_size;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long m_timecode;
|
mutable long long m_timecode;
|
||||||
BlockEntry** m_entries;
|
mutable BlockEntry** m_entries;
|
||||||
size_t m_entriesCount;
|
mutable size_t m_entriesCount;
|
||||||
|
|
||||||
void Load();
|
void Load() const;
|
||||||
void LoadBlockEntries();
|
void LoadBlockEntries() const;
|
||||||
void ParseBlockGroup(long long, long long, size_t);
|
void ParseBlockGroup(long long, long long, size_t) const;
|
||||||
void ParseSimpleBlock(long long, long long, size_t);
|
void ParseSimpleBlock(long long, long long, size_t) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Segment
|
class Segment
|
||||||
{
|
{
|
||||||
|
friend class Cues;
|
||||||
|
|
||||||
Segment(const Segment&);
|
Segment(const Segment&);
|
||||||
Segment& operator=(const Segment&);
|
Segment& operator=(const Segment&);
|
||||||
|
|
||||||
@@ -501,34 +526,24 @@ public:
|
|||||||
long long ParseHeaders(); //stops when first cluster is found
|
long long ParseHeaders(); //stops when first cluster is found
|
||||||
long LoadCluster(); //loads one cluster
|
long LoadCluster(); //loads one cluster
|
||||||
|
|
||||||
#if 0
|
|
||||||
//This pair parses one cluster, but only changes the state of the
|
//This pair parses one cluster, but only changes the state of the
|
||||||
//segment object when the cluster is actually added to the index.
|
//segment object when the cluster is actually added to the index.
|
||||||
long ParseCluster(Cluster*&, long long& newpos) const;
|
long ParseCluster(long long& cluster_pos, long long& new_pos) const;
|
||||||
bool AddCluster(Cluster*, long long);
|
bool AddCluster(long long cluster_pos, long long new_pos);
|
||||||
#endif
|
|
||||||
|
|
||||||
Tracks* GetTracks() const;
|
Tracks* GetTracks() const;
|
||||||
const SegmentInfo* GetInfo() const;
|
const SegmentInfo* GetInfo() const;
|
||||||
|
const Cues* GetCues() const;
|
||||||
|
|
||||||
long long GetDuration() 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;
|
unsigned long GetCount() const;
|
||||||
|
const Cluster* GetFirst() const;
|
||||||
|
const Cluster* GetLast() const;
|
||||||
|
const Cluster* GetNext(const Cluster*);
|
||||||
|
|
||||||
Cluster* GetNext(const Cluster*);
|
const Cluster* FindCluster(long long time_nanoseconds) const;
|
||||||
Cluster* GetCluster(long long time_nanoseconds);
|
const BlockEntry* Seek(long long time_nanoseconds, const Track*) const;
|
||||||
|
|
||||||
void GetCluster(
|
|
||||||
long long time_nanoseconds,
|
|
||||||
Track*,
|
|
||||||
Cluster*&,
|
|
||||||
const BlockEntry*&);
|
|
||||||
|
|
||||||
Cues* GetCues() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -548,11 +563,9 @@ private:
|
|||||||
void ParseSeekEntry(long long pos, long long size);
|
void ParseSeekEntry(long long pos, long long size);
|
||||||
void ParseCues(long long);
|
void ParseCues(long long);
|
||||||
|
|
||||||
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