made Cues member variables mutable
Change-Id: I405b845f37c9deaffd67e50752fb9b2aa7124484
This commit is contained in:
126
mkvparser.cpp
126
mkvparser.cpp
@@ -1740,7 +1740,7 @@ Cues::~Cues()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cues::Init()
|
void Cues::Init() const
|
||||||
{
|
{
|
||||||
if (m_cue_points)
|
if (m_cue_points)
|
||||||
return;
|
return;
|
||||||
@@ -1780,14 +1780,12 @@ void Cues::Init()
|
|||||||
pos += size; //consume payload
|
pos += size; //consume payload
|
||||||
assert(pos <= stop);
|
assert(pos <= stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadCuePoint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cues::PreloadCuePoint(
|
void Cues::PreloadCuePoint(
|
||||||
size_t& cue_points_size,
|
size_t& cue_points_size,
|
||||||
long long pos)
|
long long pos) const
|
||||||
{
|
{
|
||||||
assert(m_count == 0);
|
assert(m_count == 0);
|
||||||
|
|
||||||
@@ -1837,37 +1835,7 @@ void Cues::PreloadCuePoint(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
bool Cues::LoadCuePoint() const
|
||||||
const CuePoint* Cues::GetFirst() const
|
|
||||||
{
|
|
||||||
if (m_count < 1)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
CuePoint* const pCP = m_cue_points[0];
|
|
||||||
assert(pCP);
|
|
||||||
assert(pCP->GetTimeCode() >= 0);
|
|
||||||
|
|
||||||
return pCP;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const CuePoint* Cues::GetLast() const
|
|
||||||
{
|
|
||||||
if (m_count < 1)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
const size_t idx = m_count - 1;
|
|
||||||
|
|
||||||
CuePoint* const pCP = m_cue_points[idx];
|
|
||||||
assert(pCP);
|
|
||||||
assert(pCP->GetTimeCode() >= 0);
|
|
||||||
|
|
||||||
return pCP;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
bool Cues::LoadCuePoint()
|
|
||||||
{
|
{
|
||||||
//odbgstream os;
|
//odbgstream os;
|
||||||
//os << "Cues::LoadCuePoint" << endl;
|
//os << "Cues::LoadCuePoint" << endl;
|
||||||
@@ -1936,7 +1904,7 @@ bool Cues::Find(
|
|||||||
assert(time_ns >= 0);
|
assert(time_ns >= 0);
|
||||||
assert(pTrack);
|
assert(pTrack);
|
||||||
|
|
||||||
const_cast<Cues*>(this)->LoadCuePoint();
|
LoadCuePoint();
|
||||||
|
|
||||||
assert(m_cue_points);
|
assert(m_cue_points);
|
||||||
assert(m_count > 0);
|
assert(m_count > 0);
|
||||||
@@ -2064,92 +2032,6 @@ bool Cues::FindNext(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
const CuePoint* Cues::LoadCuePoint(
|
|
||||||
long long time_ns,
|
|
||||||
const Track* pTrack,
|
|
||||||
const CuePoint::TrackPosition*& pTP) const
|
|
||||||
{
|
|
||||||
assert(time_ns >= 0);
|
|
||||||
assert(pTrack);
|
|
||||||
|
|
||||||
//odbgstream os;
|
|
||||||
//os << "Cues::LoadCuePoint: time[sec]="
|
|
||||||
// << (double(time_ns) / 1000000000)
|
|
||||||
// << " count=" << m_count
|
|
||||||
// << " preload_count=" << m_preload_count
|
|
||||||
// << endl;
|
|
||||||
|
|
||||||
if (m_count > 0)
|
|
||||||
{
|
|
||||||
const CuePoint* pCP = GetLast();
|
|
||||||
assert(pCP);
|
|
||||||
|
|
||||||
const long long ns = pCP->GetTime(m_pSegment);
|
|
||||||
|
|
||||||
if ((ns >= time_ns) || (m_preload_count == 0))
|
|
||||||
{
|
|
||||||
const bool bFound = Find(time_ns, pTrack, pCP, pTP);
|
|
||||||
assert(bFound); //TODO
|
|
||||||
assert(pCP);
|
|
||||||
assert(pTP);
|
|
||||||
|
|
||||||
return pCP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(m_preload_count > 0);
|
|
||||||
assert(m_cue_points);
|
|
||||||
|
|
||||||
IMkvReader* const pReader = m_pSegment->m_pReader;
|
|
||||||
|
|
||||||
CuePoint** const ii = m_cue_points + m_count;
|
|
||||||
CuePoint** i = ii;
|
|
||||||
|
|
||||||
CuePoint** const jj = ii + m_preload_count;
|
|
||||||
CuePoint** j = jj;
|
|
||||||
|
|
||||||
while (i < j)
|
|
||||||
{
|
|
||||||
//INVARIANT:
|
|
||||||
//[ii, i) <= time_ns
|
|
||||||
//[i, j) ?
|
|
||||||
//[j, jj) > time_ns
|
|
||||||
|
|
||||||
CuePoint** const k = i + (j - i) / 2;
|
|
||||||
assert(k < jj);
|
|
||||||
|
|
||||||
CuePoint* const pCP = *k;
|
|
||||||
assert(pCP);
|
|
||||||
|
|
||||||
pCP->Load(pReader, 0);
|
|
||||||
|
|
||||||
const long long t = pCP->GetTime(m_pSegment);
|
|
||||||
|
|
||||||
if (t <= time_ns)
|
|
||||||
i = k + 1;
|
|
||||||
else
|
|
||||||
j = k;
|
|
||||||
|
|
||||||
assert(i <= j);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(i == j);
|
|
||||||
assert(i <= jj);
|
|
||||||
assert(i > m_cue_points);
|
|
||||||
|
|
||||||
const CuePoint* const pCP = *--i;
|
|
||||||
assert(pCP);
|
|
||||||
assert(pCP->GetTime(m_pSegment) <= time_ns);
|
|
||||||
|
|
||||||
pTP = pCP->Find(pTrack);
|
|
||||||
assert(pTP); //TODO
|
|
||||||
|
|
||||||
return pCP;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
CuePoint::CuePoint(long long pos) :
|
CuePoint::CuePoint(long long pos) :
|
||||||
m_timecode(-1 * pos),
|
m_timecode(-1 * pos),
|
||||||
m_track_positions(NULL),
|
m_track_positions(NULL),
|
||||||
|
|||||||
@@ -400,29 +400,15 @@ public:
|
|||||||
const CuePoint::TrackPosition*&) const;
|
const CuePoint::TrackPosition*&) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
const CuePoint* GetFirst() const;
|
|
||||||
const CuePoint* GetLast() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool LoadCuePoint();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
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;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user