libswresample/resample.c File Reference

audio resampling More...

#include "libavutil/log.h"
#include "libavutil/avassert.h"
#include "swresample_internal.h"
#include "resample_template.c"

Go to the source code of this file.

Data Structures

struct  ResampleContext

Defines

#define RENAME(N)   N ## _int16
#define FILTER_SHIFT   15
#define DELEM   int16_t
#define FELEM   int16_t
#define FELEM2   int32_t
#define FELEML   int64_t
#define FELEM_MAX   INT16_MAX
#define FELEM_MIN   INT16_MIN
#define OUT(d, v)
#define RENAME(N)   N ## _int32
#define FILTER_SHIFT   30
#define DELEM   int32_t
#define FELEM   int32_t
#define FELEM2   int64_t
#define FELEML   int64_t
#define FELEM_MAX   INT32_MAX
#define FELEM_MIN   INT32_MIN
#define OUT(d, v)
#define RENAME(N)   N ## _float
#define FILTER_SHIFT   0
#define DELEM   float
#define FELEM   float
#define FELEM2   float
#define FELEML   float
#define OUT(d, v)   d = v
#define RENAME(N)   N ## _double
#define FILTER_SHIFT   0
#define DELEM   double
#define FELEM   double
#define FELEM2   double
#define FELEML   double
#define OUT(d, v)   d = v

Functions

static double bessel (double x)
 0th order modified bessel function of the first kind.
static int build_filter (ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale, int filter_type, int kaiser_beta)
 builds a polyphase filterbank.
ResampleContextswri_resample_init (ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta)
void swri_resample_free (ResampleContext **c)
int swr_set_compensation (struct SwrContext *s, int sample_delta, int compensation_distance)
 Activate resampling compensation.
int swri_multiple_resample (ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed)
int64_t swr_get_delay (struct SwrContext *s, int64_t base)
 Gets the delay the next input sample will experience relative to the next output sample.


Detailed Description

audio resampling

Author:
Michael Niedermayer <michaelni@gmx.at>

Definition in file resample.c.


Define Documentation

#define DELEM   double

Definition at line 360 of file resample.c.

#define DELEM   float

Definition at line 360 of file resample.c.

#define DELEM   int32_t

Definition at line 360 of file resample.c.

#define DELEM   int16_t

Definition at line 360 of file resample.c.

#define FELEM   double

Definition at line 361 of file resample.c.

#define FELEM   float

Definition at line 361 of file resample.c.

#define FELEM   int32_t

Definition at line 361 of file resample.c.

#define FELEM   int16_t

Definition at line 361 of file resample.c.

#define FELEM2   double

Definition at line 362 of file resample.c.

#define FELEM2   float

Definition at line 362 of file resample.c.

#define FELEM2   int64_t

Definition at line 362 of file resample.c.

#define FELEM2   int32_t

Definition at line 362 of file resample.c.

#define FELEM_MAX   INT32_MAX

Definition at line 321 of file resample.c.

#define FELEM_MAX   INT16_MAX

Definition at line 321 of file resample.c.

#define FELEM_MIN   INT32_MIN

Definition at line 322 of file resample.c.

#define FELEM_MIN   INT16_MIN

Definition at line 322 of file resample.c.

#define FELEML   double

Definition at line 363 of file resample.c.

#define FELEML   float

Definition at line 363 of file resample.c.

#define FELEML   int64_t

Definition at line 363 of file resample.c.

#define FELEML   int64_t

Definition at line 363 of file resample.c.

#define FILTER_SHIFT   0

Definition at line 359 of file resample.c.

#define FILTER_SHIFT   0

Definition at line 359 of file resample.c.

#define FILTER_SHIFT   30

Definition at line 359 of file resample.c.

#define FILTER_SHIFT   15

Definition at line 359 of file resample.c.

#define OUT ( d,
 )     d = v

Definition at line 364 of file resample.c.

#define OUT ( d,
 )     d = v

Definition at line 364 of file resample.c.

#define OUT ( d,
 ) 

Value:

v = (v + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;\
                  d = (uint64_t)(v + 0x80000000) > 0xFFFFFFFF ? (v>>63) ^ 0x7FFFFFFF : v

Definition at line 364 of file resample.c.

#define OUT ( d,
 ) 

Value:

v = (v + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;\
                  d = (unsigned)(v + 32768) > 65535 ? (v>>31) ^ 32767 : v

Definition at line 364 of file resample.c.

#define RENAME (  )     N ## _double

Definition at line 358 of file resample.c.

#define RENAME (  )     N ## _float

Definition at line 358 of file resample.c.

#define RENAME (  )     N ## _int32

Definition at line 358 of file resample.c.

#define RENAME (  )     N ## _int16

Definition at line 358 of file resample.c.


Function Documentation

static double bessel ( double  x  )  [static]

0th order modified bessel function of the first kind.

Definition at line 58 of file resample.c.

static int build_filter ( ResampleContext c,
void *  filter,
double  factor,
int  tap_count,
int  alloc,
int  phase_count,
int  scale,
int  filter_type,
int  kaiser_beta 
) [static]

builds a polyphase filterbank.

Parameters:
factor resampling factor
scale wanted sum of coefficients for each filter
filter_type filter type
kaiser_beta kaiser window beta
Returns:
0 on success, negative on error

Definition at line 94 of file resample.c.

int64_t swr_get_delay ( struct SwrContext s,
int64_t  base 
)

Gets the delay the next input sample will experience relative to the next output sample.

Swresample can buffer data if more input has been provided than available output space, also converting between sample rates needs a delay. This function returns the sum of all such delays.

Parameters:
s swr context
base timebase in which the returned delay will be if its set to 1 the returned delay is in seconds if its set to 1000 the returned delay is in milli seconds if its set to the input sample rate then the returned delay is in input samples if its set to the output sample rate then the returned delay is in output samples an exact rounding free delay can be found by using LCM(in_sample_rate, out_sample_rate)
Returns:
the delay in 1/base units.

Definition at line 446 of file resample.c.

Referenced by swr_next_pts().

int swr_set_compensation ( struct SwrContext s,
int  sample_delta,
int  compensation_distance 
)

Activate resampling compensation.

Definition at line 269 of file resample.c.

Referenced by audio_decode_frame(), and swr_next_pts().

int swri_multiple_resample ( ResampleContext c,
AudioData dst,
int  dst_size,
AudioData src,
int  src_size,
int consumed 
)

Definition at line 420 of file resample.c.

Referenced by resample().

void swri_resample_free ( ResampleContext **  c  ) 

Definition at line 262 of file resample.c.

Referenced by swr_free(), and swr_init().

ResampleContext* swri_resample_init ( ResampleContext c,
int  out_rate,
int  in_rate,
int  filter_size,
int  phase_shift,
int  linear,
double  cutoff,
enum AVSampleFormat  format,
enum SwrFilterType  filter_type,
int  kaiser_beta 
) [read]

Definition at line 198 of file resample.c.

Referenced by swr_init().


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