post_pro.c
上传用户:zhouyunkk
上传日期:2013-01-10
资源大小:59k
文件大小:3k
源码类别:

语音压缩

开发平台:

C/C++

  1. /*
  2.    ITU-T G.729 Annex C - Reference C code for floating point
  3.                          implementation of G.729
  4.                          Version 1.01 of 15.September.98
  5. */
  6. /*
  7. ----------------------------------------------------------------------
  8.                     COPYRIGHT NOTICE
  9. ----------------------------------------------------------------------
  10.    ITU-T G.729 Annex C ANSI C source code
  11.    Copyright (C) 1998, AT&T, France Telecom, NTT, University of
  12.    Sherbrooke.  All rights reserved.
  13. ----------------------------------------------------------------------
  14. */
  15. /*
  16.  File : POST_PRO.C
  17.  Used for the floating point version of both
  18.  G.729 main body and G.729A
  19. */
  20. #include "typedef.h"
  21. #include "version.h"
  22. #ifdef VER_G729A
  23.  #include "ld8a.h"
  24.  #include "tab_ld8a.h"
  25. #else
  26.  #include "ld8k.h"
  27.  #include "tab_ld8k.h"
  28. #endif
  29. /*------------------------------------------------------------------------*
  30.  * Function post_process()                                                 *
  31.  *                                                                        *
  32.  * Post-processing of output speech.                                      *
  33.  *   - 2nd order high pass filter with cut off frequency at 100 Hz.       *
  34.  *-----------------------------------------------------------------------*/
  35. /*------------------------------------------------------------------------*
  36.  * 2nd order high pass filter with cut off frequency at 100 Hz.           *
  37.  * Designed with SPPACK efi command -40 dB att, 0.25 ri.                  *
  38.  *                                                                        *
  39.  * Algorithm:                                                             *
  40.  *                                                                        *
  41.  *  y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2]                          *
  42.  *                   + a[1]*y[i-1] + a[2]*y[i-2];                         *
  43.  *                                                                        *
  44.  *     b[3] = {0.93980581E+00, -0.18795834E+01,  0.93980581E+00};         *
  45.  *     a[3] = {0.10000000E+01, +0.19330735E+01, -0.93589199E+00};         *
  46.  *-----------------------------------------------------------------------*/
  47. static FLOAT x0, x1;         /* high-pass fir memory          */
  48. static FLOAT y1, y2;         /* high-pass iir memory          */
  49. void init_post_process( void
  50. )
  51. {
  52.   x0 = x1 = (F)0.0;
  53.   y2 = y1 = (F)0.0;
  54.   return;
  55. }
  56. void post_process(
  57.    FLOAT signal[],      /* (i/o)  : signal                     */
  58.    int lg               /* (i)    : lenght of signal           */
  59. )
  60. {
  61.   int i;
  62.   FLOAT x2;
  63.   FLOAT y0;
  64.   for(i=0; i<lg; i++)
  65.   {
  66.     x2 = x1;
  67.     x1 = x0;
  68.     x0 = signal[i];
  69.     y0 = y1*a100[1] + y2*a100[2] + x0*b100[0] + x1*b100[1] + x2*b100[2];
  70.     signal[i] = y0;
  71.     y2 = y1;
  72.     y1 = y0;
  73.   }
  74.   return;
  75. }