libavresample/resample.c File Reference

#include "libavutil/libm.h"
#include "libavutil/log.h"
#include "internal.h"
#include "audio_data.h"

Go to the source code of this file.

Data Structures

struct  ResampleContext


#define FILTER_SHIFT   15
#define FELEM   int16_t
#define FELEM2   int32_t
#define FELEML   int64_t
#define FELEM_MAX   INT16_MAX
#define FELEM_MIN   INT16_MIN
#define WINDOW_TYPE   9


static double bessel (double x)
 0th order modified bessel function of the first kind.
static int build_filter (FELEM *filter, double factor, int tap_count, int phase_count, int scale, int type)
 Build a polyphase filterbank.
ResampleContextff_audio_resample_init (AVAudioResampleContext *avr)
 Allocate and initialize a ResampleContext.
void ff_audio_resample_free (ResampleContext **c)
 Free a ResampleContext.
int avresample_set_compensation (AVAudioResampleContext *avr, int sample_delta, int compensation_distance)
 Set compensation for resampling.
static int resample (ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx)
int ff_audio_resample (ResampleContext *c, AudioData *dst, AudioData *src, int *consumed)
 Resample audio data.
int avresample_get_delay (AVAudioResampleContext *avr)
 Return the number of samples currently in the resampling delay buffer.

Define Documentation

#define FELEM   int16_t

Definition at line 46 of file resample.c.

#define FELEM2   int32_t

Definition at line 47 of file resample.c.

#define FELEM_MAX   INT16_MAX

Definition at line 49 of file resample.c.

#define FELEM_MIN   INT16_MIN

Definition at line 50 of file resample.c.

#define FELEML   int64_t

Definition at line 48 of file resample.c.

#define FILTER_SHIFT   15

Definition at line 45 of file resample.c.

#define WINDOW_TYPE   9

Definition at line 51 of file resample.c.

Function Documentation

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:
avr audio resample context
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_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.

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

Definition at line 240 of file resample.c.

Referenced by filter_samples().

static double bessel ( double  x  )  [static]

0th order modified bessel function of the first kind.

Definition at line 74 of file resample.c.

static int build_filter ( FELEM *  filter,
double  factor,
int  tap_count,
int  phase_count,
int  scale,
int  type 
) [static]

Build a polyphase filterbank.

[out] filter filter coefficients
factor resampling factor
tap_count tap count
phase_count phase count
scale wanted sum of coefficients for each filter
type 0->cubic 1->blackman nuttall windowed sinc 2..16->kaiser windowed sinc beta=2..16
0 on success, negative AVERROR code on failure

Definition at line 103 of file resample.c.

int ff_audio_resample ( ResampleContext c,
AudioData dst,
AudioData src,
int *  consumed 

Resample audio data.

Changes the sample rate.

All samples in the source data may not be consumed depending on the resampling parameters and the size of the output buffer. The unconsumed samples are automatically added to the start of the source in the next call. If the destination data can be reallocated, that may be done in this function in order to fit all available output. If it cannot be reallocated, fewer input samples will be consumed in order to have the output fit in the destination data buffers.
c ResampleContext
dst destination audio data
src source audio data
consumed number of samples consumed from the source
number of samples written to the destination

Definition at line 419 of file resample.c.

Referenced by avresample_convert().

void ff_audio_resample_free ( ResampleContext **  c  ) 

Free a ResampleContext.

c ResampleContext

Definition at line 231 of file resample.c.

Referenced by avresample_close().

ResampleContext* ff_audio_resample_init ( AVAudioResampleContext avr  ) 

Allocate and initialize a ResampleContext.

The parameters in the AVAudioResampleContext are used to initialize the ResampleContext.

avr AVAudioResampleContext
newly-allocated ResampleContext

Definition at line 164 of file resample.c.

Referenced by avresample_open().

static int resample ( ResampleContext c,
int16_t dst,
const int16_t src,
int *  consumed,
int  src_size,
int  dst_size,
int  update_ctx 
) [static]

Definition at line 314 of file resample.c.

Referenced by avfilter_register_all(), ff_audio_resample(), and swr_convert_internal().

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