fixed_c5x.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Copyright (C) 2003 Jean-Marc Valin */
  2. /**
  3. @file fixed_c5x.h
  4. @brief Fixed-point operations for the TI C5x DSP family
  5. */
  6. /*
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions
  9. are met:
  10. - Redistributions of source code must retain the above copyright
  11. notice, this list of conditions and the following disclaimer.
  12. - Redistributions in binary form must reproduce the above copyright
  13. notice, this list of conditions and the following disclaimer in the
  14. documentation and/or other materials provided with the distribution.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  16. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  17. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  19. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  20. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  22. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef FIXED_C5X_H
  28. #define FIXED_C5X_H
  29. #include "dsplib.h"
  30. #undef IMUL32
  31. static OPUS_INLINE long IMUL32(long i, long j)
  32. {
  33. long ac0, ac1;
  34. ac0 = _lmpy(i>>16,j);
  35. ac1 = ac0 + _lmpy(i,j>>16);
  36. return _lmpyu(i,j) + (ac1<<16);
  37. }
  38. #undef MAX16
  39. #define MAX16(a,b) _max(a,b)
  40. #undef MIN16
  41. #define MIN16(a,b) _min(a,b)
  42. #undef MAX32
  43. #define MAX32(a,b) _lmax(a,b)
  44. #undef MIN32
  45. #define MIN32(a,b) _lmin(a,b)
  46. #undef VSHR32
  47. #define VSHR32(a, shift) _lshl(a,-(shift))
  48. #undef MULT16_16_Q15
  49. #define MULT16_16_Q15(a,b) (_smpy(a,b))
  50. #undef MULT16_16SU
  51. #define MULT16_16SU(a,b) _lmpysu(a,b)
  52. #undef MULT_16_16
  53. #define MULT_16_16(a,b) _lmpy(a,b)
  54. /* FIXME: This is technically incorrect and is bound to cause problems. Is there any cleaner solution? */
  55. #undef MULT16_32_Q15
  56. #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),(b)),15))
  57. #define celt_ilog2(x) (30 - _lnorm(x))
  58. #define OVERRIDE_CELT_ILOG2
  59. #define celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)),-EXTEND32(minval((DATA *)x, len)))
  60. #define OVERRIDE_CELT_MAXABS16
  61. #endif /* FIXED_C5X_H */