40 int d, m, frames_per_10mins;
42 if (fps && fps % 30 == 0) {
43 drop_frames = fps / 30 * 2;
44 frames_per_10mins = fps / 30 * 17982;
48 d = framenum / frames_per_10mins;
49 m = framenum % frames_per_10mins;
51 return framenum + 9U * drop_frames * d + drop_frames * ((m - drop_frames) / (frames_per_10mins / 10));
56 unsigned fps = tc->
fps;
60 framenum += tc->
start;
64 ss = framenum / fps % 60;
65 mm = framenum / (fps*60LL) % 60;
66 hh = framenum / (fps*3600LL) % 24;
92 tc |= (ff / 10) << 28;
93 tc |= (ff % 10) << 24;
94 tc |= (
ss / 10) << 20;
95 tc |= (
ss % 10) << 16;
96 tc |= (mm / 10) << 12;
106 unsigned fps = tc->
fps;
108 int hh, mm,
ss, ff, ff_len, neg = 0;
109 int64_t framenum = framenum_arg;
111 framenum += tc->
start;
115 framenum = -framenum;
119 ss = framenum / fps % 60;
120 mm = framenum / (fps*60LL) % 60;
121 hh = framenum / (fps*3600LL);
124 ff_len = fps > 10000 ? 5 : fps > 1000 ? 4 : fps > 100 ? 3 : fps > 10 ? 2 : 1;
127 hh, mm,
ss, drop ?
';' :
':', ff_len, ff);
133 unsigned hh, mm,
ss, ff, drop;
137 hh, mm,
ss, drop ?
';' :
':', ff);
150 "%02"PRIu32
":%02"PRIu32
":%02"PRIu32
"%c%02"PRIu32,
154 tc25bit & 1<<24 ?
';' :
':',
162 static const int supported_fps[] = {
163 24, 25, 30, 48, 50, 60, 100, 120, 150,
167 if (fps == supported_fps[
i])
174 if ((
int)tc->
fps <= 0) {
175 av_log(log_ctx,
AV_LOG_ERROR,
"Valid timecode frame rate must be specified. Minimum value is 1\n");
179 av_log(log_ctx,
AV_LOG_ERROR,
"Drop frame is only allowed with multiples of 30000/1001 FPS\n");
191 if (!rate.
den || !rate.
num)
193 return (rate.
num + rate.
den/2LL) / rate.
den;
203 memset(tc, 0,
sizeof(*tc));
216 memset(tc, 0,
sizeof(*tc));
225 s = hh*3600LL + mm*60LL +
ss;
229 s =
s * tc->
fps + ff;
235 int tmins = 60*hh + mm;
236 tc->
start -= (tc->
fps / 30 * 2) * (tmins - tmins/10);
246 if (sscanf(str,
"%d:%d:%d%c%d", &hh, &mm, &
ss, &
c, &ff) != 5) {
248 "syntax: hh:mm:ss[:;.]ff\n");
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define ss(width, name, subs,...)
common internal and external API header
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
void ff_timecode_set_smpte(unsigned *drop, unsigned *hh, unsigned *mm, unsigned *ss, unsigned *ff, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field)
Convert SMPTE 12M binary representation to sei info.
static void frame_start(MPVMainEncContext *const m)
#define FF_ARRAY_ELEMS(a)
Rational number (pair of numerator and denominator).
unsigned fps
frame per second; must be consistent with the rate field
uint32_t flags
flags such as drop frame, +24 hours support, ...
AVRational rate
frame rate in rational form
int start
timecode frame start (first base frame number)
int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
Parse timecode representation (hh:mm:ss[:;.
static int check_timecode(void *log_ctx, AVTimecode *tc)
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.
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.
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).
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.
static int check_fps(int fps)
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
static int fps_from_frame_rate(AVRational rate)
char * av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df)
Get the timecode string from the SMPTE timecode format.
int av_timecode_check_frame_rate(AVRational rate)
Check if the timecode feature is available for the given frame rate.
uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
Convert frame number to SMPTE 12M binary representation.
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum_arg)
Load timecode string in buf.
int av_timecode_adjust_ntsc_framenum2(int framenum, int fps)
Adjust frame number for NTSC drop frame time code.
#define AV_TIMECODE_STR_SIZE
@ AV_TIMECODE_FLAG_ALLOWNEGATIVE
negative time values are allowed
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame
@ AV_TIMECODE_FLAG_24HOURSMAX
timecode wraps after 24 hours