Revision fc4d335f

View differences:

libavformat/matroskadec.c
95 95
     * the calling app uses for this track. */
96 96
    uint32_t num;
97 97
    uint32_t uid;
98
    int stream_index;
99 98

  
100 99
    char *name;
101 100
    char language[4];
......
113 112
    MatroskaTrackEncodingCompAlgo encoding_algo;
114 113
    uint8_t *encoding_settings;
115 114
    int encoding_settings_len;
115

  
116
    AVStream *stream;
116 117
} MatroskaTrack;
117 118

  
118 119
typedef struct MatroskaVideoTrack {
......
2549 2550
            int extradata_size = 0;
2550 2551
            int extradata_offset = 0;
2551 2552
            track = matroska->tracks[i];
2552
            track->stream_index = -1;
2553 2553

  
2554 2554
            /* Apply some sanity checks. */
2555 2555
            if (track->codec_id == NULL)
......
2681 2681
                       track->codec_id);
2682 2682
            }
2683 2683

  
2684
            track->stream_index = matroska->num_streams;
2685

  
2686
            matroska->num_streams++;
2687
            st = av_new_stream(s, track->stream_index);
2684
            st = track->stream = av_new_stream(s, matroska->num_streams++);
2688 2685
            if (st == NULL)
2689 2686
                return AVERROR(ENOMEM);
2690 2687
            av_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */
......
2752 2749
            MatroskaDemuxIndex *idx = &matroska->index[i];
2753 2750
            track = matroska_find_track_by_num(matroska, idx->track);
2754 2751
            if (track < 0)  continue;
2755
            stream = matroska->tracks[track]->stream_index;
2752
            stream = matroska->tracks[track]->stream->index;
2756 2753
            if (stream >= 0 && stream < matroska->ctx->nb_streams)
2757 2754
                av_add_index_entry(matroska->ctx->streams[stream],
2758 2755
                                   idx->pos, idx->time/AV_TIME_BASE,
......
2777 2774
    uint32_t *lace_size = NULL;
2778 2775
    int n, flags, laces = 0;
2779 2776
    uint64_t num;
2780
    int stream_index;
2781 2777

  
2782 2778
    /* first byte(s): tracknum */
2783 2779
    if ((n = matroska_ebmlnum_uint(data, size, &num)) < 0) {
......
2796 2792
        av_free(origdata);
2797 2793
        return res;
2798 2794
    }
2799
    stream_index = matroska->tracks[track]->stream_index;
2800
    if (stream_index < 0 || stream_index >= matroska->ctx->nb_streams) {
2801
        av_free(origdata);
2802
        return res;
2803
    }
2804
    st = matroska->ctx->streams[stream_index];
2795
    st = matroska->tracks[track]->stream;
2805 2796
    if (st->discard >= AVDISCARD_ALL) {
2806 2797
        av_free(origdata);
2807 2798
        return res;
......
2941 2932
                    memcpy(pkt->data, audiotrack->buf
2942 2933
                           + a * (h*w / a - audiotrack->pkt_cnt--), a);
2943 2934
                    pkt->pos = pos;
2944
                    pkt->stream_index = stream_index;
2935
                    pkt->stream_index = st->index;
2945 2936
                    matroska_queue_packet(matroska, pkt);
2946 2937
                }
2947 2938
            } else {
......
2972 2963

  
2973 2964
                if (n == 0)
2974 2965
                    pkt->flags = is_keyframe;
2975
                pkt->stream_index = stream_index;
2966
                pkt->stream_index = st->index;
2976 2967

  
2977 2968
                pkt->pts = timecode;
2978 2969
                pkt->pos = pos;

Also available in: Unified diff