/project/jni/sndfile/src/GSM610/code.c

https://github.com/aichunyu/FFPlayer · C · 87 lines · 42 code · 19 blank · 26 comment · 2 complexity · 705c63eda9e9948cb66c8c062b49f940 MD5 · raw file

  1. /*
  2. * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
  3. * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
  4. * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  5. */
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include "gsm610_priv.h"
  9. /*
  10. * 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER
  11. */
  12. void Gsm_Coder (
  13. struct gsm_state * State,
  14. word * s, /* [0..159] samples IN */
  15. /*
  16. * The RPE-LTD coder works on a frame by frame basis. The length of
  17. * the frame is equal to 160 samples. Some computations are done
  18. * once per frame to produce at the output of the coder the
  19. * LARc[1..8] parameters which are the coded LAR coefficients and
  20. * also to realize the inverse filtering operation for the entire
  21. * frame (160 samples of signal d[0..159]). These parts produce at
  22. * the output of the coder:
  23. */
  24. word * LARc, /* [0..7] LAR coefficients OUT */
  25. /*
  26. * Procedure 4.2.11 to 4.2.18 are to be executed four times per
  27. * frame. That means once for each sub-segment RPE-LTP analysis of
  28. * 40 samples. These parts produce at the output of the coder:
  29. */
  30. word * Nc, /* [0..3] LTP lag OUT */
  31. word * bc, /* [0..3] coded LTP gain OUT */
  32. word * Mc, /* [0..3] RPE grid selection OUT */
  33. word * xmaxc,/* [0..3] Coded maximum amplitude OUT */
  34. word * xMc /* [13*4] normalized RPE samples OUT */
  35. )
  36. {
  37. int k;
  38. word * dp = State->dp0 + 120; /* [ -120...-1 ] */
  39. word * dpp = dp; /* [ 0...39 ] */
  40. word so[160];
  41. Gsm_Preprocess (State, s, so);
  42. Gsm_LPC_Analysis (State, so, LARc);
  43. Gsm_Short_Term_Analysis_Filter (State, LARc, so);
  44. for (k = 0; k <= 3; k++, xMc += 13) {
  45. Gsm_Long_Term_Predictor ( State,
  46. so+k*40, /* d [0..39] IN */
  47. dp, /* dp [-120..-1] IN */
  48. State->e + 5, /* e [0..39] OUT */
  49. dpp, /* dpp [0..39] OUT */
  50. Nc++,
  51. bc++);
  52. Gsm_RPE_Encoding ( /*-S,-*/
  53. State->e + 5, /* e ][0..39][ IN/OUT */
  54. xmaxc++, Mc++, xMc );
  55. /*
  56. * Gsm_Update_of_reconstructed_short_time_residual_signal
  57. * ( dpp, State->e + 5, dp );
  58. */
  59. { register int i;
  60. for (i = 0; i <= 39; i++)
  61. dp[ i ] = GSM_ADD( State->e[5 + i], dpp[i] );
  62. }
  63. dp += 40;
  64. dpp += 40;
  65. }
  66. (void)memcpy( (char *)State->dp0, (char *)(State->dp0 + 160),
  67. 120 * sizeof(*State->dp0) );
  68. }