38 int d, m, frames_per_10mins;
42 frames_per_10mins = 17982;
43 }
else if (fps == 60) {
45 frames_per_10mins = 35964;
49 d = framenum / frames_per_10mins;
50 m = framenum % frames_per_10mins;
52 return framenum + 9 * drop_frames * d + drop_frames * ((m - drop_frames) / (frames_per_10mins / 10));
57 unsigned fps = tc->
fps;
61 framenum += tc->
start;
65 ss = framenum / fps % 60;
66 mm = framenum / (fps*60) % 60;
67 hh = framenum / (fps*3600) % 24;
88 int hh, mm,
ss, ff, neg = 0;
90 framenum += tc->
start;
98 ss = framenum / fps % 60;
99 mm = framenum / (fps*60) % 60;
100 hh = framenum / (fps*3600);
105 hh, mm, ss, drop ?
';' :
':', ff);
111 unsigned low = bcd & 0xf;
112 unsigned high = bcd >> 4;
113 if (low > 9 || high > 9)
115 return low + 10*high;
120 unsigned hh =
bcd2uint(tcsmpte & 0x3f);
121 unsigned mm =
bcd2uint(tcsmpte>>8 & 0x7f);
123 unsigned ff =
bcd2uint(tcsmpte>>24 & 0x3f);
124 unsigned drop = tcsmpte & 1<<30 && !prevent_df;
126 hh, mm, ss, drop ?
';' :
':', ff);
133 "%02"PRIu32
":%02"PRIu32
":%02"PRIu32
"%c%02"PRIu32,
137 tc25bit & 1<<24 ?
';' :
':',
145 static const int supported_fps[] = {
146 24, 25, 30, 48, 50, 60, 100, 120, 150,
150 if (fps == supported_fps[i])
157 if ((
int)tc->
fps <= 0) {
162 av_log(log_ctx,
AV_LOG_ERROR,
"Drop frame is only allowed with 30000/1001 or 60000/1001 FPS\n");
174 if (!rate.
den || !rate.
num)
176 return (rate.
num + rate.
den/2) / rate.
den;
186 memset(tc, 0,
sizeof(*tc));
197 int hh, mm,
ss, ff, ret;
199 if (sscanf(str,
"%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) {
201 "syntax: hh:mm:ss[:;.]ff\n");
205 memset(tc, 0,
sizeof(*tc));
214 tc->
start = (hh*3600 + mm*60 +
ss) * tc->
fps + ff;
216 int tmins = 60*hh + mm;
217 tc->
start -= 2 * (tmins - tmins/10);
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
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).
static int check_timecode(void *log_ctx, AVTimecode *tc)
int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
Parse timecode representation (hh:mm:ss[:;.
static unsigned bcd2uint(uint8_t bcd)
int start
timecode frame start (first base frame number)
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 check_fps(int fps)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned fps
frame per second; must be consistent with the rate field
#define FF_ARRAY_ELEMS(a)
int av_timecode_adjust_ntsc_framenum2(int framenum, int fps)
Adjust frame number for NTSC drop frame time code.
timecode wraps after 24 hours
AVRational rate
frame rate in rational form
static int frame_start(MpegEncContext *s)
Rational number (pair of numerator and denominator).
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 int fps_from_frame_rate(AVRational rate)
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
Load timecode string in buf.
negative time values are allowed
int av_timecode_check_frame_rate(AVRational rate)
Check if the timecode feature is available for the given frame rate.
uint32_t flags
flags such as drop frame, +24 hours support, ...
#define AV_TIMECODE_STR_SIZE
uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
Convert frame number to SMPTE 12M binary representation.