]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/omx: fix xFramerate calculation
authorAman Gupta <aman@tmm1.net>
Thu, 29 Aug 2019 23:00:50 +0000 (16:00 -0700)
committerAman Gupta <aman@tmm1.net>
Mon, 2 Sep 2019 20:46:11 +0000 (13:46 -0700)
Integer overflow in the Q16 framerate calculation was sending
invalid values to the OMX encoder.

On the RPI4, this manifested as bitrate controls being ignored
on video streams with 60000/1001 framerates. Video streams with
30000/1001 framerates were not affected.

Signed-off-by: Aman Gupta <aman@tmm1.net>
libavcodec/omx.c

index 837f5df666ae1cd44868c89b5c191821eb1192ea..0a6a3083090e2879d8ec2c6885b70f4a8587c49d 100644 (file)
@@ -473,9 +473,9 @@ static av_cold int omx_component_init(AVCodecContext *avctx, const char *role)
     in_port_params.format.video.nFrameWidth  = avctx->width;
     in_port_params.format.video.nFrameHeight = avctx->height;
     if (avctx->framerate.den > 0 && avctx->framerate.num > 0)
-        in_port_params.format.video.xFramerate = (1 << 16) * avctx->framerate.num / avctx->framerate.den;
+        in_port_params.format.video.xFramerate = (1LL << 16) * avctx->framerate.num / avctx->framerate.den;
     else
-        in_port_params.format.video.xFramerate = (1 << 16) * avctx->time_base.den / avctx->time_base.num;
+        in_port_params.format.video.xFramerate = (1LL << 16) * avctx->time_base.den / avctx->time_base.num;
 
     err = OMX_SetParameter(s->handle, OMX_IndexParamPortDefinition, &in_port_params);
     CHECK(err);