code.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. /* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/code.c,v 1.3 1996/07/02 09:59:05 jutta Exp $ */
  7. #include "config.h"
  8. #ifdef HAS_STDLIB_H
  9. #include <stdlib.h>
  10. #else
  11. # include "proto.h"
  12. extern char * memcpy P((char *, char *, int));
  13. #endif
  14. #include "private.h"
  15. #include "gsm.h"
  16. #include "proto.h"
  17. /*
  18. * 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER
  19. */
  20. void Gsm_Coder P8((S,s,LARc,Nc,bc,Mc,xmaxc,xMc),
  21. struct gsm_state * S,
  22. word * s, /* [0..159] samples IN */
  23. /*
  24. * The RPE-LTD coder works on a frame by frame basis. The length of
  25. * the frame is equal to 160 samples. Some computations are done
  26. * once per frame to produce at the output of the coder the
  27. * LARc[1..8] parameters which are the coded LAR coefficients and
  28. * also to realize the inverse filtering operation for the entire
  29. * frame (160 samples of signal d[0..159]). These parts produce at
  30. * the output of the coder:
  31. */
  32. word * LARc, /* [0..7] LAR coefficients OUT */
  33. /*
  34. * Procedure 4.2.11 to 4.2.18 are to be executed four times per
  35. * frame. That means once for each sub-segment RPE-LTP analysis of
  36. * 40 samples. These parts produce at the output of the coder:
  37. */
  38. word * Nc, /* [0..3] LTP lag OUT */
  39. word * bc, /* [0..3] coded LTP gain OUT */
  40. word * Mc, /* [0..3] RPE grid selection OUT */
  41. word * xmaxc,/* [0..3] Coded maximum amplitude OUT */
  42. word * xMc /* [13*4] normalized RPE samples OUT */
  43. )
  44. {
  45. int k;
  46. word * dp = S->dp0 + 120; /* [ -120...-1 ] */
  47. word * dpp = dp; /* [ 0...39 ] */
  48. word so[160];
  49. Gsm_Preprocess (S, s, so);
  50. Gsm_LPC_Analysis (S, so, LARc);
  51. Gsm_Short_Term_Analysis_Filter (S, LARc, so);
  52. for (k = 0; k <= 3; k++, xMc += 13) {
  53. Gsm_Long_Term_Predictor ( S,
  54. so+k*40, /* d [0..39] IN */
  55. dp, /* dp [-120..-1] IN */
  56. S->e + 5, /* e [0..39] OUT */
  57. dpp, /* dpp [0..39] OUT */
  58. Nc++,
  59. bc++);
  60. Gsm_RPE_Encoding ( S,
  61. S->e + 5,/* e ][0..39][ IN/OUT */
  62. xmaxc++, Mc++, xMc );
  63. /*
  64. * Gsm_Update_of_reconstructed_short_time_residual_signal
  65. * ( dpp, S->e + 5, dp );
  66. */
  67. { register int i;
  68. register longword ltmp;
  69. for (i = 0; i <= 39; i++)
  70. dp[ i ] = GSM_ADD( S->e[5 + i], dpp[i] );
  71. }
  72. dp += 40;
  73. dpp += 40;
  74. }
  75. (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160),
  76. 120 * sizeof(*S->dp0) );
  77. }