merged Cues::LoadCuePoint into Cues::Find
Change-Id: I7b90dd076418b75e54b1d77bb4a934220019e9df
This commit is contained in:
@@ -1028,6 +1028,7 @@ long long Segment::ParseHeaders()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
long Segment::ParseCluster(Cluster*& pCluster, long long& pos_) const
|
long Segment::ParseCluster(Cluster*& pCluster, long long& pos_) const
|
||||||
{
|
{
|
||||||
pCluster = NULL;
|
pCluster = NULL;
|
||||||
@@ -1180,6 +1181,7 @@ bool Segment::AddCluster(Cluster* pCluster, long long pos)
|
|||||||
|
|
||||||
return (pos >= stop);
|
return (pos >= stop);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
long Segment::LoadCluster()
|
long Segment::LoadCluster()
|
||||||
@@ -1833,6 +1835,7 @@ void Cues::PreloadCuePoint(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
const CuePoint* Cues::GetFirst() const
|
const CuePoint* Cues::GetFirst() const
|
||||||
{
|
{
|
||||||
if (m_count < 1)
|
if (m_count < 1)
|
||||||
@@ -1859,6 +1862,7 @@ const CuePoint* Cues::GetLast() const
|
|||||||
|
|
||||||
return pCP;
|
return pCP;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
bool Cues::LoadCuePoint()
|
bool Cues::LoadCuePoint()
|
||||||
@@ -1931,16 +1935,14 @@ bool Cues::Find(
|
|||||||
assert(time_ns >= 0);
|
assert(time_ns >= 0);
|
||||||
assert(pTrack);
|
assert(pTrack);
|
||||||
|
|
||||||
if (m_count == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
assert(m_cue_points);
|
assert(m_cue_points);
|
||||||
|
assert(m_count > 0);
|
||||||
|
|
||||||
const CuePoint* const* const ii = m_cue_points;
|
CuePoint** const ii = m_cue_points;
|
||||||
const CuePoint* const* i = ii;
|
CuePoint** i = ii;
|
||||||
|
|
||||||
const CuePoint* const* const jj = ii + m_count;
|
CuePoint** const jj = ii + m_count + m_preload_count;
|
||||||
const CuePoint* const* j = jj;
|
CuePoint** j = jj;
|
||||||
|
|
||||||
pCP = *i;
|
pCP = *i;
|
||||||
assert(pCP);
|
assert(pCP);
|
||||||
@@ -1951,6 +1953,8 @@ bool Cues::Find(
|
|||||||
return (pTP != NULL);
|
return (pTP != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMkvReader* const pReader = m_pSegment->m_pReader;
|
||||||
|
|
||||||
while (i < j)
|
while (i < j)
|
||||||
{
|
{
|
||||||
//INVARIANT:
|
//INVARIANT:
|
||||||
@@ -1958,12 +1962,14 @@ bool Cues::Find(
|
|||||||
//[i, j) ?
|
//[i, j) ?
|
||||||
//[j, jj) > time_ns
|
//[j, jj) > time_ns
|
||||||
|
|
||||||
const CuePoint* const* const k = i + (j - i) / 2;
|
CuePoint** const k = i + (j - i) / 2;
|
||||||
assert(k < jj);
|
assert(k < jj);
|
||||||
|
|
||||||
pCP = *k;
|
CuePoint* const pCP = *k;
|
||||||
assert(pCP);
|
assert(pCP);
|
||||||
|
|
||||||
|
pCP->Load(pReader, 0);
|
||||||
|
|
||||||
const long long t = pCP->GetTime(m_pSegment);
|
const long long t = pCP->GetTime(m_pSegment);
|
||||||
|
|
||||||
if (t <= time_ns)
|
if (t <= time_ns)
|
||||||
@@ -1975,26 +1981,27 @@ bool Cues::Find(
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(i == j);
|
assert(i == j);
|
||||||
assert(i > ii);
|
|
||||||
assert(i <= jj);
|
assert(i <= jj);
|
||||||
|
assert(i > ii);
|
||||||
|
|
||||||
pCP = *--i;
|
pCP = *--i;
|
||||||
assert(pCP);
|
assert(pCP);
|
||||||
assert(pCP->GetTime(m_pSegment) <= time_ns);
|
assert(pCP->GetTime(m_pSegment) <= time_ns);
|
||||||
|
|
||||||
pTP = pCP->Find(pTrack);
|
|
||||||
return (pTP != NULL);
|
|
||||||
|
|
||||||
//TODO: here and elsewhere, it's probably not correct to search
|
//TODO: here and elsewhere, it's probably not correct to search
|
||||||
//for the cue point with this time, and the search for a matching
|
//for the cue point with this time, and then search for a matching
|
||||||
//track. In principle, the matching track could be on some earlier
|
//track. In principle, the matching track could be on some earlier
|
||||||
//cue point, and with our current algorithm, we'd miss it. To make
|
//cue point, and with our current algorithm, we'd miss it. To make
|
||||||
//this bullet-proof, we'd need to create a secondary structure,
|
//this bullet-proof, we'd need to create a secondary structure,
|
||||||
//with a list of cue points that apply to a track, and then search
|
//with a list of cue points that apply to a track, and then search
|
||||||
//that track-based structure for a matching cue point.
|
//that track-based structure for a matching cue point.
|
||||||
|
|
||||||
|
pTP = pCP->Find(pTrack);
|
||||||
|
return (pTP != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool Cues::FindNext(
|
bool Cues::FindNext(
|
||||||
long long time_ns,
|
long long time_ns,
|
||||||
const Track* pTrack,
|
const Track* pTrack,
|
||||||
@@ -2051,8 +2058,10 @@ bool Cues::FindNext(
|
|||||||
pTP = pCP->Find(pTrack);
|
pTP = pCP->Find(pTrack);
|
||||||
return (pTP != NULL);
|
return (pTP != NULL);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
const CuePoint* Cues::LoadCuePoint(
|
const CuePoint* Cues::LoadCuePoint(
|
||||||
long long time_ns,
|
long long time_ns,
|
||||||
const Track* pTrack,
|
const Track* pTrack,
|
||||||
@@ -2135,6 +2144,7 @@ const CuePoint* Cues::LoadCuePoint(
|
|||||||
|
|
||||||
return pCP;
|
return pCP;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
CuePoint::CuePoint(long long pos) :
|
CuePoint::CuePoint(long long pos) :
|
||||||
@@ -2789,25 +2799,6 @@ bool Segment::SearchCues(
|
|||||||
if (m_pCues == NULL)
|
if (m_pCues == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//odbgstream os;
|
|
||||||
//os << "SearchCues:: loading cue points; time[sec]="
|
|
||||||
// << (double(time_ns) / 1000000000)
|
|
||||||
// << endl;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
while (m_pCues->LoadCuePoint())
|
|
||||||
{
|
|
||||||
const CuePoint* const pCP = m_pCues->GetLast();
|
|
||||||
assert(pCP);
|
|
||||||
|
|
||||||
const long long ns = pCP->GetTime(this);
|
|
||||||
|
|
||||||
if (ns >= time_ns)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//os << "SearchCues:: loading cue points done" << endl;
|
|
||||||
|
|
||||||
const CuePoint* pCP;
|
const CuePoint* pCP;
|
||||||
const CuePoint::TrackPosition* pTP;
|
const CuePoint::TrackPosition* pTP;
|
||||||
|
|
||||||
@@ -2817,13 +2808,6 @@ bool Segment::SearchCues(
|
|||||||
assert(pCP);
|
assert(pCP);
|
||||||
assert(pTP);
|
assert(pTP);
|
||||||
assert(pTP->m_track == pTrack->GetNumber());
|
assert(pTP->m_track == pTrack->GetNumber());
|
||||||
#else
|
|
||||||
const CuePoint::TrackPosition* pTP;
|
|
||||||
const CuePoint* const pCP = m_pCues->LoadCuePoint(time_ns, pTrack, pTP);
|
|
||||||
assert(pCP);
|
|
||||||
assert(pTP);
|
|
||||||
assert(pTP->m_track == pTrack->GetNumber());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//We have the cue point and track position we want,
|
//We have the cue point and track position we want,
|
||||||
//so we now need to search for the cluster having
|
//so we now need to search for the cluster having
|
||||||
|
|||||||
@@ -392,21 +392,27 @@ public:
|
|||||||
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
|
||||||
|
|
||||||
|
#if 0
|
||||||
const CuePoint* GetFirst() const;
|
const CuePoint* GetFirst() const;
|
||||||
const CuePoint* GetLast() const;
|
const CuePoint* GetLast() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool LoadCuePoint();
|
bool LoadCuePoint();
|
||||||
|
|
||||||
|
#if 0
|
||||||
const CuePoint* LoadCuePoint(
|
const CuePoint* LoadCuePoint(
|
||||||
long long time_ns,
|
long long time_ns,
|
||||||
const Track*,
|
const Track*,
|
||||||
const CuePoint::TrackPosition*&) const;
|
const CuePoint::TrackPosition*&) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PreloadCuePoint(size_t&, long long);
|
void PreloadCuePoint(size_t&, long long);
|
||||||
@@ -494,10 +500,12 @@ 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(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;
|
||||||
|
|||||||
Reference in New Issue
Block a user