sd_ass: fix fix_margins calculation

Saving old playresx method is incorrect after the first
configure after the subtitle is loaded.

Fixes: f862d3b6cd
This commit is contained in:
nanahi
2024-12-18 01:08:10 -05:00
committed by Dudemanguy
parent 32d103c580
commit 1723f8a9d2

View File

@@ -617,9 +617,10 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
if (override_playres) {
int vidw = dim->w - (dim->ml + dim->mr);
int vidh = dim->h - (dim->mt + dim->mb);
int old_playresx = track->PlayResX;
track->PlayResX = track->PlayResY * (double)vidw / MPMAX(vidh, 1);
double fix_margins = track->PlayResX / (double)old_playresx;
// ffmpeg and mpv use a default PlayResX of 384 when it is not known,
// this comes from VSFilter.
double fix_margins = track->PlayResX / (double)MP_ASS_FONT_PLAYRESX;
for (int n = 0; n < track->n_styles; n++) {
track->styles[n].MarginL = lrint(track->styles[n].MarginL * fix_margins);
track->styles[n].MarginR = lrint(track->styles[n].MarginR * fix_margins);