libtimecode
0.5.0
A/V TimeCode Library
Main Page
Data Structures
Files
File List
Globals
src
timecode
timecode.h
Go to the documentation of this file.
1
24
#ifndef TIMECODE_H
25
#define TIMECODE_H 1
26
27
#ifdef __cplusplus
28
extern
"C"
{
29
#endif
30
31
#include <stddef.h>
/* size_t */
32
33
#ifndef DOXYGEN_IGNORE
34
/* libtimecode version */
35
#define LIBTIMECODE_VERSION "0.5.0"
36
#define LIBTIMECODE_VERSION_MAJOR 0
37
#define LIBTIMECODE_VERSION_MINOR 0
38
#define LIBTIMECODE_VERSION_MICRO 0
39
40
/* interface revision number
41
* http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
42
*/
43
#define LIBTIMECODE_CUR 0
44
#define LIBTIMECODE_REV 0
45
#define LIBTIMECODE_AGE 0
46
#endif
47
48
#ifndef int32_t
49
typedef
int
int32_t
;
50
#endif
51
52
#ifndef int64_t
53
typedef
long
long
int
int64_t
;
54
#endif
55
59
typedef
struct
TimecodeTime
{
60
int32_t
hour
;
61
int32_t
minute
;
62
int32_t
second
;
63
int32_t
frame
;
64
int32_t
subframe
;
65
}
TimecodeTime
;
66
70
typedef
struct
TimecodeDate
{
71
int32_t
year
;
72
int32_t
month
;
73
int32_t
day
;
74
int32_t
timezone
;
75
}
TimecodeDate
;
76
77
81
typedef
struct
TimecodeRate
{
82
int32_t
num
;
83
int32_t
den
;
84
int
drop
;
85
int32_t
subframes
;
86
}
TimecodeRate
;
87
91
typedef
struct
Timecode
{
92
TimecodeTime
t
;
93
TimecodeDate
d
;
94
TimecodeRate
r
;
95
}
Timecode
;
96
97
98
/* TODO: subframe default, use 80, 100 or 384 or 600 or 5760,.. or 500000
99
* 84672000 = LCM(192k, 88.2k, 24, 25, 30)
100
*/
101
102
const
TimecodeRate
tcfps23976
= { 24000, 1001, 0, 80};
103
const
TimecodeRate
tcfps24
= { 24, 1, 0, 80};
104
const
TimecodeRate
tcfps24976
= { 25000, 1001, 0, 80};
105
const
TimecodeRate
tcfps25
= { 25, 1, 0, 80};
106
const
TimecodeRate
tcfps2997ndf
= { 30000, 1001, 0, 80};
107
const
TimecodeRate
tcfps2997df
= { 30000, 1001, 1, 80};
108
const
TimecodeRate
tcfps30
= { 30, 1, 0, 80};
109
const
TimecodeRate
tcfps30df
= { 30, 1, 1, 80};
110
const
TimecodeRate
tcfps5994
= { 60000, 1001, 0, 80};
111
const
TimecodeRate
tcfps60
= { 30, 1, 0, 80};
112
113
const
TimecodeRate
tcfpsDS
= { 10, 1, 0, 1000};
114
const
TimecodeRate
tcfpsCS
= { 100, 1, 0, 1000};
115
const
TimecodeRate
tcfpsMS
= { 1000, 1, 0, 1000};
116
const
TimecodeRate
tcfpsUS
= { 1000000, 1, 0, 1};
117
const
TimecodeRate
tcfpsNS
= {1000000000, 1, 0, 1};
118
119
#define TCFPS23976 (&tcfps23976)
120
#define TCFPS24 (&tcfps24)
121
#define TCFPS24976 (&tcfps24976)
122
#define TCFPS25 (&tcfps25)
123
#define TCFPS2997DF (&tcfps2997df)
124
#define TCFPS30 (&tcfps30)
125
#define TCFPSMS (&tcfpsMS)
126
127
128
/* --- misc functions --- */
129
136
double
timecode_rate_to_double
(
TimecodeRate
const
*
const
r);
137
146
double
timecode_frames_per_timecode_frame
(
TimecodeRate
const
*
const
r,
const
double
samplerate);
147
148
149
/* --- timecode <> sample,frame-number --- */
150
165
int64_t
timecode_to_sample
(
TimecodeTime
const
*
const
t,
TimecodeRate
const
*
const
r,
const
double
samplerate);
166
181
void
timecode_sample_to_time
(
TimecodeTime
*
const
t,
TimecodeRate
const
*
const
r,
const
double
samplerate,
const
int64_t sample);
182
183
194
int64_t
timecode_to_framenumber
(
TimecodeTime
const
*
const
t,
TimecodeRate
const
*
const
r);
195
206
void
timecode_framenumber_to_time
(
TimecodeTime
*
const
t,
TimecodeRate
const
*
const
r,
const
int64_t frameno);
207
219
void
timecode_convert_rate
(
TimecodeTime
*
const
t_out,
TimecodeRate
const
*
const
r_out,
TimecodeTime
*
const
t_in,
TimecodeRate
const
*
const
r_in);
220
221
222
/* --- float seconds --- */
223
231
double
timecode_sample_to_seconds
(
const
int64_t sample,
double
samplerate);
232
240
int64_t
timecode_seconds_to_sample
(
const
double
sec,
double
samplerate);
241
249
double
timecode_framenumber_to_seconds
(
const
int64_t frameno,
TimecodeRate
const
*
const
r);
250
260
int64_t
timecode_seconds_to_framenumber
(
const
double
sec,
TimecodeRate
const
*
const
r);
261
271
void
timecode_seconds_to_time
(
TimecodeTime
*
const
t,
TimecodeRate
const
*
const
r,
const
double
sec);
272
282
double
timecode_to_sec
(
TimecodeTime
const
*
const
t,
TimecodeRate
const
*
const
r);
283
284
285
/* --- add/subtract timecodes at same frame rate --- */
286
297
void
timecode_time_add
(
TimecodeTime
*
const
res,
TimecodeRate
const
*
const
r,
TimecodeTime
const
*
const
t1,
TimecodeTime
const
*
const
t2);
298
309
void
timecode_time_subtract
(
TimecodeTime
*
const
res,
TimecodeRate
const
*
const
r,
TimecodeTime
const
*
const
t1,
TimecodeTime
const
*
const
t2);
310
311
312
/* --- comparison operators at same frame rate --- */
313
324
int
timecode_time_compare
(
TimecodeRate
const
*
const
r,
TimecodeTime
const
*
const
a,
TimecodeTime
const
*
const
b);
325
335
int
timecode_date_compare
(
TimecodeDate
const
*
const
a,
TimecodeDate
const
*
const
b);
336
350
int
timecode_datetime_compare
(
TimecodeRate
const
*
const
r,
Timecode
const
*
const
a,
Timecode
const
*
const
b);
351
352
353
/* --- increment, decrement --- */
354
360
void
timecode_date_increment
(
TimecodeDate
*
const
d);
361
367
void
timecode_date_decrement
(
TimecodeDate
*
const
d);
368
375
int
timecode_time_increment
(
TimecodeTime
*
const
t,
TimecodeRate
const
*
const
r);
376
383
int
timecode_time_decrement
(
TimecodeTime
*
const
t,
TimecodeRate
const
*
const
r);
384
392
int
timecode_datetime_increment
(
Timecode
*
const
dt);
393
401
int
timecode_datetime_decrement
(
Timecode
*
const
dt);
402
403
404
/* --- parse from string, export to string --- */
405
412
void
timecode_time_to_string
(
char
*smptestring,
TimecodeTime
const
*
const
t);
413
469
size_t
timecode_strftimecode
(
char
*str,
const
size_t
maxsize,
const
char
*format,
const
Timecode
const
*
const
t);
470
481
size_t
timecode_strftime
(
char
*str,
const
size_t
maxsize,
const
char
*format,
const
TimecodeTime
const
*
const
t,
const
TimecodeRate
const
*
const
r);
482
491
void
timecode_parse_time
(
TimecodeTime
*
const
t,
TimecodeRate
const
*
const
r,
const
char
*val);
492
493
/* TODO, ideas */
494
// parse date, timezone, parse packed format "HHMMSSFF"
495
// Bar, Beat, Tick Time (Tempo-Based Time)
496
497
#ifdef __cplusplus
498
}
499
#endif
500
501
502
#endif
Generated on Fri Nov 2 2012 02:27:16 for libtimecode by
1.8.2