SpeexStereoState stereo;
void *dec_state;
SpeexHeader *header;
+ int frame_size;
} LibSpeexContext;
if (s->header) {
avctx->sample_rate = s->header->rate;
avctx->channels = s->header->nb_channels;
- avctx->frame_size = s->header->frame_size;
+ avctx->frame_size = s->frame_size = s->header->frame_size;
+ if (s->header->frames_per_packet)
+ avctx->frame_size *= s->header->frames_per_packet;
mode = speex_lib_get_mode(s->header->mode);
if (!mode) {
return -1;
}
- if (!s->header)
- speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &avctx->frame_size);
+ if (!s->header) {
+ speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &s->frame_size);
+ }
if (avctx->channels == 2) {
SpeexCallback callback;
static int libspeex_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- const uint8_t *buf, int buf_size)
+ AVPacket *avpkt)
{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
LibSpeexContext *s = avctx->priv_data;
int16_t *output = data, *end;
int i, num_samples;
- num_samples = avctx->frame_size * avctx->channels;
- end = output + *data_size/2;
+ num_samples = s->frame_size * avctx->channels;
+ end = output + *data_size / sizeof(*output);
speex_bits_read_from(&s->bits, buf, buf_size);
break;
if (avctx->channels == 2)
- speex_decode_stereo_int(output, avctx->frame_size, &s->stereo);
+ speex_decode_stereo_int(output, s->frame_size, &s->stereo);
output += num_samples;
}
- *data_size = i * avctx->channels * avctx->frame_size * 2;
+ avctx->frame_size = s->frame_size * i;
+ *data_size = avctx->channels * avctx->frame_size * sizeof(*output);
return buf_size;
}
AVCodec libspeex_decoder = {
"libspeex",
- CODEC_TYPE_AUDIO,
+ AVMEDIA_TYPE_AUDIO,
CODEC_ID_SPEEX,
sizeof(LibSpeexContext),
libspeex_decode_init,