mac_32.c 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. ********************************************************************************
  3. *
  4. * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
  5. * R99 Version 3.3.0
  6. * REL-4 Version 4.1.0
  7. *
  8. ********************************************************************************
  9. *
  10. * File : mac_32.c
  11. * Purpose : 32 x 32 and 32 x 16 bit DPF multiy & accumulate
  12. * (similar as Mpy_32 and Mpy_32_16 in oper_32b.c)
  13. *
  14. ********************************************************************************
  15. */
  16. /*
  17. ********************************************************************************
  18. * MODULE INCLUDE FILE AND VERSION ID
  19. ********************************************************************************
  20. */
  21. #include "mac_32.h"
  22. const char mac_32_id[] = "@(#)$Id $" mac_32_h;
  23. /*
  24. ********************************************************************************
  25. * INCLUDE FILES
  26. ********************************************************************************
  27. */
  28. #include "typedef.h"
  29. #include "basic_op.h"
  30. #include "oper_32b.h"
  31. #include "count.h"
  32. /*
  33. ********************************************************************************
  34. * PUBLIC PROGRAM CODE
  35. ********************************************************************************
  36. */
  37. /*****************************************************************************
  38. * Function Mac_32() *
  39. * *
  40. * Multiply two 32 bit integers (DPF) and accumulate with (normal) 32 bit *
  41. * integer. The multiplication result is divided by 2**31 *
  42. * *
  43. * L_32 = L_32 + (hi1*hi2)<<1 + ( (hi1*lo2)>>15 + (lo1*hi2)>>15 )<<1 *
  44. * *
  45. * This operation can also be viewed as the multiplication of two Q31 *
  46. * number and the result is also in Q31. *
  47. * *
  48. * Arguments: *
  49. * *
  50. * hi1 hi part of first number *
  51. * lo1 lo part of first number *
  52. * hi2 hi part of second number *
  53. * lo2 lo part of second number *
  54. * *
  55. *****************************************************************************
  56. */
  57. Word32 Mac_32 (Word32 L_32, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
  58. {
  59. L_32 = L_mac_ex (L_32, hi1, hi2);
  60. L_32 = L_mac_ex (L_32, mult_ex (hi1, lo2), 1);
  61. L_32 = L_mac_ex (L_32, mult_ex (lo1, hi2), 1);
  62. return (L_32);
  63. }
  64. /*****************************************************************************
  65. * Function Mac_32_16() *
  66. * *
  67. * Multiply a 16 bit integer by a 32 bit (DPF) and accumulate with (normal)*
  68. * 32 bit integer. The multiplication result is divided by 2**15 *
  69. * *
  70. * *
  71. * L_32 = L_32 + (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1 *
  72. * *
  73. * Arguments: *
  74. * *
  75. * hi hi part of 32 bit number. *
  76. * lo lo part of 32 bit number. *
  77. * n 16 bit number. *
  78. * *
  79. *****************************************************************************
  80. */
  81. Word32 Mac_32_16 (Word32 L_32, Word16 hi, Word16 lo, Word16 n)
  82. {
  83. L_32 = L_mac_ex (L_32, hi, n);
  84. L_32 = L_mac_ex (L_32, mult_ex (lo, n), 1);
  85. return (L_32);
  86. }