video: report negative subtitle/OSD margins if necessary

Until now, it used only coordinates clipped to the screen for this,
which meant no negative margins were ever reported to libass. This broke
proper rendering of explicitly positioned ASS events (libass simply
could not know the real video size in this case.)

Fix this by reporting margins even if they're negative. This makes it
apparently work correctly with vo_gpu at least.

Note that I'm not really sure if anything in the rendering chain
required non-negative margins. If so, and that code implicitly assumed
it, I suppose crashes and such are possible.
This commit is contained in:
wm4 2020-03-26 12:23:32 +01:00
parent 30f6f27976
commit 537f011c6d
1 changed files with 4 additions and 4 deletions

View File

@ -90,6 +90,10 @@ 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;
@ -107,10 +111,6 @@ 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;
}
static void calc_margin(float opts[2], int out[2], int size)