avcfg: Ensure that ternary operator always evaluates to int64

When building with MSVC, if the 3rd operator is a double, the entire
expression always promoted double, and is then cast to int64.

When TRUE, this evaluates to (gint64) (gdouble) (INT64_MAX)
which overflows to INT64_MIN on MSVC, but not on C99 compilers.

This causes us to fail the g_return_if_fail inside g_param_spec_int64
when built with MSVC.
This commit is contained in:
Nirbheek Chauhan 2018-10-16 04:08:57 +05:30
parent ef106350d4
commit 21a18e22e1

View file

@ -298,8 +298,8 @@ install_opts (GObjectClass * gobject_class, const AVClass ** obj, guint prop_id,
case AV_OPT_TYPE_INT64:
/* ffmpeg expresses all ranges with doubles, this is sad */
pspec = g_param_spec_int64 (name, name, help,
(gint64) (min == (gdouble) INT64_MIN ? INT64_MIN : min),
(gint64) (max == (gdouble) INT64_MAX ? INT64_MAX : max),
(min == (gdouble) INT64_MIN ? INT64_MIN : (gint64) min),
(max == (gdouble) INT64_MAX ? INT64_MAX : (gint64) max),
opt->default_val.i64, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class, prop_id++, pspec);
break;