Skip to content

Commit

Permalink
sd_ass: fix fix_margins calculation
Browse files Browse the repository at this point in the history
Saving old playresx method is incorrect after the first
configure after the subtitle is loaded.

Fixes: f862d3b
  • Loading branch information
na-na-hi authored and Dudemanguy committed Dec 19, 2024
1 parent 32d103c commit 1723f8a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sub/sd_ass.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1723f8a

Please sign in to comment.