fixed_tm.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Copyright (C) 2007 Hong Zhiqian */
  2. /**
  3. @file fixed_tm.h
  4. @author Hong Zhiqian
  5. @brief Various compatibility routines for Speex (TriMedia version)
  6. */
  7. /*
  8. Redistribution and use in source and binary forms, with or without
  9. modification, are permitted provided that the following conditions
  10. are met:
  11. - Redistributions of source code must retain the above copyright
  12. notice, this list of conditions and the following disclaimer.
  13. - Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. - Neither the name of the Xiph.org Foundation nor the names of its
  17. contributors may be used to endorse or promote products derived from
  18. this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
  23. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  27. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #ifndef FIXED_TM_H
  32. #define FIXED_TM_H
  33. #include <ops/custom_defs.h>
  34. #undef SATURATE
  35. #undef SATURATE16
  36. #undef SATURATE32
  37. #define SATURATE(x,a) iclipi(x,a)
  38. #define SATURATE16(x,a) iclipi(x,a)
  39. #define SATURATE32(x,a) iclipi(x,a)
  40. #undef EXTEND32
  41. #define EXTEND32(x) sex16(x)
  42. #undef NEG16
  43. #undef NEG32
  44. #define NEG16(x) ineg((int)(x))
  45. #define NEG32(x) ineg(x)
  46. #undef ABS
  47. #undef ABS16
  48. #undef ABS32
  49. #define ABS(x) iabs(x)
  50. #define ABS32(x) iabs(x)
  51. #define ABS16(x) iabs((int)(x))
  52. #undef MIN16
  53. #undef MIN32
  54. #define MIN16(a,b) imin((int)(a),(int)(b))
  55. #define MIN32(a,b) imin(a,b)
  56. #undef MAX16
  57. #undef MAX32
  58. #define MAX16(a,b) imax((int)(a),(int)(b))
  59. #define MAX32(a,b) imax(a,b)
  60. #undef ADD16
  61. #undef SUB16
  62. #undef ADD32
  63. #undef SUB32
  64. #undef MULT16_16
  65. #undef MULT16_16_16
  66. #define ADD16(a,b) ((int)(a) + (int)(b))
  67. #define SUB16(a,b) ((int)(a) - (int)(b))
  68. #define ADD32(a,b) ((int)(a) + (int)(b))
  69. #define SUB32(a,b) ((int)(a) - (int)(b))
  70. #define MULT16_16_16(a,b) ((int)(a) * (int)(b))
  71. #define MULT16_16(a,b) ((int)(a) * (int)(b))
  72. #if TM_DEBUGMEM_ALIGNNMENT
  73. #include <stdio.h>
  74. #define TMDEBUG_ALIGNMEM(x) \
  75. { if( ((int)(x) & (int)(0x00000003)) != 0 ) \
  76. { printf("memory not align. file: %s, line: %d\n", __FILE__, __LINE__); \
  77. } \
  78. }
  79. #else
  80. #define TMDEBUG_ALIGNMEM(x)
  81. #endif
  82. #endif