Revision c1658257

View differences:

libavformat/matroskadec.c
1471 1471
        track->end_timecode = FFMAX(track->end_timecode, timecode+duration);
1472 1472
    }
1473 1473

  
1474
    if (matroska->skip_to_keyframe) {
1474
    if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
1475 1475
        if (!is_keyframe || timecode < matroska->skip_to_timecode)
1476 1476
            return res;
1477 1477
        matroska->skip_to_keyframe = 0;
......
1689 1689
                              int64_t timestamp, int flags)
1690 1690
{
1691 1691
    MatroskaDemuxContext *matroska = s->priv_data;
1692
    MatroskaTrack *tracks = matroska->tracks.elem;
1692 1693
    AVStream *st = s->streams[stream_index];
1693
    int index;
1694
    int i, index, index_sub, index_min;
1694 1695

  
1695 1696
    if (timestamp < 0)
1696 1697
        timestamp = 0;
......
1709 1710
    if (index < 0)
1710 1711
        return 0;
1711 1712

  
1712
    url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET);
1713
    index_min = index;
1714
    for (i=0; i < matroska->tracks.nb_elem; i++) {
1715
        tracks[i].end_timecode = 0;
1716
        if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE
1717
            && !tracks[i].stream->discard != AVDISCARD_ALL) {
1718
            index_sub = av_index_search_timestamp(tracks[i].stream, st->index_entries[index].timestamp, AVSEEK_FLAG_BACKWARD);
1719
            if (index_sub >= 0
1720
                && st->index_entries[index_sub].pos < st->index_entries[index_min].pos
1721
                && st->index_entries[index].timestamp - st->index_entries[index_sub].timestamp < 30000000000/matroska->time_scale)
1722
                index_min = index_sub;
1723
        }
1724
    }
1725

  
1726
    url_fseek(s->pb, st->index_entries[index_min].pos, SEEK_SET);
1713 1727
    matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY);
1714 1728
    matroska->skip_to_timecode = st->index_entries[index].timestamp;
1715 1729
    matroska->done = 0;

Also available in: Unified diff