77 const float *in1,
const float *in2,
81 for (i = 0; i <
len; i++)
82 out[i] = in2[i] * window[i] + in1[i] * (1.0 - window[i]);
94 else if (ret != nb_samples) {
101 if (celt_size != nb_samples) {
130 static const float delay[16] = { 0.0 };
146 "Error feeding initial silence to the resampler.\n");
177 int redundancy_size, redundancy_pos;
178 int ret,
i, consumed;
226 redundancy_size = size - (consumed + 7) / 8;
227 size -= redundancy_size;
233 if (redundancy_pos) {
246 int celt_output_samples = samples;
256 out_tmp[
i] += delay_samples;
258 celt_output_samples -= delay_samples;
261 "Spurious CELT delay samples present.\n");
280 void *delaybuf[2] = { s->
celt_output[0] + celt_output_samples,
286 celt_output_samples);
304 if (!redundancy_pos) {
312 s->
cur_out[i] + samples - 120 + delayed_samples,
323 s->
cur_out[i] + 120 + delayed_samples,
333 const uint8_t *buf,
int buf_size,
336 int output_samples = 0;
337 int flush_needed = 0;
347 int64_t cur_samplerate;
355 if (!buf && !flush_needed)
411 return output_samples;
415 int *got_frame_ptr,
AVPacket *avpkt)
420 int buf_size = avpkt->
size;
421 int coded_samples = 0;
422 int decoded_samples = INT_MAX;
423 int delayed_samples = 0;
431 delayed_samples =
FFMAX(delayed_samples,
447 frame->
nb_samples = coded_samples + delayed_samples;
461 for (i = 0; i < avctx->
channels; i++) {
473 float sync_dummy[32];
474 int out_dummy = (!out[0]) | ((!out[1]) << 1);
511 "Mismatching coded sample count in substream %d.\n", i);
523 decoded_samples =
FFMIN(decoded_samples, ret);
533 if (buffer_samples) {
536 buf[0] += decoded_samples;
537 buf[1] += decoded_samples;
544 for (i = 0; i < avctx->
channels; i++) {
556 if (c->
gain_i && decoded_samples > 0) {
564 *got_frame_ptr = !!decoded_samples;
693 #define OFFSET(x) offsetof(OpusContext, x) 694 #define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM 696 {
"apply_phase_inv",
"Apply intensity stereo phase inversion",
OFFSET(apply_phase_inv),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
AD },
int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size, int self_delimiting)
Parse Opus packet info from raw packet data.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static av_cold int opus_decode_close(AVCodecContext *avctx)
int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, float **output, int channels, int frame_size, int start_band, int end_band)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
av_cold void swr_close(SwrContext *s)
Closes the context so that swr_is_initialized() returns 0.
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
Read data from an AVAudioFifo.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
static const uint16_t silk_frame_duration_ms[16]
int frame_count
frame count
float redundancy_buf[2][960]
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
static const AVOption opus_options[]
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
static int opus_decode_redundancy(OpusStreamContext *s, const uint8_t *data, int size)
const char * av_default_item_name(void *ptr)
Return the context name.
uint32_t ff_opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits)
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#define FF_ARRAY_ELEMS(a)
#define AV_CH_LAYOUT_STEREO
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Macro definitions for various function/variable attributes.
const uint8_t ff_celt_band_end[]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
void(* vector_fmac_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float and add to destination vector.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static int opus_flush_resample(OpusStreamContext *s, int nb_samples)
enum AVSampleFormat sample_fmt
audio sample format
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int opus_decode_frame(OpusStreamContext *s, const uint8_t *data, int size)
bitstream reader API header.
static void opus_fade(float *out, const float *in1, const float *in2, const float *window, int len)
static av_cold int opus_decode_init(AVCodecContext *avctx)
ChannelMap * channel_maps
libswresample public header
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void ff_celt_flush(CeltFrame *f)
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
const char * name
Name of the codec implementation.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
static SDL_Window * window
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
audio channel layout utility functions
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int frame_size[MAX_FRAMES]
frame sizes
int frame_duration
frame duration, in samples @ 48kHz
void ff_celt_free(CeltFrame **f)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int out_dummy_allocated_size
#define AV_EF_EXPLODE
abort decoding on minor error detection
static const AVClass opus_class
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
static int get_silk_samplerate(int config)
Libavcodec external API header.
int sample_rate
samples per second
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
void ff_silk_flush(SilkContext *s)
main external API structure.
const float ff_celt_window2[120]
int ff_silk_init(AVCodecContext *avctx, SilkContext **ps, int output_channels)
static av_always_inline uint32_t opus_rc_tell(const OpusRangeCoder *rc)
CELT: estimate bits of entropy that have thus far been consumed for the current CELT frame...
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int config
configuration: tells the audio mode, bandwidth, and frame duration
void ff_silk_free(SilkContext **ps)
Describe the class of an AVClass context structure.
void ff_opus_rc_dec_raw_init(OpusRangeCoder *rc, const uint8_t *rightend, uint32_t bytes)
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
const VDPAUPixFmtMap * map
static int opus_decode_subpacket(OpusStreamContext *s, const uint8_t *buf, int buf_size, int nb_samples)
int stereo
whether this packet is mono or stereo
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count, const uint8_t *in_arg[SWR_CH_MAX], int in_count)
int data_size
size of the useful data – packet size - padding
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
static int opus_decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
static int opus_init_resample(OpusStreamContext *s)
common internal api header.
static const int silk_resample_delay[]
int ff_silk_decode_superframe(SilkContext *s, OpusRangeCoder *rc, float *output[2], enum OpusBandwidth bandwidth, int coded_channels, int duration_ms)
Decode the LP layer of one Opus frame (which may correspond to several SILK frames).
OpusStreamContext * streams
int packet_size
packet size
OpusRangeCoder redundancy_rc
int ff_opus_rc_dec_init(OpusRangeCoder *rc, const uint8_t *data, int size)
int channels
number of audio channels
int frame_offset[MAX_FRAMES]
frame offsets
enum OpusBandwidth bandwidth
bandwidth
static av_cold void opus_decode_flush(AVCodecContext *ctx)
float * redundancy_output[2]
uint32_t ff_opus_rc_dec_uint(OpusRangeCoder *rc, uint32_t size)
CELT: read a uniform distribution.
av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, OpusContext *s)
Filter the word “frame” indicates either a video frame or a group of audio samples
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
uint8_t ** extended_data
pointers to the data planes/channels.
#define AV_CH_LAYOUT_MONO
int swr_is_initialized(struct SwrContext *s)
Check whether an swr context has been initialized or not.
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
int ff_celt_init(AVCodecContext *avctx, CeltFrame **f, int output_channels, int apply_phase_inv)
AVAudioFifo * sync_buffer
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
void * av_mallocz_array(size_t nmemb, size_t size)