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