mirror of https://github.com/mpv-player/mpv
sd_ass: fix margins for all styles when overriding PlayResX
Also save old playresx and use it instead of assuming values of things we know.
This commit is contained in:
parent
d2efa1c1be
commit
f862d3b6cd
11
sub/sd_ass.c
11
sub/sd_ass.c
|
@ -550,12 +550,13 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
|
||||||
if (override_playres) {
|
if (override_playres) {
|
||||||
int vidw = dim->w - (dim->ml + dim->mr);
|
int vidw = dim->w - (dim->ml + dim->mr);
|
||||||
int vidh = dim->h - (dim->mt + dim->mb);
|
int vidh = dim->h - (dim->mt + dim->mb);
|
||||||
|
int old_playresx = track->PlayResX;
|
||||||
track->PlayResX = track->PlayResY * (double)vidw / MPMAX(vidh, 1);
|
track->PlayResX = track->PlayResY * (double)vidw / MPMAX(vidh, 1);
|
||||||
// ffmpeg and mpv use a default PlayResX of 384 when it is not known,
|
double fix_margins = track->PlayResX / (double)old_playresx;
|
||||||
// this comes from VSFilter.
|
for (int n = 0; n < track->n_styles; n++) {
|
||||||
double fix_margins = track->PlayResX / (double)MP_ASS_FONT_PLAYRESX;
|
track->styles[n].MarginL = round(track->styles[n].MarginL * fix_margins);
|
||||||
track->styles->MarginL = round(track->styles->MarginL * fix_margins);
|
track->styles[n].MarginR = round(track->styles[n].MarginR * fix_margins);
|
||||||
track->styles->MarginR = round(track->styles->MarginR * fix_margins);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue