gavl

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

timecode.h
1 /*****************************************************************
2 * gavl - a general purpose audio/video processing library
3 *
4 * Copyright (c) 2001 - 2011 Members of the Gmerlin project
5 * gmerlin-general@lists.sourceforge.net
6 * http://gmerlin.sourceforge.net
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * *****************************************************************/
21
22 #ifndef TIMECODE_H_INCLUDED
23 #define TIMECODE_H_INCLUDED
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <gavl/gavldefs.h>
30
43 typedef uint64_t gavl_timecode_t;
44
45 #define GAVL_TIMECODE_SIGN_MASK (0x1LL<<62)
46 #define GAVL_TIMECODE_INVALID_MASK (0x1LL<<63)
47
48 #define GAVL_TIMECODE_DROP_FRAME (1<<0)
49
50 #define GAVL_TIMECODE_UNDEFINED GAVL_TIMECODE_INVALID_MASK
51
52
59 typedef struct
60 {
61 int int_framerate;
62 int flags;
63 } gavl_timecode_format_t;
64
71 GAVL_PUBLIC
72 void gavl_timecode_format_copy(gavl_timecode_format_t * dst,
73 const gavl_timecode_format_t * src);
74
75
84 GAVL_PUBLIC
85 void gavl_timecode_to_hmsf(gavl_timecode_t tc,
86 int * hours,
87 int * minutes,
88 int * seconds,
89 int * frames);
90
98 GAVL_PUBLIC
99 void gavl_timecode_to_ymd(gavl_timecode_t tc,
100 int * year,
101 int * month,
102 int * day);
103
112 GAVL_PUBLIC
113 void gavl_timecode_from_hmsf(gavl_timecode_t * tc,
114 int hours,
115 int minutes,
116 int seconds,
117 int frames);
118
126 GAVL_PUBLIC
127 void gavl_timecode_from_ymd(gavl_timecode_t * tc,
128 int year,
129 int month,
130 int day);
131
141 GAVL_PUBLIC
142 int64_t gavl_timecode_to_framecount(const gavl_timecode_format_t * tf,
143 gavl_timecode_t tc);
144
154 GAVL_PUBLIC
155 gavl_timecode_t gavl_timecode_from_framecount(const gavl_timecode_format_t * tf,
156 int64_t fc);
157
165 GAVL_PUBLIC
166 void gavl_timecode_dump(const gavl_timecode_format_t * tf,
167 gavl_timecode_t tc);
168
169
170 /* -YYYY-MM-DD-HH:MM:SS.FFFF */
171
172 #define GAVL_TIMECODE_STRING_LEN 26
185 GAVL_PUBLIC
186 void gavl_timecode_prettyprint(const gavl_timecode_format_t * tf,
187 gavl_timecode_t tc,
188 char str[GAVL_TIMECODE_STRING_LEN]);
189
190 /* -HH:MM:SS:FF */
191
192 #define GAVL_TIMECODE_STRING_LEN_SHORT 13
202 GAVL_PUBLIC
203 void gavl_timecode_prettyprint_short(gavl_timecode_t tc,
204 char str[GAVL_TIMECODE_STRING_LEN_SHORT]);
205
206
211 #ifdef __cplusplus
212 }
213 #endif
214
215 #endif /* TIMECODE_H_INCLUDED */
216
gavl_timecode_format_t
Timecode format.
Definition: timecode.h:59
GAVL_TIMECODE_STRING_LEN_SHORT
#define GAVL_TIMECODE_STRING_LEN_SHORT
Definition: timecode.h:193
gavl_timecode_format_t::flags
int flags
Zero or more of the flags defined above.
Definition: timecode.h:62
gavl_timecode_to_hmsf
GAVL_PUBLIC void gavl_timecode_to_hmsf(gavl_timecode_t tc, int *hours, int *minutes, int *seconds, int *frames)
Extract the time part of the timecode.
gavl_timecode_format_t::int_framerate
int int_framerate
Integer framerate. A value of zero signals, that no timecodes are available.
Definition: timecode.h:61
gavl_timecode_t
uint64_t gavl_timecode_t
Typedef for timecodes.
Definition: timecode.h:43
gavl_timecode_to_ymd
GAVL_PUBLIC void gavl_timecode_to_ymd(gavl_timecode_t tc, int *year, int *month, int *day)
Extract the date part of the timecode.
gavl_timecode_from_framecount
GAVL_PUBLIC gavl_timecode_t gavl_timecode_from_framecount(const gavl_timecode_format_t *tf, int64_t fc)
Get a timecode from the frame count.
gavl_timecode_to_framecount
GAVL_PUBLIC int64_t gavl_timecode_to_framecount(const gavl_timecode_format_t *tf, gavl_timecode_t tc)
Get the frame count from the timecode.
gavl_timecode_dump
GAVL_PUBLIC void gavl_timecode_dump(const gavl_timecode_format_t *tf, gavl_timecode_t tc)
Dump a timecode to stderr.
gavl_timecode_prettyprint_short
GAVL_PUBLIC void gavl_timecode_prettyprint_short(gavl_timecode_t tc, char str[GAVL_TIMECODE_STRING_LEN_SHORT])
Print a short timecode into a string.
gavl_timecode_prettyprint
GAVL_PUBLIC void gavl_timecode_prettyprint(const gavl_timecode_format_t *tf, gavl_timecode_t tc, char str[GAVL_TIMECODE_STRING_LEN])
Print a full timecode into a string.
gavl_timecode_format_copy
GAVL_PUBLIC void gavl_timecode_format_copy(gavl_timecode_format_t *dst, const gavl_timecode_format_t *src)
Copy one timecode format to another.
gavl_timecode_from_ymd
GAVL_PUBLIC void gavl_timecode_from_ymd(gavl_timecode_t *tc, int year, int month, int day)
Set the date part of the timecode.
gavl_timecode_from_hmsf
GAVL_PUBLIC void gavl_timecode_from_hmsf(gavl_timecode_t *tc, int hours, int minutes, int seconds, int frames)
Set the time part of the timecode.
GAVL_TIMECODE_STRING_LEN
#define GAVL_TIMECODE_STRING_LEN
Definition: timecode.h:172