FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
resample.c File Reference

audio resampling More...

#include "libavutil/avassert.h"
#include "resample.h"

Go to the source code of this file.

Functions

static double eval_poly (const double *coeff, int size, double x)
 
static double bessel (double x)
 0th order modified bessel function of the first kind. More...
 
static int build_filter (ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale, int filter_type, double kaiser_beta)
 builds a polyphase filterbank. More...
 
static ResampleContextresample_init (ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, int exact_rational)
 
static void resample_free (ResampleContext **c)
 
static int rebuild_filter_bank_with_compensation (ResampleContext *c)
 
static int set_compensation (ResampleContext *c, int sample_delta, int compensation_distance)
 
static int swri_resample (ResampleContext *c, uint8_t *dst, const uint8_t *src, int *consumed, int src_size, int dst_size, int update_ctx)
 
static int multiple_resample (ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed)
 
static int64_t get_delay (struct SwrContext *s, int64_t base)
 
static int64_t get_out_samples (struct SwrContext *s, int in_samples)
 
static int resample_flush (struct SwrContext *s)
 
static int invert_initial_buffer (ResampleContext *c, AudioData *dst, const AudioData *src, int in_count, int *out_idx, int *out_sz)
 

Variables

struct Resampler const swri_resampler
 

Detailed Description

audio resampling

Author
Michael Niedermayer micha.nosp@m.elni.nosp@m.@gmx..nosp@m.at

Definition in file resample.c.

Function Documentation

static double eval_poly ( const double *  coeff,
int  size,
double  x 
)
inlinestatic

Definition at line 32 of file resample.c.

Referenced by bessel().

static double bessel ( double  x)
static

0th order modified bessel function of the first kind.

Algorithm taken from the Boost project, source: https://searchcode.com/codesearch/view/14918379/ Use, modification and distribution are subject to the Boost Software License, Version 1.0 (see notice below). Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following:

The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition at line 72 of file resample.c.

Referenced by build_filter().

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

builds a polyphase filterbank.

Parameters
factorresampling factor
scalewanted sum of coefficients for each filter
filter_typefilter type
kaiser_betakaiser window beta
Returns
0 on success, negative on error

Definition at line 144 of file resample.c.

Referenced by rebuild_filter_bank_with_compensation(), and resample_init().

static ResampleContext* resample_init ( ResampleContext c,
int  out_rate,
int  in_rate,
int  filter_size,
int  phase_shift,
int  linear,
double  cutoff0,
enum AVSampleFormat  format,
enum SwrFilterType  filter_type,
double  kaiser_beta,
double  precision,
int  cheby,
int  exact_rational 
)
static

Definition at line 301 of file resample.c.

static void resample_free ( ResampleContext **  c)
static

Definition at line 392 of file resample.c.

static int rebuild_filter_bank_with_compensation ( ResampleContext c)
static

Definition at line 399 of file resample.c.

Referenced by set_compensation().

static int set_compensation ( ResampleContext c,
int  sample_delta,
int  compensation_distance 
)
static

Definition at line 447 of file resample.c.

static int swri_resample ( ResampleContext c,
uint8_t dst,
const uint8_t src,
int *  consumed,
int  src_size,
int  dst_size,
int  update_ctx 
)
static

Definition at line 468 of file resample.c.

Referenced by multiple_resample().

static int multiple_resample ( ResampleContext c,
AudioData dst,
int  dst_size,
AudioData src,
int  src_size,
int *  consumed 
)
static

Definition at line 506 of file resample.c.

static int64_t get_delay ( struct SwrContext s,
int64_t  base 
)
static

Definition at line 536 of file resample.c.

static int64_t get_out_samples ( struct SwrContext s,
int  in_samples 
)
static

Definition at line 546 of file resample.c.

static int resample_flush ( struct SwrContext s)
static

Definition at line 565 of file resample.c.

static int invert_initial_buffer ( ResampleContext c,
AudioData dst,
const AudioData src,
int  in_count,
int *  out_idx,
int *  out_sz 
)
static

Definition at line 582 of file resample.c.

Variable Documentation

struct Resampler const swri_resampler
Initial value:
={
}
static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed)
Definition: resample.c:506
static void resample_free(ResampleContext **c)
Definition: resample.c:392
static int set_compensation(ResampleContext *c, int sample_delta, int compensation_distance)
Definition: resample.c:447
static int invert_initial_buffer(ResampleContext *c, AudioData *dst, const AudioData *src, int in_count, int *out_idx, int *out_sz)
Definition: resample.c:582
static int resample_flush(struct SwrContext *s)
Definition: resample.c:565
static ResampleContext * resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, int exact_rational)
Definition: resample.c:301
static int64_t get_delay(struct SwrContext *s, int64_t base)
Definition: resample.c:536
static int64_t get_out_samples(struct SwrContext *s, int in_samples)
Definition: resample.c:546

Definition at line 629 of file resample.c.

Referenced by swr_init().