Postfilter functions

Postfilter functions (gain control, wiener denoise filter, DC filter, kalman smoothening, plus surrounding code to wrap it). More...


Functions

static void adaptive_gain_control (float *out, const float *in, const float *speech_synth, int size, float alpha, float *gain_mem)
 Adaptive gain control (as used in postfilter).
static int kalman_smoothen (WMAVoiceContext *s, int pitch, const float *in, float *out, int size)
 Kalman smoothing function.
static float tilt_factor (const float *lpcs, int n_lpcs)
 Get the tilt factor of a formant filter from its transfer function.
static void calc_input_response (WMAVoiceContext *s, float *lpcs, int fcb_type, float *coeffs, int remainder)
 Derive denoise filter coefficients (in real domain) from the LPCs.
static void wiener_denoise (WMAVoiceContext *s, int fcb_type, float *synth_pf, int size, const float *lpcs)
 This function applies a Wiener filter on the (noisy) speech signal as a means to denoise it.
static void postfilter (WMAVoiceContext *s, const float *synth, float *samples, int size, const float *lpcs, float *zero_exc_pf, int fcb_type, int pitch)
 Averaging projection filter, the postfilter used in WMAVoice.


Detailed Description

Postfilter functions (gain control, wiener denoise filter, DC filter, kalman smoothening, plus surrounding code to wrap it).

Function Documentation

static void adaptive_gain_control ( float *  out,
const float *  in,
const float *  speech_synth,
int  size,
float  alpha,
float *  gain_mem 
) [static]

Adaptive gain control (as used in postfilter).

Identical to ff_adaptive_gain_control() in acelp_vectors.c, except that the energy here is calculated using sum(abs(...)), whereas the other codecs (e.g. AMR-NB, SIPRO) use sqrt(dotproduct(...)).

Parameters:
out output buffer for filtered samples
in input buffer containing the samples as they are after the postfilter steps so far
speech_synth input buffer containing speech synth before postfilter
size input buffer size
alpha exponential filter factor
gain_mem pointer to filter memory (single float)

Definition at line 454 of file wmavoice.c.

Referenced by postfilter().

static void calc_input_response ( WMAVoiceContext s,
float *  lpcs,
int  fcb_type,
float *  coeffs,
int  remainder 
) [static]

Derive denoise filter coefficients (in real domain) from the LPCs.

Definition at line 553 of file wmavoice.c.

Referenced by wiener_denoise().

static int kalman_smoothen ( WMAVoiceContext s,
int  pitch,
const float *  in,
float *  out,
int  size 
) [static]

Kalman smoothing function.

This function looks back pitch +/- 3 samples back into history to find the best fitting curve (that one giving the optimal gain of the two signals, i.e. the highest dot product between the two), and then uses that signal history to smoothen the output of the speech synthesis filter.

Parameters:
s WMA Voice decoding context
pitch pitch of the speech signal
in input speech signal
out output pointer for smoothened signal
size input/output buffer size
Returns:
-1 if no smoothening took place, e.g. because no optimal fit could be found, or 0 on success.

Definition at line 494 of file wmavoice.c.

Referenced by postfilter().

static void postfilter ( WMAVoiceContext s,
const float *  synth,
float *  samples,
int  size,
const float *  lpcs,
float *  zero_exc_pf,
int  fcb_type,
int  pitch 
) [static]

Averaging projection filter, the postfilter used in WMAVoice.

This uses the following steps:

  • A zero-synthesis filter (generate excitation from synth signal)
  • Kalman smoothing on excitation, based on pitch
  • Re-synthesized smoothened output
  • Iterative Wiener denoise filter
  • Adaptive gain filter
  • DC filter

Parameters:
s WMAVoice decoding context
synth Speech synthesis output (before postfilter)
samples Output buffer for filtered samples
size Buffer size of synth & samples
lpcs Generated LPCs used for speech synthesis
fcb_type Frame type (silence, hardcoded, AW-pulses or FCB-pulses)
pitch Pitch of the input signal

Definition at line 750 of file wmavoice.c.

static float tilt_factor ( const float *  lpcs,
int  n_lpcs 
) [static]

Get the tilt factor of a formant filter from its transfer function.

See also:
tilt_factor() in amrnbdec.c, which does essentially the same, but somehow (??) it does a speech synthesis filter in the middle, which is missing here
Parameters:
lpcs LPC coefficients
n_lpcs Size of LPC buffer
Returns:
the tilt factor

Definition at line 540 of file wmavoice.c.

static void wiener_denoise ( WMAVoiceContext s,
int  fcb_type,
float *  synth_pf,
int  size,
const float *  lpcs 
) [static]

This function applies a Wiener filter on the (noisy) speech signal as a means to denoise it.

  • take RDFT of LPCs to get the power spectrum of the noise + speech;
  • using this power spectrum, calculate (for each frequency) the Wiener filter gain, which depends on the frequency power and desired level of noise subtraction (when set too high, this leads to artifacts) We can do this symmetrically over the X-axis (so 0-4kHz is the inverse of 4-8kHz);
  • by doing a phase shift, calculate the Hilbert transform of this array of per-frequency filter-gains to get the filtering coefficients;
  • smoothen/normalize/de-tilt these filter coefficients as desired;
  • take RDFT of noisy sound, apply the coefficients and take its IRDFT to get the denoised speech signal;
  • the leftover (i.e. output of the IRDFT on denoised speech data beyond the frame boundary) are saved and applied to subsequent frames by an overlap-add method (otherwise you get clicking-artifacts).

Parameters:
s WMA Voice decoding context
s fcb_type Frame (codebook) type
synth_pf input: the noisy speech signal, output: denoised speech data; should be 16-byte aligned (for ASM purposes)
size size of the speech data
lpcs LPCs used to synthesize this frame's speech data

Definition at line 669 of file wmavoice.c.

Referenced by postfilter().


Generated on Fri Oct 26 02:36:56 2012 for FFmpeg by  doxygen 1.5.8