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;
44 SpeexHeader *header =
NULL;
49 header = speex_packet_to_header(avctx->
extradata,
56 avctx->
channels = header->nb_channels;
57 spx_mode = header->mode;
58 speex_header_free(header);
61 case 8000: spx_mode = 0;
break;
62 case 16000: spx_mode = 1;
break;
63 case 32000: spx_mode = 2;
break;
67 "Decoding as 32kHz ultra-wideband\n",
73 mode = speex_lib_get_mode(spx_mode);
85 "Decoding as stereo.\n", avctx->
channels);
91 speex_bits_init(&s->
bits);
100 callback.callback_id = SPEEX_INBAND_STEREO;
101 callback.func = speex_std_stereo_request_handler;
102 callback.data = &s->
stereo;
103 s->
stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
104 speex_decoder_ctl(s->
dec_state, SPEEX_SET_HANDLER, &callback);
114 int *got_frame_ptr,
AVPacket *avpkt)
117 int buf_size = avpkt->
size;
120 int ret, consumed = 0;
134 if (speex_bits_remaining(&s->
bits) < 5 ||
135 speex_bits_peek_unsigned(&s->
bits, 5) == 0xF) {
137 if (!buf || !buf_size) {
142 speex_bits_read_from(&s->
bits, buf, buf_size);
165 speex_bits_destroy(&s->
bits);
174 speex_bits_reset(&s->
bits);