~ubuntu-branches/ubuntu/trusty/gavl/trusty

« back to all changes in this revision

Viewing changes to include/gavl/timecode.h

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis
  • Date: 2009-01-17 20:38:33 UTC
  • mfrom: (1.1.3 upstream) (4.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090117203833-t8fq1e1jdquyelmy
Tags: 1.1.0-2
Fixed debian/copyright 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************
 
2
 * gavl - a general purpose audio/video processing library
 
3
 *
 
4
 * Copyright (c) 2001 - 2008 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
#pragma GCC visibility push(default)
 
30
 
 
31
  
 
32
/** \defgroup timecode Timecodes
 
33
 *  \brief Timecode definitions
 
34
 *
 
35
 *  Timecodes are usually associated with video frames
 
36
 *  and represent a unique time (e.g. Wall clock time) within
 
37
 *  the whole footage.
 
38
 *
 
39
 *  Since 1.1.0
 
40
 *
 
41
 * @{
 
42
 */
 
43
 
 
44
typedef uint64_t gavl_timecode_t; //!< Typedef for timecodes
 
45
 
 
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
 
48
 
 
49
#define GAVL_TIMECODE_DROP_FRAME (1<<0) //!< NTSC drop frame is used
 
50
 
 
51
#define GAVL_TIMECODE_UNDEFINED GAVL_TIMECODE_INVALID_MASK //! Convenience macro
 
52
  
 
53
/** \brief Timecode format
 
54
 *
 
55
 *  The timecode format should always be associated with
 
56
 *  a video format. Some functions require the timecode *and* the
 
57
 *  video format.
 
58
 */
 
59
  
 
60
typedef struct
 
61
  {
 
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;
 
65
  
 
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
 
72
 */
 
73
  
 
74
void gavl_timecode_to_hmsf(gavl_timecode_t tc,
 
75
                           int * hours,
 
76
                           int * minutes,
 
77
                           int * seconds,
 
78
                           int * frames);
 
79
 
 
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
 
85
 */
 
86
  
 
87
void gavl_timecode_to_ymd(gavl_timecode_t tc,
 
88
                          int * year,
 
89
                          int * month,
 
90
                          int * day);
 
91
 
 
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
 
98
 */
 
99
  
 
100
void gavl_timecode_from_hmsf(gavl_timecode_t * tc,
 
101
                            int hours,
 
102
                            int minutes,
 
103
                            int seconds,
 
104
                            int frames);
 
105
 
 
106
/** \brief Set the date part of the timecode
 
107
 *  \param tc A timecode
 
108
 *  \param year The year
 
109
 *  \param month The month
 
110
 *  \param day The day
 
111
 */
 
112
  
 
113
void gavl_timecode_from_ymd(gavl_timecode_t * tc,
 
114
                            int year,
 
115
                            int month,
 
116
                            int day);
 
117
 
 
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
 
123
 *
 
124
 *  If the time is larger than 24 hours, the framecount is calculated from
 
125
 *  00:00:00, January 1, 1970
 
126
 */
 
127
  
 
128
int64_t gavl_timecode_to_framecount(const gavl_timecode_format_t * tf,
 
129
                                    gavl_timecode_t tc);
 
130
 
 
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
 
136
 *
 
137
 *  If the date fields are non-zero, the framecount is calculated from
 
138
 *  00:00:00, January 1, 1970
 
139
 */
 
140
 
 
141
gavl_timecode_t gavl_timecode_from_framecount(const gavl_timecode_format_t * tf,
 
142
                                              int64_t fc);
 
143
 
 
144
/** \brief Dump a timecode to stderr
 
145
 *  \param tf The timecode format
 
146
 *  \param tc A timecode
 
147
 *
 
148
 *  This is used mainly for debugging
 
149
 */
 
150
  
 
151
void gavl_timecode_dump(const gavl_timecode_format_t * tf,
 
152
                        gavl_timecode_t tc);
 
153
  
 
154
 
 
155
/* -YYYY-MM-DD-HH:MM:SS.FFFF */
 
156
 
 
157
#define GAVL_TIMECODE_STRING_LEN 26 /*!< Length for a string into
 
158
                                      which a timecode will be printed */
 
159
 
 
160
 
 
161
void gavl_timecode_prettyprint(const gavl_timecode_format_t * tf,
 
162
                               gavl_timecode_t tc,
 
163
                               char str[GAVL_TIMECODE_STRING_LEN]);
 
164
 
 
165
 
 
166
  
 
167
/*
 
168
 * @}
 
169
 */
 
170
 
 
171
#pragma GCC visibility pop
 
172
  
 
173
#ifdef __cplusplus
 
174
}
 
175
#endif
 
176
 
 
177
#endif /* TIMECODE_H_INCLUDED */
 
178