21 #include <speex/speex.h>
22 #include <speex/speex_header.h>
23 #include <speex/speex_stereo.h>
24 #include <speex/speex_callbacks.h>
26 #include "libavutil/channel_layout.h"
27 #include "libavutil/common.h"
42 const SpeexMode *
mode;
43 SpeexHeader *header = NULL;
48 header = speex_packet_to_header(avctx->
extradata,
65 avctx->
channels = header->nb_channels;
66 spx_mode = header->mode;
67 speex_header_free(header);
70 case 8000: spx_mode = 0;
break;
71 case 16000: spx_mode = 1;
break;
72 case 32000: spx_mode = 2;
break;
76 "Decoding as 32kHz ultra-wideband\n",
82 mode = speex_lib_get_mode(spx_mode);
94 "Decoding as stereo.\n", avctx->
channels);
100 speex_bits_init(&s->
bits);
109 callback.callback_id = SPEEX_INBAND_STEREO;
110 callback.func = speex_std_stereo_request_handler;
111 callback.data = &s->
stereo;
112 s->
stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
113 speex_decoder_ctl(s->
dec_state, SPEEX_SET_HANDLER, &callback);
120 int *got_frame_ptr,
AVPacket *avpkt)
123 int buf_size = avpkt->
size;
127 int ret, consumed = 0;
133 output = (int16_t *)frame->
data[0];
139 if (speex_bits_remaining(&s->
bits) < 5 ||
140 speex_bits_peek_unsigned(&s->
bits, 5) == 0xF) {
142 if (!buf || !buf_size) {
147 speex_bits_read_from(&s->
bits, buf, buf_size);
169 speex_bits_destroy(&s->
bits);
178 speex_bits_reset(&s->
bits);
#define AVERROR_PATCHWELCOME
static void callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time)
This structure describes decoded (raw) audio or video data.
AVCodec ff_libspeex_decoder
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_cold int init(AVCodecContext *avctx)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
#define AV_CH_LAYOUT_STEREO
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
enum AVSampleFormat sample_fmt
audio sample format
const char * name
Name of the codec implementation.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_cold void libspeex_decode_flush(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Libavcodec external API header.
uint64_t channel_layout
Audio channel layout.
static av_cold int libspeex_decode_init(AVCodecContext *avctx)
static void flush(AVCodecContext *avctx)
int sample_rate
samples per second
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static av_cold int libspeex_decode_close(AVCodecContext *avctx)
#define MKTAG(a, b, c, d)
static int libspeex_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
#define CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time...
common internal api header.
#define AVERROR_INVALIDDATA
int channels
number of audio channels
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.