From 7c2c1dbe8005b2d2f9aac7f5f10b46715f27addd Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 3 Nov 2014 21:54:49 +0100 Subject: [PATCH] demux: fix PTS comparison This was relying on the fact that timestamps will always be numerically larger than MP_NOPTS_VALUE, but the trick didn't actually work for MP_PTS_MIN. Be a bit more sincere, and don't rely on this anymore. This fixes the comparison, and avoids the readahead amount displaying as "???" in some situations (since one of the values was NOPTS). --- demux/demux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/demux/demux.c b/demux/demux.c index 5e7268d622..73bc6247c2 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -148,9 +148,11 @@ struct demux_stream { struct demux_packet *tail; }; +// Return "a", or if that is NOPTS, return "def". +#define PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a)) // If one of the values is NOPTS, always pick the other one. -#define MP_PTS_MIN(a, b) ((a) == MP_NOPTS_VALUE || ((a) > (b)) ? (b) : (a)) -#define MP_PTS_MAX(a, b) ((a) == MP_NOPTS_VALUE || ((a) < (b)) ? (b) : (a)) +#define MP_PTS_MIN(a, b) MPMIN(PTS_OR_DEF(a, b), PTS_OR_DEF(b, a)) +#define MP_PTS_MAX(a, b) MPMAX(PTS_OR_DEF(a, b), PTS_OR_DEF(b, a)) static void demuxer_sort_chapters(demuxer_t *demuxer); static void *demux_thread(void *pctx);