POST_PRO.C
Upload User: meifeng08
Upload Date: 2013-06-18
Package Size: 5304k
Code Size: 3k
Category:

Voice Compress

Development Platform:

C/C++

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