pre_proc.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 : PRE_PROC.C
  17.  Used for the floating point version of both
  18.  G.729 main body and G.729A
  19. */
  20. /*------------------------------------------------------------------------*
  21.  * Function pre_process()                                                 *
  22.  *                                                                        *
  23.  * Preprocessing of input speech.                                         *
  24.  *   - 2nd order high pass filter with cut off frequency at 140 Hz.       *
  25.  *-----------------------------------------------------------------------*/
  26. #include "typedef.h"
  27. #include "version.h"
  28. #ifdef VER_G729A
  29.  #include "ld8a.h"
  30.  #include "tab_ld8a.h"
  31. #else
  32.  #include "ld8k.h"
  33.  #include "tab_ld8k.h"
  34. #endif
  35. /*------------------------------------------------------------------------*
  36.  * 2nd order high pass filter with cut off frequency at 140 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.92727435E+00, -0.18544941E+01, 0.92727435E+00};          *
  45.  *     a[3] = {0.10000000E+01, 0.19059465E+01, -0.91140240E+00};          *
  46.  *-----------------------------------------------------------------------*/
  47. static FLOAT x0, x1;         /* high-pass fir memory          */
  48. static FLOAT y1, y2;         /* high-pass iir memory          */
  49. void init_pre_process( void
  50. )
  51. {
  52.   x0 = x1 = (F)0.0;
  53.   y2 = y1 = (F)0.0;
  54.   return;
  55. }
  56. void pre_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*a140[1] + y2*a140[2] + x0*b140[0] + x1*b140[1] + x2*b140[2];
  70.     signal[i] = y0;
  71.     y2 = y1;
  72.     y1 = y0;
  73.   }
  74.   return;
  75. }