libavresample/avresample.h File Reference

external API header More...

#include "libavutil/audioconvert.h"
#include "libavutil/avutil.h"
#include "libavutil/dict.h"
#include "libavutil/log.h"
#include "libavresample/version.h"

Go to the source code of this file.

Defines

#define AVRESAMPLE_MAX_CHANNELS   32

Typedefs

typedef struct
AVAudioResampleContext 
AVAudioResampleContext

Enumerations

enum  AVMixCoeffType { AV_MIX_COEFF_TYPE_Q8, AV_MIX_COEFF_TYPE_Q15, AV_MIX_COEFF_TYPE_FLT, AV_MIX_COEFF_TYPE_NB }
 Mixing Coefficient Types. More...

Functions

unsigned avresample_version (void)
 Return the LIBAVRESAMPLE_VERSION_INT constant.
const char * avresample_configuration (void)
 Return the libavresample build-time configuration.
const char * avresample_license (void)
 Return the libavresample license.
const AVClassavresample_get_class (void)
 Get the AVClass for AVAudioResampleContext.
AVAudioResampleContextavresample_alloc_context (void)
 Allocate AVAudioResampleContext and set options.
int avresample_open (AVAudioResampleContext *avr)
 Initialize AVAudioResampleContext.
void avresample_close (AVAudioResampleContext *avr)
 Close AVAudioResampleContext.
void avresample_free (AVAudioResampleContext **avr)
 Free AVAudioResampleContext and associated AVOption values.
int avresample_build_matrix (uint64_t in_layout, uint64_t out_layout, double center_mix_level, double surround_mix_level, double lfe_mix_level, int normalize, double *matrix, int stride)
 Generate a channel mixing matrix.
int avresample_get_matrix (AVAudioResampleContext *avr, double *matrix, int stride)
 Get the current channel mixing matrix.
int avresample_set_matrix (AVAudioResampleContext *avr, const double *matrix, int stride)
 Set channel mixing matrix.
int avresample_set_compensation (AVAudioResampleContext *avr, int sample_delta, int compensation_distance)
 Set compensation for resampling.
int avresample_convert (AVAudioResampleContext *avr, void **output, int out_plane_size, int out_samples, void **input, int in_plane_size, int in_samples)
 Convert input samples and write them to the output FIFO.
int avresample_get_delay (AVAudioResampleContext *avr)
 Return the number of samples currently in the resampling delay buffer.
int avresample_available (AVAudioResampleContext *avr)
 Return the number of available samples in the output FIFO.
int avresample_read (AVAudioResampleContext *avr, void **output, int nb_samples)
 Read samples from the output FIFO.


Detailed Description

external API header

Definition in file avresample.h.


Define Documentation

#define AVRESAMPLE_MAX_CHANNELS   32


Typedef Documentation

Definition at line 38 of file avresample.h.


Enumeration Type Documentation

Mixing Coefficient Types.

Enumerator:
AV_MIX_COEFF_TYPE_Q8 
AV_MIX_COEFF_TYPE_Q15  16-bit 8.8 fixed-point
AV_MIX_COEFF_TYPE_FLT  32-bit 17.15 fixed-point
AV_MIX_COEFF_TYPE_NB  floating-point

Definition at line 41 of file avresample.h.


Function Documentation

AVAudioResampleContext* avresample_alloc_context ( void   ) 

Allocate AVAudioResampleContext and set options.

Returns:
allocated audio resample context, or NULL on failure

Definition at line 65 of file options.c.

Referenced by config_output(), config_props(), and main().

int avresample_available ( AVAudioResampleContext avr  ) 

Return the number of available samples in the output FIFO.

During conversion, if the user does not specify an output buffer or specifies an output buffer that is smaller than what is needed, remaining samples that are not written to the output are stored to an internal FIFO buffer. The samples in the FIFO can be read with avresample_read() or avresample_convert().

See also:
avresample_read()

