Revision a8fd7e76

View differences:

libavformat/matroskadec.c
139 139
    EbmlList encodings;
140 140

  
141 141
    AVStream *stream;
142
    int64_t first_timecode;
143 142
    int64_t end_timecode;
144 143
} MatroskaTrack;
145 144

  
......
1182 1181
        st = track->stream = av_new_stream(s, 0);
1183 1182
        if (st == NULL)
1184 1183
            return AVERROR(ENOMEM);
1185
        track->first_timecode = AV_NOPTS_VALUE;
1186 1184

  
1187 1185
        if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")
1188 1186
            && track->codec_priv.size >= 40
......
1468 1466
        if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE
1469 1467
            && timecode < track->end_timecode)
1470 1468
            is_keyframe = 0;  /* overlapping subtitles are not key frame */
1471
        if (is_keyframe) {
1469
        if (is_keyframe)
1472 1470
            av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME);
1473
            if (track->first_timecode == AV_NOPTS_VALUE)
1474
                track->first_timecode = timecode;
1475
        }
1476 1471
        track->end_timecode = FFMAX(track->end_timecode, timecode+duration);
1477 1472
    }
1478 1473

  
......
1697 1692
    MatroskaTrack *tracks = matroska->tracks.elem;
1698 1693
    AVStream *st = s->streams[stream_index];
1699 1694
    int i, index, index_sub, index_min;
1700
    int64_t first_timecode = 0;
1701

  
1702
    for (i=0; i < matroska->tracks.nb_elem; i++)
1703
        if (tracks[i].stream->index == stream_index &&
1704
            tracks[i].first_timecode != AV_NOPTS_VALUE)
1705
            first_timecode = tracks[i].first_timecode;
1706 1695

  
1707
    if (timestamp < first_timecode)
1708
        timestamp = first_timecode;
1696
    if (!st->nb_index_entries)
1697
        return 0;
1698
    timestamp = FFMAX(timestamp, st->index_entries[0].timestamp);
1709 1699

  
1710 1700
    if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
1711
        if (st->nb_index_entries)
1712
            url_fseek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET);
1701
        url_fseek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET);
1713 1702
        while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
1714 1703
            matroska_clear_queue(matroska);
1715 1704
            if (matroska_parse_cluster(matroska) < 0)

Also available in: Unified diff