Revision 6833385d libavcodec/libspeexdec.c

View differences:

libavcodec/libspeexdec.c
29 29
    SpeexStereoState stereo;
30 30
    void *dec_state;
31 31
    SpeexHeader *header;
32
    int frame_size;
32 33
} LibSpeexContext;
33 34

  
34 35

  
......
52 53
    if (s->header) {
53 54
        avctx->sample_rate = s->header->rate;
54 55
        avctx->channels    = s->header->nb_channels;
55
        avctx->frame_size  = s->header->frame_size;
56
        avctx->frame_size  = s->frame_size = s->header->frame_size;
56 57
        if (s->header->frames_per_packet)
57 58
            avctx->frame_size *= s->header->frames_per_packet;
58 59

  
......
76 77
        return -1;
77 78
    }
78 79

  
79
    if (!s->header)
80
    if (!s->header) {
80 81
        speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &avctx->frame_size);
82
        s->frame_size = avctx->frame_size;
83
    }
81 84

  
82 85
    if (avctx->channels == 2) {
83 86
        SpeexCallback callback;
......
100 103
    int16_t *output = data, *end;
101 104
    int i, num_samples;
102 105

  
103
    num_samples = s->header->frame_size * avctx->channels;
106
    num_samples = s->frame_size * avctx->channels;
104 107
    end = output + *data_size / sizeof(*output);
105 108

  
106 109
    speex_bits_read_from(&s->bits, buf, buf_size);
......
115 118
            break;
116 119

  
117 120
        if (avctx->channels == 2)
118
            speex_decode_stereo_int(output, s->header->frame_size, &s->stereo);
121
            speex_decode_stereo_int(output, s->frame_size, &s->stereo);
119 122

  
120 123
        output += num_samples;
121 124
    }
122 125

  
123
    avctx->frame_size = s->header->frame_size * i;
126
    avctx->frame_size = s->frame_size * i;
124 127
    *data_size = avctx->channels * avctx->frame_size * sizeof(*output);
125 128
    return buf_size;
126 129
}

Also available in: Unified diff