libavcodec/g729postfilter.c File Reference

#include <inttypes.h>
#include <limits.h>
#include "avcodec.h"
#include "g729.h"
#include "acelp_pitch_delay.h"
#include "g729postfilter.h"
#include "celp_math.h"
#include "acelp_filters.h"
#include "acelp_vectors.h"
#include "celp_filters.h"
#include "mathops.h"

Go to the source code of this file.

Defines

#define FRAC_BITS   15

Functions

static void residual_filter (int16_t *out, const int16_t *filter_coeffs, const int16_t *in, int subframe_size)
 Residual signal calculation (4.2.1 if G.729).
static int16_t long_term_filter (DSPContext *dsp, int pitch_delay_int, const int16_t *residual, int16_t *residual_filt, int subframe_size)
 long-term postfilter (4.2.1)
static int16_t get_tilt_comp (DSPContext *dsp, int16_t *lp_gn, const int16_t *lp_gd, int16_t *speech, int subframe_size)
 Calculate reflection coefficient for tilt compensation filter (4.2.3).
static int16_t apply_tilt_comp (int16_t *out, int16_t *res_pst, int refl_coeff, int subframe_size, int16_t ht_prev_data)
 Apply tilt compensation filter (4.2.3).
void ff_g729_postfilter (DSPContext *dsp, int16_t *ht_prev_data, int *voicing, const int16_t *lp_filter_coeffs, int pitch_delay_int, int16_t *residual, int16_t *res_filter_data, int16_t *pos_filter_data, int16_t *speech, int subframe_size)
 Signal postfiltering (4.2).
int16_t ff_g729_adaptive_gain_control (int gain_before, int gain_after, int16_t *speech, int subframe_size, int16_t gain_prev)
 Adaptive gain control (4.2.4).

Variables

static const int16_t ff_g729_interp_filt_short [(ANALYZED_FRAC_DELAYS+1)*SHORT_INT_FILT_LEN]
 short interpolation filter (of length 33, according to spec) for computing signal with non-integer delay
static const int16_t ff_g729_interp_filt_long [(ANALYZED_FRAC_DELAYS+1)*LONG_INT_FILT_LEN]
 long interpolation filter (of length 129, according to spec) for computing signal with non-integer delay
static const int16_t formant_pp_factor_num_pow [10]
 formant_pp_factor_num_pow[i] = FORMANT_PP_FACTOR_NUM^(i+1)
static const int16_t formant_pp_factor_den_pow [10]
 formant_pp_factor_den_pow[i] = FORMANT_PP_FACTOR_DEN^(i+1)


Define Documentation

#define FRAC_BITS   15


Function Documentation

static int16_t apply_tilt_comp ( int16_t out,
int16_t res_pst,
int  refl_coeff,
int  subframe_size,
int16_t  ht_prev_data 
) [static]

Apply tilt compensation filter (4.2.3).

Parameters:
res_pst [in/out] residual signal (partially filtered)
k1 (3.12) reflection coefficient
subframe_size size of subframe
ht_prev_data previous data for 4.2.3, equation 86
Returns:
new value for ht_prev_data

Definition at line 476 of file g729postfilter.c.

Referenced by ff_g729_postfilter().

int16_t ff_g729_adaptive_gain_control ( int  gain_before,
int  gain_after,
int16_t speech,
int  subframe_size,
int16_t  gain_prev 
)

Adaptive gain control (4.2.4).

Parameters:
gain_before gain of speech before applying postfilters
gain_after gain of speech after applying postfilters
speech [in/out] signal buffer
subframe_size length of subframe
gain_prev (3.12) previous value of gain coefficient
Returns:
(3.12) last value of gain coefficient

Definition at line 574 of file g729postfilter.c.

Referenced by decode_frame().

void ff_g729_postfilter ( DSPContext dsp,
int16_t ht_prev_data,
int *  voicing,
const int16_t lp_filter_coeffs,
int  pitch_delay_int,
int16_t residual,
int16_t res_filter_data,
int16_t pos_filter_data,
int16_t speech,
int  subframe_size 
)

Signal postfiltering (4.2).

Parameters:
dsp initialized DSP context
ht_prev_data [in/out] (Q12) pointer to variable receiving tilt compensation filter data from previous subframe
voicing [in/out] (Q0) pointer to variable receiving voicing decision
lp_filter_coeffs (Q12) LP filter coefficients
pitch_delay_int integer part of the pitch delay
residual [in/out] (Q0) residual signal buffer (used in long-term postfilter)
res_filter_data [in/out] (Q0) speech data of previous subframe
pos_filter_data [in/out] (Q0) previous speech data for short-term postfilter
speech [in/out] (Q0) signal buffer
subframe_size size of subframe
Filtering has the following stages: Long-term postfilter (4.2.1) Short-term postfilter (4.2.2). Tilt-compensation (4.2.3)

