21 #include <speex/speex.h>
22 #include <speex/speex_header.h>
23 #include <speex/speex_stereo.h>
24 #include <speex/speex_callbacks.h>
43 const SpeexMode *
mode;
48 header = speex_packet_to_header(avctx->
extradata,
66 s->
pktsize = ((
const int[]){5,10,15,20,20,28,28,38,38,46,62})[quality];
71 avctx->
channels = header->nb_channels;
72 spx_mode = header->mode;
73 speex_header_free(header);
76 case 8000: spx_mode = 0;
break;
77 case 16000: spx_mode = 1;
break;
78 case 32000: spx_mode = 2;
break;
82 "Decoding as 32kHz ultra-wideband\n",
88 mode = speex_lib_get_mode(spx_mode);
100 "Decoding as stereo.\n", avctx->
channels);
106 speex_bits_init(&s->
bits);
115 callback.callback_id = SPEEX_INBAND_STEREO;
116 callback.func = speex_std_stereo_request_handler;
117 callback.data = &s->
stereo;
118 s->
stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
119 speex_decoder_ctl(s->
dec_state, SPEEX_SET_HANDLER, &callback);
126 int *got_frame_ptr,
AVPacket *avpkt)
129 int buf_size = avpkt->
size;
133 int ret, consumed = 0;
140 output = (int16_t *)frame->
data[0];
146 if (speex_bits_remaining(&s->
bits) < 5 ||
147 speex_bits_peek_unsigned(&s->
bits, 5) == 0xF) {
149 if (!buf || !buf_size) {
153 if (s->
pktsize && buf_size == 62)
156 speex_bits_read_from(&s->
bits, buf, buf_size);
157 consumed = avpkt->
size;
180 speex_bits_destroy(&s->
bits);
189 speex_bits_reset(&s->
bits);