130 av_dlog(avr,
"remap channels during in_copy\n");
133 av_dlog(avr,
"remap channels during in_convert\n");
136 av_dlog(avr,
"remap channels during out_convert\n");
139 av_dlog(avr,
"remap channels during out_copy\n");
188 "resample_out_buffer");
293 av_dlog(avr,
"[FIFO] add %s to out_fifo\n", converted->
name);
303 av_dlog(avr,
"[FIFO] read from out_fifo to output\n");
304 av_dlog(avr,
"[end conversion]\n");
308 }
else if (converted) {
311 av_dlog(avr,
"[copy] %s to output\n", converted->
name);
318 av_dlog(avr,
"[end conversion]\n");
321 av_dlog(avr,
"[end conversion]\n");
326 uint8_t **output,
int out_plane_size,
327 int out_samples,
uint8_t **input,
328 int in_plane_size,
int in_samples)
333 int ret, direct_output;
352 av_dlog(avr,
"[start conversion]\n");
372 current_buffer = &input_buffer;
378 av_dlog(avr,
"[copy] %s to output\n", current_buffer->
name);
386 (!direct_output || out_samples < in_samples)) {
390 av_dlog(avr,
"[copy] %s to out_buffer\n", current_buffer->
name);
404 av_dlog(avr,
"[convert] %s to in_buffer\n", current_buffer->
name);
410 av_dlog(avr,
"[copy] %s to in_buffer\n", current_buffer->
name);
419 av_dlog(avr,
"[downmix] in_buffer\n");
431 current_buffer =
NULL;
441 av_dlog(avr,
"[resample] %s to %s\n",
442 current_buffer ? current_buffer->
name :
"null",
451 av_dlog(avr,
"[end conversion]\n");
455 current_buffer = resample_out;
459 av_dlog(avr,
"[upmix] %s\n", current_buffer->
name);
466 if (current_buffer == &output_buffer) {
467 av_dlog(avr,
"[end conversion]\n");
472 if (direct_output && out_samples >= current_buffer->
nb_samples) {
474 av_dlog(avr,
"[convert] %s to output\n", current_buffer->
name);
479 av_dlog(avr,
"[end conversion]\n");
486 av_dlog(avr,
"[convert] %s to out_buffer\n", current_buffer->
name);
502 int in_channels, out_channels, i, o;
521 for (o = 0; o < out_channels; o++)
522 for (i = 0; i < in_channels; i++)
523 matrix[o * stride + i] = avr->
mix_matrix[o * in_channels + i];
531 int in_channels, out_channels, i, o;
552 for (o = 0; o < out_channels; o++)
553 for (i = 0; i < in_channels; i++)
554 avr->
mix_matrix[o * in_channels + i] = matrix[o * stride + i];
560 const int *channel_map)
563 int in_channels, ch, i;
571 memset(info, 0,
sizeof(*info));
574 for (ch = 0; ch < in_channels; ch++) {
575 if (channel_map[ch] >= in_channels) {
579 if (channel_map[ch] < 0) {
583 }
else if (info->
input_map[channel_map[ch]] >= 0) {
596 for (ch = 0, i = 0; ch < in_channels && i < in_channels; ch++, i++) {
597 while (ch < in_channels && info->input_map[ch] >= 0)
599 while (i < in_channels && info->channel_map[i] >= 0)
601 if (ch >= in_channels || i >= in_channels)
629 #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
int input_map[AVRESAMPLE_MAX_CHANNELS]
dest index of each input channel
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.
int do_zero
zeroing needed
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 avresample_set_channel_mapping(AVAudioResampleContext *avr, const int *channel_map)
Set a customized input channel mapping.
int ff_audio_mix(AudioMix *am, AudioData *src)
Apply channel mixing to audio data using the current mixing matrix.
int channel_zero[AVRESAMPLE_MAX_CHANNELS]
dest index to zero
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.
AudioConvert * ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map)
Allocate and initialize AudioConvert context for sample format conversion.
void avresample_close(AVAudioResampleContext *avr)
Close AVAudioResampleContext.
AudioMix * am
channel mixing context
int ff_audio_data_set_channels(AudioData *a, int channels)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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 channel_copy[AVRESAMPLE_MAX_CHANNELS]
dest index to copy from
int upmix_needed
upmixing is needed
static void output_buffer(int16_t **samples, int nchan, int blocksize, int32_t **buffer)
ResampleContext * resample
resampling context
enum RemapPoint remap_point
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.
ChannelMapInfo ch_map_info
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.
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.
AVAudioFifo * out_fifo
FIFO for output samples.
ResampleContext * ff_audio_resample_init(AVAudioResampleContext *avr)
Allocate and initialize a ResampleContext.
#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.
int in_copy_needed
input data copy is needed
const char * avresample_configuration(void)
Return the libavresample build-time configuration.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src)
Resample audio data.
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
int channel_map[AVRESAMPLE_MAX_CHANNELS]
source index of each output channel, -1 if not remapped
enum AVSampleFormat out_sample_fmt
output sample format
int ff_audio_data_copy(AudioData *dst, AudioData *src, ChannelMapInfo *map)
Copy data from one AudioData to another.
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.
void ff_audio_resample_free(ResampleContext **c)
Free a ResampleContext.
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.