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 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 #ifndef INCLUDED_IMF_TIME_CODE_H
7 #define INCLUDED_IMF_TIME_CODE_H
8 
9 #include "ImfExport.h"
10 #include "ImfNamespace.h"
11 
12 //-----------------------------------------------------------------------------
13 //
14 // class TimeCode
15 //
16 // A TimeCode object stores time and control codes as described
17 // in SMPTE standard 12M-1999. A TimeCode object contains the
18 // following fields:
19 //
20 // Time Address:
21 //
22 // hours integer, range 0 - 23
23 // minutes integer, range 0 - 59
24 // seconds integer, range 0 - 59
25 // frame integer, range 0 - 29
26 //
27 // Flags:
28 //
29 // drop frame flag boolean
30 // color frame flag boolean
31 // field/phase flag boolean
32 // bgf0 boolean
33 // bgf1 boolean
34 // bgf2 boolean
35 //
36 // Binary groups for user-defined data and control codes:
37 //
38 // binary group 1 integer, range 0 - 15
39 // binary group 2 integer, range 0 - 15
40 // ...
41 // binary group 8 integer, range 0 - 15
42 //
43 // Class TimeCode contains methods to convert between the fields
44 // listed above and a more compact representation where the fields
45 // are packed into two unsigned 32-bit integers. In the packed
46 // integer representations, bit 0 is the least significant bit,
47 // and bit 31 is the most significant bit of the integer value.
48 //
49 // The time address and flags fields can be packed in three
50 // different ways:
51 //
52 // bits packing for packing for packing for
53 // 24-frame 60-field 50-field
54 // film television television
55 //
56 // 0 - 3 frame units frame units frame units
57 // 4 - 5 frame tens frame tens frame tens
58 // 6 unused, set to 0 drop frame flag unused, set to 0
59 // 7 unused, set to 0 color frame flag color frame flag
60 // 8 - 11 seconds units seconds units seconds units
61 // 12 - 14 seconds tens seconds tens seconds tens
62 // 15 phase flag field/phase flag bgf0
63 // 16 - 19 minutes units minutes units minutes units
64 // 20 - 22 minutes tens minutes tens minutes tens
65 // 23 bgf0 bgf0 bgf2
66 // 24 - 27 hours units hours units hours units
67 // 28 - 29 hours tens hours tens hours tens
68 // 30 bgf1 bgf1 bgf1
69 // 31 bgf2 bgf2 field/phase flag
70 //
71 // User-defined data and control codes are packed as follows:
72 //
73 // bits field
74 //
75 // 0 - 3 binary group 1
76 // 4 - 7 binary group 2
77 // 8 - 11 binary group 3
78 // 12 - 15 binary group 4
79 // 16 - 19 binary group 5
80 // 20 - 23 binary group 6
81 // 24 - 27 binary group 7
82 // 28 - 31 binary group 8
83 //
84 //-----------------------------------------------------------------------------
85 
87 
89 {
90 public:
91  //---------------------
92  // Bit packing variants
93  //---------------------
94 
96  {
97  TV60_PACKING, // packing for 60-field television
98  TV50_PACKING, // packing for 50-field television
99  FILM24_PACKING // packing for 24-frame film
100  };
101 
102  //-------------------------------------
103  // Constructors and assignment operator
104  //-------------------------------------
105 
106  IMF_EXPORT
107  TimeCode (); // all fields set to 0 or false
108 
109  IMF_EXPORT
110  TimeCode (
111  int hours,
112  int minutes,
113  int seconds,
114  int frame,
115  bool dropFrame = false,
116  bool colorFrame = false,
117  bool fieldPhase = false,
118  bool bgf0 = false,
119  bool bgf1 = false,
120  bool bgf2 = false,
121  int binaryGroup1 = 0,
122  int binaryGroup2 = 0,
123  int binaryGroup3 = 0,
124  int binaryGroup4 = 0,
125  int binaryGroup5 = 0,
126  int binaryGroup6 = 0,
127  int binaryGroup7 = 0,
128  int binaryGroup8 = 0);
129 
130  IMF_EXPORT
131  TimeCode (
132  unsigned int timeAndFlags,
133  unsigned int userData = 0,
134  Packing packing = TV60_PACKING);
135 
136  IMF_EXPORT
137  TimeCode (const TimeCode& other);
138 
139  ~TimeCode () = default;
140 
141  IMF_EXPORT
142  TimeCode& operator= (const TimeCode& other);
143 
144  //----------------------------
145  // Access to individual fields
146  //----------------------------
147 
148  IMF_EXPORT
149  int hours () const;
150  IMF_EXPORT
151  void setHours (int value);
152 
153  IMF_EXPORT
154  int minutes () const;
155  IMF_EXPORT
156  void setMinutes (int value);
157 
158  IMF_EXPORT
159  int seconds () const;
160  IMF_EXPORT
161  void setSeconds (int value);
162 
163  IMF_EXPORT
164  int frame () const;
165  IMF_EXPORT
166  void setFrame (int value);
167 
168  IMF_EXPORT
169  bool dropFrame () const;
170  IMF_EXPORT
171  void setDropFrame (bool value);
172 
173  IMF_EXPORT
174  bool colorFrame () const;
175  IMF_EXPORT
176  void setColorFrame (bool value);
177 
178  IMF_EXPORT
179  bool fieldPhase () const;
180  IMF_EXPORT
181  void setFieldPhase (bool value);
182 
183  IMF_EXPORT
184  bool bgf0 () const;
185  IMF_EXPORT
186  void setBgf0 (bool value);
187 
188  IMF_EXPORT
189  bool bgf1 () const;
190  IMF_EXPORT
191  void setBgf1 (bool value);
192 
193  IMF_EXPORT
194  bool bgf2 () const;
195  IMF_EXPORT
196  void setBgf2 (bool value);
197 
198  IMF_EXPORT
199  int binaryGroup (int group) const; // group must be between 1 and 8
200  IMF_EXPORT
201  void setBinaryGroup (int group, int value);
202 
203  //---------------------------------
204  // Access to packed representations
205  //---------------------------------
206 
207  IMF_EXPORT
208  unsigned int timeAndFlags (Packing packing = TV60_PACKING) const;
209 
210  IMF_EXPORT
211  void setTimeAndFlags (unsigned int value, Packing packing = TV60_PACKING);
212 
213  IMF_EXPORT
214  unsigned int userData () const;
215 
216  IMF_EXPORT
217  void setUserData (unsigned int value);
218 
219  //---------
220  // Equality
221  //---------
222 
223  IMF_EXPORT
224  bool operator== (const TimeCode& v) const;
225  IMF_EXPORT
226  bool operator!= (const TimeCode& v) const;
227 
228 private:
229  unsigned int _time;
230  unsigned int _user;
231 };
232 
234 
235 #endif
#define IMF_EXPORT_ENUM
Definition: ImfExport.h:56
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:83
const GLdouble * v
Definition: glcorearb.h:837
TV60_PACKING
Definition: ImfTimeCode.h:97
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
#define IMF_EXPORT
Definition: ImfExport.h:54
LeafData & operator=(const LeafData &)=delete
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:80
TV50_PACKING
Definition: ImfTimeCode.h:97
Definition: core.h:1131
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
#define IMF_EXPORT_TYPE
Definition: ImfExport.h:57