[FFmpeg-devel] [PATCH] v4l2_m2m: Fix integer overflow in timestamp handling

wm4 nfxjfg at googlemail.com
Sun Jan 21 14:14:05 EET 2018


On Sun, 21 Jan 2018 00:52:18 +0000
Mark Thompson <sw at jkqxz.net> wrote:

> ---
> struct timeval elements are not big enough in a 32-bit ABI.
> 
> 
>  libavcodec/v4l2_buffers.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
> index 8e4d4d1..aef911f 100644
> --- a/libavcodec/v4l2_buffers.c
> +++ b/libavcodec/v4l2_buffers.c
> @@ -69,7 +69,8 @@ static inline uint64_t v4l2_get_pts(V4L2Buffer *avbuf)
>      int64_t v4l2_pts;
>  
>      /* convert pts back to encoder timebase */
> -    v4l2_pts = avbuf->buf.timestamp.tv_sec * USEC_PER_SEC + avbuf->buf.timestamp.tv_usec;
> +    v4l2_pts = (int64_t)avbuf->buf.timestamp.tv_sec * USEC_PER_SEC +
> +                        avbuf->buf.timestamp.tv_usec;
>  
>      return av_rescale_q(v4l2_pts, v4l2_timebase, s->avctx->time_base);
>  }

LGTM.

(By god, did they really have to use struct timeval for video
timestamps...)


More information about the ffmpeg-devel mailing list