Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
7.2 KiB

  1. /*
  2. * CVBase.h
  3. * CoreVideo
  4. *
  5. * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  6. *
  7. */
  8. /*! @header CVBase.h
  9. @copyright 2004 Apple Computer, Inc. All rights reserved.
  10. @availability Mac OS X 10.4 or later
  11. @discussion Here you can find the type declarations for CoreVideo. CoreVideo uses a CVTimeStamp structure to store video display time stamps.
  12. */
  13. #if !defined(__COREVIDEO_CVBASE_H__)
  14. #define __COREVIDEO_CVBASE_H__ 1
  15. #include <TargetConditionals.h>
  16. #include <AvailabilityMacros.h>
  17. #if TARGET_OS_MAC
  18. #include <CoreFoundation/CFBase.h>
  19. #else
  20. #include <MacTypes.h>
  21. #include <CFBase.h>
  22. #endif
  23. #if defined(__cplusplus)
  24. extern "C" {
  25. #endif
  26. #define CV_EXPORT CF_EXPORT
  27. #define CV_INLINE CF_INLINE
  28. #if TARGET_OS_WIN32
  29. #define CVDIRECT3DDEVICE LPDIRECT3DDEVICE9
  30. #define CVDIRECT3DTEXTURE LPDIRECT3DTEXTURE9
  31. #define CVDIRECT3DSURFACE LPDIRECT3DSURFACE9
  32. #define CVDIRECT3D LPDIRECT3D9
  33. #endif //TARGET_OS_WIN32
  34. /*!
  35. @typedef CVOptionFlags
  36. @abstract Flags to be used for the display and render call back functions.
  37. @discussion ***Values to be defined***
  38. */
  39. typedef uint64_t CVOptionFlags;
  40. /*!
  41. @struct CVSMPTETime
  42. @abstract A structure for holding a SMPTE time.
  43. @field subframes
  44. The number of subframes in the full message.
  45. @field subframeDivisor
  46. The number of subframes per frame (typically 80).
  47. @field counter
  48. The total number of messages received.
  49. @field type
  50. The kind of SMPTE time using the SMPTE time type constants.
  51. @field flags
  52. A set of flags that indicate the SMPTE state.
  53. @field hours
  54. The number of hourse in the full message.
  55. @field minutes
  56. The number of minutes in the full message.
  57. @field seconds
  58. The number of seconds in the full message.
  59. @field frames
  60. The number of frames in the full message.
  61. */
  62. struct CVSMPTETime
  63. {
  64. SInt16 subframes;
  65. SInt16 subframeDivisor;
  66. UInt32 counter;
  67. UInt32 type;
  68. UInt32 flags;
  69. SInt16 hours;
  70. SInt16 minutes;
  71. SInt16 seconds;
  72. SInt16 frames;
  73. };
  74. typedef struct CVSMPTETime CVSMPTETime;
  75. /*!
  76. @enum SMPTE Time Types
  77. @abstract Constants that describe the type of SMPTE time.
  78. @constant kCVSMPTETimeType24
  79. 24 Frame
  80. @constant kCVSMPTETimeType25
  81. 25 Frame
  82. @constant kCVSMPTETimeType30Drop
  83. 30 Drop Frame
  84. @constant kCVSMPTETimeType30
  85. 30 Frame
  86. @constant kCVSMPTETimeType2997
  87. 29.97 Frame
  88. @constant kCVSMPTETimeType2997Drop
  89. 29.97 Drop Frame
  90. @constant kCVSMPTETimeType60
  91. 60 Frame
  92. @constant kCVSMPTETimeType5994
  93. 59.94 Frame
  94. */
  95. enum
  96. {
  97. kCVSMPTETimeType24 = 0,
  98. kCVSMPTETimeType25 = 1,
  99. kCVSMPTETimeType30Drop = 2,
  100. kCVSMPTETimeType30 = 3,
  101. kCVSMPTETimeType2997 = 4,
  102. kCVSMPTETimeType2997Drop = 5,
  103. kCVSMPTETimeType60 = 6,
  104. kCVSMPTETimeType5994 = 7
  105. };
  106. /*!
  107. @enum SMPTE State Flags
  108. @abstract Flags that describe the SMPTE time state.
  109. @constant kCVSMPTETimeValid
  110. The full time is valid.
  111. @constant kCVSMPTETimeRunning
  112. Time is running.
  113. */
  114. enum
  115. {
  116. kCVSMPTETimeValid = (1L << 0),
  117. kCVSMPTETimeRunning = (1L << 1)
  118. };
  119. enum {
  120. kCVTimeIsIndefinite = 1 << 0
  121. };
  122. typedef struct
  123. {
  124. int64_t timeValue;
  125. int32_t timeScale;
  126. int32_t flags;
  127. } CVTime;
  128. /*!
  129. @struct CVTimeStamp
  130. @abstract CoreVideo uses a CVTimeStamp structure to store video display time stamps.
  131. @discussion This structure is purposely very similar to AudioTimeStamp defined in the CoreAudio framework.
  132. 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.
  133. @field videoTimeScale The scale (in units per second) of the videoTime and videoPeriod values
  134. @field videoTime This represents the start of a frame (or field for interlaced)
  135. @field hostTime Host root timebase time
  136. @field rateScalar This is the current rate of the device as measured by the timestamps, divided by the nominal rate
  137. @field videoPeriod This is the nominal update period of the current output device
  138. @field smpteTime SMPTE time representation of the time stamp.
  139. @field flags Possible values are:
  140. kCVTimeStampVideoTimeValid
  141. kCVTimeStampHostTimeValid
  142. kCVTimeStampSMPTETimeValid
  143. kCVTimeStampVideoPeriodValid
  144. kCVTimeStampRateScalarValid
  145. There are flags for each field to make it easier to detect interlaced vs progressive output
  146. kCVTimeStampTopField
  147. kCVTimeStampBottomField
  148. Some commonly used combinations of timestamp flags
  149. kCVTimeStampVideoHostTimeValid
  150. kCVTimeStampIsInterlaced
  151. @field version The current CVTimeStamp is version 0.
  152. @field reserved Reserved. Do not use.
  153. */
  154. typedef struct
  155. {
  156. uint32_t version; // Currently will be 0.
  157. int32_t videoTimeScale; // Video timescale (units per second)
  158. int64_t videoTime; // This represents the start of a frame (or field for interlaced) .. think vsync - still not 100% sure on the name
  159. uint64_t hostTime; // Host root timebase time
  160. double rateScalar; // Current rate as measured by the timestamps divided by the nominal rate
  161. int64_t videoRefreshPeriod; // Hint for nominal output rate
  162. CVSMPTETime smpteTime;
  163. uint64_t flags;
  164. uint64_t reserved;
  165. } CVTimeStamp;
  166. // Flags for the CVTimeStamp structure
  167. enum
  168. {
  169. kCVTimeStampVideoTimeValid = (1L << 0),
  170. kCVTimeStampHostTimeValid = (1L << 1),
  171. kCVTimeStampSMPTETimeValid = (1L << 2),
  172. kCVTimeStampVideoRefreshPeriodValid = (1L << 3),
  173. kCVTimeStampRateScalarValid = (1L << 4),
  174. // There are flags for each field to make it easier to detect interlaced vs progressive output
  175. kCVTimeStampTopField = (1L << 16),
  176. kCVTimeStampBottomField = (1L << 17)
  177. };
  178. // Some commonly used combinations of timestamp flags
  179. enum
  180. {
  181. kCVTimeStampVideoHostTimeValid = (kCVTimeStampVideoTimeValid | kCVTimeStampHostTimeValid),
  182. kCVTimeStampIsInterlaced = (kCVTimeStampTopField | kCVTimeStampBottomField)
  183. };
  184. CV_EXPORT const CVTime kCVZeroTime;
  185. CV_EXPORT const CVTime kCVIndefiniteTime;
  186. #if defined(__cplusplus)
  187. }
  188. #endif
  189. #endif