84 #include <speex/speex.h>
85 #include <speex/speex_header.h>
86 #include <speex/speex_stereo.h>
114 const char *mode_str =
"unknown";
118 case SPEEX_MODEID_NB: mode_str =
"narrowband";
break;
119 case SPEEX_MODEID_WB: mode_str =
"wideband";
break;
120 case SPEEX_MODEID_UWB: mode_str =
"ultra-wideband";
break;
148 const SpeexMode *
mode;
156 "mono are supported\n", avctx->
channels);
162 case 8000: mode = &speex_nb_mode;
break;
163 case 16000: mode = &speex_wb_mode;
break;
164 case 32000: mode = &speex_uwb_mode;
break;
167 "Resample to 8, 16, or 32 kHz.\n", avctx->
sample_rate);
193 speex_encoder_ctl(s->
enc_state, SPEEX_SET_ABR,
195 speex_encoder_ctl(s->
enc_state, SPEEX_GET_ABR,
198 speex_encoder_ctl(s->
enc_state, SPEEX_SET_BITRATE,
200 speex_encoder_ctl(s->
enc_state, SPEEX_GET_BITRATE,
205 speex_encoder_ctl(s->
enc_state, SPEEX_SET_QUALITY,
207 speex_encoder_ctl(s->
enc_state, SPEEX_GET_BITRATE,
217 speex_encoder_ctl(s->
enc_state, SPEEX_SET_VAD, &s->
vad);
221 speex_encoder_ctl(s->
enc_state, SPEEX_SET_DTX, &s->
dtx);
229 speex_encoder_ctl(s->
enc_state, SPEEX_SET_COMPLEXITY, &complexity);
231 speex_encoder_ctl(s->
enc_state, SPEEX_GET_COMPLEXITY, &complexity);
239 speex_encoder_ctl(s->
enc_state, SPEEX_GET_LOOKAHEAD, &avctx->
delay);
245 header_data = speex_header_to_packet(&s->
header, &header_size);
250 speex_header_free(header_data);
255 #if FF_API_OLD_ENCODE_AUDIO
259 speex_header_free(header_data);
267 memcpy(avctx->
extradata, header_data, header_size);
269 speex_header_free(header_data);
272 speex_bits_init(&s->
bits);
288 speex_encode_stereo_int(samples, s->
header.frame_size, &s->
bits);
299 speex_bits_pack(&s->
bits, 15, 5);
309 ret = speex_bits_write(&s->
bits, avpkt->
data, avpkt->
size);
310 speex_bits_reset(&s->
bits);
327 speex_bits_destroy(&s->
bits);
331 #if FF_API_OLD_ENCODE_AUDIO
339 #define OFFSET(x) offsetof(LibSpeexEncContext, x)
340 #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
343 {
"cbr_quality",
"Set quality value (0 to 10) for CBR",
OFFSET(cbr_quality),
AV_OPT_TYPE_INT, { .i64 = 8 }, 0, 10,
AE },
344 {
"frames_per_packet",
"Number of frames to encode in each packet",
OFFSET(frames_per_packet),
AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 8,
AE },
359 {
"compression_level",
"3" },
377 .supported_samplerates = (
const int[]){ 8000, 16000, 32000, 0 },
379 .priv_class = &
class,