HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfTimeCode.h
Go to the documentation of this 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 
35 
36 #ifndef INCLUDED_IMF_TIME_CODE_H
37 #define INCLUDED_IMF_TIME_CODE_H
38 
39 #include "ImfExport.h"
40 #include "ImfNamespace.h"
41 
42 //-----------------------------------------------------------------------------
43 //
44 // class TimeCode
45 //
46 // A TimeCode object stores time and control codes as described
47 // in SMPTE standard 12M-1999. A TimeCode object contains the
48 // following fields:
49 //
50 // Time Address:
51 //
52 // hours integer, range 0 - 23
53 // minutes integer, range 0 - 59
54 // seconds integer, range 0 - 59
55 // frame integer, range 0 - 29
56 //
57 // Flags:
58 //
59 // drop frame flag boolean
60 // color frame flag boolean
61 // field/phase flag boolean
62 // bgf0 boolean
63 // bgf1 boolean
64 // bgf2 boolean
65 //
66 // Binary groups for user-defined data and control codes:
67 //
68 // binary group 1 integer, range 0 - 15
69 // binary group 2 integer, range 0 - 15
70 // ...
71 // binary group 8 integer, range 0 - 15
72 //
73 // Class TimeCode contains methods to convert between the fields
74 // listed above and a more compact representation where the fields
75 // are packed into two unsigned 32-bit integers. In the packed
76 // integer representations, bit 0 is the least significant bit,
77 // and bit 31 is the most significant bit of the integer value.
78 //
79 // The time address and flags fields can be packed in three
80 // different ways:
81 //
82 // bits packing for packing for packing for
83 // 24-frame 60-field 50-field
84 // film television television
85 //
86 // 0 - 3 frame units frame units frame units
87 // 4 - 5 frame tens frame tens frame tens
88 // 6 unused, set to 0 drop frame flag unused, set to 0
89 // 7 unused, set to 0 color frame flag color frame flag
90 // 8 - 11 seconds units seconds units seconds units
91 // 12 - 14 seconds tens seconds tens seconds tens
92 // 15 phase flag field/phase flag bgf0
93 // 16 - 19 minutes units minutes units minutes units
94 // 20 - 22 minutes tens minutes tens minutes tens
95 // 23 bgf0 bgf0 bgf2
96 // 24 - 27 hours units hours units hours units
97 // 28 - 29 hours tens hours tens hours tens
98 // 30 bgf1 bgf1 bgf1
99 // 31 bgf2 bgf2 field/phase flag
100 //
101 // User-defined data and control codes are packed as follows:
102 //
103 // bits field
104 //
105 // 0 - 3 binary group 1
106 // 4 - 7 binary group 2
107 // 8 - 11 binary group 3
108 // 12 - 15 binary group 4
109 // 16 - 19 binary group 5
110 // 20 - 23 binary group 6
111 // 24 - 27 binary group 7
112 // 28 - 31 binary group 8
113 //
114 //-----------------------------------------------------------------------------
115 
117 
118 
119 class TimeCode
120 {
121  public:
122 
123  //---------------------
124  // Bit packing variants
125  //---------------------
126 
127  enum Packing
128  {
129  TV60_PACKING, // packing for 60-field television
130  TV50_PACKING, // packing for 50-field television
131  FILM24_PACKING // packing for 24-frame film
132  };
133 
134 
135  //-------------------------------------
136  // Constructors and assignment operator
137  //-------------------------------------
138 
139  IMF_EXPORT
140  TimeCode (); // all fields set to 0 or false
141 
142  IMF_EXPORT
143  TimeCode (int hours,
144  int minutes,
145  int seconds,
146  int frame,
147  bool dropFrame = false,
148  bool colorFrame = false,
149  bool fieldPhase = false,
150  bool bgf0 = false,
151  bool bgf1 = false,
152  bool bgf2 = false,
153  int binaryGroup1 = 0,
154  int binaryGroup2 = 0,
155  int binaryGroup3 = 0,
156  int binaryGroup4 = 0,
157  int binaryGroup5 = 0,
158  int binaryGroup6 = 0,
159  int binaryGroup7 = 0,
160  int binaryGroup8 = 0);
161 
162  IMF_EXPORT
163  TimeCode (unsigned int timeAndFlags,
164  unsigned int userData = 0,
165  Packing packing = TV60_PACKING);
166 
167  IMF_EXPORT
168  TimeCode (const TimeCode &other);
169 
170  IMF_EXPORT
171  TimeCode & operator = (const TimeCode &other);
172 
173 
174  //----------------------------
175  // Access to individual fields
176  //----------------------------
177 
178  IMF_EXPORT
179  int hours () const;
180  IMF_EXPORT
181  void setHours (int value);
182 
183  IMF_EXPORT
184  int minutes () const;
185  IMF_EXPORT
186  void setMinutes (int value);
187 
188  IMF_EXPORT
189  int seconds () const;
190  IMF_EXPORT
191  void setSeconds (int value);
192 
193  IMF_EXPORT
194  int frame () const;
195  IMF_EXPORT
196  void setFrame (int value);
197 
198  IMF_EXPORT
199  bool dropFrame () const;
200  IMF_EXPORT
201  void setDropFrame (bool value);
202 
203  IMF_EXPORT
204  bool colorFrame () const;
205  IMF_EXPORT
206  void setColorFrame (bool value);
207 
208  IMF_EXPORT
209  bool fieldPhase () const;
210  IMF_EXPORT
211  void setFieldPhase (bool value);
212 
213  IMF_EXPORT
214  bool bgf0 () const;
215  IMF_EXPORT
216  void setBgf0 (bool value);
217 
218  IMF_EXPORT
219  bool bgf1 () const;
220  IMF_EXPORT
221  void setBgf1 (bool value);
222 
223  IMF_EXPORT
224  bool bgf2 () const;
225  IMF_EXPORT
226  void setBgf2 (bool value);
227 
228  IMF_EXPORT
229  int binaryGroup (int group) const; // group must be between 1 and 8
230  IMF_EXPORT
231  void setBinaryGroup (int group, int value);
232 
233 
234  //---------------------------------
235  // Access to packed representations
236  //---------------------------------
237 
238  IMF_EXPORT
239  unsigned int timeAndFlags (Packing packing = TV60_PACKING) const;
240 
241  IMF_EXPORT
242  void setTimeAndFlags (unsigned int value,
243  Packing packing = TV60_PACKING);
244 
245  IMF_EXPORT
246  unsigned int userData () const;
247 
248  IMF_EXPORT
249  void setUserData (unsigned int value);
250 
251 
252  //---------
253  // Equality
254  //---------
255 
256  IMF_EXPORT
257  bool operator == (const TimeCode &v) const;
258  IMF_EXPORT
259  bool operator != (const TimeCode &v) const;
260 
261  private:
262 
263  unsigned int _time;
264  unsigned int _user;
265 };
266 
267 
268 
270 
271 
272 
273 
274 
275 #endif
IMF_EXPORT void setMinutes(int value)
IMF_EXPORT void setDropFrame(bool value)
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:109
IMF_EXPORT void setColorFrame(bool value)
IMF_EXPORT void setFrame(int value)
IMF_EXPORT void setBinaryGroup(int group, int value)
IMF_EXPORT TimeCode()
IMF_EXPORT bool bgf1() const
IMF_EXPORT void setSeconds(int value)
IMF_EXPORT void setHours(int value)
IMF_EXPORT bool operator==(const TimeCode &v) const
IMF_EXPORT int frame() const
IMF_EXPORT bool bgf2() const
IMF_EXPORT TimeCode & operator=(const TimeCode &other)
const GLdouble * v
Definition: glcorearb.h:836
IMF_EXPORT int hours() const
IMF_EXPORT void setBgf1(bool value)
#define IMF_EXPORT
Definition: ImfExport.h:44
IMF_EXPORT unsigned int userData() const
IMF_EXPORT bool operator!=(const TimeCode &v) const
IMF_EXPORT void setTimeAndFlags(unsigned int value, Packing packing=TV60_PACKING)
IMF_EXPORT bool fieldPhase() const
IMF_EXPORT void setFieldPhase(bool value)
IMF_EXPORT bool colorFrame() const
IMF_EXPORT bool dropFrame() const
GLboolean GLuint group
Definition: glew.h:2750
GLsizei const GLfloat * value
Definition: glcorearb.h:823
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:108
IMF_EXPORT void setUserData(unsigned int value)
IMF_EXPORT void setBgf2(bool value)
IMF_EXPORT unsigned int timeAndFlags(Packing packing=TV60_PACKING) const
IMF_EXPORT bool bgf0() const
GLfloat seconds
Definition: wglew.h:950
IMF_EXPORT void setBgf0(bool value)
IMF_EXPORT int minutes() const
IMF_EXPORT int binaryGroup(int group) const
IMF_EXPORT int seconds() const