History

avutil/opt: Fix AV_OPT_TYPE_CONST default value

It uses the int64_t instead of the double member. (This code can currently not be reached: av_opt_get() calls av_opt_find2() with NULL as unit in which case AV_OPT_TYPE_CONST options are never returned, leading av_opt_get() to always return AVERROR_OPTION_NOT_FOUND when searching for AV_OPT_TYPE_CONST*. For the same reason the code read_number() will never be called from get_number() when searching for an option of type AV_OPT_TYPE_CONST. The other callers of read_number() also only call it with types other than AV_OPT_TYPE_CONST.)

Andreas Rheinhardt committed 2 years ago

Commit ed56ca81 parent 8b83b521 file · +2 −2Browse files

Unified · Split

libavutil/opt.c+2−2
@@ -93,7 +93,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 92 unmodified lines
9393 *den = ((AVRational *)dst)->den;
9494 return 0;
9595 case AV_OPT_TYPE_CONST:
96− *num = o->default_val.dbl;
96+ *intnum = o->default_val.i64;
9797 return 0;
9898 }
9999 return AVERROR(EINVAL);
@@ -878,7 +878,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) · 778 unmodified lines
878878 ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational *)dst)->num, ((AVRational *)dst)->den);
879879 break;
880880 case AV_OPT_TYPE_CONST:
881− ret = snprintf(buf, sizeof(buf), "%f", o->default_val.dbl);
881+ ret = snprintf(buf, sizeof(buf), "%"PRId64, o->default_val.i64);
882882 break;
883883 case AV_OPT_TYPE_STRING:
884884 if (*(uint8_t **)dst) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t