ccs宏定义与调用问题

2019-03-24 10:07发布

  1. #ifdef __cplusplus
  2. extern "C" {
  3. #endif
  4. void PolyphaseMono(short *pcm, int *vbuf, const int *coefBase);
  5. void PolyphaseStereo(short *pcm, int *vbuf, const int *coefBase);
  6. #ifdef __cplusplus
  7. }
  8. #endif
复制代码
  1. #if (defined _WIN32 && !defined _WIN32_WCE) || (defined __WINS__ && defined _SYMBIAN) || defined(_OPENWAVE_SIMULATOR) || defined(WINCE_EMULATOR) /* Symbian emulator for Ix86 */

  2. #pragma warning( disable : 4035 )        /* complains about inline asm not returning a value */

  3. static __inline int MULSHIFT32(int x, int y)       
  4. {
  5. __asm {
  6. mov         eax, x
  7. imul        y
  8. mov         eax, edx
  9. }
  10. }

  11. static __inline int FASTABS(int x)
  12. {
  13. int sign;

  14. sign = x >> (sizeof(int) * 8 - 1);
  15. x ^= sign;
  16. x -= sign;

  17. return x;
  18. }

  19. static __inline int CLZ(int x)
  20. {
  21. int numZeros;

  22. if (!x)
  23. return (sizeof(int) * 8);

  24. numZeros = 0;
  25. while (!(x & 0x80000000)) {
  26. numZeros++;
  27. x <<= 1;
  28. }

  29. return numZeros;
  30. }

  31. /* MADD64, SHL64, SAR64:
  32. * write in assembly to avoid dependency on run-time lib for 64-bit shifts, muls
  33. * (sometimes compiler thunks to function calls instead of code generating)
  34. * required for Symbian emulator
  35. */
  36. #ifdef __CW32__
  37. typedef long long Word64;
  38. #else
  39. typedef __int64 Word64;
  40. #endif

  41. static __inline Word64 MADD64(Word64 sum, int x, int y)
  42. {
  43. unsigned int sumLo = ((unsigned int *)&sum)[0];
  44. int sumHi = ((int *)&sum)[1];

  45. __asm {
  46. mov         eax, x
  47. imul        y
  48. add         eax, sumLo
  49. adc         edx, sumHi
  50. }

  51. /* equivalent to return (sum + ((__int64)x * y)); */
  52. }

  53. static __inline Word64 SHL64(Word64 x, int n)
  54. {
  55. unsigned int xLo = ((unsigned int *)&x)[0];
  56. int xHi = ((int *)&x)[1];
  57. unsigned char nb = (unsigned char)n;

  58. if (n < 32) {
  59. __asm {
  60. mov         edx, xHi
  61. mov         eax, xLo
  62. mov         cl, nb
  63. shld edx, eax, cl
  64. shl eax, cl
  65. }
  66. } else if (n < 64) {
  67. /* shl masks cl to 0x1f */
  68. __asm {
  69. mov         edx, xLo
  70. mov         cl, nb
  71. xor eax, eax
  72. shl edx, cl
  73. }
  74. } else {
  75. __asm {
  76. xor         edx, edx
  77. xor         eax, eax
  78. }
  79. }
  80. }

  81. static __inline Word64 SAR64(Word64 x, int n)
  82. {
  83. unsigned int xLo = ((unsigned int *)&x)[0];
  84. int xHi = ((int *)&x)[1];
  85. unsigned char nb = (unsigned char)n;

  86. if (n < 32) {
  87. __asm {
  88. mov         edx, xHi
  89. mov         eax, xLo
  90. mov         cl, nb
  91. shrd        eax, edx, cl
  92. sar         edx, cl
  93. }
  94. } else if (n < 64) {
  95. /* sar masks cl to 0x1f */
  96. __asm {
  97. mov         edx, xHi
  98. mov         eax, xHi
  99. mov         cl, nb
  100. sar         edx, 31
  101. sar         eax, cl
  102. }
  103. } else {
  104. __asm {
  105. sar         xHi, 31
  106. mov         eax, xHi
  107. mov         edx, xHi
  108. }
  109. }
  110. }

  111. #elif (defined _WIN32) && (defined _WIN32_WCE)

  112. /* use asm function for now (EVC++ 3.0 does horrible job compiling __int64 version) */
  113. #define MULSHIFT32        xmp3_MULSHIFT32
  114. int MULSHIFT32(int x, int y);

  115. static __inline int FASTABS(int x)
  116. {
  117. int sign;

  118. sign = x >> (sizeof(int) * 8 - 1);
  119. x ^= sign;
  120. x -= sign;

  121. return x;
  122. }

  123. static __inline int CLZ(int x)
  124. {
  125. int numZeros;

  126. if (!x)
  127. return (sizeof(int) * 8);

  128. numZeros = 0;
  129. while (!(x & 0x80000000)) {
  130. numZeros++;
  131. x <<= 1;
  132. }

  133. return numZeros;
  134. }

  135. #elif defined ARM_ADS

  136. static __inline int MULSHIFT32(int x, int y)
  137. {

  138. int zlow;
  139. __asm {
  140. smull zlow,y,x,y
  141. }

  142. return y;
  143. }

  144. static __inline int FASTABS(int x)
  145. {
  146. int t=0; /*Really is not necessary to initialiaze only to avoid warning*/

  147. __asm {
  148. eor        t, x, x, asr #31 // T:=X XOR (X>>31)
  149. sub        t, t, x, asr #31 // T:=T-(X>>31)
  150. }

  151. return t;
  152. }

  153. static __inline int CLZ(int x)
  154. {
  155. int numZeros;

  156. if (!x)
  157. return (sizeof(int) * 8);

  158. numZeros = 0;
  159. while (!(x & 0x80000000)) {
  160. numZeros++;
  161. x <<= 1;
  162. }

  163. return numZeros;
  164. }

  165. #elif defined(__GNUC__) && defined(ARM)

  166. typedef long long Word64;

  167. #define MULSHIFT32        xmp3_MULSHIFT32
  168. extern int MULSHIFT32(int x, int y);


  169. #define FASTABS        xmp3_FASTABS
  170. int FASTABS(int x);


  171. static __inline int CLZ(int x)
  172. {
  173. int numZeros;

  174. if (!x)
  175. return (sizeof(int) * 8);

  176. numZeros = 0;
  177. while (!(x & 0x80000000)) {
  178. numZeros++;
  179. x <<= 1;
  180. }

  181. return numZeros;
  182. }

  183. #else

  184. #error Unsupported platform in assembly.h

  185. #endif        /* platforms */

  186. #endif /* _ASSEMBLY_H */
复制代码
如上在一个头文件里面这样定义了,在.c文件里调用的时候就提示(.c文件里包含了这些头文件)
  1. Description        Resource        Path        Location        Type
  2. unresolved symbol FASTABS, first referenced in ./stproc.obj        mp3_6         C/C++ Problem
  3. unresolved symbol MULSHIFT32, first referenced in ./stproc.obj        mp3_6         C/C++ Problem
  4. unresolved symbol PolyphaseMono, first referenced in ./subband.obj        mp3_6         C/C++ Problem
复制代码这是为什么
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
5条回答
dontium
2019-03-24 12:17
楼主帖了那么多,等有时间了再看吧。

一周热门 更多>

相关问题

    相关文章