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

Function write_option

fftools/cmdutils.c:240–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240static int write_option(void *optctx, const OptionDef *po, const char *opt,
241 const char *arg, const OptionDef *defs)
242{
243 /* new-style options contain an offset into optctx, old-style address of
244 * a global var*/
245 void *dst = po->flags & OPT_FLAG_OFFSET ?
246 (uint8_t *)optctx + po->u.off : po->u.dst_ptr;
247 char *arg_allocated = NULL;
248
249 enum OptionType so_type = po->type;
250
251 SpecifierOptList *sol = NULL;
252 double num;
253 int ret = 0;
254
255 if (*opt == '/') {
256 opt++;
257
258 if (!opt_has_arg(po)) {
259 av_log(NULL, AV_LOG_FATAL,
260 "Requested to load an argument from file for an option '%s'"
261 " which does not take an argument\n",
262 po->name);
263 return AVERROR(EINVAL);
264 }
265
266 arg_allocated = read_file_to_string(arg);
267 if (!arg_allocated) {
268 av_log(NULL, AV_LOG_FATAL,
269 "Error reading the value for option '%s' from file: %s\n",
270 opt, arg);
271 return AVERROR(EINVAL);
272 }
273
274 arg = arg_allocated;
275 }
276
277 if (po->flags & OPT_FLAG_SPEC) {
278 const char *p = strchr(opt, ':');
279 char *str;
280
281 sol = dst;
282 ret = GROW_ARRAY(sol->opt, sol->nb_opt);
283 if (ret < 0)
284 goto finish;
285
286 str = av_strdup(p ? p + 1 : "");
287 if (!str) {
288 ret = AVERROR(ENOMEM);
289 goto finish;
290 }
291 sol->opt[sol->nb_opt - 1].specifier = str;
292
293 if (po->flags & OPT_FLAG_PERSTREAM) {
294 ret = stream_specifier_parse(&sol->opt[sol->nb_opt - 1].stream_spec,
295 str, 0, NULL);
296 if (ret < 0)
297 goto finish;

Callers 2

parse_optionFunction · 0.85
parse_optgroupFunction · 0.85

Calls 9

opt_has_argFunction · 0.85
av_logFunction · 0.85
read_file_to_stringFunction · 0.85
av_strdupFunction · 0.85
stream_specifier_parseFunction · 0.85
av_freepFunction · 0.85
parse_numberFunction · 0.85
av_parse_timeFunction · 0.85
find_optionFunction · 0.85

Tested by

no test coverage detected