1
0
Fork 0

matroskadec_haali: skip subtitle cues when seeking a video stream

The subtitle Cues are useless when seeking a video stream, so simply ignore them.
This commit is contained in:
Hendrik Leppkes 2015-04-08 13:07:20 +02:00
parent cb05e81e74
commit fc527fcf53
Signed by: hendrik
GPG Key ID: 846079A4B0A7C1B5
1 changed files with 26 additions and 0 deletions

View File

@ -3289,6 +3289,26 @@ void mkv_Seek_CueAware(MatroskaFile *mf, ulonglong timecode, unsigned flags, uns
mkv_Seek(mf, timecode, flags);
}
static inline int CueSuitableForSeeking(MatroskaFile *mf, int nCue) {
if (nCue < 0 || nCue >= mf->nCues)
return 0;
int nTrack = -1;
unsigned char nBestTrackType = TT_SUB;
for (int n = 0; n < mf->nTracks; ++n) {
if (!(mf->trackMask & (ULL(1)<<n)) && mf->Tracks[n]->Type < nBestTrackType)
nBestTrackType = mf->Tracks[n]->Type;
if (mf->Tracks[n]->Number == mf->Cues[nCue].Track)
nTrack = n;
}
if (nTrack >= 0 && nTrack < mf->nTracks && mf->Tracks[nTrack]->Type > nBestTrackType)
return 0;
return 1;
}
void mkv_Seek(MatroskaFile *mf,ulonglong timecode,unsigned flags) {
int i,j,m,ret;
unsigned n,z;
@ -3339,6 +3359,12 @@ void mkv_Seek(MatroskaFile *mf,ulonglong timecode,unsigned flags) {
// pass 1
for (;;) {
if (!CueSuitableForSeeking(mf, j)) {
// skip this Cue, re-start from previous
--j;
goto again;
}
for (n=0;n<mf->nTracks;++n) {
m_kftime[n] = MAXU64;
m_seendf[n] = 0;