summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-04 23:56:20 +0200
committerwm4 <wm4@nowhere>2013-08-05 00:00:26 +0200
commitee2e3b3374c4756dc881962bea4e4615805a8122 (patch)
treeeefd7cd4f17e6b68d2a7eebf4d9fcd1db0b9b1f1 /core
parentcccfac47a423cbaeda04f9864c4676ed1c9d5002 (diff)
downloadmpv-ee2e3b3374c4756dc881962bea4e4615805a8122.tar.bz2
mpv-ee2e3b3374c4756dc881962bea4e4615805a8122.tar.xz
core: change speed option/property to double
The --speed option and the speed property used float. Change them to double. Change the commands that manipulate the property (speed_mult/add) to double as well. Since the cycle command shares code with the add command, we change that as well. The reason for this change is that this allows better control over speed, such as stepping by semitones. Using floats is also just plain unnecessary.
Diffstat (limited to 'core')
-rw-r--r--core/command.c8
-rw-r--r--core/input/input.c17
-rw-r--r--core/mplayer.c2
-rw-r--r--core/options.c2
-rw-r--r--core/options.h2
5 files changed, 16 insertions, 15 deletions
diff --git a/core/command.c b/core/command.c
index e50121fede..a2d4d2ee56 100644
--- a/core/command.c
+++ b/core/command.c
@@ -127,7 +127,7 @@ static int mp_property_playback_speed(m_option_t *prop, int action,
double orig_speed = opts->playback_speed;
switch (action) {
case M_PROPERTY_SET: {
- opts->playback_speed = *(float *) arg;
+ opts->playback_speed = *(double *) arg;
// Adjust time until next frame flip for nosound mode
mpctx->time_frame *= orig_speed / opts->playback_speed;
if (mpctx->sh_audio)
@@ -2186,8 +2186,8 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
.inc = 1,
.wrap = cmd->id == MP_CMD_CYCLE,
};
- if (cmd->args[1].v.f)
- s.inc = cmd->args[1].v.f;
+ if (cmd->args[1].v.d)
+ s.inc = cmd->args[1].v.d;
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_SWITCH, &s, mpctx);
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
show_property_osd(mpctx, cmd->args[0].v.s, cmd->on_osd);
@@ -2221,7 +2221,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
}
case MP_CMD_SPEED_MULT: {
- float v = cmd->args[0].v.f;
+ double v = cmd->args[0].v.d;
v *= mpctx->opts->playback_speed;
mp_property_do("speed", M_PROPERTY_SET, &v, mpctx);
show_property_osd(mpctx, "speed", cmd->on_osd);
diff --git a/core/input/input.c b/core/input/input.c
index 855e09887b..ae1358a76d 100644
--- a/core/input/input.c
+++ b/core/input/input.c
@@ -92,13 +92,14 @@ struct key_name {
#define ARG_INT { .type = {"", NULL, &m_option_type_int} }
#define ARG_FLOAT { .type = {"", NULL, &m_option_type_float} }
+#define ARG_DOUBLE { .type = {"", NULL, &m_option_type_double} }
#define ARG_STRING { .type = {"", NULL, &m_option_type_string} }
#define ARG_CHOICE(c) { .type = {"", NULL, &m_option_type_choice, \
M_CHOICES(c)} }
#define ARG_TIME { .type = {"", NULL, &m_option_type_time} }
-#define OARG_FLOAT(def) { .type = {"", NULL, &m_option_type_float}, \
- .optional = true, .v.f = def }
+#define OARG_DOUBLE(def) { .type = {"", NULL, &m_option_type_double}, \
+ .optional = true, .v.d = def }
#define OARG_INT(def) { .type = {"", NULL, &m_option_type_int}, \
.optional = true, .v.i = def }
#define OARG_CHOICE(def, c) { .type = {"", NULL, &m_option_type_choice, \
@@ -129,7 +130,7 @@ static const mp_cmd_t mp_cmds[] = {
{"exact", 1}, {"1", 1},
{"keyframes", -1}, {"-1", -1})),
}},
- { MP_CMD_SPEED_MULT, "speed_mult", { ARG_FLOAT } },
+ { MP_CMD_SPEED_MULT, "speed_mult", { ARG_DOUBLE } },
{ MP_CMD_QUIT, "quit", { OARG_INT(0) } },
{ MP_CMD_QUIT_WATCH_LATER, "quit_watch_later", },
{ MP_CMD_STOP, "stop", },
@@ -195,12 +196,12 @@ static const mp_cmd_t mp_cmds[] = {
{ MP_CMD_KEYDOWN_EVENTS, "key_down_event", { ARG_INT } },
{ MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
{ MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } },
- { MP_CMD_ADD, "add", { ARG_STRING, OARG_FLOAT(0) } },
+ { MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(0) } },
{ MP_CMD_CYCLE, "cycle", {
ARG_STRING,
{ .type = {"", NULL, &m_option_type_cycle_dir},
.optional = true,
- .v.f = 1 },
+ .v.d = 1 },
}},
{ MP_CMD_ENABLE_INPUT_SECTION, "enable_section", {
@@ -776,15 +777,15 @@ void mp_input_rm_key_fd(struct input_ctx *ictx, int fd)
static int parse_cycle_dir(const struct m_option *opt, struct bstr name,
struct bstr param, void *dst)
{
- float val;
+ double val;
if (bstrcmp0(param, "up") == 0) {
val = +1;
} else if (bstrcmp0(param, "down") == 0) {
val = -1;
} else {
- return m_option_type_float.parse(opt, name, param, dst);
+ return m_option_type_double.parse(opt, name, param, dst);
}
- *(float *)dst = val;
+ *(double *)dst = val;
return 1;
}
diff --git a/core/mplayer.c b/core/mplayer.c
index 31b1e88efa..d3872442ee 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -1576,7 +1576,7 @@ static int build_afilter_chain(struct MPContext *mpctx)
new_srate = 8000;
if (new_srate > 192000)
new_srate = 192000;
- opts->playback_speed = (float)new_srate / sh_audio->samplerate;
+ opts->playback_speed = (double)new_srate / sh_audio->samplerate;
}
}
return init_audio_filters(sh_audio, new_srate,
diff --git a/core/options.c b/core/options.c
index e2a7589708..0409288b9e 100644
--- a/core/options.c
+++ b/core/options.c
@@ -448,7 +448,7 @@ const m_option_t mp_opts[] = {
OPT_INTRANGE("srate", force_srate, 0, 1000, 8*48000),
OPT_CHMAP("channels", audio_output_channels, CONF_MIN, .min = 1),
OPT_AUDIOFORMAT("format", audio_output_format, 0),
- OPT_FLOATRANGE("speed", playback_speed, 0, 0.01, 100.0),
+ OPT_DOUBLE("speed", playback_speed, M_OPT_RANGE, .min = 0.01, .max = 100.0),
// set a-v distance
OPT_FLOATRANGE("audio-delay", audio_delay, 0, -100.0, 100.0),
diff --git a/core/options.h b/core/options.h
index 9a8deb9e4d..c83ab7a73a 100644
--- a/core/options.h
+++ b/core/options.h
@@ -159,7 +159,7 @@ typedef struct MPOpts {
int audio_output_format;
int force_srate;
int dtshd;
- float playback_speed;
+ double playback_speed;
struct m_obj_settings *vf_settings;
struct m_obj_settings *af_settings;
float movie_aspect;