diff options
author | wm4 <wm4@nowhere> | 2019-06-15 17:50:41 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-19 20:37:05 +0200 |
commit | e1c8069b686bf67d0c2aa6a1527d5b244e170a18 (patch) | |
tree | 58371a8938d48043e9c5d2d902b81a18a16bb54d /video/out/aspect.c | |
parent | d34550930b208c1b24474a2a25b44fc44ab6dc0a (diff) | |
download | mpv-e1c8069b686bf67d0c2aa6a1527d5b244e170a18.tar.bz2 mpv-e1c8069b686bf67d0c2aa6a1527d5b244e170a18.tar.xz |
aspect: fix some UB problems in corner cases
--video-margin-ratio-left=0.2 --video-margin-ratio-right=0.9 (added in
the the next commit) will set f_w to inf, resulting in some garbage
being propagated. Later, the OSD margins are computed from values before
various sanity clamping is applied, which makes libass suffer from
bullshit values.
I'm very sure it's OK and more correct to compute the OSD margins using
the later values, but I'm not sure about that.
Diffstat (limited to 'video/out/aspect.c')
-rw-r--r-- | video/out/aspect.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/video/out/aspect.c b/video/out/aspect.c index 0d37501d11..896fa4980f 100644 --- a/video/out/aspect.c +++ b/video/out/aspect.c @@ -44,12 +44,12 @@ static void aspect_calc_panscan(struct mp_vo_opts *opts, } int vo_panscan_area = window_h - fheight; - double f_w = fwidth / (double)fheight; + double f_w = fwidth / (double)MPMAX(fheight, 1); double f_h = 1; if (vo_panscan_area == 0) { vo_panscan_area = window_w - fwidth; f_w = 1; - f_h = fheight / (double)fwidth; + f_h = fheight / (double)MPMAX(fwidth, 1); } if (unscaled) { @@ -90,10 +90,6 @@ static void src_dst_split_scaling(int src_size, int dst_size, *dst_start = (dst_size - scaled_src_size) * align + pan * scaled_src_size; *dst_end = *dst_start + scaled_src_size; - // Distance of screen frame to video - *osd_margin_a = *dst_start; - *osd_margin_b = dst_size - *dst_end; - // Clip to screen int s_src = *src_end - *src_start; int s_dst = *dst_end - *dst_start; @@ -111,6 +107,10 @@ static void src_dst_split_scaling(int src_size, int dst_size, // For sanity: avoid bothering VOs with corner cases clamp_size(src_size, src_start, src_end); clamp_size(dst_size, dst_start, dst_end); + + // Distance of screen frame to video + *osd_margin_a = *dst_start; + *osd_margin_b = dst_size - *dst_end; } void mp_get_src_dst_rects(struct mp_log *log, struct mp_vo_opts *opts, |