From 1723f8a9d200bed5e225ba640411d06782cca8ca Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Wed, 18 Dec 2024 01:08:10 -0500 Subject: [PATCH] sd_ass: fix fix_margins calculation Saving old playresx method is incorrect after the first configure after the subtitle is loaded. Fixes: f862d3b6cd66abee98f2af21c36255ef7361cb80 --- sub/sd_ass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 3aef76c911c4c..4f9cd3eb48eeb 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -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);