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

Function parse_primary

libavutil/eval.c:382–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382static int parse_primary(AVExpr **e, Parser *p)
383{
384 AVExpr *d = av_mallocz(sizeof(AVExpr));
385 char *next = p->s, *s0 = p->s;
386 int ret, i;
387
388 if (!d)
389 return AVERROR(ENOMEM);
390
391 /* number */
392 d->value = av_strtod(p->s, &next);
393 if (next != p->s) {
394 d->type = e_value;
395 p->s= next;
396 *e = d;
397 return 0;
398 }
399 d->value = 1;
400
401 /* named constants */
402 for (i=0; p->const_names && p->const_names[i]; i++) {
403 if (strmatch(p->s, p->const_names[i])) {
404 p->s+= strlen(p->const_names[i]);
405 d->type = e_const;
406 d->const_index = i;
407 *e = d;
408 return 0;
409 }
410 }
411 for (i = 0; i < FF_ARRAY_ELEMS(constants); i++) {
412 if (strmatch(p->s, constants[i].name)) {
413 p->s += strlen(constants[i].name);
414 d->type = e_value;
415 d->value = constants[i].value;
416 *e = d;
417 return 0;
418 }
419 }
420
421 p->s= strchr(p->s, '(');
422 if (!p->s) {
423 av_log(p, AV_LOG_ERROR, "Undefined constant or missing '(' in '%s'\n", s0);
424 p->s= next;
425 av_expr_free(d);
426 return AVERROR(EINVAL);
427 }
428 p->s++; // "("
429 if (*next == '(') { // special case do-nothing
430 av_freep(&d);
431 if ((ret = parse_expr(&d, p)) < 0)
432 return ret;
433 if (p->s[0] != ')') {
434 av_log(p, AV_LOG_ERROR, "Missing ')' in '%s'\n", s0);
435 av_expr_free(d);
436 return AVERROR(EINVAL);
437 }
438 p->s++; // ")"
439 *e = d;

Callers 2

parse_powFunction · 0.85
parse_dBFunction · 0.85

Calls 7

av_strtodFunction · 0.85
strmatchFunction · 0.85
av_logFunction · 0.85
av_expr_freeFunction · 0.85
av_freepFunction · 0.85
av_malloczFunction · 0.70
parse_exprFunction · 0.70

Tested by

no test coverage detected