int parse_forced_key_frames(const m_option_t *opt, const char *arg) { double ts; const char *p; int nts = 1, idx = 0, len; for (p = arg; *p; p++) nts += *p == ','; free(forced_key_frames_ts); forced_key_frames_ts = calloc(sizeof(*forced_key_frames_ts), nts); p = arg; while (1) { len = parse_timestring(p, &ts, ','); if (!len) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option force-key-frames: invalid time: '%s'\n", p); return M_OPT_INVALID; } forced_key_frames_ts[idx++] = ts; if (!p[len]) break; p += len + 1; } forced_key_frames_number = idx; forced_key_frames_idx = 0; for (idx = 1; idx < forced_key_frames_number; idx++) { if (forced_key_frames_ts[idx - 1] >= forced_key_frames_ts[idx]) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option force-key-frames: " "timestamps are not in ascending order\n"); return M_OPT_INVALID; } } return 0; }
static int parse_time(const m_option_t* opt,const char *name, char *param, void* dst, int src) { double time; if (param == NULL || strlen(param) == 0) return M_OPT_MISSING_PARAM; time = parse_timestring(param); if (time == -1e100) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: invalid time: '%s'\n", name,param); return M_OPT_INVALID; } if (dst) *(double *)dst = time; return 1; }
static int parse_time_size(const m_option_t* opt,const char *name, char *param, void* dst, int src) { m_time_size_t ts; char unit[4]; double end_at; if (param == NULL || strlen(param) == 0) return M_OPT_MISSING_PARAM; ts.pos=0; /* End at size parsing */ if(sscanf(param, "%lf%3s", &end_at, unit) == 2) { ts.type = END_AT_SIZE; if(!strcasecmp(unit, "b")) ; else if(!strcasecmp(unit, "kb")) end_at *= 1024; else if(!strcasecmp(unit, "mb")) end_at *= 1024*1024; else if(!strcasecmp(unit, "gb")) end_at *= 1024*1024*1024; else ts.type = END_AT_NONE; if (ts.type == END_AT_SIZE) { ts.pos = end_at; goto out; } } /* End at time parsing. This has to be last because the parsing accepts * even a number followed by garbage */ if ((end_at = parse_timestring(param)) == -1e100) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: invalid time or size: '%s'\n", name,param); return M_OPT_INVALID; } ts.type = END_AT_TIME; ts.pos = end_at; out: if(dst) *(m_time_size_t *)dst = ts; return 1; }