MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / av_parse_time

Function av_parse_time

libavutil/parseutils.c:592–754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590}
591
592int av_parse_time(int64_t *timeval, const char *timestr, int duration)
593{
594 const char *p, *q;
595 int64_t t, now64;
596 time_t now;
597 struct tm dt = { 0 }, tmbuf;
598 int today = 0, negative = 0, microseconds = 0, suffix = 1000000;
599 int i;
600 static const char * const date_fmt[] = {
601 "%Y - %m - %d",
602 "%Y%m%d",
603 };
604 static const char * const time_fmt[] = {
605 "%H:%M:%S",
606 "%H%M%S",
607 };
608 static const char * const tz_fmt[] = {
609 "%H:%M",
610 "%H%M",
611 "%H",
612 };
613
614 p = timestr;
615 q = NULL;
616 *timeval = INT64_MIN;
617 if (!duration) {
618 now64 = av_gettime();
619 now = now64 / 1000000;
620
621 if (!av_strcasecmp(timestr, "now")) {
622 *timeval = now64;
623 return 0;
624 }
625
626 /* parse the year-month-day part */
627 for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) {
628 q = av_small_strptime(p, date_fmt[i], &dt);
629 if (q)
630 break;
631 }
632
633 /* if the year-month-day part is missing, then take the
634 * current year-month-day time */
635 if (!q) {
636 today = 1;
637 q = p;
638 }
639 p = q;
640
641 if (*p == 'T' || *p == 't')
642 p++;
643 else
644 while (av_isspace(*p))
645 p++;
646
647 /* parse the hour-minute-second part */
648 for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) {
649 q = av_small_strptime(p, time_fmt[i], &dt);

Callers 15

mcc_write_headerFunction · 0.85
rtsp_parse_range_nptFunction · 0.85
parse_timesFunction · 0.85
parse_adaptation_setsFunction · 0.85
concat_parse_scriptFunction · 0.85
get_metadata_durationFunction · 0.85
opt_set_elemFunction · 0.85
test_av_parse_timeFunction · 0.85
opt_stats_periodFunction · 0.85
opt_recording_timestampFunction · 0.85
parse_read_intervalFunction · 0.85

Calls 6

av_gettimeFunction · 0.85
av_strcasecmpFunction · 0.85
av_small_strptimeFunction · 0.85
av_isspaceFunction · 0.85
av_isdigitFunction · 0.85
av_timegmFunction · 0.85

Tested by 1

test_av_parse_timeFunction · 0.68