121 "resample_out_buffer");
222 av_dlog(avr,
"[FIFO] add %s to out_fifo\n", converted->
name);
232 av_dlog(avr,
"[FIFO] read from out_fifo to output\n");
233 av_dlog(avr,
"[end conversion]\n");
237 }
else if (converted) {
240 av_dlog(avr,
"[copy] %s to output\n", converted->
name);
245 av_dlog(avr,
"[end conversion]\n");
248 av_dlog(avr,
"[end conversion]\n");
253 uint8_t **output,
int out_plane_size,
254 int out_samples,
uint8_t **input,
255 int in_plane_size,
int in_samples)
260 int ret, direct_output;
279 av_dlog(avr,
"[start conversion]\n");
299 current_buffer = &input_buffer;
305 av_dlog(avr,
"[copy] %s to output\n", current_buffer->
name);
318 av_dlog(avr,
"[convert] %s to in_buffer\n", current_buffer->
name);
324 av_dlog(avr,
"[copy] %s to in_buffer\n", current_buffer->
name);
331 av_dlog(avr,
"[downmix] in_buffer\n");
343 current_buffer =
NULL;
353 av_dlog(avr,
"[resample] %s to %s\n",
354 current_buffer ? current_buffer->
name :
"null",
363 av_dlog(avr,
"[end conversion]\n");
367 current_buffer = resample_out;
371 av_dlog(avr,
"[upmix] %s\n", current_buffer->
name);
378 if (current_buffer == &output_buffer) {
379 av_dlog(avr,
"[end conversion]\n");
384 if (direct_output && out_samples >= current_buffer->
nb_samples) {
386 av_dlog(avr,
"[convert] %s to output\n", current_buffer->
name);
391 av_dlog(avr,
"[end conversion]\n");
398 av_dlog(avr,
"[convert] %s to out_buffer\n", current_buffer->
name);
414 int in_channels, out_channels, i, o;
433 for (o = 0; o < out_channels; o++)
434 for (i = 0; i < in_channels; i++)
435 matrix[o * stride + i] = avr->
mix_matrix[o * in_channels + i];
443 int in_channels, out_channels, i, o;
464 for (o = 0; o < out_channels; o++)
465 for (i = 0; i < in_channels; i++)
466 avr->
mix_matrix[o * in_channels + i] = matrix[o * stride + i];
490 #define LICENSE_PREFIX "libavresample license: "
int in_channels
number of input channels
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AudioConvert * ac_in
input sample format conversion context
const char * name
name for debug logging
int ff_audio_data_realloc(AudioData *a, int nb_samples)
Reallocate AudioData.
#define LIBAVRESAMPLE_VERSION_INT
AudioData * out_buffer
buffer for converted output
Audio buffer used for intermediate storage between conversion phases.
memory handling functions
int ff_audio_data_add_to_fifo(AVAudioFifo *af, AudioData *a, int offset, int nb_samples)
Add samples in AudioData to an AVAudioFifo.
AudioData * ff_audio_data_alloc(int channels, int nb_samples, enum AVSampleFormat sample_fmt, const char *name)
Allocate AudioData.
int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples)
Read samples from the output FIFO.
double * mix_matrix
mix matrix only used if avresample_set_matrix() is called before avresample_open() ...
uint64_t out_channel_layout
output channel layout
int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in)
Convert audio data from one sample format to another.
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
int ff_audio_mix(AudioMix *am, AudioData *src)
Apply channel mixing to audio data using the current mixing matrix.
void avresample_free(AVAudioResampleContext **avr)
Free AVAudioResampleContext and associated AVOption values.
int nb_samples
current number of samples
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
AudioData * in_buffer
buffer for converted input
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
Read data from an AVAudioFifo.
int allocated_channels
allocated channel count
int out_channels
number of output channels
static int handle_buffered_output(AVAudioResampleContext *avr, AudioData *output, AudioData *converted)
int ff_audio_mix_set_matrix(AudioMix *am, const double *matrix, int stride)
Set the current mixing matrix.
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
Get the planar alternative form of the given sample format.
const char * avresample_license(void)
Return the libavresample license.
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
void avresample_close(AVAudioResampleContext *avr)
Close AVAudioResampleContext.
AudioMix * am
channel mixing context
int ff_audio_data_set_channels(AudioData *a, int channels)
int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src)
Resample audio data.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
int out_convert_needed
output sample format conversion is needed
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
void av_log(void *avcl, int level, const char *fmt,...)
void ff_audio_convert_free(AudioConvert **ac)
Free AudioConvert.
AudioConvert * ac_out
output sample format conversion context
int ff_audio_data_read_from_fifo(AVAudioFifo *af, AudioData *a, int nb_samples)
Read samples from an AVAudioFifo to AudioData.
#define LIBAV_CONFIGURATION
int upmix_needed
upmixing is needed
static void output_buffer(int16_t **samples, int nchan, int blocksize, int32_t **buffer)
ResampleContext * resample
resampling context
int ff_audio_data_copy(AudioData *dst, AudioData *src)
Copy data from one AudioData to another.
int ff_audio_data_init(AudioData *a, uint8_t **src, int plane_size, int channels, int nb_samples, enum AVSampleFormat sample_fmt, int read_only, const char *name)
Initialize AudioData using a given source.
uint64_t in_channel_layout
input channel layout
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
int avresample_set_matrix(AVAudioResampleContext *avr, const double *matrix, int stride)
Set channel mixing matrix.
AudioConvert * ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate)
Allocate and initialize AudioConvert context for sample format conversion.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
int in_sample_rate
input sample rate
#define attribute_align_arg
int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix, int stride)
Get the current channel mixing matrix.
int avresample_available(AVAudioResampleContext *avr)
Return the number of available samples in the output FIFO.
void ff_audio_resample_free(ResampleContext **c)
Free a ResampleContext.
AVAudioFifo * out_fifo
FIFO for output samples.
#define AVRESAMPLE_MAX_CHANNELS
enum AVSampleFormat internal_sample_fmt
internal sample format
int force_resampling
force resampling
void ff_audio_mix_free(AudioMix **am_p)
Free an AudioMix context.
const char * avresample_configuration(void)
Return the libavresample build-time configuration.
ResampleContext * ff_audio_resample_init(AVAudioResampleContext *avr)
Allocate and initialize a ResampleContext.
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
enum AVSampleFormat in_sample_fmt
input sample format
int attribute_align_arg avresample_convert(AVAudioResampleContext *avr, uint8_t **output, int out_plane_size, int out_samples, uint8_t **input, int in_plane_size, int in_samples)
Convert input samples and write them to the output FIFO.
int in_convert_needed
input sample format conversion is needed
enum AVSampleFormat out_sample_fmt
output sample format
void av_opt_free(void *obj)
Free all string and binary options in obj.
common internal and external API header
int resample_channels
number of channels used for resampling
AudioData * resample_out_buffer
buffer for output from resampler
int resample_needed
resampling is needed
AVSampleFormat
Audio Sample Formats.
AudioMix * ff_audio_mix_alloc(AVAudioResampleContext *avr)
Allocate and initialize an AudioMix context.
unsigned avresample_version(void)
Return the LIBAVRESAMPLE_VERSION_INT constant.
int allocated_samples
number of samples the buffer can hold
int out_sample_rate
output sample rate
void ff_audio_data_free(AudioData **a)
Free AudioData.
int downmix_needed
downmixing is needed
int avresample_open(AVAudioResampleContext *avr)
Initialize AVAudioResampleContext.
int mixing_needed
either upmixing or downmixing is needed
int ff_audio_mix_get_matrix(AudioMix *am, double *matrix, int stride)
Get the current mixing matrix.
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)