Compare commits
53 Commits
libwebm-1.
...
libwebm-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a977a2b536 | ||
|
|
5e72a2dfc2 | ||
|
|
056b0d96a8 | ||
|
|
dbc58d0510 | ||
|
|
a131a01446 | ||
|
|
b8cb358204 | ||
|
|
5b06b22b31 | ||
|
|
598de03ef3 | ||
|
|
94f2d589fc | ||
|
|
786357a59d | ||
|
|
6e723319e8 | ||
|
|
9911f61616 | ||
|
|
b0f96983d2 | ||
|
|
6d7732575a | ||
|
|
8081c58b9b | ||
|
|
00aa1804e9 | ||
|
|
bb8dfbe026 | ||
|
|
b81751642e | ||
|
|
3b0f1b6d2b | ||
|
|
d1aff34626 | ||
|
|
6623441ee8 | ||
|
|
3ba8df9a64 | ||
|
|
bebe4accb8 | ||
|
|
93263f0b4a | ||
|
|
e1e757f919 | ||
|
|
6c45ab2d4c | ||
|
|
cb7b24880f | ||
|
|
157775ac74 | ||
|
|
fd1d8006f0 | ||
|
|
9203d2dcd1 | ||
|
|
be2f81abca | ||
|
|
cb5414a42a | ||
|
|
2ce6965b2d | ||
|
|
8db600e1c9 | ||
|
|
85353469f8 | ||
|
|
d97f236f81 | ||
|
|
790f639f2f | ||
|
|
91dbee4b6e | ||
|
|
1e6c5cbaf7 | ||
|
|
c62b9f8a21 | ||
|
|
5dd6000dc7 | ||
|
|
3ea595b132 | ||
|
|
14e42cf98b | ||
|
|
6c9f4d11a1 | ||
|
|
95c134ad53 | ||
|
|
30bf3472bf | ||
|
|
7adec5248a | ||
|
|
093b78faf2 | ||
|
|
ed90de0d52 | ||
|
|
a01e568293 | ||
|
|
d7ce23a019 | ||
|
|
acf7ddb273 | ||
|
|
fc12207e15 |
26
RELEASE.TXT
26
RELEASE.TXT
@@ -1,3 +1,29 @@
|
|||||||
|
1.0.0.5
|
||||||
|
* Handled case when no duration
|
||||||
|
* Handled empty clusters
|
||||||
|
* Handled empty clusters when seeking
|
||||||
|
* Implemented check lacing bits
|
||||||
|
|
||||||
|
1.0.0.4
|
||||||
|
* Made Cues member variables mutables
|
||||||
|
* Defined against badly-formatted cue points
|
||||||
|
* Segment::GetCluster returns CuePoint too
|
||||||
|
* Separated cue-based searches
|
||||||
|
|
||||||
|
1.0.0.3
|
||||||
|
* Added Block::GetOffset() to get a frame's offset in a block
|
||||||
|
* Changed cluster count type from size_t to long
|
||||||
|
* Parsed SeekHead to find cues
|
||||||
|
* Allowed seeking beyond end of cluster cache
|
||||||
|
* Added not to attempt to reparse cues element
|
||||||
|
* Restructured Segment::LoadCluster
|
||||||
|
* Marked position of cues without parsing cues element
|
||||||
|
* Allowed cue points to be loaded incrementally
|
||||||
|
* Implemented to load lazily cue points as they're searched
|
||||||
|
* Merged Cues::LoadCuePoint into Cues::Find
|
||||||
|
* Lazy init cues
|
||||||
|
* Loaded cue point during find
|
||||||
|
|
||||||
1.0.0.2
|
1.0.0.2
|
||||||
* added support for Cues element
|
* added support for Cues element
|
||||||
* seeking was improved
|
* seeking was improved
|
||||||
|
|||||||
2559
mkvparser.cpp
2559
mkvparser.cpp
File diff suppressed because it is too large
Load Diff
278
mkvparser.hpp
278
mkvparser.hpp
@@ -37,7 +37,7 @@ short Unserialize2SInt(IMkvReader*, long long);
|
|||||||
signed char Unserialize1SInt(IMkvReader*, long long);
|
signed char Unserialize1SInt(IMkvReader*, long long);
|
||||||
bool Match(IMkvReader*, long long&, unsigned long, long long&);
|
bool Match(IMkvReader*, long long&, unsigned long, long long&);
|
||||||
bool Match(IMkvReader*, long long&, unsigned long, char*&);
|
bool Match(IMkvReader*, long long&, unsigned long, char*&);
|
||||||
bool Match(IMkvReader*, long long&, unsigned long,unsigned char*&, size_t&);
|
bool Match(IMkvReader*, long long&, unsigned long, unsigned char*&, size_t&);
|
||||||
bool Match(IMkvReader*, long long&, unsigned long, double&);
|
bool Match(IMkvReader*, long long&, unsigned long, double&);
|
||||||
bool Match(IMkvReader*, long long&, unsigned long, short&);
|
bool Match(IMkvReader*, long long&, unsigned long, short&);
|
||||||
|
|
||||||
@@ -56,6 +56,7 @@ struct EBMLHeader
|
|||||||
long long m_docTypeReadVersion;
|
long long m_docTypeReadVersion;
|
||||||
|
|
||||||
long long Parse(IMkvReader*, long long&);
|
long long Parse(IMkvReader*, long long&);
|
||||||
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -73,23 +74,34 @@ 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);
|
||||||
|
bool IsInvisible() const;
|
||||||
|
|
||||||
|
int GetFrameCount() const; //to index frames: [0, count)
|
||||||
|
|
||||||
|
struct Frame
|
||||||
|
{
|
||||||
|
long long pos; //absolute offset
|
||||||
|
long len;
|
||||||
|
|
||||||
long long GetOffset() const;
|
|
||||||
long GetSize() const;
|
|
||||||
long Read(IMkvReader*, unsigned char*) const;
|
long Read(IMkvReader*, unsigned char*) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
const Frame& GetFrame(int frame_index) const;
|
||||||
|
|
||||||
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;
|
||||||
long long m_frameOff;
|
|
||||||
long m_frameSize;
|
Frame* m_frames;
|
||||||
|
int m_frame_count;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -102,10 +114,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 +134,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 +157,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
|
||||||
@@ -184,14 +196,18 @@ class Track
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Segment* const m_pSegment;
|
Segment* const m_pSegment;
|
||||||
|
const long long m_element_start;
|
||||||
|
const long long m_element_size;
|
||||||
virtual ~Track();
|
virtual ~Track();
|
||||||
|
|
||||||
long long GetType() const;
|
long long GetType() const;
|
||||||
long long GetNumber() const;
|
long long GetNumber() const;
|
||||||
|
unsigned long long GetUid() const;
|
||||||
const char* GetNameAsUTF8() const;
|
const char* GetNameAsUTF8() const;
|
||||||
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;
|
||||||
|
|
||||||
@@ -205,13 +221,15 @@ public:
|
|||||||
{
|
{
|
||||||
long long type;
|
long long type;
|
||||||
long long number;
|
long long number;
|
||||||
long long uid;
|
unsigned long long uid;
|
||||||
char* nameAsUTF8;
|
char* nameAsUTF8;
|
||||||
char* codecId;
|
char* codecId;
|
||||||
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();
|
||||||
};
|
};
|
||||||
@@ -219,9 +237,14 @@ public:
|
|||||||
long GetFirst(const BlockEntry*&) const;
|
long GetFirst(const BlockEntry*&) const;
|
||||||
long GetNext(const BlockEntry* pCurr, const BlockEntry*& pNext) const;
|
long GetNext(const BlockEntry* pCurr, const BlockEntry*& pNext) const;
|
||||||
virtual bool VetEntry(const BlockEntry*) const = 0;
|
virtual bool VetEntry(const BlockEntry*) const = 0;
|
||||||
|
virtual long Seek(long long time_ns, const BlockEntry*&) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Track(Segment*, const Info&);
|
Track(
|
||||||
|
Segment*,
|
||||||
|
const Info&,
|
||||||
|
long long element_start,
|
||||||
|
long long element_size);
|
||||||
const Info m_info;
|
const Info m_info;
|
||||||
|
|
||||||
class EOSBlock : public BlockEntry
|
class EOSBlock : public BlockEntry
|
||||||
@@ -230,7 +253,7 @@ protected:
|
|||||||
EOSBlock();
|
EOSBlock();
|
||||||
|
|
||||||
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;
|
||||||
@@ -247,12 +270,17 @@ class VideoTrack : public Track
|
|||||||
VideoTrack& operator=(const VideoTrack&);
|
VideoTrack& operator=(const VideoTrack&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoTrack(Segment*, const Info&);
|
VideoTrack(
|
||||||
|
Segment*,
|
||||||
|
const Info&,
|
||||||
|
long long element_start,
|
||||||
|
long long element_size);
|
||||||
long long GetWidth() const;
|
long long GetWidth() const;
|
||||||
long long GetHeight() const;
|
long long GetHeight() const;
|
||||||
double GetFrameRate() const;
|
double GetFrameRate() const;
|
||||||
|
|
||||||
bool VetEntry(const BlockEntry*) const;
|
bool VetEntry(const BlockEntry*) const;
|
||||||
|
long Seek(long long time_ns, const BlockEntry*&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long m_width;
|
long long m_width;
|
||||||
@@ -268,11 +296,16 @@ class AudioTrack : public Track
|
|||||||
AudioTrack& operator=(const AudioTrack&);
|
AudioTrack& operator=(const AudioTrack&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AudioTrack(Segment*, const Info&);
|
AudioTrack(
|
||||||
|
Segment*,
|
||||||
|
const Info&,
|
||||||
|
long long element_start,
|
||||||
|
long long element_size);
|
||||||
double GetSamplingRate() const;
|
double GetSamplingRate() const;
|
||||||
long long GetChannels() const;
|
long long GetChannels() const;
|
||||||
long long GetBitDepth() const;
|
long long GetBitDepth() const;
|
||||||
bool VetEntry(const BlockEntry*) const;
|
bool VetEntry(const BlockEntry*) const;
|
||||||
|
long Seek(long long time_ns, const BlockEntry*&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_rate;
|
double m_rate;
|
||||||
@@ -290,18 +323,30 @@ public:
|
|||||||
Segment* const m_pSegment;
|
Segment* const m_pSegment;
|
||||||
const long long m_start;
|
const long long m_start;
|
||||||
const long long m_size;
|
const long long m_size;
|
||||||
|
const long long m_element_start;
|
||||||
|
const long long m_element_size;
|
||||||
|
|
||||||
Tracks(Segment*, long long start, long long size);
|
Tracks(
|
||||||
|
Segment*,
|
||||||
|
long long start,
|
||||||
|
long long size,
|
||||||
|
long long element_start,
|
||||||
|
long long element_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;
|
||||||
Track** m_trackEntriesEnd;
|
Track** m_trackEntriesEnd;
|
||||||
|
|
||||||
void ParseTrackEntry(long long, long long, Track*&);
|
void ParseTrackEntry(
|
||||||
|
long long,
|
||||||
|
long long,
|
||||||
|
Track*&,
|
||||||
|
long long element_start,
|
||||||
|
long long element_size);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned long GetTracksCount() const;
|
unsigned long GetTracksCount() const;
|
||||||
@@ -317,9 +362,18 @@ public:
|
|||||||
Segment* const m_pSegment;
|
Segment* const m_pSegment;
|
||||||
const long long m_start;
|
const long long m_start;
|
||||||
const long long m_size;
|
const long long m_size;
|
||||||
|
const long long m_element_start;
|
||||||
|
const long long m_element_size;
|
||||||
|
|
||||||
|
SegmentInfo(
|
||||||
|
Segment*,
|
||||||
|
long long start,
|
||||||
|
long long size,
|
||||||
|
long long element_start,
|
||||||
|
long long element_size);
|
||||||
|
|
||||||
SegmentInfo(Segment*, long long start, long long size);
|
|
||||||
~SegmentInfo();
|
~SegmentInfo();
|
||||||
|
|
||||||
long long GetTimeCodeScale() const;
|
long long GetTimeCodeScale() const;
|
||||||
long long GetDuration() const; //scaled
|
long long GetDuration() const; //scaled
|
||||||
const char* GetMuxingAppAsUTF8() const;
|
const char* GetMuxingAppAsUTF8() const;
|
||||||
@@ -334,6 +388,49 @@ private:
|
|||||||
char* m_pTitleAsUTF8;
|
char* m_pTitleAsUTF8;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SeekHead
|
||||||
|
{
|
||||||
|
SeekHead(const SeekHead&);
|
||||||
|
SeekHead& operator=(const SeekHead&);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Segment* const m_pSegment;
|
||||||
|
const long long m_start;
|
||||||
|
const long long m_size;
|
||||||
|
const long long m_element_start;
|
||||||
|
const long long m_element_size;
|
||||||
|
|
||||||
|
SeekHead(
|
||||||
|
Segment*,
|
||||||
|
long long start,
|
||||||
|
long long size,
|
||||||
|
long long element_start,
|
||||||
|
long long element_size);
|
||||||
|
|
||||||
|
~SeekHead();
|
||||||
|
|
||||||
|
struct Entry
|
||||||
|
{
|
||||||
|
long long id;
|
||||||
|
long long pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
int GetCount() const;
|
||||||
|
const Entry* GetEntry(int idx) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Entry* m_entries;
|
||||||
|
int m_count;
|
||||||
|
|
||||||
|
static void ParseEntry(
|
||||||
|
IMkvReader*,
|
||||||
|
long long pos,
|
||||||
|
long long size,
|
||||||
|
Entry*&);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class Cues;
|
class Cues;
|
||||||
class CuePoint
|
class CuePoint
|
||||||
{
|
{
|
||||||
@@ -346,10 +443,13 @@ class CuePoint
|
|||||||
CuePoint& operator=(const CuePoint&);
|
CuePoint& operator=(const CuePoint&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
long long m_element_start;
|
||||||
|
long long m_element_size;
|
||||||
|
|
||||||
void Load(IMkvReader*);
|
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(const Segment*) const; //absolute and scaled (ns units)
|
||||||
|
|
||||||
struct TrackPosition
|
struct TrackPosition
|
||||||
{
|
{
|
||||||
@@ -378,7 +478,12 @@ class Cues
|
|||||||
{
|
{
|
||||||
friend class Segment;
|
friend class Segment;
|
||||||
|
|
||||||
Cues(Segment*, long long start, long long size);
|
Cues(
|
||||||
|
Segment*,
|
||||||
|
long long start,
|
||||||
|
long long size,
|
||||||
|
long long element_start,
|
||||||
|
long long element_size);
|
||||||
~Cues();
|
~Cues();
|
||||||
|
|
||||||
Cues(const Cues&);
|
Cues(const Cues&);
|
||||||
@@ -388,6 +493,8 @@ public:
|
|||||||
Segment* const m_pSegment;
|
Segment* const m_pSegment;
|
||||||
const long long m_start;
|
const long long m_start;
|
||||||
const long long m_size;
|
const long long m_size;
|
||||||
|
const long long m_element_start;
|
||||||
|
const long long m_element_size;
|
||||||
|
|
||||||
bool Find( //lower bound of time_ns
|
bool Find( //lower bound of time_ns
|
||||||
long long time_ns,
|
long long time_ns,
|
||||||
@@ -403,15 +510,18 @@ public:
|
|||||||
const CuePoint::TrackPosition*&) const;
|
const CuePoint::TrackPosition*&) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const CuePoint* GetFirst() const;
|
||||||
|
const CuePoint* GetLast() const;
|
||||||
const CuePoint* GetNext(const CuePoint*) const;
|
const CuePoint* GetNext(const CuePoint*) const;
|
||||||
|
|
||||||
const BlockEntry* GetBlock(
|
const BlockEntry* GetBlock(
|
||||||
const CuePoint*,
|
const CuePoint*,
|
||||||
const CuePoint::TrackPosition*) const;
|
const CuePoint::TrackPosition*) const;
|
||||||
|
|
||||||
|
bool LoadCuePoint() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init() const;
|
void Init() const;
|
||||||
bool LoadCuePoint() const;
|
|
||||||
void PreloadCuePoint(size_t&, long long) const;
|
void PreloadCuePoint(size_t&, long long) const;
|
||||||
|
|
||||||
mutable CuePoint** m_cue_points;
|
mutable CuePoint** m_cue_points;
|
||||||
@@ -429,45 +539,64 @@ 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,
|
||||||
|
long long element_start,
|
||||||
|
long long element_size);
|
||||||
|
|
||||||
Cluster(); //EndOfStream
|
Cluster(); //EndOfStream
|
||||||
~Cluster();
|
~Cluster();
|
||||||
|
|
||||||
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*, long long ns = -1) 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;
|
||||||
|
|
||||||
|
static bool HasBlockEntries(const Segment*, long long);
|
||||||
|
long GetEntryCount() const;
|
||||||
|
|
||||||
|
void Load() const;
|
||||||
|
void LoadBlockEntries() const;
|
||||||
|
long LoadBlockEntries(long long& pos, long& size) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Cluster(Segment*, long, long long off);
|
Cluster(
|
||||||
|
Segment*,
|
||||||
|
long,
|
||||||
|
long long off,
|
||||||
|
long long element_start,
|
||||||
|
long long element_size);
|
||||||
|
|
||||||
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;
|
||||||
|
const long long m_element_start;
|
||||||
|
const long long m_element_size;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long m_timecode;
|
mutable long long m_timecode;
|
||||||
BlockEntry** m_entries;
|
mutable BlockEntry** m_entries;
|
||||||
size_t m_entriesCount;
|
mutable long m_entries_count;
|
||||||
|
|
||||||
void Load();
|
void ParseBlockGroup(long long, long long, size_t) const;
|
||||||
void LoadBlockEntries();
|
void ParseSimpleBlock(long long, long long, size_t) const;
|
||||||
void ParseBlockGroup(long long, long long, size_t);
|
|
||||||
void ParseSimpleBlock(long long, long long, size_t);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -475,6 +604,8 @@ private:
|
|||||||
class Segment
|
class Segment
|
||||||
{
|
{
|
||||||
friend class Cues;
|
friend class Cues;
|
||||||
|
friend class VideoTrack;
|
||||||
|
friend class AudioTrack;
|
||||||
|
|
||||||
Segment(const Segment&);
|
Segment(const Segment&);
|
||||||
Segment& operator=(const Segment&);
|
Segment& operator=(const Segment&);
|
||||||
@@ -493,35 +624,51 @@ public:
|
|||||||
|
|
||||||
long Load(); //loads headers and all clusters
|
long Load(); //loads headers and all clusters
|
||||||
|
|
||||||
//for incremental loading (splitter)
|
//for incremental loading
|
||||||
long long Unparsed() const;
|
long long Unparsed() const;
|
||||||
long long ParseHeaders(); //stops when first cluster is found
|
long long ParseHeaders(); //stops when first cluster is found
|
||||||
long LoadCluster(); //loads one cluster
|
//long FindNextCluster(long long& pos, long& size) const;
|
||||||
|
long LoadCluster(long long& pos, long& size); //load one cluster
|
||||||
|
long LoadCluster();
|
||||||
|
|
||||||
|
long ParseNext(
|
||||||
|
const Cluster* pCurr,
|
||||||
|
const Cluster*& pNext,
|
||||||
|
long long& pos,
|
||||||
|
long& size);
|
||||||
|
|
||||||
#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;
|
const SeekHead* GetSeekHead() const;
|
||||||
|
const Tracks* GetTracks() const;
|
||||||
const SegmentInfo* GetInfo() const;
|
const SegmentInfo* GetInfo() const;
|
||||||
const Cues* GetCues() const;
|
const Cues* GetCues() const;
|
||||||
|
|
||||||
long long GetDuration() const;
|
long long GetDuration() const;
|
||||||
|
|
||||||
unsigned long GetCount() const;
|
unsigned long GetCount() const;
|
||||||
Cluster* GetFirst();
|
const Cluster* GetFirst() const;
|
||||||
Cluster* GetLast();
|
const Cluster* GetLast() const;
|
||||||
Cluster* GetNext(const Cluster*);
|
const Cluster* GetNext(const Cluster*);
|
||||||
|
|
||||||
Cluster* FindCluster(long long time_nanoseconds);
|
const Cluster* FindCluster(long long time_nanoseconds) const;
|
||||||
const BlockEntry* Seek(long long time_nanoseconds, const Track*);
|
//const BlockEntry* Seek(long long time_nanoseconds, const Track*) const;
|
||||||
|
|
||||||
|
const Cluster* FindOrPreloadCluster(long long pos);
|
||||||
|
|
||||||
|
long ParseCues(
|
||||||
|
long long cues_off, //offset relative to start of segment
|
||||||
|
long long& parse_pos,
|
||||||
|
long& parse_len);
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
SeekHead* m_pSeekHead;
|
||||||
SegmentInfo* m_pInfo;
|
SegmentInfo* m_pInfo;
|
||||||
Tracks* m_pTracks;
|
Tracks* m_pTracks;
|
||||||
Cues* m_pCues;
|
Cues* m_pCues;
|
||||||
@@ -533,9 +680,9 @@ private:
|
|||||||
void AppendCluster(Cluster*);
|
void AppendCluster(Cluster*);
|
||||||
void PreloadCluster(Cluster*, ptrdiff_t);
|
void PreloadCluster(Cluster*, ptrdiff_t);
|
||||||
|
|
||||||
void ParseSeekHead(long long pos, long long size);
|
//void ParseSeekHead(long long pos, long long size);
|
||||||
void ParseSeekEntry(long long pos, long long size);
|
//void ParseSeekEntry(long long pos, long long size);
|
||||||
void ParseCues(long long);
|
//void ParseCues(long long);
|
||||||
|
|
||||||
const BlockEntry* GetBlock(
|
const BlockEntry* GetBlock(
|
||||||
const CuePoint&,
|
const CuePoint&,
|
||||||
@@ -543,7 +690,14 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} //end namespace mkvparser
|
} //end namespace mkvparser
|
||||||
|
|
||||||
|
inline long mkvparser::Segment::LoadCluster()
|
||||||
|
{
|
||||||
|
long long pos;
|
||||||
|
long size;
|
||||||
|
|
||||||
|
return LoadCluster(pos, size);
|
||||||
|
}
|
||||||
|
|
||||||
#endif //MKVPARSER_HPP
|
#endif //MKVPARSER_HPP
|
||||||
|
|||||||
@@ -43,13 +43,13 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="false"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="4"
|
||||||
Detect64BitPortabilityProblems="false"
|
Detect64BitPortabilityProblems="false"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
|||||||
52
sample.cpp
52
sample.cpp
@@ -109,22 +109,32 @@ int main(int argc, char* argv[])
|
|||||||
printf("\t\tDuration\t\t: %lld\n", duration_ns);
|
printf("\t\tDuration\t\t: %lld\n", duration_ns);
|
||||||
|
|
||||||
const double duration_sec = double(duration_ns) / 1000000000;
|
const double duration_sec = double(duration_ns) / 1000000000;
|
||||||
printf("\t\tDuration(secs)\t\t: %7.3f\n", duration_sec);
|
printf("\t\tDuration(secs)\t\t: %7.3lf\n", duration_sec);
|
||||||
|
|
||||||
if (pTitle == NULL)
|
if (pTitle == NULL)
|
||||||
printf("\t\tTrack Name\t\t: NULL\n");
|
printf("\t\tTrack Name\t\t: NULL\n");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
printf("\t\tTrack Name\t\t: %ls\n", pTitle);
|
printf("\t\tTrack Name\t\t: %ls\n", pTitle);
|
||||||
|
delete [] pTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (pMuxingApp == NULL)
|
if (pMuxingApp == NULL)
|
||||||
printf("\t\tMuxing App\t\t: NULL\n");
|
printf("\t\tMuxing App\t\t: NULL\n");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
printf("\t\tMuxing App\t\t: %ls\n", pMuxingApp);
|
printf("\t\tMuxing App\t\t: %ls\n", pMuxingApp);
|
||||||
|
delete [] pMuxingApp;
|
||||||
|
}
|
||||||
|
|
||||||
if (pWritingApp == NULL)
|
if (pWritingApp == NULL)
|
||||||
printf("\t\tWriting App\t\t: NULL\n");
|
printf("\t\tWriting App\t\t: NULL\n");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
printf("\t\tWriting App\t\t: %ls\n", pWritingApp);
|
printf("\t\tWriting App\t\t: %ls\n", pWritingApp);
|
||||||
|
delete [] pWritingApp;
|
||||||
|
}
|
||||||
|
|
||||||
// pos of segment payload
|
// pos of segment payload
|
||||||
printf("\t\tPosition(Segment)\t: %lld\n", pSegment->m_start);
|
printf("\t\tPosition(Segment)\t: %lld\n", pSegment->m_start);
|
||||||
@@ -132,7 +142,7 @@ int main(int argc, char* argv[])
|
|||||||
// size of segment payload
|
// size of segment payload
|
||||||
printf("\t\tSize(Segment)\t\t: %lld\n", pSegment->m_size);
|
printf("\t\tSize(Segment)\t\t: %lld\n", pSegment->m_size);
|
||||||
|
|
||||||
mkvparser::Tracks* const pTracks = pSegment->GetTracks();
|
const mkvparser::Tracks* pTracks = pSegment->GetTracks();
|
||||||
|
|
||||||
unsigned long i = 0;
|
unsigned long i = 0;
|
||||||
const unsigned long j = pTracks->GetTracksCount();
|
const unsigned long j = pTracks->GetTracksCount();
|
||||||
@@ -148,19 +158,22 @@ int main(int argc, char* argv[])
|
|||||||
if (pTrack == NULL)
|
if (pTrack == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const long long trackType_ = pTrack->GetType();
|
const long long trackType = pTrack->GetType();
|
||||||
unsigned long trackType = static_cast<unsigned long>(trackType_);
|
const long long trackNumber = pTrack->GetNumber();
|
||||||
|
const unsigned long long trackUid = pTrack->GetUid();
|
||||||
unsigned long trackNumber = pTrack->GetNumber();
|
|
||||||
const wchar_t* const pTrackName = utf8towcs(pTrack->GetNameAsUTF8());
|
const wchar_t* const pTrackName = utf8towcs(pTrack->GetNameAsUTF8());
|
||||||
|
|
||||||
printf("\t\tTrack Type\t\t: %ld\n", trackType);
|
printf("\t\tTrack Type\t\t: %lld\n", trackType);
|
||||||
printf("\t\tTrack Number\t\t: %ld\n", trackNumber);
|
printf("\t\tTrack Number\t\t: %lld\n", trackNumber);
|
||||||
|
printf("\t\tTrack Uid\t\t: %lld\n", trackUid);
|
||||||
|
|
||||||
if (pTrackName == NULL)
|
if (pTrackName == NULL)
|
||||||
printf("\t\tTrack Name\t\t: NULL\n");
|
printf("\t\tTrack Name\t\t: NULL\n");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
printf("\t\tTrack Name\t\t: %ls \n", pTrackName);
|
printf("\t\tTrack Name\t\t: %ls \n", pTrackName);
|
||||||
|
delete [] pTrackName;
|
||||||
|
}
|
||||||
|
|
||||||
const char* const pCodecId = pTrack->GetCodecId();
|
const char* const pCodecId = pTrack->GetCodecId();
|
||||||
|
|
||||||
@@ -175,7 +188,10 @@ int main(int argc, char* argv[])
|
|||||||
if (pCodecName == NULL)
|
if (pCodecName == NULL)
|
||||||
printf("\t\tCodec Name\t\t: NULL\n");
|
printf("\t\tCodec Name\t\t: NULL\n");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
printf("\t\tCodec Name\t\t: %ls\n", pCodecName);
|
printf("\t\tCodec Name\t\t: %ls\n", pCodecName);
|
||||||
|
delete [] pCodecName;
|
||||||
|
}
|
||||||
|
|
||||||
if (trackType == VIDEO_TRACK)
|
if (trackType == VIDEO_TRACK)
|
||||||
{
|
{
|
||||||
@@ -220,7 +236,7 @@ int main(int argc, char* argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mkvparser::Cluster* pCluster = pSegment->GetFirst();
|
const mkvparser::Cluster* pCluster = pSegment->GetFirst();
|
||||||
|
|
||||||
while ((pCluster != NULL) && !pCluster->EOS())
|
while ((pCluster != NULL) && !pCluster->EOS())
|
||||||
{
|
{
|
||||||
@@ -235,18 +251,26 @@ int main(int argc, char* argv[])
|
|||||||
while ((pBlockEntry != NULL) && !pBlockEntry->EOS())
|
while ((pBlockEntry != NULL) && !pBlockEntry->EOS())
|
||||||
{
|
{
|
||||||
const Block* const pBlock = pBlockEntry->GetBlock();
|
const Block* const pBlock = pBlockEntry->GetBlock();
|
||||||
const unsigned long trackNum = pBlock->GetTrackNumber();
|
const long long trackNum = pBlock->GetTrackNumber();
|
||||||
const Track* const pTrack = pTracks->GetTrackByNumber(trackNum);
|
const unsigned long tn = static_cast<unsigned long>(trackNum);
|
||||||
|
const Track* const pTrack = pTracks->GetTrackByNumber(tn);
|
||||||
const long long trackType = pTrack->GetType();
|
const long long trackType = pTrack->GetType();
|
||||||
const long size = pBlock->GetSize();
|
const int frameCount = pBlock->GetFrameCount();
|
||||||
const long long time_ns = pBlock->GetTime(pCluster);
|
const long long time_ns = pBlock->GetTime(pCluster);
|
||||||
|
|
||||||
printf("\t\t\tBlock\t\t:%s,%15ld,%s,%15lld\n",
|
printf("\t\t\tBlock\t\t:%s,%s,%15lld\n",
|
||||||
(trackType == VIDEO_TRACK) ? "V" : "A",
|
(trackType == VIDEO_TRACK) ? "V" : "A",
|
||||||
size,
|
|
||||||
pBlock->IsKey() ? "I" : "P",
|
pBlock->IsKey() ? "I" : "P",
|
||||||
time_ns);
|
time_ns);
|
||||||
|
|
||||||
|
for (int i = 0; i < frameCount; ++i)
|
||||||
|
{
|
||||||
|
const Block::Frame& theFrame = pBlock->GetFrame(i);
|
||||||
|
const long size = theFrame.len;
|
||||||
|
const long long offset = theFrame.pos;
|
||||||
|
printf("\t\t\t %15ld,%15llx\n", size, offset);
|
||||||
|
}
|
||||||
|
|
||||||
pBlockEntry = pCluster->GetNext(pBlockEntry);
|
pBlockEntry = pCluster->GetNext(pBlockEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,13 +43,13 @@
|
|||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\"
|
AdditionalIncludeDirectories="..\"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="false"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="4"
|
||||||
Detect64BitPortabilityProblems="false"
|
Detect64BitPortabilityProblems="false"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
|||||||
Reference in New Issue
Block a user