diff options
author | wm4 <wm4@nowhere> | 2020-03-13 16:49:39 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-03-13 17:34:46 +0100 |
commit | 8d965a1bfb3782343a03cff44977f11bb920f0b1 (patch) | |
tree | 2d115c24510ab36cc9ac7af8dea2b710537561c9 /video | |
parent | 5d5a7e19537a036fe16ce04555e6ce9449c47494 (diff) | |
download | mpv-8d965a1bfb3782343a03cff44977f11bb920f0b1.tar.bz2 mpv-8d965a1bfb3782343a03cff44977f11bb920f0b1.tar.xz |
options: change how option range min/max is handled
Before this commit, option declarations used M_OPT_MIN/M_OPT_MAX (and
some other identifiers based on these) to signal whether an option had
min/max values. Remove these flags, and make it use a range implicitly
on the condition if min<max is true.
This requires care in all cases when only M_OPT_MIN or M_OPT_MAX were
set (instead of both). Generally, the commit replaces all these
instances with using DBL_MAX/DBL_MIN for the "unset" part of the range.
This also happens to fix some cases where you could pass over-large
values to integer options, which were silently truncated, but now cause
an error.
This commit has some higher potential for regressions.
Diffstat (limited to 'video')
-rw-r--r-- | video/decode/vd_lavc.c | 3 | ||||
-rw-r--r-- | video/out/vo_null.c | 2 | ||||
-rw-r--r-- | video/out/vo_xv.c | 5 |
3 files changed, 6 insertions, 4 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index b41c4c48c6..76f2b46e3e 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -15,6 +15,7 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ +#include <float.h> #include <stdio.h> #include <stdlib.h> #include <pthread.h> @@ -110,7 +111,7 @@ const struct m_sub_options vd_lavc_conf = { OPT_DISCARD("vd-lavc-skipidct", skip_idct, 0), OPT_DISCARD("vd-lavc-skipframe", skip_frame, 0), OPT_DISCARD("vd-lavc-framedrop", framedrop, 0), - OPT_INT("vd-lavc-threads", threads, M_OPT_MIN, .min = 0), + OPT_INT("vd-lavc-threads", threads, 0, .min = 0, .max = DBL_MAX), OPT_FLAG("vd-lavc-bitexact", bitexact, 0), OPT_FLAG("vd-lavc-assume-old-x264", old_x264, 0), OPT_FLAG("vd-lavc-check-hw-profile", check_hw_profile, 0), diff --git a/video/out/vo_null.c b/video/out/vo_null.c index a9b1ed12a4..7a0662fcb9 100644 --- a/video/out/vo_null.c +++ b/video/out/vo_null.c @@ -98,7 +98,7 @@ const struct vo_driver video_out_null = { .uninit = uninit, .priv_size = sizeof(struct priv), .options = (const struct m_option[]) { - OPT_DOUBLE("fps", cfg_fps, M_OPT_RANGE, .min = 0, .max = 10000), + OPT_DOUBLE("fps", cfg_fps, 0, .min = 0, .max = 10000), {0}, }, .options_prefix = "vo-null", diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index e75a653d65..06812336d1 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -17,6 +17,7 @@ * with mpv. If not, see <http://www.gnu.org/licenses/>. */ +#include <float.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -897,8 +898,8 @@ const struct vo_driver video_out_xv = { .cfg_buffers = 2, }, .options = (const struct m_option[]) { - OPT_INT("port", xv_port, M_OPT_MIN, .min = 0), - OPT_INT("adaptor", cfg_xv_adaptor, M_OPT_MIN, .min = -1), + OPT_INT("port", xv_port, 0, .min = 0, .max = DBL_MAX), + OPT_INT("adaptor", cfg_xv_adaptor, 0, .min = -1, .max = DBL_MAX), OPT_CHOICE("ck", xv_ck_info.source, 0, ({"use", CK_SRC_USE}, {"set", CK_SRC_SET}, |