diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 338f69868e52371416ec8b5ab82dee4e7b9e9b9e..1d9f58dbb2fd7894cacd61b5f43a8e1b1dc2a446 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -660,10 +660,7 @@ static int matroska_ebmlnum_sint(MatroskaDemuxContext *matroska,
         return res;
 
     /* make signed (weird way) */
-    if (unum == (uint64_t)-1)
-        *num = INT64_MAX;
-    else
-        *num = unum - ((1LL << ((7 * res) - 1)) - 1);
+    *num = unum - ((1LL << (7*res - 1)) - 1);
 
     return res;
 }