提交 aca516cd 编写于 作者: V Vladimir Voroshilov 提交者: Michael Niedermayer

G.729 postfilter

上级 16bbb8df
......@@ -159,7 +159,7 @@ OBJS-$(CONFIG_FLIC_DECODER) += flicvideo.o
OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o
OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o
OBJS-$(CONFIG_FRWU_DECODER) += frwu.o
OBJS-$(CONFIG_G729_DECODER) += g729dec.o lsp.o celp_math.o acelp_filters.o acelp_pitch_delay.o acelp_vectors.o
OBJS-$(CONFIG_G729_DECODER) += g729dec.o lsp.o celp_math.o acelp_filters.o acelp_pitch_delay.o acelp_vectors.o g729postfilter.o
OBJS-$(CONFIG_GIF_DECODER) += gifdec.o lzw.o
OBJS-$(CONFIG_GIF_ENCODER) += gif.o lzwenc.o
OBJS-$(CONFIG_GSM_DECODER) += gsmdec.o gsmdec_data.o msgsmdec.o
......
......@@ -39,6 +39,7 @@
#include "acelp_pitch_delay.h"
#include "acelp_vectors.h"
#include "g729data.h"
#include "g729postfilter.h"
/**
* minimum quantized LSF value (3.2.4)
......@@ -122,6 +123,16 @@ typedef struct {
/// previous speech data for LP synthesis filter
int16_t syn_filter_data[10];
/// residual signal buffer (used in long-term postfilter)
int16_t residual[SUBFRAME_SIZE + RES_PREV_DATA_SIZE];
/// previous speech data for residual calculation filter
int16_t res_filter_data[SUBFRAME_SIZE+10];
/// previous speech data for short-term postfilter
int16_t pos_filter_data[SUBFRAME_SIZE+10];
/// (1.14) pitch gain of current and five previous subframes
int16_t past_gain_pitch[6];
......@@ -133,6 +144,7 @@ typedef struct {
int16_t onset; ///< detected onset level (0-2)
int16_t was_periodic; ///< whether previous frame was declared as periodic or not (4.4)
int16_t ht_prev_data; ///< previous data for 4.2.3, equation 86
uint16_t rand_value; ///< random number generator value (4.4.4)
int ma_predictor_prev; ///< switched MA predictor of LSP quantizer from last good frame
......@@ -625,6 +637,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
/* Save data (without postfilter) for use in next subframe. */
memcpy(ctx->syn_filter_data, synth+SUBFRAME_SIZE, 10 * sizeof(int16_t));
/* Call postfilter and also update voicing decision for use in next frame. */
g729_postfilter(
&ctx->dsp,
&ctx->ht_prev_data,
&is_periodic,
&lp[i][0],
pitch_delay_int[0],
ctx->residual,
ctx->res_filter_data,
ctx->pos_filter_data,
synth+10,
SUBFRAME_SIZE);
if (frame_erasure)
ctx->pitch_delay_int_prev = FFMIN(ctx->pitch_delay_int_prev + 1, PITCH_DELAY_MAX);
else
......
此差异已折叠。
/*
* 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册