diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-04-08 14:07:20 +0300 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2017-08-04 20:18:07 +0300 |
commit | 60066475c49a3031a31b3ad8fef011339990dec0 (patch) | |
tree | 130b6df928c60a7d871d38e3ee4d23dd06065520 | |
parent | 7b3164e5767bc2609cbf825deae9d17b25b462d7 (diff) |
matroskadec_haali: skip subtitle cues when seeking a video stream
The subtitle Cues are useless when seeking a video stream, so simply ignore them.
-rw-r--r-- | libavformat/MatroskaParser.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libavformat/MatroskaParser.c b/libavformat/MatroskaParser.c index 364c20ccc0..12ca04c483 100644 --- a/libavformat/MatroskaParser.c +++ b/libavformat/MatroskaParser.c @@ -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; |