Revision 5358a81f

View differences:

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

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

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

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

  
......
1692 1697
    MatroskaTrack *tracks = matroska->tracks.elem;
1693 1698
    AVStream *st = s->streams[stream_index];
1694 1699
    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;
1695 1706

  
1696
    if (timestamp < 0)
1697
        timestamp = 0;
1707
    if (timestamp < first_timecode)
1708
        timestamp = first_timecode;
1698 1709

  
1699 1710
    if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
1700 1711
        if (st->nb_index_entries)

Also available in: Unified diff