FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
audio_convert.h File Reference
#include "libavutil/samplefmt.h"
#include "avresample.h"
#include "internal.h"
#include "audio_data.h"

Go to the source code of this file.

Functions

void ff_audio_convert_set_func (AudioConvert *ac, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int ptr_align, int samples_align, const char *descr, void *conv)
 Set conversion function if the parameters match. More...
 
AudioConvertff_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. More...
 
void ff_audio_convert_free (AudioConvert **ac)
 Free AudioConvert. More...
 
int ff_audio_convert (AudioConvert *ac, AudioData *out, AudioData *in)
 Convert audio data from one sample format to another. More...
 
void ff_audio_convert_init_aarch64 (AudioConvert *ac)
 
void ff_audio_convert_init_arm (AudioConvert *ac)
 
void ff_audio_convert_init_x86 (AudioConvert *ac)
 

Function Documentation

void ff_audio_convert_set_func ( AudioConvert ac,
enum AVSampleFormat  out_fmt,
enum AVSampleFormat  in_fmt,
int  channels,
int  ptr_align,
int  samples_align,
const char *  descr,
void conv 
)

Set conversion function if the parameters match.

This compares the parameters of the conversion function to the parameters in the AudioConvert context. If the parameters do not match, no changes are made to the active functions. If the parameters do match and the alignment is not constrained, the function is set as the generic conversion function. If the parameters match and the alignment is constrained, the function is set as the optimized conversion function.

Parameters
acAudioConvert context
out_fmtoutput sample format
in_fmtinput sample format
channelsnumber of channels, or 0 for any number of channels
ptr_alignbuffer pointer alignment, in bytes
samples_alignbuffer size alignment, in samples
descrfunction type description (e.g. "C" or "SSE")
convconversion function pointer

Definition at line 70 of file audio_convert.c.

Referenced by ff_audio_convert_init_aarch64(), ff_audio_convert_init_arm(), and ff_audio_convert_init_x86().

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.

Parameters
avrAVAudioResampleContext
out_fmtoutput sample format
in_fmtinput sample format
channelsnumber of channels
sample_ratesample rate (used for dithering)
apply_mapapply channel map during conversion
Returns
newly-allocated AudioConvert context

Referenced by avresample_open(), and ff_dither_alloc().

void ff_audio_convert_free ( AudioConvert **  ac)

Free AudioConvert.

The AudioConvert must have been previously allocated with ff_audio_convert_alloc().

Parameters
acAudioConvert struct

Referenced by avresample_close(), and ff_dither_free().

int ff_audio_convert ( AudioConvert ac,
AudioData out,
AudioData in 
)

Convert audio data from one sample format to another.

For each call, the alignment of the input and output AudioData buffers are examined to determine whether to use the generic or optimized conversion function (when available).

The number of samples to convert is determined by in->nb_samples. The output buffer must be large enough to handle this many samples. out->nb_samples is set by this function before a successful return.

Parameters
acAudioConvert context
outoutput audio data
ininput audio data
Returns
0 on success, negative AVERROR code on failure

Referenced by avresample_convert(), and ff_convert_dither().

void ff_audio_convert_init_aarch64 ( AudioConvert ac)

Definition at line 34 of file audio_convert_init.c.

void ff_audio_convert_init_arm ( AudioConvert ac)

Definition at line 34 of file audio_convert_init.c.

void ff_audio_convert_init_x86 ( AudioConvert ac)

Definition at line 146 of file audio_convert_init.c.