Compare commits

...

18 Commits

Author SHA1 Message Date
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
matthewjheaney
024ad97571 set version to 1.0.0.3
Change-Id: I629400289383482462dac5d0b00f9f615d83db89
2010-10-08 20:19:47 -04:00
matthewjheaney
8f2a2e04d7 load cue point during find
Change-Id: Ied0ea43c85cba47af61c0f60698df18c58389d0c
2010-10-08 20:08:15 -04:00
matthewjheaney
9105d61514 lazy init cues
Change-Id: I20e923bcc4be0dd607fb66a63c4f94b96854573e
2010-10-08 19:35:32 -04:00
matthewjheaney
77f61bdd68 merged Cues::LoadCuePoint into Cues::Find
Change-Id: I7b90dd076418b75e54b1d77bb4a934220019e9df
2010-10-08 19:06:20 -04:00
matthewjheaney
485b6e8125 lazy load cue points as they're searched
Change-Id: Ifa767e579624f4da06670bf791a85cbee4336682
2010-10-08 18:26:44 -04:00
matthewjheaney
1d0c804fb9 allow cue points to be loaded incrementally
Change-Id: I6c10647c8885d9dcb0d6cb10dd2d6ba94a04ea38
2010-10-07 19:07:48 -04:00
matthewjheaney
b607880184 mark position of cues without parsing cues element
Change-Id: I351ecca9dd82be95f8ef46f967983e612846ce87
2010-10-07 14:33:38 -04:00
matthewjheaney
d2688d316d restructured Segment::LoadCluster
Change-Id: Iaf792807445f3866f4ace4cc5663eb6396ac34be
2010-10-06 12:13:33 -04:00
matthewjheaney
885d2e1ef8 do not attempt to reparse cues element
Change-Id: Iebab4960f849fa65ecded360f73c0df8ebac4cc5
2010-10-05 20:42:28 -04:00
matthewjheaney
1cf3a81c78 allow seeking beyond end of cluster cache
Change-Id: I254039af3cb72039b5204f52d0dd613f7a47782d
2010-10-05 20:18:19 -04:00
matthewjheaney
6efbd56948 parse SeekHead to find Cues
Change-Id: I08334e48c587e08392c29dfa4118eb92eca7c25d
2010-10-05 14:12:15 -04:00
matthewjheaney
f56533b30e changed cluster count type from size_t to long
Change-Id: I1957e20b7f565d8e43ee3f983eaceb67f2ddf3cd
2010-10-04 13:55:03 -04:00
Jeff Koppi
ec2b951a78 Add Block::GetOffset() accessor.
Change-Id: I6172c412a8b2b093a365d634e48fcd7a09363111

Added accessor for Block, to query offset value.
2010-10-01 17:21:28 -04:00
2 changed files with 1134 additions and 522 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -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;
@@ -333,14 +334,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 +366,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 +376,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 +389,35 @@ 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* 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 +429,10 @@ class Cluster
public: public:
Segment* const m_pSegment; Segment* const m_pSegment;
const size_t m_index; long 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();
@@ -430,7 +453,7 @@ 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:
long long m_pos; long long m_pos;
@@ -438,7 +461,7 @@ public:
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 +474,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 +491,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*&);
}; };