summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-03-13 16:49:39 +0100
committerwm4 <wm4@nowhere>2020-03-13 17:34:46 +0100
commit8d965a1bfb3782343a03cff44977f11bb920f0b1 (patch)
tree2d115c24510ab36cc9ac7af8dea2b710537561c9 /demux
parent5d5a7e19537a036fe16ce04555e6ce9449c47494 (diff)
downloadmpv-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 'demux')
-rw-r--r--demux/demux.c10
-rw-r--r--demux/demux_mkv.c9
2 files changed, 11 insertions, 8 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 1c7c3057b1..82641cb6af 100644
--- a/demux/demux.c
+++ b/demux/demux.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 <string.h>
@@ -114,14 +115,15 @@ const struct m_sub_options demux_conf = {
OPT_CHOICE("cache", enable_cache, 0,
({"no", 0}, {"auto", -1}, {"yes", 1})),
OPT_FLAG("cache-on-disk", disk_cache, 0),
- OPT_DOUBLE("demuxer-readahead-secs", min_secs, M_OPT_MIN, .min = 0),
+ OPT_DOUBLE("demuxer-readahead-secs", min_secs, 0,
+ .min = 0, .max = DBL_MAX),
// (The MAX_BYTES sizes may not be accurate because the max field is
// of double type.)
OPT_BYTE_SIZE("demuxer-max-bytes", max_bytes, 0, 0, MAX_BYTES),
OPT_BYTE_SIZE("demuxer-max-back-bytes", max_bytes_bw, 0, 0, MAX_BYTES),
OPT_FLAG("demuxer-donate-buffer", donate_fw, 0),
OPT_FLAG("force-seekable", force_seekable, 0),
- OPT_DOUBLE("cache-secs", min_secs_cache, M_OPT_MIN, .min = 0,
+ OPT_DOUBLE("cache-secs", min_secs_cache, 0, .min = 0, .max = DBL_MAX,
.deprecation_message = "will use unlimited time"),
OPT_FLAG("access-references", access_references, 0),
OPT_CHOICE("demuxer-seekable-cache", seekable_cache, 0,
@@ -134,8 +136,8 @@ const struct m_sub_options demux_conf = {
1024, ({"auto", -1})),
OPT_INTRANGE("video-backward-batch", back_batch[STREAM_VIDEO], 0, 0, 1024),
OPT_INTRANGE("audio-backward-batch", back_batch[STREAM_AUDIO], 0, 0, 1024),
- OPT_DOUBLE("demuxer-backward-playback-step", back_seek_size, M_OPT_MIN,
- .min = 0),
+ OPT_DOUBLE("demuxer-backward-playback-step", back_seek_size, 0,
+ .min = 0, .max = DBL_MAX),
OPT_STRING("metadata-codepage", meta_cp, 0),
OPT_FLAG("demuxer-force-retry-on-eof", force_retry_eof, 0,
.deprecation_message = "temporary debug option, no replacement"),
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index a65afbfbc5..f16f537bd3 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -20,6 +20,7 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <float.h>
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
@@ -230,10 +231,10 @@ const struct m_sub_options demux_mkv_conf = {
.opts = (const m_option_t[]) {
OPT_CHOICE("subtitle-preroll", subtitle_preroll, 0,
({"no", 0}, {"yes", 1}, {"index", 2})),
- OPT_DOUBLE("subtitle-preroll-secs", subtitle_preroll_secs,
- M_OPT_MIN, .min = 0),
- OPT_DOUBLE("subtitle-preroll-secs-index", subtitle_preroll_secs_index,
- M_OPT_MIN, .min = 0),
+ OPT_DOUBLE("subtitle-preroll-secs", subtitle_preroll_secs, 0,
+ .min = 0, .max = DBL_MAX),
+ OPT_DOUBLE("subtitle-preroll-secs-index", subtitle_preroll_secs_index, 0,
+ .min = 0, .max = DBL_MAX),
OPT_CHOICE("probe-video-duration", probe_duration, 0,
({"no", 0}, {"yes", 1}, {"full", 2})),
OPT_FLAG("probe-start-time", probe_start_time, 0),