Definition at line 514 of file g729postfilter.c.

Referenced by decode_frame().

static int16_t get_tilt_comp ( DSPContext dsp,
int16_t lp_gn,
const int16_t lp_gd,
int16_t speech,
int  subframe_size 
) [static]

Calculate reflection coefficient for tilt compensation filter (4.2.3).

Parameters:
dsp initialized DSP context
lp_gn (3.12) coefficients of A(z/FORMANT_PP_FACTOR_NUM) filter
lp_gd (3.12) coefficients of A(z/FORMANT_PP_FACTOR_DEN) filter
speech speech to update
subframe_size size of subframe
Returns:
(3.12) reflection coefficient
Remarks:
The routine also calculates the gain term for the short-term filter (gf) and multiplies the speech data by 1/gf.
Note:
All members of lp_gn, except 10-19 must be equal to zero.

Definition at line 424 of file g729postfilter.c.

Referenced by ff_g729_postfilter().

static int16_t long_term_filter ( DSPContext dsp,
int  pitch_delay_int,
const int16_t residual,
int16_t residual_filt,
int  subframe_size 
) [static]

long-term postfilter (4.2.1)

Parameters:
dsp initialized DSP context
pitch_delay_int integer part of the pitch delay in the first subframe
residual filtering input data
residual_filt [out] speech signal with applied A(z/FORMANT_PP_FACTOR_NUM) filter
subframe_size size of subframe
Returns:
0 if long-term prediction gain is less than 3dB, 1 - otherwise

Definition at line 110 of file g729postfilter.c.

Referenced by ff_g729_postfilter().

static void residual_filter ( int16_t out,
const int16_t filter_coeffs,
const int16_t in,
int  subframe_size 
) [static]

Residual signal calculation (4.2.1 if G.729).

Parameters:
out [out] output data filtered through A(z/FORMANT_PP_FACTOR_NUM)
filter_coeffs (3.12) A(z/FORMANT_PP_FACTOR_NUM) filter coefficients
in input speech data to process
subframe_size size of one subframe
Note:
in buffer must contain 10 items of previous speech data before top of the buffer
Remarks:
It is safe to pass the same buffer for input and output.

Definition at line 86 of file g729postfilter.c.

Referenced by ff_g729_postfilter().


Variable Documentation

const int16_t ff_g729_interp_filt_long[(ANALYZED_FRAC_DELAYS+1)*LONG_INT_FILT_LEN] [static]

Initial value:

 {
   0, 31915, 29436, 25569, 20676, 15206,  9639,  4439,
   0, -3390, -5579, -6549, -6414, -5392, -3773, -1874,
   0,  1595,  2727,  3303,  3319,  2850,  2030,  1023,
   0,  -887, -1527, -1860, -1876, -1614, -1150,  -579,
   0,   501,   859,  1041,  1044,   892,   631,   315,
   0,  -266,  -453,  -543,  -538,  -455,  -317,  -156,
   0,   130,   218,   258,   253,   212,   147,    72,
   0,   -59,  -101,  -122,  -123,  -106,   -77,   -40,
}
long interpolation filter (of length 129, according to spec) for computing signal with non-integer delay

Definition at line 49 of file g729postfilter.c.

Referenced by long_term_filter().

const int16_t ff_g729_interp_filt_short[(ANALYZED_FRAC_DELAYS+1)*SHORT_INT_FILT_LEN] [static]

Initial value:

 {
      0, 31650, 28469, 23705, 18050, 12266,  7041,  2873,
      0, -1597, -2147, -1992, -1492,  -933,  -484,  -188,
}
short interpolation filter (of length 33, according to spec) for computing signal with non-integer delay

Definition at line 40 of file g729postfilter.c.

Referenced by long_term_filter().

const int16_t formant_pp_factor_den_pow[10] [static]

Initial value:

 {
  
  22938, 16057, 11240, 7868, 5508, 3856, 2699, 1889, 1322, 925
}
formant_pp_factor_den_pow[i] = FORMANT_PP_FACTOR_DEN^(i+1)

Definition at line 71 of file g729postfilter.c.

Referenced by ff_g729_postfilter().

const int16_t formant_pp_factor_num_pow[10] [static]

Initial value:

 {
  
  18022, 9912, 5451, 2998, 1649, 907, 499, 274, 151, 83
}
formant_pp_factor_num_pow[i] = FORMANT_PP_FACTOR_NUM^(i+1)

Definition at line 63 of file g729postfilter.c.

Referenced by ff_g729_postfilter().


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