From 5d1f0efc43c64c25f5edd4101bc1f0013bcacb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Cezner?= Date: Sun, 15 Jan 2023 11:49:35 +0100 Subject: [PATCH] vlc-video: Fix videos larger than 1080p being squished Fix an overflow in display_width caused by unsafe multiplication of the video width by Sample Aspect Ratio. --- plugins/vlc-video/vlc-video-source.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/vlc-video/vlc-video-source.c b/plugins/vlc-video/vlc-video-source.c index b4e324736..559a45827 100644 --- a/plugins/vlc-video/vlc-video-source.c +++ b/plugins/vlc-video/vlc-video-source.c @@ -401,8 +401,8 @@ static void calculate_display_size(struct vlc_source *c, unsigned *width, if (track->i_type != libvlc_track_video) continue; - int display_width = track->video->i_width; - int display_height = track->video->i_height; + unsigned display_width = track->video->i_width; + unsigned display_height = track->video->i_height; if (display_width == 0 || display_height == 0) continue; @@ -410,9 +410,9 @@ static void calculate_display_size(struct vlc_source *c, unsigned *width, /* Adjust for Sample Aspect Ratio (SAR) */ if (track->video->i_sar_num > 0 && track->video->i_sar_den > 0) { - display_width = display_width * - track->video->i_sar_num / - track->video->i_sar_den; + display_width = (unsigned)util_mul_div64( + display_width, track->video->i_sar_num, + track->video->i_sar_den); } switch (track->video->i_orientation) {