CVBase.pas 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. {
  2. * CVBase.h
  3. * CoreVideo
  4. *
  5. * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  6. *
  7. }
  8. { Pascal Translation: Gale R Paeper, <[email protected]>, 2008 }
  9. {
  10. Modified for use with Free Pascal
  11. Version 210
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$mode macpas}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$calling mwpascal}
  19. unit CVBase;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  22. {$setc GAP_INTERFACES_VERSION := $0210}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __i386__ and defined CPUI386}
  38. {$setc __i386__ := 1}
  39. {$elsec}
  40. {$setc __i386__ := 0}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  43. {$error Conflicting definitions for __ppc__ and __i386__}
  44. {$endc}
  45. {$ifc defined __ppc__ and __ppc__}
  46. {$setc TARGET_CPU_PPC := TRUE}
  47. {$setc TARGET_CPU_X86 := FALSE}
  48. {$elifc defined __i386__ and __i386__}
  49. {$setc TARGET_CPU_PPC := FALSE}
  50. {$setc TARGET_CPU_X86 := TRUE}
  51. {$elsec}
  52. {$error Neither __ppc__ nor __i386__ is defined.}
  53. {$endc}
  54. {$setc TARGET_CPU_PPC_64 := FALSE}
  55. {$ifc defined FPC_BIG_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  58. {$elifc defined FPC_LITTLE_ENDIAN}
  59. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  60. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  61. {$elsec}
  62. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  63. {$endc}
  64. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  65. {$setc CALL_NOT_IN_CARBON := FALSE}
  66. {$setc OLDROUTINENAMES := FALSE}
  67. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  68. {$setc OPAQUE_UPP_TYPES := TRUE}
  69. {$setc OTCARBONAPPLICATION := TRUE}
  70. {$setc OTKERNEL := FALSE}
  71. {$setc PM_USE_SESSION_APIS := TRUE}
  72. {$setc TARGET_API_MAC_CARBON := TRUE}
  73. {$setc TARGET_API_MAC_OS8 := FALSE}
  74. {$setc TARGET_API_MAC_OSX := TRUE}
  75. {$setc TARGET_CARBON := TRUE}
  76. {$setc TARGET_CPU_68K := FALSE}
  77. {$setc TARGET_CPU_MIPS := FALSE}
  78. {$setc TARGET_CPU_SPARC := FALSE}
  79. {$setc TARGET_OS_MAC := TRUE}
  80. {$setc TARGET_OS_UNIX := FALSE}
  81. {$setc TARGET_OS_WIN32 := FALSE}
  82. {$setc TARGET_RT_MAC_68881 := FALSE}
  83. {$setc TARGET_RT_MAC_CFM := FALSE}
  84. {$setc TARGET_RT_MAC_MACHO := TRUE}
  85. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  86. {$setc TYPE_BOOL := FALSE}
  87. {$setc TYPE_EXTENDED := FALSE}
  88. {$setc TYPE_LONGLONG := TRUE}
  89. uses MacTypes, CFBase;
  90. {$ALIGN POWER}
  91. {! @header CVBase.h
  92. @copyright 2004 Apple Computer, Inc. All rights reserved.
  93. @availability Mac OS X 10.4 or later
  94. @discussion Here you can find the type declarations for CoreVideo. CoreVideo uses a CVTimeStamp structure to store video display time stamps.
  95. }
  96. {!
  97. @typedef CVOptionFlags
  98. @abstract Flags to be used for the display and render call back functions.
  99. @discussion ***Values to be defined***
  100. }
  101. type
  102. CVOptionFlags = UInt64;
  103. {!
  104. @struct CVSMPTETime
  105. @abstract A structure for holding a SMPTE time.
  106. @field subframes
  107. The number of subframes in the full message.
  108. @field subframeDivisor
  109. The number of subframes per frame (typically 80).
  110. @field counter
  111. The total number of messages received.
  112. @field type
  113. The kind of SMPTE time using the SMPTE time type constants.
  114. @field flags
  115. A set of flags that indicate the SMPTE state.
  116. @field hours
  117. The number of hourse in the full message.
  118. @field minutes
  119. The number of minutes in the full message.
  120. @field seconds
  121. The number of seconds in the full message.
  122. @field frames
  123. The number of frames in the full message.
  124. }
  125. type
  126. CVSMPTETime = record
  127. subframes: SInt16;
  128. subframeDivisor: SInt16;
  129. counter: UInt32;
  130. typ: UInt32;
  131. flags: UInt32;
  132. hours: SInt16;
  133. minutes: SInt16;
  134. seconds: SInt16;
  135. frames: SInt16;
  136. end;
  137. {!
  138. @enum SMPTE Time Types
  139. @abstract Constants that describe the type of SMPTE time.
  140. @constant kCVSMPTETimeType24
  141. 24 Frame
  142. @constant kCVSMPTETimeType25
  143. 25 Frame
  144. @constant kCVSMPTETimeType30Drop
  145. 30 Drop Frame
  146. @constant kCVSMPTETimeType30
  147. 30 Frame
  148. @constant kCVSMPTETimeType2997
  149. 29.97 Frame
  150. @constant kCVSMPTETimeType2997Drop
  151. 29.97 Drop Frame
  152. @constant kCVSMPTETimeType60
  153. 60 Frame
  154. @constant kCVSMPTETimeType5994
  155. 59.94 Frame
  156. }
  157. const
  158. kCVSMPTETimeType24 = 0;
  159. kCVSMPTETimeType25 = 1;
  160. kCVSMPTETimeType30Drop = 2;
  161. kCVSMPTETimeType30 = 3;
  162. kCVSMPTETimeType2997 = 4;
  163. kCVSMPTETimeType2997Drop = 5;
  164. kCVSMPTETimeType60 = 6;
  165. kCVSMPTETimeType5994 = 7;
  166. {!
  167. @enum SMPTE State Flags
  168. @abstract Flags that describe the SMPTE time state.
  169. @constant kCVSMPTETimeValid
  170. The full time is valid.
  171. @constant kCVSMPTETimeRunning
  172. Time is running.
  173. }
  174. const
  175. kCVSMPTETimeValid = 1 shl 0;
  176. kCVSMPTETimeRunning = 1 shl 1;
  177. const
  178. kCVTimeIsIndefinite = 1 shl 0;
  179. type
  180. CVTime = record
  181. timeValue: SInt64;
  182. timeScale: SInt32;
  183. flags: SInt32;
  184. end;
  185. {!
  186. @struct CVTimeStamp
  187. @abstract CoreVideo uses a CVTimeStamp structure to store video display time stamps.
  188. @discussion This structure is purposely very similar to AudioTimeStamp defined in the CoreAudio framework.
  189. Most of the CVTimeStamp struct should be fairly self-explanatory. However, it is probably worth pointing out that unlike the audio time stamps, floats are not used to represent the video equivalent of sample times. This was done partly to avoid precision issues, and partly because QuickTime still uses integers for time values and time scales. In the actual implementation it has turned out to be very convenient to use integers, and we can represent framerates like NTSC (30000/1001 fps) exactly. The mHostTime structure field uses the same Mach absolute time base that is used in CoreAudio, so that clients of the CoreVideo API can synchronize between the two subsystems.
  190. @field videoTimeScale The scale (in units per second) of the videoTime and videoPeriod values
  191. @field videoTime This represents the start of a frame (or field for interlaced)
  192. @field hostTime Host root timebase time
  193. @field rateScalar This is the current rate of the device as measured by the timestamps, divided by the nominal rate
  194. @field videoPeriod This is the nominal update period of the current output device
  195. @field smpteTime SMPTE time representation of the time stamp.
  196. @field flags Possible values are:
  197. kCVTimeStampVideoTimeValid
  198. kCVTimeStampHostTimeValid
  199. kCVTimeStampSMPTETimeValid
  200. kCVTimeStampVideoPeriodValid
  201. kCVTimeStampRateScalarValid
  202. There are flags for each field to make it easier to detect interlaced vs progressive output
  203. kCVTimeStampTopField
  204. kCVTimeStampBottomField
  205. Some commonly used combinations of timestamp flags
  206. kCVTimeStampVideoHostTimeValid
  207. kCVTimeStampIsInterlaced
  208. @field version The current CVTimeStamp is version 0.
  209. @field reserved Reserved. Do not use.
  210. }
  211. type
  212. CVTimeStamp = record
  213. version: UInt32; // Currently will be 0.
  214. videoTimeScale: SInt32; // Video timescale (units per second)
  215. videoTime: SInt64; // This represents the start of a frame (or field for interlaced) .. think vsync - still not 100% sure on the name
  216. hostTime: UInt64; // Host root timebase time
  217. rateScalar: Float64; // Current rate as measured by the timestamps divided by the nominal rate
  218. videoRefreshPeriod: SInt64; // Hint for nominal output rate
  219. smpteTime: CVSMPTETime;
  220. flags: UInt64;
  221. reserved: UInt64;
  222. end;
  223. // Flags for the CVTimeStamp structure
  224. const
  225. kCVTimeStampVideoTimeValid = 1 shl 0;
  226. kCVTimeStampHostTimeValid = 1 shl 1;
  227. kCVTimeStampSMPTETimeValid = 1 shl 2;
  228. kCVTimeStampVideoRefreshPeriodValid = 1 shl 3;
  229. kCVTimeStampRateScalarValid = 1 shl 4;
  230. // There are flags for each field to make it easier to detect interlaced vs progressive output
  231. kCVTimeStampTopField = 1 shl 16;
  232. kCVTimeStampBottomField = 1 shl 17;
  233. // Some commonly used combinations of timestamp flags
  234. const
  235. kCVTimeStampVideoHostTimeValid = kCVTimeStampVideoTimeValid or kCVTimeStampHostTimeValid;
  236. kCVTimeStampIsInterlaced = kCVTimeStampTopField or kCVTimeStampBottomField;
  237. var kCVZeroTime: CVTime; external name '_kCVZeroTime'; (* attribute const *)
  238. var kCVIndefiniteTime: CVTime; external name '_kCVIndefiniteTime'; (* attribute const *)
  239. end.