Compare commits

..

14 Commits

Author SHA1 Message Date
matthewjheaney
6c9f4d11a1 set version to 1.0.0.6
Change-Id: I259171d7bce7f670cb937707a9864aa0b9eb0d22
2010-11-05 15:21:28 -04:00
matthewjheaney
95c134ad53 ensure const correctness
Change-Id: Ia401d66519d1d663e9630ad1e70f18adec0f0bb5
2010-11-04 19:15:16 -04:00
matthewjheaney
7adec5248a added lacing support
Change-Id: I79ce0b6820f62846b05edbc8a0cb381aa2bc32a6
2010-11-02 11:44:31 -04:00
matthewjheaney
093b78faf2 set version to 1.0.0.5
Change-Id: I3643a0019110b1ff7359a8d414bf0cd2ba9b5d54
2010-10-29 14:31:47 -04:00
matthewjheaney
ed90de0d52 check lacing bits
Change-Id: Iaa3a65429b7f3211868a86bbb83ce8018350554a
2010-10-29 14:04:43 -04:00
matthewjheaney
a01e568293 removed IsBFrame selector
Change-Id: Iae51165c318997a9131e9af5c667cfac1f37e773
2010-10-28 17:28:59 -04:00
matthewjheaney
d7ce23a019 handle empty clusters when seeking
Change-Id: I9bb39ff95e308639402e1c7f9aec59c81350d091
2010-10-28 14:45:27 -04:00
matthewjheaney
acf7ddb273 handle empty clusters
Change-Id: I57b085367e1b900acb0ddd6ee419e317f261718a
2010-10-27 16:47:14 -04:00
matthewjheaney
fc12207e15 handle case when no duration
Change-Id: I694f6ce6ae9ecc6fc3b90b954dd7041e82fb9ac0
2010-10-22 13:46:39 -04:00
matthewjheaney
c2f6bea0d8 changed version to 1.0.0.4
Change-Id: I8580a5de258d74b6a83505046d014ad9c6abfc23
2010-10-14 19:34:37 -04:00
matthewjheaney
16934eb76f separate cue-based searches
Change-Id: I5d98be1c9c5bc33b4ef216f48de22220f38c0f36
2010-10-13 13:44:13 -04:00
matthewjheaney
9c15c0f40b Segment::GetCluster returns CuePoint too
Change-Id: Id1b865a9efdcee6b6ef68d4fb323da50f1942f2a
2010-10-12 15:29:28 -04:00
matthewjheaney
43f77d54bd defend against badly-formatted cue points
Change-Id: I72bab89f0828b2c5275a4c4b3ac22ee61a173ddf
2010-10-11 19:09:27 -04:00
matthewjheaney
aec650fed7 made Cues member variables mutable
Change-Id: I405b845f37c9deaffd67e50752fb9b2aa7124484
2010-10-11 12:59:17 -04:00
2 changed files with 694 additions and 376 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -73,23 +73,44 @@ public:
const long long m_size;
Block(long long start, long long size, IMkvReader*);
~Block();
long long GetTrackNumber() const;
long long GetTimeCode(Cluster*) const; //absolute, but not scaled
long long GetTime(Cluster*) const; //absolute, and scaled (ns units)
long long GetTimeCode(const Cluster*) const; //absolute, but not scaled
long long GetTime(const Cluster*) const; //absolute, and scaled (ns)
bool IsKey() const;
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 GetSize() const;
long Read(IMkvReader*, unsigned char*) const;
#else
const Frame& GetFrame(int frame_index) const;
#endif
private:
long long m_track; //Track::Number()
short m_timecode; //relative to cluster
unsigned char m_flags;
#if 0
long long m_frameOff;
long m_frameSize;
#else
Frame* m_frames;
int m_frame_count;
#endif
};
@@ -102,10 +123,10 @@ class BlockEntry
public:
virtual ~BlockEntry();
virtual bool EOS() const = 0;
virtual Cluster* GetCluster() const = 0;
virtual const Cluster* GetCluster() const = 0;
virtual size_t GetIndex() const = 0;
virtual const Block* GetBlock() const = 0;
virtual bool IsBFrame() const = 0;
//virtual bool IsBFrame() const = 0;
protected:
BlockEntry();
@@ -122,10 +143,10 @@ public:
SimpleBlock(Cluster*, size_t, long long start, long long size);
bool EOS() const;
Cluster* GetCluster() const;
const Cluster* GetCluster() const;
size_t GetIndex() const;
const Block* GetBlock() const;
bool IsBFrame() const;
//bool IsBFrame() const;
protected:
Cluster* const m_pCluster;
@@ -145,10 +166,10 @@ public:
~BlockGroup();
bool EOS() const;
Cluster* GetCluster() const;
const Cluster* GetCluster() const;
size_t GetIndex() const;
const Block* GetBlock() const;
bool IsBFrame() const;
//bool IsBFrame() const;
short GetPrevTimeCode() const; //relative to block's time
short GetNextTimeCode() const; //as above
@@ -192,6 +213,7 @@ public:
const char* GetCodecNameAsUTF8() const;
const char* GetCodecId() const;
const unsigned char* GetCodecPrivate(size_t&) const;
bool GetLacing() const;
const BlockEntry* GetEOS() const;
@@ -211,7 +233,9 @@ public:
unsigned char* codecPrivate;
size_t codecPrivateSize;
char* codecNameAsUTF8;
bool lacing;
Settings settings;
Info();
void Clear();
};
@@ -294,8 +318,8 @@ public:
Tracks(Segment*, long long start, long long size);
virtual ~Tracks();
Track* GetTrackByNumber(unsigned long tn) const;
Track* GetTrackByIndex(unsigned long idx) const;
const Track* GetTrackByNumber(unsigned long tn) const;
const Track* GetTrackByIndex(unsigned long idx) const;
private:
Track** m_trackEntries;
@@ -334,18 +358,19 @@ private:
char* m_pTitleAsUTF8;
};
class Cues;
class CuePoint
{
friend class Cues;
CuePoint(size_t, long long);
~CuePoint();
CuePoint(const CuePoint&);
CuePoint& operator=(const CuePoint&);
public:
explicit CuePoint(long long);
~CuePoint();
//void Parse(IMkvReader*, long long start, long long size);
void Load(IMkvReader*, long long);
void Load(IMkvReader*);
long long GetTimeCode() const; //absolute but unscaled
long long GetTime(Segment*) const; //absolute and scaled (ns units)
@@ -365,7 +390,7 @@ public:
const TrackPosition* Find(const Track*) const;
private:
//long long m_pos;
const size_t m_index;
long long m_timecode;
TrackPosition* m_track_positions;
size_t m_track_positions_count;
@@ -375,6 +400,11 @@ private:
class Cues
{
friend class Segment;
Cues(Segment*, long long start, long long size);
~Cues();
Cues(const Cues&);
Cues& operator=(const Cues&);
@@ -383,9 +413,6 @@ public:
const long long m_start;
const long long m_size;
Cues(Segment*, long long start, long long size);
~Cues();
bool Find( //lower bound of time_ns
long long time_ns,
const Track*,
@@ -400,29 +427,23 @@ public:
const CuePoint::TrackPosition*&) const;
#endif
#if 0
const CuePoint* GetFirst() const;
const CuePoint* GetLast() const;
#endif
const CuePoint* GetNext(const CuePoint*) const;
bool LoadCuePoint();
#if 0
const CuePoint* LoadCuePoint(
long long time_ns,
const Track*,
const CuePoint::TrackPosition*&) const;
#endif
const BlockEntry* GetBlock(
const CuePoint*,
const CuePoint::TrackPosition*) const;
private:
void Init();
void PreloadCuePoint(size_t&, long long);
void Init() const;
bool LoadCuePoint() const;
void PreloadCuePoint(size_t&, long long) const;
CuePoint** m_cue_points;
//size_t m_cue_points_size;
size_t m_count;
size_t m_preload_count;
long long m_pos;
mutable CuePoint** m_cue_points;
mutable size_t m_count;
mutable size_t m_preload_count;
mutable long long m_pos;
};
@@ -434,7 +455,6 @@ class Cluster
public:
Segment* const m_pSegment;
long m_index;
public:
static Cluster* Parse(Segment*, long, long long off);
@@ -444,41 +464,46 @@ public:
bool EOS() const;
long long GetTimeCode(); //absolute, but not scaled
long long GetTime(); //absolute, and scaled (nanosecond units)
long long GetFirstTime(); //time (ns) of first (earliest) block
long long GetTimeCode() const; //absolute, but not scaled
long long GetTime() const; //absolute, and scaled (nanosecond units)
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* GetLast();
const BlockEntry* GetFirst() const;
const BlockEntry* GetLast() const;
const BlockEntry* GetNext(const BlockEntry*) const;
const BlockEntry* GetEntry(const Track*);
const BlockEntry* GetEntry(const Track*) const;
const BlockEntry* GetEntry(
const CuePoint&,
const CuePoint::TrackPosition&);
const BlockEntry* GetMaxKey(const VideoTrack*);
const CuePoint::TrackPosition&) const;
const BlockEntry* GetMaxKey(const VideoTrack*) const;
protected:
Cluster(Segment*, long, long long off);
public:
long long m_pos;
long long m_size;
//TODO: these should all be private, with public selector functions
long m_index;
mutable long long m_pos;
mutable long long m_size;
private:
long long m_timecode;
BlockEntry** m_entries;
size_t m_entriesCount;
mutable long long m_timecode;
mutable BlockEntry** m_entries;
mutable size_t m_entriesCount;
void Load();
void LoadBlockEntries();
void ParseBlockGroup(long long, long long, size_t);
void ParseSimpleBlock(long long, long long, size_t);
void Load() const;
void LoadBlockEntries() const;
void ParseBlockGroup(long long, long long, size_t) const;
void ParseSimpleBlock(long long, long long, size_t) const;
};
class Segment
{
friend class Cues;
Segment(const Segment&);
Segment& operator=(const Segment&);
@@ -501,34 +526,24 @@ public:
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;
bool AddCluster(Cluster*, long long);
#endif
long ParseCluster(long long& cluster_pos, long long& new_pos) const;
bool AddCluster(long long cluster_pos, long long new_pos);
Tracks* GetTracks() const;
const SegmentInfo* GetInfo() const;
const Cues* GetCues() 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;
const Cluster* GetFirst() const;
const Cluster* GetLast() const;
const Cluster* GetNext(const Cluster*);
Cluster* GetNext(const Cluster*);
Cluster* GetCluster(long long time_nanoseconds);
void GetCluster(
long long time_nanoseconds,
Track*,
Cluster*&,
const BlockEntry*&);
Cues* GetCues() const;
const Cluster* FindCluster(long long time_nanoseconds) const;
const BlockEntry* Seek(long long time_nanoseconds, const Track*) const;
private:
@@ -548,11 +563,9 @@ private:
void ParseSeekEntry(long long pos, long long size);
void ParseCues(long long);
bool SearchCues(
long long time_ns,
Track*,
Cluster*&,
const BlockEntry*&);
const BlockEntry* GetBlock(
const CuePoint&,
const CuePoint::TrackPosition&);
};