POST_PRO.C
上传用户:meifeng08
上传日期:2013-06-18
资源大小:5304k
文件大小:3k
源码类别:

语音压缩

开发平台:

C/C++

  1. /* Version 3.3    Last modified: December 26, 1995 */
  2. /*------------------------------------------------------------------------*
  3.  * Function Post_Process()                                                *
  4.  *                                                                        *
  5.  * Post-processing of output speech.                                      *
  6.  *   - 2nd order high pass filter with cut off frequency at 100 Hz.       *
  7.  *   - Multiplication by two of output speech with saturation.            *
  8.  *-----------------------------------------------------------------------*/
  9. #include "typedef.h"
  10. #include "basic_op.h"
  11. #include "oper_32b.h"
  12. #include "ld8k.h"
  13. #include "tab_ld8k.h"
  14. /*------------------------------------------------------------------------*
  15.  * 2nd order high pass filter with cut off frequency at 100 Hz.           *
  16.  * Designed with SPPACK efi command -40 dB att, 0.25 ri.                  *
  17.  *                                                                        *
  18.  * Algorithm:                                                             *
  19.  *                                                                        *
  20.  *  y[i] = b[0]*x[i]   + b[1]*x[i-1]   + b[2]*x[i-2]                      *
  21.  *                     + a[1]*y[i-1]   + a[2]*y[i-2];                     *
  22.  *                                                                        *
  23.  *     b[3] = {0.93980581E+00, -0.18795834E+01, 0.93980581E+00};          *
  24.  *     a[3] = {0.10000000E+01, 0.19330735E+01, -0.93589199E+00};          *
  25.  *-----------------------------------------------------------------------*/
  26. /* Static values to be preserved between calls */
  27. /* y[] values is keep in double precision      */
  28. static Word16 y2_hi, y2_lo, y1_hi, y1_lo, x0, x1;
  29. /* Initialization of static values */
  30. void Init_Post_Process(void)
  31. {
  32.   y2_hi = 0;
  33.   y2_lo = 0;
  34.   y1_hi = 0;
  35.   y1_lo = 0;
  36.   x0   = 0;
  37.   x1   = 0;
  38. }
  39. void Post_Process(
  40.   Word16 signal[],    /* input/output signal */
  41.   Word16 lg)          /* length of signal    */
  42. {
  43.   Word16 i, x2;
  44.   Word32 L_tmp;
  45.   for(i=0; i<lg; i++)
  46.   {
  47.      x2 = x1;
  48.      x1 = x0;
  49.      x0 = signal[i];
  50.      /*  y[i] = b[0]*x[i]   + b[1]*x[i-1]   + b[2]*x[i-2]    */
  51.      /*                     + a[1]*y[i-1] + a[2] * y[i-2];      */
  52.      L_tmp     = Mpy_32_16(y1_hi, y1_lo, a100[1]);
  53.      L_tmp     = L_add(L_tmp, Mpy_32_16(y2_hi, y2_lo, a100[2]));
  54.      L_tmp     = L_mac(L_tmp, x0, b100[0]);
  55.      L_tmp     = L_mac(L_tmp, x1, b100[1]);
  56.      L_tmp     = L_mac(L_tmp, x2, b100[2]);
  57.      L_tmp     = L_shl(L_tmp, 2);      /* Q29 --> Q31 (Q13 --> Q15) */
  58.      /* Multiplication by two of output speech with saturation. */
  59.      signal[i] = round(L_shl(L_tmp, 1));
  60.      y2_hi = y1_hi;
  61.      y2_lo = y1_lo;
  62.      L_Extract(L_tmp, &y1_hi, &y1_lo);
  63.   }
  64.   return;
  65. }