From 9c9ec073bd4919239b04cbd9a4a9f86fa177dc65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 8 Sep 2023 01:41:49 +0200 Subject: [PATCH] sd_lavc: account for floating point inaccuracy Timestamps are converted from microsecond resolution timestamp, we don't have more precision, so we have to account for that when comparing the floating point values as them will slightly be off. Fixes: #12327 --- sub/sd_lavc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c index e3a62da9f1..43dbfeee00 100644 --- a/sub/sd_lavc.c +++ b/sub/sd_lavc.c @@ -398,7 +398,7 @@ static struct sub *get_current(struct sd_lavc_priv *priv, double pts) continue; if (pts == MP_NOPTS_VALUE || ((sub->pts == MP_NOPTS_VALUE || pts + 1e-6 >= sub->pts) && - (sub->endpts == MP_NOPTS_VALUE || pts < sub->endpts))) + (sub->endpts == MP_NOPTS_VALUE || pts + 1e-6 < sub->endpts))) { // Ignore "trailing" subtitles with unknown length after 1 minute. if (sub->endpts == MP_NOPTS_VALUE && pts >= sub->pts + 60)