FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavutil
timecode.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006 Smartjog S.A.S, Baptiste Coudurier <baptiste.coudurier@gmail.com>
3
* Copyright (c) 2011-2012 Smartjog S.A.S, Clément Bœsch <clement.boesch@smartjog.com>
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* FFmpeg 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 GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
/**
23
* @file
24
* Timecode helpers header
25
*/
26
27
#ifndef AVUTIL_TIMECODE_H
28
#define AVUTIL_TIMECODE_H
29
30
#include <stdint.h>
31
#include "
rational.h
"
32
33
#define AV_TIMECODE_STR_SIZE 16
34
35
enum
AVTimecodeFlag
{
36
AV_TIMECODE_FLAG_DROPFRAME
= 1<<0,
///< timecode is drop frame
37
AV_TIMECODE_FLAG_24HOURSMAX
= 1<<1,
///< timecode wraps after 24 hours
38
AV_TIMECODE_FLAG_ALLOWNEGATIVE
= 1<<2,
///< negative time values are allowed
39
};
40
41
typedef
struct
{
42
int
start
;
///< timecode frame start (first base frame number)
43
uint32_t
flags
;
///< flags such as drop frame, +24 hours support, ...
44
AVRational
rate
;
///< frame rate in rational form
45
unsigned
fps
;
///< frame per second; must be consistent with the rate field
46
}
AVTimecode
;
47
48
/**
49
* Adjust frame number for NTSC drop frame time code.
50
*
51
* @param framenum frame number to adjust
52
* @param fps frame per second, 30 or 60
53
* @return adjusted frame number
54
* @warning adjustment is only valid in NTSC 29.97 and 59.94
55
*/
56
int
av_timecode_adjust_ntsc_framenum2
(
int
framenum,
int
fps);
57
58
/**
59
* Convert frame number to SMPTE 12M binary representation.
60
*
61
* @param tc timecode data correctly initialized
62
* @param framenum frame number
63
* @return the SMPTE binary representation
64
*
65
* @note Frame number adjustment is automatically done in case of drop timecode,
66
* you do NOT have to call av_timecode_adjust_ntsc_framenum2().
67
* @note The frame number is relative to tc->start.
68
* @note Color frame (CF), binary group flags (BGF) and biphase mark polarity
69
* correction (PC) bits are set to zero.
70
*/
71
uint32_t
av_timecode_get_smpte_from_framenum
(
const
AVTimecode
*
tc
,
int
framenum);
72
73
/**
74
* Load timecode string in buf.
75
*
76
* @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
77
* @param tc timecode data correctly initialized
78
* @param framenum frame number
79
* @return the buf parameter
80
*
81
* @note Timecode representation can be a negative timecode and have more than
82
* 24 hours, but will only be honored if the flags are correctly set.
83
* @note The frame number is relative to tc->start.
84
*/
85
char
*
av_timecode_make_string
(
const
AVTimecode
*
tc
,
char
*
buf
,
int
framenum);
86
87
/**
88
* Get the timecode string from the SMPTE timecode format.
89
*
90
* @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
91
* @param tcsmpte the 32-bit SMPTE timecode
92
* @param prevent_df prevent the use of a drop flag when it is known the DF bit
93
* is arbitrary
94
* @return the buf parameter
95
*/
96
char
*
av_timecode_make_smpte_tc_string
(
char
*
buf
, uint32_t tcsmpte,
int
prevent_df);
97
98
/**
99
* Get the timecode string from the 25-bit timecode format (MPEG GOP format).
100
*
101
* @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
102
* @param tc25bit the 25-bits timecode
103
* @return the buf parameter
104
*/
105
char
*
av_timecode_make_mpeg_tc_string
(
char
*
buf
, uint32_t tc25bit);
106
107
/**
108
* Init a timecode struct with the passed parameters.
109
*
110
* @param log_ctx a pointer to an arbitrary struct of which the first field
111
* is a pointer to an AVClass struct (used for av_log)
112
* @param tc pointer to an allocated AVTimecode
113
* @param rate frame rate in rational form
114
* @param flags miscellaneous flags such as drop frame, +24 hours, ...
115
* (see AVTimecodeFlag)
116
* @param frame_start the first frame number
117
* @return 0 on success, AVERROR otherwise
118
*/
119
int
av_timecode_init
(
AVTimecode
*
tc
,
AVRational
rate,
int
flags
,
int
frame_start
,
void
*log_ctx);
120
121
/**
122
* Parse timecode representation (hh:mm:ss[:;.]ff).
123
*
124
* @param log_ctx a pointer to an arbitrary struct of which the first field is a
125
* pointer to an AVClass struct (used for av_log).
126
* @param tc pointer to an allocated AVTimecode
127
* @param rate frame rate in rational form
128
* @param str timecode string which will determine the frame start
129
* @return 0 on success, AVERROR otherwise
130
*/
131
int
av_timecode_init_from_string
(
AVTimecode
*
tc
,
AVRational
rate,
const
char
*str,
void
*log_ctx);
132
133
/**
134
* Check if the timecode feature is available for the given frame rate
135
*
136
* @return 0 if supported, <0 otherwise
137
*/
138
int
av_timecode_check_frame_rate
(
AVRational
rate);
139
140
#endif
/* AVUTIL_TIMECODE_H */
Generated on Sun Jul 20 2014 23:06:08 for FFmpeg by
1.8.2