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

different IIR filters implementation More...

#include <math.h>
#include "libavutil/attributes.h"
#include "libavutil/common.h"
#include "iirfilter.h"

Go to the source code of this file.

Data Structures

struct  FFIIRFilterCoeffs
 IIR filter global parameters. More...
 
struct  FFIIRFilterState
 IIR filter state. More...
 

Macros

#define MAXORDER   30
 maximum supported filter order More...
 
#define CONV_S16(dest, source)   dest = av_clip_int16(lrintf(source));
 
#define CONV_FLT(dest, source)   dest = source;
 
#define FILTER_BW_O4_1(i0, i1, i2, i3, fmt)
 
#define FILTER_BW_O4(type, fmt)
 
#define FILTER_DIRECT_FORM_II(type, fmt)
 
#define FILTER_O2(type, fmt)
 

Functions

static av_cold int butterworth_init_coeffs (void *avc, struct FFIIRFilterCoeffs *c, enum IIRFilterMode filt_mode, int order, float cutoff_ratio, float stopband)
 
static av_cold int biquad_init_coeffs (void *avc, struct FFIIRFilterCoeffs *c, enum IIRFilterMode filt_mode, int order, float cutoff_ratio, float stopband)
 
av_cold struct FFIIRFilterCoeffsff_iir_filter_init_coeffs (void *avc, enum IIRFilterType filt_type, enum IIRFilterMode filt_mode, int order, float cutoff_ratio, float stopband, float ripple)
 Initialize filter coefficients. More...
 
av_cold struct FFIIRFilterStateff_iir_filter_init_state (int order)
 Create new filter state. More...
 
void ff_iir_filter (const struct FFIIRFilterCoeffs *c, struct FFIIRFilterState *s, int size, const int16_t *src, int sstep, int16_t *dst, int dstep)
 Perform IIR filtering on signed 16-bit input samples. More...
 
void ff_iir_filter_flt (const struct FFIIRFilterCoeffs *c, struct FFIIRFilterState *s, int size, const float *src, int sstep, float *dst, int dstep)
 Perform IIR filtering on floating-point input samples. More...
 
av_cold void ff_iir_filter_free_statep (struct FFIIRFilterState **state)
 Free and zero filter state. More...
 
av_cold void ff_iir_filter_free_coeffsp (struct FFIIRFilterCoeffs **coeffsp)
 Free filter coefficients. More...
 
void ff_iir_filter_init (FFIIRFilterContext *f)
 Initialize FFIIRFilterContext. More...
 

Detailed Description

different IIR filters implementation

Definition in file iirfilter.c.

Macro Definition Documentation

#define MAXORDER   30

maximum supported filter order

Definition at line 52 of file iirfilter.c.

Referenced by butterworth_init_coeffs(), and ff_iir_filter_init_coeffs().

#define CONV_S16 (   dest,
  source 
)    dest = av_clip_int16(lrintf(source));

Definition at line 210 of file iirfilter.c.

#define CONV_FLT (   dest,
  source 
)    dest = source;

Definition at line 212 of file iirfilter.c.

#define FILTER_BW_O4_1 (   i0,
  i1,
  i2,
  i3,
  fmt 
)
Value:
in = *src0 * c->gain + \
c->cy[0] * s->x[i0] + \
c->cy[1] * s->x[i1] + \
c->cy[2] * s->x[i2] + \
c->cy[3] * s->x[i3]; \
res = (s->x[i0] + in) * 1 + \
(s->x[i1] + s->x[i3]) * 4 + \
s->x[i2] * 6; \
CONV_ ## fmt(*dst0, res) \
s->x[i0] = in; \
src0 += sstep; \
dst0 += dstep;
const char * s
Definition: avisynth_c.h:631
const char * fmt
Definition: avisynth_c.h:632
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
#define src0
Definition: h264pred.c:138
static double c[64]

Definition at line 214 of file iirfilter.c.

#define FILTER_BW_O4 (   type,
  fmt 
)
Value:
{ \
int i; \
const type *src0 = src; \
type *dst0 = dst; \
for (i = 0; i < size; i += 4) { \
float in, res; \
FILTER_BW_O4_1(0, 1, 2, 3, fmt); \
FILTER_BW_O4_1(1, 2, 3, 0, fmt); \
FILTER_BW_O4_1(2, 3, 0, 1, fmt); \
FILTER_BW_O4_1(3, 0, 1, 2, fmt); \
} \
}
const char * fmt
Definition: avisynth_c.h:632
ptrdiff_t size
Definition: opengl_enc.c:101
#define src
Definition: vp9dsp.c:530
#define FILTER_BW_O4_1(i0, i1, i2, i3, fmt)
Definition: iirfilter.c:214
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
GLint GLenum type
Definition: opengl_enc.c:105
#define src0
Definition: h264pred.c:138
for(j=16;j >0;--j)

Definition at line 228 of file iirfilter.c.

Referenced by ff_iir_filter(), and ff_iir_filter_flt().

