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
86OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
87
88
89class IMF_EXPORT_TYPE TimeCode
90{
91 public:
92
93 //---------------------
94 // Bit packing variants
95 //---------------------
96
97 enum IMF_EXPORT_ENUM Packing
98 {
99 TV60_PACKING, // packing for 60-field television
100 TV50_PACKING, // packing for 50-field television
101 FILM24_PACKING // packing for 24-frame film
102 };
103
104
105 //-------------------------------------
106 // Constructors and assignment operator
107 //-------------------------------------
108
109 IMF_EXPORT
110 TimeCode (); // all fields set to 0 or false
111
112 IMF_EXPORT
113 TimeCode (int hours,
114 int minutes,
115 int seconds,
116 int frame,
117 bool dropFrame = false,
118 bool colorFrame = false,
119 bool fieldPhase = false,
120 bool bgf0 = false,
121 bool bgf1 = false,
122 bool bgf2 = false,
123 int binaryGroup1 = 0,
124 int binaryGroup2 = 0,
125 int binaryGroup3 = 0,
126 int binaryGroup4 = 0,
127 int binaryGroup5 = 0,
128 int binaryGroup6 = 0,
129 int binaryGroup7 = 0,
130 int binaryGroup8 = 0);
131
132 IMF_EXPORT
133 TimeCode (unsigned int timeAndFlags,
134 unsigned int userData = 0,
135 Packing packing = TV60_PACKING);
136
137 IMF_EXPORT
138 TimeCode (const TimeCode &other);
139
140 ~TimeCode () = default;
141
142 IMF_EXPORT
143 TimeCode & operator = (const TimeCode &other);
144
145
146 //----------------------------
147 // Access to individual fields
148 //----------------------------
149
150 IMF_EXPORT
151 int hours () const;
152 IMF_EXPORT
153 void setHours (int value);
154
155 IMF_EXPORT
156 int minutes () const;
157 IMF_EXPORT
158 void setMinutes (int value);
159
160 IMF_EXPORT
161 int seconds () const;
162 IMF_EXPORT
163 void setSeconds (int value);
164
165 IMF_EXPORT
166 int frame () const;
167 IMF_EXPORT
168 void setFrame (int value);
169
170 IMF_EXPORT
171 bool dropFrame () const;
172 IMF_EXPORT
173 void setDropFrame (bool value);
174
175 IMF_EXPORT
176 bool colorFrame () const;
177 IMF_EXPORT
178 void setColorFrame (bool value);
179
180 IMF_EXPORT
181 bool fieldPhase () const;
182 IMF_EXPORT
183 void setFieldPhase (bool value);
184
185 IMF_EXPORT
186 bool bgf0 () const;
187 IMF_EXPORT
188 void setBgf0 (bool value);
189
190 IMF_EXPORT
191 bool bgf1 () const;
192 IMF_EXPORT
193 void setBgf1 (bool value);
194
195 IMF_EXPORT
196 bool bgf2 () const;
197 IMF_EXPORT
198 void setBgf2 (bool value);
199
200 IMF_EXPORT
201 int binaryGroup (int group) const; // group must be between 1 and 8
202 IMF_EXPORT
203 void setBinaryGroup (int group, int value);
204
205
206 //---------------------------------
207 // Access to packed representations
208 //---------------------------------
209
210 IMF_EXPORT
211 unsigned int timeAndFlags (Packing packing = TV60_PACKING) const;
212
213 IMF_EXPORT
214 void setTimeAndFlags (unsigned int value,
215 Packing packing = TV60_PACKING);
216
217 IMF_EXPORT
218 unsigned int userData () const;
219
220 IMF_EXPORT
221 void setUserData (unsigned int value);
222
223
224 //---------
225 // Equality
226 //---------
227
228 IMF_EXPORT
229 bool operator == (const TimeCode &v) const;
230 IMF_EXPORT
231 bool operator != (const TimeCode &v) const;
232
233 private:
234
235 unsigned int _time;
236 unsigned int _user;
237};
238
239
240
241OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
242
243
244
245
246
247#endif
248

source code of include/OpenEXR/ImfTimeCode.h