/src/FreeImage/Source/OpenEXR/IlmImf/ImfTimeCode.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 226 lines · 69 code · 39 blank · 118 comment · 0 complexity · 87bb56994ff6583f9de15dd011f86d74 MD5 · raw file

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
  4. // Digital Ltd. LLC
  5. //
  6. // All rights reserved.
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions are
  10. // 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
  14. // copyright notice, this list of conditions and the following disclaimer
  15. // in the documentation and/or other materials provided with the
  16. // distribution.
  17. // * Neither the name of Industrial Light & Magic nor the names of
  18. // its contributors may be used to endorse or promote products derived
  19. // from this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. //
  33. ///////////////////////////////////////////////////////////////////////////
  34. #ifndef INCLUDED_IMF_TIME_CODE_H
  35. #define INCLUDED_IMF_TIME_CODE_H
  36. //-----------------------------------------------------------------------------
  37. //
  38. // class TimeCode
  39. //
  40. // A TimeCode object stores time and control codes as described
  41. // in SMPTE standard 12M-1999. A TimeCode object contains the
  42. // following fields:
  43. //
  44. // Time Address:
  45. //
  46. // hours integer, range 0 - 23
  47. // minutes integer, range 0 - 59
  48. // seconds integer, range 0 - 59
  49. // frame integer, range 0 - 29
  50. //
  51. // Flags:
  52. //
  53. // drop frame flag boolean
  54. // color frame flag boolean
  55. // field/phase flag boolean
  56. // bgf0 boolean
  57. // bgf1 boolean
  58. // bgf2 boolean
  59. //
  60. // Binary groups for user-defined data and control codes:
  61. //
  62. // binary group 1 integer, range 0 - 15
  63. // binary group 2 integer, range 0 - 15
  64. // ...
  65. // binary group 8 integer, range 0 - 15
  66. //
  67. // Class TimeCode contains methods to convert between the fields
  68. // listed above and a more compact representation where the fields
  69. // are packed into two unsigned 32-bit integers. In the packed
  70. // integer representations, bit 0 is the least significant bit,
  71. // and bit 31 is the most significant bit of the integer value.
  72. //
  73. // The time address and flags fields can be packed in three
  74. // different ways:
  75. //
  76. // bits packing for packing for packing for
  77. // 24-frame 60-field 50-field
  78. // film television television
  79. //
  80. // 0 - 3 frame units frame units frame units
  81. // 4 - 5 frame tens frame tens frame tens
  82. // 6 unused, set to 0 drop frame flag unused, set to 0
  83. // 7 unused, set to 0 color frame flag color frame flag
  84. // 8 - 11 seconds units seconds units seconds units
  85. // 12 - 14 seconds tens seconds tens seconds tens
  86. // 15 phase flag field/phase flag bgf0
  87. // 16 - 19 minutes units minutes units minutes units
  88. // 20 - 22 minutes tens minutes tens minutes tens
  89. // 23 bgf0 bgf0 bgf2
  90. // 24 - 27 hours units hours units hours units
  91. // 28 - 29 hours tens hours tens hours tens
  92. // 30 bgf1 bgf1 bgf1
  93. // 31 bgf2 bgf2 field/phase flag
  94. //
  95. // User-defined data and control codes are packed as follows:
  96. //
  97. // bits field
  98. //
  99. // 0 - 3 binary group 1
  100. // 4 - 7 binary group 2
  101. // 8 - 11 binary group 3
  102. // 12 - 15 binary group 4
  103. // 16 - 19 binary group 5
  104. // 20 - 23 binary group 6
  105. // 24 - 27 binary group 7
  106. // 28 - 31 binary group 8
  107. //
  108. //-----------------------------------------------------------------------------
  109. namespace Imf {
  110. class TimeCode
  111. {
  112. public:
  113. //---------------------
  114. // Bit packing variants
  115. //---------------------
  116. enum Packing
  117. {
  118. TV60_PACKING, // packing for 60-field television
  119. TV50_PACKING, // packing for 50-field television
  120. FILM24_PACKING // packing for 24-frame film
  121. };
  122. //-------------------------------------
  123. // Constructors and assignment operator
  124. //-------------------------------------
  125. TimeCode (); // all fields set to 0 or false
  126. TimeCode (int hours,
  127. int minutes,
  128. int seconds,
  129. int frame,
  130. bool dropFrame = false,
  131. bool colorFrame = false,
  132. bool fieldPhase = false,
  133. bool bgf0 = false,
  134. bool bgf1 = false,
  135. bool bgf2 = false,
  136. int binaryGroup1 = 0,
  137. int binaryGroup2 = 0,
  138. int binaryGroup3 = 0,
  139. int binaryGroup4 = 0,
  140. int binaryGroup5 = 0,
  141. int binaryGroup6 = 0,
  142. int binaryGroup7 = 0,
  143. int binaryGroup8 = 0);
  144. TimeCode (unsigned int timeAndFlags,
  145. unsigned int userData = 0,
  146. Packing packing = TV60_PACKING);
  147. TimeCode (const TimeCode &other);
  148. TimeCode & operator = (const TimeCode &other);
  149. //----------------------------
  150. // Access to individual fields
  151. //----------------------------
  152. int hours () const;
  153. void setHours (int value);
  154. int minutes () const;
  155. void setMinutes (int value);
  156. int seconds () const;
  157. void setSeconds (int value);
  158. int frame () const;
  159. void setFrame (int value);
  160. bool dropFrame () const;
  161. void setDropFrame (bool value);
  162. bool colorFrame () const;
  163. void setColorFrame (bool value);
  164. bool fieldPhase () const;
  165. void setFieldPhase (bool value);
  166. bool bgf0 () const;
  167. void setBgf0 (bool value);
  168. bool bgf1 () const;
  169. void setBgf1 (bool value);
  170. bool bgf2 () const;
  171. void setBgf2 (bool value);
  172. int binaryGroup (int group) const; // group must be between 1 and 8
  173. void setBinaryGroup (int group, int value);
  174. //---------------------------------
  175. // Access to packed representations
  176. //---------------------------------
  177. unsigned int timeAndFlags (Packing packing = TV60_PACKING) const;
  178. void setTimeAndFlags (unsigned int value,
  179. Packing packing = TV60_PACKING);
  180. unsigned int userData () const;
  181. void setUserData (unsigned int value);
  182. private:
  183. unsigned int _time;
  184. unsigned int _user;
  185. };
  186. } // namespace Imf
  187. #endif