summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-29 19:39:41 +0200
committerwm4 <wm4@nowhere>2013-06-29 22:58:14 +0200
commitada06703fbc78d2218b045e0e72156a9d9ee240a (patch)
tree40030e51987bb2967c2ab6566814ec506eacc382
parente5c094754157102a964364041d6fb0caf2188809 (diff)
downloadmpv-ada06703fbc78d2218b045e0e72156a9d9ee240a.tar.bz2
mpv-ada06703fbc78d2218b045e0e72156a9d9ee240a.tar.xz
sd_ass: convert pts to integer for get_text()
Gives more consistent rounding, which makes sub_step behave better.
-rw-r--r--sub/sd_ass.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index c82e1e80bb..0200dd4e68 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -264,14 +264,13 @@ static char *get_text(struct sd *sd, double pts)
if (pts == MP_NOPTS_VALUE)
return NULL;
+ long long ipts = pts * 1000 + 0.5;
struct buf b = {ctx->last_text, sizeof(ctx->last_text) - 1};
for (int i = 0; i < track->n_events; ++i) {
ASS_Event *event = track->events + i;
- double start = event->Start / 1000.0;
- double end = (event->Start + event->Duration) / 1000.0;
- if (pts >= start && pts < end) {
+ if (ipts >= event->Start && ipts < event->Start + event->Duration) {
if (event->Text) {
int start = b.len;
ass_to_plaintext(&b, event->Text);