Message ID | AS8P250MB0744990A267FC8EDC99F170F8F402@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM |
---|---|
State | Accepted |
Commit | ed56ca856c3bc6e99cf12d748b351e5ea35964da |
Headers | show |
Series | [FFmpeg-devel] avutil/opt: Fix AV_OPT_TYPE_CONST default value | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
Andreas Rheinhardt: > 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.) > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavutil/opt.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavutil/opt.c b/libavutil/opt.c > index 0908751752..d13b1ab504 100644 > --- a/libavutil/opt.c > +++ b/libavutil/opt.c > @@ -93,7 +93,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > *den = ((AVRational *)dst)->den; > return 0; > case AV_OPT_TYPE_CONST: > - *num = o->default_val.dbl; > + *intnum = o->default_val.i64; > return 0; > } > return AVERROR(EINVAL); > @@ -878,7 +878,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) > ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational *)dst)->num, ((AVRational *)dst)->den); > break; > case AV_OPT_TYPE_CONST: > - ret = snprintf(buf, sizeof(buf), "%f", o->default_val.dbl); > + ret = snprintf(buf, sizeof(buf), "%"PRId64, o->default_val.i64); > break; > case AV_OPT_TYPE_STRING: > if (*(uint8_t **)dst) { Will apply tomorrow unless there are objections. - Andreas
Quoting Andreas Rheinhardt (2024-02-04 17:54:35) > 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.) Is there a reason you're not disabling that code with an assert instead?
diff --git a/libavutil/opt.c b/libavutil/opt.c index 0908751752..d13b1ab504 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -93,7 +93,7 @@ FF_ENABLE_DEPRECATION_WARNINGS *den = ((AVRational *)dst)->den; return 0; case AV_OPT_TYPE_CONST: - *num = o->default_val.dbl; + *intnum = o->default_val.i64; return 0; } return AVERROR(EINVAL); @@ -878,7 +878,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational *)dst)->num, ((AVRational *)dst)->den); break; case AV_OPT_TYPE_CONST: - ret = snprintf(buf, sizeof(buf), "%f", o->default_val.dbl); + ret = snprintf(buf, sizeof(buf), "%"PRId64, o->default_val.i64); break; case AV_OPT_TYPE_STRING: if (*(uint8_t **)dst) {
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.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavutil/opt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)