MCPcopy Index your code
hub / github.com/byhook/ffmpeg4android / write_option

Function write_option

ffmpeg-single-cmd/src/main/cpp/cmdutils.c:295–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293#endif /* HAVE_COMMANDLINETOARGVW */
294
295static int write_option(void *optctx, const OptionDef *po, const char *opt,
296 const char *arg)
297{
298 /* new-style options contain an offset into optctx, old-style address of
299 * a global var*/
300 void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ?
301 (uint8_t *)optctx + po->u.off : po->u.dst_ptr;
302 int *dstcount;
303
304 if (po->flags & OPT_SPEC) {
305 SpecifierOpt **so = dst;
306 char *p = strchr(opt, ':');
307 char *str;
308
309 dstcount = (int *)(so + 1);
310 *so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1);
311 str = av_strdup(p ? p + 1 : "");
312 if (!str)
313 return AVERROR(ENOMEM);
314 (*so)[*dstcount - 1].specifier = str;
315 dst = &(*so)[*dstcount - 1].u;
316 }
317
318 if (po->flags & OPT_STRING) {
319 char *str;
320 str = av_strdup(arg);
321 av_freep(dst);
322 if (!str)
323 return AVERROR(ENOMEM);
324 *(char **)dst = str;
325 } else if (po->flags & OPT_BOOL || po->flags & OPT_INT) {
326 *(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX);
327 } else if (po->flags & OPT_INT64) {
328 *(int64_t *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX);
329 } else if (po->flags & OPT_TIME) {
330 *(int64_t *)dst = parse_time_or_die(opt, arg, 1);
331 } else if (po->flags & OPT_FLOAT) {
332 *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY);
333 } else if (po->flags & OPT_DOUBLE) {
334 *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY);
335 } else if (po->u.func_arg) {
336 int ret = po->u.func_arg(optctx, opt, arg);
337 if (ret < 0) {
338 av_log(NULL, AV_LOG_ERROR,
339 "Failed to set value '%s' for option '%s': %s\n",
340 arg, opt, av_err2str(ret));
341 return ret;
342 }
343 }
344 if (po->flags & OPT_EXIT)
345 exit_program(0);
346
347 return 0;
348}
349
350int parse_option(void *optctx, const char *opt, const char *arg,
351 const OptionDef *options)

Callers 2

parse_optionFunction · 0.85
parse_optgroupFunction · 0.85

Calls 4

grow_arrayFunction · 0.85
parse_number_or_dieFunction · 0.85
parse_time_or_dieFunction · 0.85
exit_programFunction · 0.85

Tested by

no test coverage detected