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,
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);
83 "Decoding as stereo.\n", avctx->
channels);
89 speex_bits_init(&s->
bits);
97 SpeexCallback callback;
98 callback.callback_id = SPEEX_INBAND_STEREO;
99 callback.func = speex_std_stereo_request_handler;
100 callback.data = &s->
stereo;
101 s->
stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
102 speex_decoder_ctl(s->
dec_state, SPEEX_SET_HANDLER, &callback);
112 int *got_frame_ptr,
AVPacket *avpkt)
115 int buf_size = avpkt->
size;
118 int ret, consumed = 0;
132 if (speex_bits_remaining(&s->
bits) < 5 ||
133 speex_bits_peek_unsigned(&s->
bits, 5) == 0x1F) {
135 if (!buf || !buf_size) {
140 speex_bits_read_from(&s->
bits, buf, buf_size);
163 speex_bits_destroy(&s->
bits);
172 speex_bits_reset(&s->
bits);
This structure describes decoded (raw) audio or video data.
AVCodec ff_libspeex_decoder
AVFrame * coded_frame
the picture in the bitstream
#define AV_CH_LAYOUT_STEREO
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
enum AVSampleFormat sample_fmt
audio sample format
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int init(AVCodecParserContext *s)
static av_cold void libspeex_decode_flush(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
uint64_t channel_layout
Audio channel layout.
audio channel layout utility functions
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
#define CODEC_CAP_SUBFRAMES
static av_cold int libspeex_decode_init(AVCodecContext *avctx)
int sample_rate
samples per second
main external API structure.
static void close(AVCodecParserContext *s)
static av_cold int libspeex_decode_close(AVCodecContext *avctx)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
static int libspeex_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
common internal and external API header
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
#define AVERROR_INVALIDDATA
int channels
number of audio channels
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)