#define FILTER_DIRECT_FORM_II (   type,
  fmt 
)
Value:
{ \
int i; \
const type *src0 = src; \
type *dst0 = dst; \
for (i = 0; i < size; i++) { \
int j; \
float in, res; \
in = *src0 * c->gain; \
for (j = 0; j < c->order; j++) \
in += c->cy[j] * s->x[j]; \
res = s->x[0] + in + s->x[c->order >> 1] * c->cx[c->order >> 1]; \
for (j = 1; j < c->order >> 1; j++) \
res += (s->x[j] + s->x[c->order - j]) * c->cx[j]; \
for (j = 0; j < c->order - 1; j++) \
s->x[j] = s->x[j + 1]; \
CONV_ ## fmt(*dst0, res) \
s->x[c->order - 1] = in; \
src0 += sstep; \
dst0 += dstep; \
} \
}
const char * s
Definition: avisynth_c.h:631
const char * fmt
Definition: avisynth_c.h:632
ptrdiff_t size
Definition: opengl_enc.c:101
#define src
Definition: vp9dsp.c:530
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
GLint GLenum type
Definition: opengl_enc.c:105
#define src0
Definition: h264pred.c:138
static double c[64]
for(j=16;j >0;--j)

Definition at line 241 of file iirfilter.c.

Referenced by ff_iir_filter(), and ff_iir_filter_flt().

#define FILTER_O2 (   type,
  fmt 
)
Value:
{ \
int i; \
const type *src0 = src; \
type *dst0 = dst; \
for (i = 0; i < size; i++) { \
float in = *src0 * c->gain + \
s->x[0] * c->cy[0] + \
s->x[1] * c->cy[1]; \
CONV_ ## fmt(*dst0, s->x[0] + in + s->x[1] * c->cx[1]) \
s->x[0] = s->x[1]; \
s->x[1] = in; \
src0 += sstep; \
dst0 += dstep; \
} \
}
const char * s
Definition: avisynth_c.h:631
const char * fmt
Definition: avisynth_c.h:632
ptrdiff_t size
Definition: opengl_enc.c:101
#define src
Definition: vp9dsp.c:530
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
GLint GLenum type
Definition: opengl_enc.c:105
#define src0
Definition: h264pred.c:138
static double c[64]
for(j=16;j >0;--j)

Definition at line 263 of file iirfilter.c.

Referenced by ff_iir_filter(), and ff_iir_filter_flt().

Function Documentation

static av_cold int butterworth_init_coeffs ( void avc,
struct FFIIRFilterCoeffs c,
enum IIRFilterMode  filt_mode,
int  order,
float  cutoff_ratio,
float  stopband 
)
static

Definition at line 54 of file iirfilter.c.

Referenced by ff_iir_filter_init_coeffs().

static av_cold int biquad_init_coeffs ( void avc,
struct FFIIRFilterCoeffs c,
enum IIRFilterMode  filt_mode,
int  order,
float  cutoff_ratio,
float  stopband 
)
static

Definition at line 119 of file iirfilter.c.

Referenced by ff_iir_filter_init_coeffs().

av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs ( void avc,
enum IIRFilterType  filt_type,
enum IIRFilterMode  filt_mode,
int  order,
float  cutoff_ratio,
float  stopband,
float  ripple 
)

Initialize filter coefficients.

Parameters
avca pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct
filt_typefilter type (e.g. Butterworth)
filt_modefilter mode (e.g. lowpass)
orderfilter order
cutoff_ratiocutoff to input frequency ratio
stopbandstopband to input frequency ratio (used by bandpass and bandstop filter modes)
rippleripple factor (used only in Chebyshev filters)
Returns
pointer to filter coefficients structure or NULL if filter cannot be created

Definition at line 162 of file iirfilter.c.

Referenced by ff_psy_preprocess_init(), and main().

av_cold struct FFIIRFilterState* ff_iir_filter_init_state ( int  order)

Create new filter state.

Parameters
orderfilter order
Returns
pointer to new filter state or NULL if state creation fails

Definition at line 204 of file iirfilter.c.

Referenced by ff_psy_preprocess_init(), and main().

void ff_iir_filter ( const struct FFIIRFilterCoeffs coeffs,
struct FFIIRFilterState state,
int  size,
const int16_t *  src,
int  sstep,
int16_t *  dst,
int  dstep 
)

Perform IIR filtering on signed 16-bit input samples.

Parameters
coeffspointer to filter coefficients
statepointer to filter state
sizeinput length
srcsource samples
sstepsource stride
dstfiltered samples (destination may be the same as input)
dstepdestination stride

Definition at line 279 of file iirfilter.c.

Referenced by main().

void ff_iir_filter_flt ( const struct FFIIRFilterCoeffs coeffs,
struct FFIIRFilterState state,
int  size,
const float *  src,
int  sstep,
float *  dst,
int  dstep 
)

Perform IIR filtering on floating-point input samples.

Parameters
coeffspointer to filter coefficients
statepointer to filter state
sizeinput length
srcsource samples
sstepsource stride
dstfiltered samples (destination may be the same as input)
dstepdestination stride

Definition at line 292 of file iirfilter.c.

Referenced by ff_iir_filter_init().

av_cold void ff_iir_filter_free_statep ( struct FFIIRFilterState **  state)

Free and zero filter state.

Parameters
statepointer to pointer allocated with ff_iir_filter_init_state()

Definition at line 305 of file iirfilter.c.

Referenced by ff_psy_preprocess_end(), and main().

av_cold void ff_iir_filter_free_coeffsp ( struct FFIIRFilterCoeffs **  coeffs)

Free filter coefficients.

Parameters
coeffspointer allocated with ff_iir_filter_init_coeffs()

Definition at line 310 of file iirfilter.c.

Referenced by ff_iir_filter_init_coeffs(), ff_psy_preprocess_end(), and main().

void ff_iir_filter_init ( FFIIRFilterContext f)

Initialize FFIIRFilterContext.

Definition at line 320 of file iirfilter.c.

Referenced by ff_psy_preprocess_init().