Просмотр исходного кода

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.
Lukáš Cezner 2 лет назад
Родитель
Сommit
5d1f0efc43
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      plugins/vlc-video/vlc-video-source.c

+ 5 - 5
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) {