avresample_convert()

Parameters:
avr audio resample context
Returns:
number of samples available for reading

Definition at line 382 of file utils.c.

Referenced by filter_samples(), get_delay(), and main().

int avresample_build_matrix ( uint64_t  in_layout,
uint64_t  out_layout,
double  center_mix_level,
double  surround_mix_level,
double  lfe_mix_level,
int  normalize,
double *  matrix,
int  stride 
)

Generate a channel mixing matrix.

This function is the one used internally by libavresample for building the default mixing matrix. It is made public just as a utility function for building custom matrices.

Parameters:
in_layout input channel layout
out_layout output channel layout
center_mix_level mix level for the center channel
surround_mix_level mix level for the surround channel(s)
lfe_mix_level mix level for the low-frequency effects channel
normalize if 1, coefficients will be normalized to prevent overflow. if 0, coefficients will not be normalized.
[out] matrix mixing coefficients; matrix[i + stride * o] is the weight of input channel i in output channel o.
stride distance between adjacent input channels in the matrix array
Returns:
0 on success, negative AVERROR code on failure

Definition at line 83 of file audio_mix_matrix.c.

Referenced by ff_audio_mix_init().

void avresample_close ( AVAudioResampleContext avr  ) 

Close AVAudioResampleContext.

This closes the context, but it does not change the parameters. The context can be reopened with avresample_open(). It does, however, clear the output FIFO and any remaining leftover samples in the resampling delay buffer. If there was a custom matrix being used, that is also cleared.

See also:
avresample_convert()

avresample_set_matrix()

Parameters:
avr audio resample context

Definition at line 159 of file utils.c.

Referenced by avresample_free(), avresample_open(), avresample_set_compensation(), config_output(), main(), and uninit().

const char* avresample_configuration ( void   ) 

Return the libavresample build-time configuration.

Returns:
configure string

Definition at line 405 of file utils.c.

int avresample_convert ( AVAudioResampleContext avr,
void **  output,
int  out_plane_size,
int  out_samples,
void **  input,
int  in_plane_size,
int  in_samples 
)

Convert input samples and write them to the output FIFO.

The output data can be NULL or have fewer allocated samples than required. In this case, any remaining samples not written to the output will be added to an internal FIFO buffer, to be returned at the next call to this function or to avresample_read().

If converting sample rate, there may be data remaining in the internal resampling delay buffer. avresample_get_delay() tells the number of remaining samples. To get this data as output, call avresample_convert() with NULL input.

At the end of the conversion process, there may be data remaining in the internal FIFO buffer. avresample_available() tells the number of remaining samples. To get this data as output, either call avresample_convert() with NULL input or call avresample_read().

See also:
avresample_available()

avresample_read()

avresample_get_delay()

Parameters:
avr audio resample context
output output data pointers
out_plane_size output plane size, in bytes. This can be 0 if unknown, but that will lead to optimized functions not being used directly on the output, which could slow down some conversions.
out_samples maximum number of samples that the output buffer can hold
input input data pointers
in_plane_size input plane size, in bytes This can be 0 if unknown, but that will lead to optimized functions not being used directly on the input, which could slow down some conversions.
in_samples number of input samples to convert
Returns:
number of samples written to the output buffer, not including converted samples added to the internal output FIFO

Definition at line 224 of file utils.c.

Referenced by filter_samples(), main(), request_frame(), and write_to_fifo().

void avresample_free ( AVAudioResampleContext **  avr  ) 

Free AVAudioResampleContext and associated AVOption values.

This also calls avresample_close() before freeing.

Parameters:
avr audio resample context

Definition at line 173 of file utils.c.

Referenced by config_output(), main(), and uninit().

const AVClass* avresample_get_class ( void   ) 

Get the AVClass for AVAudioResampleContext.

Can be used in combination with AV_OPT_SEARCH_FAKE_OBJ for examining options without allocating a context.

