[FFmpeg-cvslog] lavc/hevc: check framerate num/den to be strictly positive

Anton Khirnov git at videolan.org
Thu Sep 12 12:18:19 EEST 2024


ffmpeg | branch: release/6.0 | Anton Khirnov <anton at khirnov.net> | Sun Sep  1 15:41:24 2024 +0200| [c22db2bcf239efb2b9dfd8150df0273d98aec03f] | committer: Anton Khirnov

lavc/hevc: check framerate num/den to be strictly positive

Rather than just != 0. These values are read as uint32 and can become
negative when cast to int.

(cherry picked from commit eec1a7a6bb952c09945d908d2d5de35909516778)
Signed-off-by: Anton Khirnov <anton at khirnov.net>
(cherry picked from commit 9cadadb9a12aaf30b196c896073c473d91a2bdf0)
Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c22db2bcf239efb2b9dfd8150df0273d98aec03f
---

 libavcodec/hevc_parser.c | 2 +-
 libavcodec/hevcdec.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 59f9a0ff3e..d03af01fd0 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -105,7 +105,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal,
         den = ps->sps->vui.vui_time_scale;
     }
 
-    if (num != 0 && den != 0)
+    if (num > 0 && den > 0)
         av_reduce(&avctx->framerate.den, &avctx->framerate.num,
                   num, den, 1 << 30);
 
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 0e2844f47c..8f6e965a3a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -374,7 +374,7 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
         den = sps->vui.vui_time_scale;
     }
 
-    if (num != 0 && den != 0)
+    if (num > 0 && den > 0)
         av_reduce(&avctx->framerate.den, &avctx->framerate.num,
                   num, den, 1 << 30);
 }



More information about the ffmpeg-cvslog mailing list