summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-26 18:36:45 +0100
committerwm4 <wm4@nowhere>2015-12-26 18:36:45 +0100
commit05444e81357c5f8053795e270b57453b0a6e3e65 (patch)
tree351782c72c3e88a2e2c5653b8309eb21797f8450
parent190dea149aea07bc4be41c684a50db4231ccb0da (diff)
downloadmpv-05444e81357c5f8053795e270b57453b0a6e3e65.tar.bz2
mpv-05444e81357c5f8053795e270b57453b0a6e3e65.tar.xz
command: replace ROUND() with lrint()
lrint() pretty much does what ROUND() is supposed to do, but it's more precise.
-rw-r--r--common/common.h2
-rw-r--r--player/command.c9
2 files changed, 4 insertions, 7 deletions
diff --git a/common/common.h b/common/common.h
index cc7093a4fc..7312b85ec8 100644
--- a/common/common.h
+++ b/common/common.h
@@ -32,8 +32,6 @@
#define MP_CONCAT_(a, b) a ## b
#define MP_CONCAT(a, b) MP_CONCAT_(a, b)
-#define ROUND(x) ((int)((x) < 0 ? (x) - 0.5 : (x) + 0.5))
-
#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
diff --git a/player/command.c b/player/command.c
index 677c3af957..53ac5c1828 100644
--- a/player/command.c
+++ b/player/command.c
@@ -240,7 +240,7 @@ static char *format_file_size(int64_t size)
static char *format_delay(double time)
{
- return talloc_asprintf(NULL, "%d ms", ROUND(time * 1000));
+ return talloc_asprintf(NULL, "%d ms", (int)lrint(time * 1000));
}
// Property-option bridge. (Maps the property to the option with the same name.)
@@ -791,7 +791,7 @@ static int mp_property_chapter(void *ctx, struct m_property *prop,
int step_all;
if (action == M_PROPERTY_SWITCH) {
struct m_property_switch_arg *sarg = arg;
- step_all = ROUND(sarg->inc);
+ step_all = lrint(sarg->inc);
// Check threshold for relative backward seeks
if (mpctx->opts->chapter_seek_threshold >= 0 && step_all < 0) {
double current_chapter_start =
@@ -2374,9 +2374,8 @@ static int mp_property_frame_number(void *ctx, struct m_property *prop,
if (!mpctx->d_video)
return M_PROPERTY_UNAVAILABLE;
- int frame_number = ROUND(get_current_pos_ratio(mpctx, false) *
- (double)get_frame_count(mpctx));
- return m_property_int_ro(action, arg, frame_number);
+ return m_property_int_ro(action, arg,
+ lrint(get_current_pos_ratio(mpctx, false) * get_frame_count(mpctx)));
}
static int mp_property_frame_count(void *ctx, struct m_property *prop,