[FFmpeg-cvslog] fftools/ffprobe: Avoid overflow when calculating DAR

Derek Buitenhuis git at videolan.org
Sun May 5 13:57:00 EEST 2024


ffmpeg | branch: master | Derek Buitenhuis <derek.buitenhuis at gmail.com> | Fri May  3 17:33:58 2024 +0100| [f8a613d6a86f1f2875cbebc8f1f60cfe39256fd1] | committer: Derek Buitenhuis

fftools/ffprobe: Avoid overflow when calculating DAR

Both the codecpar's width and height, and the SAR num and den are
ints, which can overflow. Cast to int64_t, which is what av_reduce
takes.

Without this, occasionally, display_aspect_ratio can be negative in
ffprobe's -show_stream output.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>

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

 fftools/ffprobe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 0d4cd0b048..5b40dad527 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3324,8 +3324,8 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
         if (sar.num) {
             print_q("sample_aspect_ratio", sar, ':');
             av_reduce(&dar.num, &dar.den,
-                      par->width  * sar.num,
-                      par->height * sar.den,
+                      (int64_t) par->width  * sar.num,
+                      (int64_t) par->height * sar.den,
                       1024*1024);
             print_q("display_aspect_ratio", dar, ':');
         } else {



More information about the ffmpeg-cvslog mailing list