Revision 8f8320d7 libavformat/oggparsespeex.c

View differences:

libavformat/oggparsespeex.c
32 32

  
33 33
struct speex_params {
34 34
    int final_packet_duration;
35
    int seq;
35 36
};
36 37

  
37 38
static int speex_header(AVFormatContext *s, int idx) {
38 39
    struct ogg *ogg = s->priv_data;
39 40
    struct ogg_stream *os = ogg->streams + idx;
41
    struct speex_params *spxp = os->private;
40 42
    AVStream *st = s->streams[idx];
41 43
    uint8_t *p = os->buf + os->pstart;
42 44

  
43
    if (os->seq > 1)
45
    if (!spxp) {
46
        spxp = av_mallocz(sizeof(*spxp));
47
        os->private = spxp;
48
    }
49

  
50
    if (spxp->seq > 1)
44 51
        return 0;
45 52

  
46
    if (os->seq == 0) {
53
    if (spxp->seq == 0) {
47 54
        int frames_per_packet;
48 55
        st->codec->codec_type = CODEC_TYPE_AUDIO;
49 56
        st->codec->codec_id = CODEC_ID_SPEEX;
......
70 77
    } else
71 78
        vorbis_comment(s, p, os->psize);
72 79

  
80
    spxp->seq++;
73 81
    return 1;
74 82
}
75 83

  
......
90 98
    struct speex_params *spxp = os->private;
91 99
    int packet_size = s->streams[idx]->codec->frame_size;
92 100

  
93
    if (!spxp) {
94
        spxp = av_mallocz(sizeof(*spxp));
95
        os->private = spxp;
96
    }
97

  
98 101
    if (os->flags & OGG_FLAG_EOS && os->lastpts != AV_NOPTS_VALUE &&
99 102
        os->granule > 0) {
100 103
        /* first packet of final page. we have to calculate the final packet

Also available in: Unified diff