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

James Almer jamrial at gmail.com
Sat Nov 4 16:01:14 CET 2017


On 11/4/2017 6:06 AM, Rémi Denis-Courmont wrote:
> 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)

$ grep INT64_MIN stdint.h
stdint.h:#define INT64_MIN  (-9223372036854775807LL - 1)

Maybe just use INT64_MIN?

>  
>  /**
>   * Internal time base represented as integer
> 



More information about the libav-devel mailing list