Go to the documentation of this file.
39 int d, m, frames_per_10mins;
41 if (fps && fps % 30 == 0) {
42 drop_frames = fps / 30 * 2;
43 frames_per_10mins = fps / 30 * 17982;
47 d = framenum / frames_per_10mins;
48 m = framenum % frames_per_10mins;
50 return framenum + 9
U * drop_frames * d + drop_frames * ((m - drop_frames) / (frames_per_10mins / 10));
55 unsigned fps = tc->
fps;
59 framenum += tc->
start;
63 ss = framenum / fps % 60;
64 mm = framenum / (fps*60) % 60;
65 hh = framenum / (fps*3600) % 24;
91 tc |= (ff / 10) << 28;
92 tc |= (ff % 10) << 24;
93 tc |= (
ss / 10) << 20;
94 tc |= (
ss % 10) << 16;
95 tc |= (mm / 10) << 12;
107 int hh, mm,
ss, ff, ff_len, neg = 0;
108 int64_t framenum = framenum_arg;
110 framenum += tc->
start;
114 framenum = -framenum;
118 ss = framenum / fps % 60;
119 mm = framenum / (fps*60LL) % 60;
120 hh = framenum / (fps*3600LL);
123 ff_len = fps > 10000 ? 5 : fps > 1000 ? 4 : fps > 100 ? 3 : fps > 10 ? 2 : 1;
126 hh, mm,
ss, drop ?
';' :
':', ff_len, ff);
132 unsigned low = bcd & 0xf;
133 unsigned high = bcd >> 4;
134 if (low > 9 ||
high > 9)
136 return low + 10*
high;
141 unsigned hh =
bcd2uint(tcsmpte & 0x3f);
142 unsigned mm =
bcd2uint(tcsmpte>>8 & 0x7f);
144 unsigned ff =
bcd2uint(tcsmpte>>24 & 0x3f);
145 unsigned drop = tcsmpte & 1<<30 && !prevent_df;
151 ff += !!(tcsmpte & 1 << 7);
153 ff += !!(tcsmpte & 1 << 23);
158 hh, mm,
ss, drop ?
';' :
':', ff);
171 "%02"PRIu32
":%02"PRIu32
":%02"PRIu32
"%c%02"PRIu32,
175 tc25bit & 1<<24 ?
';' :
':',
183 static const int supported_fps[] = {
184 24, 25, 30, 48, 50, 60, 100, 120, 150,
188 if (fps == supported_fps[
i])
195 if ((
int)tc->
fps <= 0) {
196 av_log(log_ctx,
AV_LOG_ERROR,
"Valid timecode frame rate must be specified. Minimum value is 1\n");
200 av_log(log_ctx,
AV_LOG_ERROR,
"Drop frame is only allowed with multiples of 30000/1001 FPS\n");
212 if (!rate.
den || !rate.
num)
214 return (rate.
num + rate.
den/2LL) / rate.
den;
224 memset(tc, 0,
sizeof(*tc));
236 memset(tc, 0,
sizeof(*tc));
245 tc->
start = (hh*3600 + mm*60 +
ss) * tc->
fps + ff;
247 int tmins = 60*hh + mm;
248 tc->
start -= (tc->
fps / 30 * 2) * (tmins - tmins/10);
258 if (sscanf(str,
"%d:%d:%d%c%d", &hh, &mm, &
ss, &
c, &ff) != 5) {
260 "syntax: hh:mm:ss[:;.]ff\n");
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_TIMECODE_STR_SIZE
int av_timecode_check_frame_rate(AVRational rate)
Check if the timecode feature is available for the given frame rate.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
char * av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df)
Get the timecode string from the SMPTE timecode format.
static unsigned bcd2uint(uint8_t bcd)
uint32_t flags
flags such as drop frame, +24 hours support, ...
uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff)
Convert sei info to SMPTE 12M binary representation.
static void frame_start(MpegEncContext *s)
int start
timecode frame start (first base frame number)
#define ss(width, name, subs,...)
static int check_timecode(void *log_ctx, AVTimecode *tc)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
int av_timecode_adjust_ntsc_framenum2(int framenum, int fps)
Adjust frame number for NTSC drop frame time code.
Rational number (pair of numerator and denominator).
unsigned fps
frame per second; must be consistent with the rate field
AVRational rate
frame rate in rational form
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx)
Init a timecode struct from the passed timecode components.
@ AV_TIMECODE_FLAG_24HOURSMAX
timecode wraps after 24 hours
uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
Convert frame number to SMPTE 12M binary representation.
#define i(width, name, range_min, range_max)
char * av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field)
Get the timecode string from the SMPTE timecode format.
static int fps_from_frame_rate(AVRational rate)
@ AV_TIMECODE_FLAG_ALLOWNEGATIVE
negative time values are allowed
static int check_fps(int fps)
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame
char * av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit)
Get the timecode string from the 25-bit timecode format (MPEG GOP format).
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
Parse timecode representation (hh:mm:ss[:;.
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum_arg)
Load timecode string in buf.