FixMath.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:7k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       FixMath.h
  3.  
  4.      Contains:   Fixed Math Interfaces.
  5.  
  6.      Version:    Technology: Mac OS 8
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1985-2001 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __FIXMATH__
  18. #define __FIXMATH__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #if PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #if PRAGMA_IMPORT
  29. #pragma import on
  30. #endif
  31. #if PRAGMA_STRUCT_ALIGN
  32.     #pragma options align=mac68k
  33. #elif PRAGMA_STRUCT_PACKPUSH
  34.     #pragma pack(push, 2)
  35. #elif PRAGMA_STRUCT_PACK
  36.     #pragma pack(2)
  37. #endif
  38. #define fixed1              ((Fixed) 0x00010000L)
  39. #define fract1              ((Fract) 0x40000000L)
  40. #define positiveInfinity    ((long)  0x7FFFFFFFL)
  41. #define negativeInfinity    ((long)  0x80000000L)
  42. /*
  43.     FixRatio, FixMul, and FixRound were previously in ToolUtils.h
  44. */
  45. EXTERN_API( Fixed )
  46. FixRatio                        (short                  numer,
  47.                                  short                  denom)                              ONEWORDINLINE(0xA869);
  48. EXTERN_API( Fixed )
  49. FixMul                          (Fixed                  a,
  50.                                  Fixed                  b)                                  ONEWORDINLINE(0xA868);
  51. EXTERN_API( short )
  52. FixRound                        (Fixed                  x)                                  ONEWORDINLINE(0xA86C);
  53. EXTERN_API( Fract )
  54. Fix2Frac                        (Fixed                  x)                                  ONEWORDINLINE(0xA841);
  55. EXTERN_API( long )
  56. Fix2Long                        (Fixed                  x)                                  ONEWORDINLINE(0xA840);
  57. EXTERN_API( Fixed )
  58. Long2Fix                        (long                   x)                                  ONEWORDINLINE(0xA83F);
  59. EXTERN_API( Fixed )
  60. Frac2Fix                        (Fract                  x)                                  ONEWORDINLINE(0xA842);
  61. EXTERN_API( Fract )
  62. FracMul                         (Fract                  x,
  63.                                  Fract                  y)                                  ONEWORDINLINE(0xA84A);
  64. EXTERN_API( Fixed )
  65. FixDiv                          (Fixed                  x,
  66.                                  Fixed                  y)                                  ONEWORDINLINE(0xA84D);
  67. EXTERN_API( Fract )
  68. FracDiv                         (Fract                  x,
  69.                                  Fract                  y)                                  ONEWORDINLINE(0xA84B);
  70. EXTERN_API( Fract )
  71. FracSqrt                        (Fract                  x)                                  ONEWORDINLINE(0xA849);
  72. EXTERN_API( Fract )
  73. FracSin                         (Fixed                  x)                                  ONEWORDINLINE(0xA848);
  74. EXTERN_API( Fract )
  75. FracCos                         (Fixed                  x)                                  ONEWORDINLINE(0xA847);
  76. EXTERN_API( Fixed )
  77. FixATan2                        (long                   x,
  78.                                  long                   y)                                  ONEWORDINLINE(0xA818);
  79. /*
  80.     Frac2X, Fix2X, X2Fix, and X2Frac translate to and from
  81.     the floating point type "extended" (that's what the X is for).
  82.     On the original Mac this was 80-bits and the functions could be
  83.     accessed via A-Traps.  When the 68881 co-processor was added,
  84.     it used 96-bit floating point types, so the A-Traps could not 
  85.     be used.  When PowerPC was added, it used 64-bit floating point
  86.     types, so yet another prototype was added.
  87. */
  88. #if TARGET_CPU_68K
  89. #if TARGET_RT_MAC_68881
  90. #if CALL_NOT_IN_CARBON
  91. EXTERN_API( long double )
  92. Frac2X                          (Fract                  x);
  93. EXTERN_API( long double )
  94. Fix2X                           (Fixed                  x);
  95. EXTERN_API( Fixed )
  96. X2Fix                           (long double            x);
  97. EXTERN_API( Fract )
  98. X2Frac                          (long double            x);
  99. #endif  /* CALL_NOT_IN_CARBON */
  100. #else
  101. #if CALL_NOT_IN_CARBON
  102. EXTERN_API( long double )
  103. Frac2X                          (Fract                  x)                                  ONEWORDINLINE(0xA845);
  104. EXTERN_API( long double )
  105. Fix2X                           (Fixed                  x)                                  ONEWORDINLINE(0xA843);
  106. EXTERN_API( Fixed )
  107. X2Fix                           (long double            x)                                  ONEWORDINLINE(0xA844);
  108. EXTERN_API( Fract )
  109. X2Frac                          (long double            x)                                  ONEWORDINLINE(0xA846);
  110. #endif  /* CALL_NOT_IN_CARBON */
  111. #endif  /* TARGET_RT_MAC_68881 */
  112. #else
  113. EXTERN_API( double )
  114. Frac2X                          (Fract                  x);
  115. EXTERN_API( double )
  116. Fix2X                           (Fixed                  x);
  117. EXTERN_API( Fixed )
  118. X2Fix                           (double                 x);
  119. EXTERN_API( Fract )
  120. X2Frac                          (double                 x);
  121. #endif  /* TARGET_CPU_68K */
  122. /* QuickTime 3.0 makes these Wide routines available on other platforms*/
  123. #if TARGET_CPU_PPC || !TARGET_OS_MAC || TARGET_CPU_X86
  124. EXTERN_API_C( short )
  125. WideCompare                     (const wide *           target,
  126.                                  const wide *           source);
  127. EXTERN_API_C( wide *)
  128. WideAdd                         (wide *                 target,
  129.                                  const wide *           source);
  130. EXTERN_API_C( wide *)
  131. WideSubtract                    (wide *                 target,
  132.                                  const wide *           source);
  133. EXTERN_API_C( wide *)
  134. WideNegate                      (wide *                 target);
  135. EXTERN_API_C( wide *)
  136. WideShift                       (wide *                 target,
  137.                                  long                   shift);
  138. EXTERN_API_C( unsigned long )
  139. WideSquareRoot                  (const wide *           source);
  140. EXTERN_API_C( wide *)
  141. WideMultiply                    (long                   multiplicand,
  142.                                  long                   multiplier,
  143.                                  wide *                 target);
  144. /* returns the quotient */
  145. EXTERN_API_C( long )
  146. WideDivide                      (const wide *           dividend,
  147.                                  long                   divisor,
  148.                                  long *                 remainder);
  149. /* quotient replaces dividend */
  150. EXTERN_API_C( wide *)
  151. WideWideDivide                  (wide *                 dividend,
  152.                                  long                   divisor,
  153.                                  long *                 remainder);
  154. EXTERN_API_C( wide *)
  155. WideBitShift                    (wide *                 src,
  156.                                  long                   shift);
  157. #endif  /* TARGET_CPU_PPC || !TARGET_OS_MAC || TARGET_CPU_X86 */
  158. #if PRAGMA_STRUCT_ALIGN
  159.     #pragma options align=reset
  160. #elif PRAGMA_STRUCT_PACKPUSH
  161.     #pragma pack(pop)
  162. #elif PRAGMA_STRUCT_PACK
  163.     #pragma pack()
  164. #endif
  165. #ifdef PRAGMA_IMPORT_OFF
  166. #pragma import off
  167. #elif PRAGMA_IMPORT
  168. #pragma import reset
  169. #endif
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. #endif /* __FIXMATH__ */