See also:
av_opt_find().
Returns:
AVClass for AVAudioResampleContext

Definition at line 86 of file options.c.

int avresample_get_delay ( AVAudioResampleContext avr  ) 

Return the number of samples currently in the resampling delay buffer.

When resampling, there may be a delay between the input and output. Any unconverted samples in each call are stored internally in a delay buffer. This function allows the user to determine the current number of samples in the delay buffer, which can be useful for synchronization.

See also:
avresample_convert()
Parameters:
avr audio resample context
Returns:
number of samples currently in the resampling delay buffer

Definition at line 474 of file resample.c.

Referenced by filter_samples(), get_delay(), main(), and request_frame().

int avresample_get_matrix ( AVAudioResampleContext avr,
double *  matrix,
int  stride 
)

Get the current channel mixing matrix.

Parameters:
avr audio resample context
matrix mixing coefficients; matrix[i + stride * o] is the weight of input channel i in output channel o.
stride distance between adjacent input channels in the matrix array
Returns:
0 on success, negative AVERROR code on failure

Definition at line 245 of file audio_mix_matrix.c.

Referenced by avresample_set_compensation().

const char* avresample_license ( void   ) 

Return the libavresample license.

Definition at line 399 of file utils.c.

int avresample_open ( AVAudioResampleContext avr  ) 

Initialize AVAudioResampleContext.

Parameters:
avr audio resample context
Returns:
0 on success, negative AVERROR code on failure

Definition at line 31 of file utils.c.

Referenced by avresample_set_compensation(), config_output(), config_props(), and main().

int avresample_read ( AVAudioResampleContext avr,
void **  output,
int  nb_samples 
)

Read samples from the output FIFO.

During conversion, if the user does not specify an output buffer or specifies an output buffer that is smaller than what is needed, remaining samples that are not written to the output are stored to an internal FIFO buffer. This function can be used to read samples from that internal FIFO.

See also:
avresample_available()

avresample_convert()

Parameters:
avr audio resample context
output output data pointers. May be NULL, in which case nb_samples of data is discarded from output FIFO.
nb_samples number of samples to read from the FIFO
Returns:
the number of samples written to output

Definition at line 387 of file utils.c.

Referenced by filter_samples().

int avresample_set_compensation ( AVAudioResampleContext avr,
int  sample_delta,
int  compensation_distance 
)

Set compensation for resampling.

This can be called anytime after avresample_open(). If resampling was not being done previously, the AVAudioResampleContext is closed and reopened with resampling enabled. In this case, any samples remaining in the output FIFO and the current channel mixing matrix will be restored after reopening the context.

Parameters:
avr audio resample context
sample_delta compensation delta, in samples
compensation_distance compensation distance, in samples
Returns:
0 on success, negative AVERROR code on failure

Definition at line 240 of file resample.c.

Referenced by filter_samples().

int avresample_set_matrix ( AVAudioResampleContext avr,
const double *  matrix,
int  stride 
)

Set channel mixing matrix.

Allows for setting a custom mixing matrix, overriding the default matrix generated internally during avresample_open(). This function can be called anytime on an allocated context, either before or after calling avresample_open(). avresample_convert() always uses the current matrix. Calling avresample_close() on the context will clear the current matrix.

See also:
avresample_close()
Parameters:
avr audio resample context
matrix mixing coefficients; matrix[i + stride * o] is the weight of input channel i in output channel o.
stride distance between adjacent input channels in the matrix array
Returns:
0 on success, negative AVERROR code on failure

Definition at line 294 of file audio_mix_matrix.c.

Referenced by avresample_set_compensation(), and ff_audio_mix_init().

unsigned avresample_version ( void   ) 

Return the LIBAVRESAMPLE_VERSION_INT constant.

Definition at line 394 of file utils.c.


Generated on Fri Oct 26 02:48:02 2012 for FFmpeg by  doxygen 1.5.8