mirror of
https://github.com/mpv-player/mpv
synced 2025-02-06 15:11:58 +00:00
sd_lavc: don't stretch DVD subtitles to video aspect
I'm not sure what's correct: stretching the DVD subtitles from storage aspect ratio to video display aspect ratio, or displaying subtitles using 1:1 PAR. Until now, DVD subtitles (as well as all other bitmap subtitles) were always stretched to the video. There are good arguments why this would be the correct behavior: DVDs were made for playback on TV, which display anamorphic video by adjusting the horizontal refresh rate, and thus wouldn't even be capable of DVD subtitles with square PAR (other than resampling the subtitles additionally). However, I haven't seen a sample yet where subtitles do _not_ look stretched using this method. Rendering them at 1:1 PAR looks better. Technically, we render them at display PAR (and not 1:1 PAR). Do this in a way so that the subtitle area is always inside of the video frame if display and video aspect ratios mismatch. For DVB subtitles, the old method looks more correct, so this is special cased to DVD subtitles. I might revert this commit if it turns out that it's an disimprovement.
This commit is contained in:
parent
3d439368a1
commit
130866e269
@ -211,13 +211,25 @@ static void get_bitmaps(struct sd *sd, struct mp_osd_res d, double pts,
|
||||
int inw = priv->avctx->width;
|
||||
int inh = priv->avctx->height;
|
||||
guess_resolution(priv->avctx->codec_id, &inw, &inh);
|
||||
double xscale = (double) (d.w - d.ml - d.mr) / inw;
|
||||
double yscale = (double) (d.h - d.mt - d.mb) / inh;
|
||||
int vidw = d.w - d.ml - d.mr;
|
||||
int vidh = d.h - d.mt - d.mb;
|
||||
double xscale = (double)vidw / inw;
|
||||
double yscale = (double)vidh / inh;
|
||||
if (priv->avctx->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
|
||||
// For DVD subs, try to keep the subtitle PAR at display PAR.
|
||||
if (d.video_par > 1.0) {
|
||||
xscale /= d.video_par;
|
||||
} else {
|
||||
yscale *= d.video_par;
|
||||
}
|
||||
}
|
||||
int cx = vidw / 2 - (int)(inw * xscale) / 2;
|
||||
int cy = vidh / 2 - (int)(inh * yscale) / 2;
|
||||
for (int i = 0; i < priv->count; i++) {
|
||||
struct sub_bitmap *bi = &priv->inbitmaps[i];
|
||||
struct sub_bitmap *bo = &priv->outbitmaps[i];
|
||||
bo->x = bi->x * xscale + d.ml;
|
||||
bo->y = bi->y * yscale + d.mt;
|
||||
bo->x = bi->x * xscale + cx + d.ml;
|
||||
bo->y = bi->y * yscale + cy + d.mt;
|
||||
bo->dw = bi->w * xscale;
|
||||
bo->dh = bi->h * yscale;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user