1
/*****************************************************************
2
* gavl - a general purpose audio/video processing library
4
* Copyright (c) 2001 - 2008 Members of the Gmerlin project
5
* gmerlin-general@lists.sourceforge.net
6
* http://gmerlin.sourceforge.net
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.
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.
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
* *****************************************************************/
22
#ifndef TIMECODE_H_INCLUDED
23
#define TIMECODE_H_INCLUDED
29
#pragma GCC visibility push(default)
32
/** \defgroup timecode Timecodes
33
* \brief Timecode definitions
35
* Timecodes are usually associated with video frames
36
* and represent a unique time (e.g. Wall clock time) within
44
typedef uint64_t gavl_timecode_t; //!< Typedef for timecodes
46
#define GAVL_TIMECODE_SIGN_MASK (0x1LL<<62) //!< If 1, timecode is negative
47
#define GAVL_TIMECODE_INVALID_MASK (0x1LL<<63) //!< If 1, timecode is invalid
49
#define GAVL_TIMECODE_DROP_FRAME (1<<0) //!< NTSC drop frame is used
51
#define GAVL_TIMECODE_UNDEFINED GAVL_TIMECODE_INVALID_MASK //! Convenience macro
53
/** \brief Timecode format
55
* The timecode format should always be associated with
56
* a video format. Some functions require the timecode *and* the
62
int int_framerate; //!< Integer framerate. A value of zero signals, that no timecodes are available.
63
int flags; //!< Zero or more of the flags defined above
64
} gavl_timecode_format_t;
66
/** \brief Extract the time part of the timecode
67
* \param tc A timecode
68
* \param hours If non NULL, returns the hours
69
* \param minutes If non NULL, returns the minutes
70
* \param seconds If non NULL, returns the seconds
71
* \param frames If non NULL, returns the frames
74
void gavl_timecode_to_hmsf(gavl_timecode_t tc,
80
/** \brief Extract the date part of the timecode
81
* \param tc A timecode
82
* \param year If non NULL, returns the year
83
* \param month If non NULL, returns the month
84
* \param day If non NULL, returns the day
87
void gavl_timecode_to_ymd(gavl_timecode_t tc,
92
/** \brief Set the time part of the timecode
93
* \param tc A timecode
94
* \param hours The hours
95
* \param minutes The minutes
96
* \param seconds The seconds
97
* \param frames The frames
100
void gavl_timecode_from_hmsf(gavl_timecode_t * tc,
106
/** \brief Set the date part of the timecode
107
* \param tc A timecode
108
* \param year The year
109
* \param month The month
113
void gavl_timecode_from_ymd(gavl_timecode_t * tc,
118
/** \brief Get the frame count from the timecode
119
* \param tf The timecode format
120
* \param vf The video format
121
* \param tc A timecode
122
* \returns The frame count
124
* If the time is larger than 24 hours, the framecount is calculated from
125
* 00:00:00, January 1, 1970
128
int64_t gavl_timecode_to_framecount(const gavl_timecode_format_t * tf,
131
/** \brief Get a timecode from the frame count
132
* \param tf The timecode format
133
* \param vf The video format
134
* \param fc The frame count
135
* \returns The timecode corresponding to the framecount
137
* If the date fields are non-zero, the framecount is calculated from
138
* 00:00:00, January 1, 1970
141
gavl_timecode_t gavl_timecode_from_framecount(const gavl_timecode_format_t * tf,
144
/** \brief Dump a timecode to stderr
145
* \param tf The timecode format
146
* \param tc A timecode
148
* This is used mainly for debugging
151
void gavl_timecode_dump(const gavl_timecode_format_t * tf,
155
/* -YYYY-MM-DD-HH:MM:SS.FFFF */
157
#define GAVL_TIMECODE_STRING_LEN 26 /*!< Length for a string into
158
which a timecode will be printed */
161
void gavl_timecode_prettyprint(const gavl_timecode_format_t * tf,
163
char str[GAVL_TIMECODE_STRING_LEN]);
171
#pragma GCC visibility pop
177
#endif /* TIMECODE_H_INCLUDED */