[libav-devel] [PATCH] avutil: make AV_NOPTS_VALUE signed negative

Rémi Denis-Courmont remi at remlab.net
Sat Nov 4 10:06:18 CET 2017


libav generally uses int64_t to represent timestamps, and thus
AV_NOPTS_VALUE has to fit witin the range of int64_t.

The current definition of AV_NOPTS_VALUE results in AV_NOPTS_VALUE
having the same type as uint64_t, since its value is positive and
cannot be represented by int64_t.

See also ISO C11 §6.4.4.1 clause 5.

This patch ensures that AV_NOPTS_VALUE is an int64_t, avoiding
undefined overflowing conversion from uint64_t to int64_t.
---
 libavutil/avutil.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 2339fe3c9c..9a5d8dbe57 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -238,7 +238,7 @@ enum AVMediaType {
  * either pts or dts.
  */
 
-#define AV_NOPTS_VALUE          INT64_C(0x8000000000000000)
+#define AV_NOPTS_VALUE          (-INT64_C(0x7fffffffffffffff) - 1)
 
 /**
  * Internal time base represented as integer
-- 
2.15.0



More information about the libav-devel mailing list