librempeg/libavcodec/g729postfilter.h

96 lines
3.1 KiB
C
Raw Normal View History

2008-09-03 08:55:53 +00:00
/*
* G.729, G729 Annex D postfilter
* Copyright (c) 2008 Vladimir Voroshilov
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FFMPEG_G729POSTFILTER_H
#define FFMPEG_G729POSTFILTER_H
#include <stdint.h>
/**
* tilt compensation factor (G.729, k1>0)
* 0.2 in Q15
*/
#define G729_TILT_FACTOR_PLUS 6554
/**
* tilt compensation factor (G.729, k1<0)
* 0.9 in Q15
*/
#define G729_TILT_FACTOR_MINUS 29491
/* 4.2.2 */
#define FORMANT_PP_FACTOR_NUM 18022 //0.55 in Q15
#define FORMANT_PP_FACTOR_DEN 22938 //0.70 in Q15
/**
* 1.0 / (1.0 + 0.5) in Q15
* where 0.5 is the minimum value of
* weight factor, controlling amount of long-term postfiltering
*/
#define MIN_LT_FILT_FACTOR_A 21845
/**
* Short interpolation filter length
*/
#define SHORT_INT_FILT_LEN 2
/**
* Long interpolation filter length
*/
#define LONG_INT_FILT_LEN 8
/**
* Number of analyzed fractional pitch delays in second stage of long-term
* postfilter
*/
#define ANALYZED_FRAC_DELAYS 7
/**
* Amount of past residual signal data stored in buffer
*/
#define RES_PREV_DATA_SIZE (PITCH_DELAY_MAX + LONG_INT_FILT_LEN + 1)
/**
* \brief Signal postfiltering (4.2)
* \param dsp initialized DSP context
* \param ht_prev_data [in/out] (Q12) pointer to variable receiving tilt
* compensation filter data from previous subframe
* \param voicing [in/out] (Q0) pointer to variable receiving voicing decision
* \param lp_filter_coeffs (Q12) LP filter coefficients
* \param pitch_delay_int integer part of the pitch delay
* \param residual [in/out] (Q0) residual signal buffer (used in long-term postfilter)
* \param res_filter_data [in/out] (Q0) speech data of previous subframe
* \param pos_filter_data [in/out] (Q0) previous speech data for short-term postfilter
* \param speech [in/out] (Q0) signal buffer
* \param 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)
*/
void g729_postfilter(DSPContext *dsp, int16_t* ht_prev_data, int16_t* 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);
#endif // FFMPEG_G729POSTFILTER_H