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
116OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
117
118
119class 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 ~TimeCode () = default;
171
172 IMF_EXPORT
173 TimeCode & operator = (const TimeCode &other);
174
175
176 //----------------------------
177 // Access to individual fields
178 //----------------------------
179
180 IMF_EXPORT
181 int hours () const;
182 IMF_EXPORT
183 void setHours (int value);
184
185 IMF_EXPORT
186 int minutes () const;
187 IMF_EXPORT
188 void setMinutes (int value);
189
190 IMF_EXPORT
191 int seconds () const;
192 IMF_EXPORT
193 void setSeconds (int value);
194
195 IMF_EXPORT
196 int frame () const;
197 IMF_EXPORT
198 void setFrame (int value);
199
200 IMF_EXPORT
201 bool dropFrame () const;
202 IMF_EXPORT
203 void setDropFrame (bool value);
204
205 IMF_EXPORT
206 bool colorFrame () const;
207 IMF_EXPORT
208 void setColorFrame (bool value);
209
210 IMF_EXPORT
211 bool fieldPhase () const;
212 IMF_EXPORT
213 void setFieldPhase (bool value);
214
215 IMF_EXPORT
216 bool bgf0 () const;
217 IMF_EXPORT
218 void setBgf0 (bool value);
219
220 IMF_EXPORT
221 bool bgf1 () const;
222 IMF_EXPORT
223 void setBgf1 (bool value);
224
225 IMF_EXPORT
226 bool bgf2 () const;
227 IMF_EXPORT
228 void setBgf2 (bool value);
229
230 IMF_EXPORT
231 int binaryGroup (int group) const; // group must be between 1 and 8
232 IMF_EXPORT
233 void setBinaryGroup (int group, int value);
234
235
236 //---------------------------------
237 // Access to packed representations
238 //---------------------------------
239
240 IMF_EXPORT
241 unsigned int timeAndFlags (Packing packing = TV60_PACKING) const;
242
243 IMF_EXPORT
244 void setTimeAndFlags (unsigned int value,
245 Packing packing = TV60_PACKING);
246
247 IMF_EXPORT
248 unsigned int userData () const;
249
250 IMF_EXPORT
251 void setUserData (unsigned int value);
252
253
254 //---------
255 // Equality
256 //---------
257
258 IMF_EXPORT
259 bool operator == (const TimeCode &v) const;
260 IMF_EXPORT
261 bool operator != (const TimeCode &v) const;
262
263 private:
264
265 unsigned int _time;
266 unsigned int _user;
267};
268
269
270
271OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
272
273
274
275
276
277#endif
278

source code of include/OpenEXR/ImfTimeCode.h