sd_ass: fix margin y scale with font size

--sub-margin-y is documented to scale with font size, which is scaled
"by" or "with" window depending on the options. However, when using
ass_set_font_scale to change font size, the y margin isn't scaled, so it is
still scaled to video size. This causes the y margin size becoming smaller
when the video becomes smaller, even when the font size isn't changing.

Fix this by also scale the MarginV with the font scale. Also use lrint
instead of round.
This commit is contained in:
nanahi 2024-06-14 01:56:24 -04:00 committed by Kacper Michajłow
parent b59ac04db9
commit 07acdf09b3
1 changed files with 3 additions and 2 deletions

View File

@ -592,8 +592,9 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
track->PlayResX = track->PlayResY * (double)vidw / MPMAX(vidh, 1);
double fix_margins = track->PlayResX / (double)old_playresx;
for (int n = 0; n < track->n_styles; n++) {
track->styles[n].MarginL = round(track->styles[n].MarginL * fix_margins);
track->styles[n].MarginR = round(track->styles[n].MarginR * fix_margins);
track->styles[n].MarginL = lrint(track->styles[n].MarginL * fix_margins);
track->styles[n].MarginR = lrint(track->styles[n].MarginR * fix_margins);
track->styles[n].MarginV = lrint(track->styles[n].MarginV * set_font_scale);
}
}
}