21 #include <speex/speex.h>
22 #include <speex/speex_header.h>
23 #include <speex/speex_stereo.h>
24 #include <speex/speex_callbacks.h>
42 const SpeexMode *
mode;
43 SpeexHeader *header =
NULL;
48 header = speex_packet_to_header(avctx->
extradata,
55 avctx->
channels = header->nb_channels;
56 spx_mode = header->mode;
57 speex_header_free(header);
60 case 8000: spx_mode = 0;
break;
61 case 16000: spx_mode = 1;
break;
62 case 32000: spx_mode = 2;
break;
66 "Decoding as 32kHz ultra-wideband\n",
72 mode = speex_lib_get_mode(spx_mode);
84 "Decoding as stereo.\n", avctx->
channels);
90 speex_bits_init(&s->
bits);
99 callback.callback_id = SPEEX_INBAND_STEREO;
100 callback.func = speex_std_stereo_request_handler;
101 callback.data = &s->
stereo;
102 s->
stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
103 speex_decoder_ctl(s->
dec_state, SPEEX_SET_HANDLER, &callback);
110 int *got_frame_ptr,
AVPacket *avpkt)
113 int buf_size = avpkt->
size;
117 int ret, consumed = 0;
125 output = (int16_t *)frame->
data[0];
131 if (speex_bits_remaining(&s->
bits) < 5 ||
132 speex_bits_peek_unsigned(&s->
bits, 5) == 0xF) {
134 if (!buf || !buf_size) {
139 speex_bits_read_from(&s->
bits, buf, buf_size);
161 speex_bits_destroy(&s->
bits);
170 speex_bits_reset(&s->
bits);