Previous fixes in bcc3d72 make subtitles on videos with non-square pixel aspect ratios appear incorrect. This can happen on subtitles for SD Blu-rays where the video resolution is 720x480 but the aspect ratio is 4:3. The scaling still applies when the video frame is cropped with filters so the previous fix will still work. Fixes #15415.
Unified · Split
| @@ -540,7 +540,8 @@ struct mp_osd_res osd_get_vo_res(struct osd_state *osd) · 539 unmodified lines | |||
| 540 | // fills the whole video area (especially if the video is magnified, e.g. on | 540 | // fills the whole video area (especially if the video is magnified, e.g. on |
| 541 | // fullscreen). If compensate_par is >0, adjust the way the subtitles are | 541 | // fullscreen). If compensate_par is >0, adjust the way the subtitles are |
| 542 | // "stretched" on the screen, and letter-box the result. If compensate_par | 542 | // "stretched" on the screen, and letter-box the result. If compensate_par |
| 543 | // is <0, strictly letter-box the subtitles. If it is 0, stretch them. | 543 | // is <0, strictly letter-box the subtitles according to the supplied aspect |
| 544 | // ratio. If it is 0, stretch them. | ||
| 544 | void osd_rescale_bitmaps(struct sub_bitmaps *imgs, int frame_w, int frame_h, | 545 | void osd_rescale_bitmaps(struct sub_bitmaps *imgs, int frame_w, int frame_h, |
| 545 | struct mp_osd_res res, double compensate_par) | 546 | struct mp_osd_res res, double compensate_par) |
| 546 | { | 547 | { |
| @@ -550,7 +551,7 @@ void osd_rescale_bitmaps(struct sub_bitmaps *imgs, int frame_w, int frame_h, · 3 unmodified lines | |||
| 550 | double yscale = (double)vidh / frame_h; | 551 | double yscale = (double)vidh / frame_h; |
| 551 | if (compensate_par < 0) { | 552 | if (compensate_par < 0) { |
| 552 | assert(res.display_par); | 553 | assert(res.display_par); |
| 553 | compensate_par = xscale / yscale / res.display_par; | 554 | compensate_par = xscale / yscale / res.display_par / compensate_par * -1; |
| 554 | } | 555 | } |
| 555 | if (compensate_par > 0) | 556 | if (compensate_par > 0) |
| 556 | xscale /= compensate_par; | 557 | xscale /= compensate_par; |
| @@ -472,7 +472,24 @@ static struct sub_bitmaps *get_bitmaps(struct sd *sd, struct mp_osd_res d, · 471 unmodified lines | |||
| 472 | video_par = par; | 472 | video_par = par; |
| 473 | } | 473 | } |
| 474 | if (priv->avctx->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE) | 474 | if (priv->avctx->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE) |
| 475 | video_par = -1; | 475 | { |
| 476 | // For Blu-ray subs on SD video, try to match the video PAR. | ||
| 477 | if (priv->video_params.w == 720 && | ||
| 478 | (priv->video_params.h == 480 || | ||
| 479 | priv->video_params.h == 576)) | ||
| 480 | { | ||
| 481 | double par = priv->video_params.p_w / (double)priv->video_params.p_h; | ||
| 482 | if (isnormal(par)) | ||
| 483 | video_par = par * -1; | ||
| 484 | else | ||
| 485 | video_par = -1; | ||
| 486 | } | ||
| 487 | else | ||
| 488 | { | ||
| 489 | // Force letter-boxing on all other Blu-ray subtitles | ||
| 490 | video_par = -1; | ||
| 491 | } | ||
| 492 | } | ||
| 476 | if (opts->stretch_image_subs) | 493 | if (opts->stretch_image_subs) |
| 477 | d.ml = d.mr = d.mt = d.mb = 0; | 494 | d.ml = d.mr = d.mt = d.mb = 0; |
| 478 | int w = priv->avctx->width; | 495 | int w = priv->avctx->width; |