mirror of
https://github.com/mpv-player/mpv
synced 2024-12-20 05:42:19 +00:00
vd: move aspect calculation to a function
This function would probably be useful in other places too. I'm not sure why vd.c doesn't apply the aspect if it changes size by less than 4 pixels. Maybe it's supposed to avoid ugly results with bad scalers if the difference is too small to be noticed normally.
This commit is contained in:
parent
7eb13c4028
commit
f5bf6c0fb3
@ -120,30 +120,16 @@ int mpcodecs_reconfig_vo(sh_video_t *sh, const struct mp_image_params *params)
|
||||
else if (sh->stream_aspect != 0.0)
|
||||
sh->aspect = sh->stream_aspect;
|
||||
|
||||
int d_w = p.w;
|
||||
int d_h = p.h;
|
||||
|
||||
if (sh->aspect > 0.01) {
|
||||
int new_w = d_h * sh->aspect;
|
||||
int new_h = d_h;
|
||||
// we don't like horizontal downscale
|
||||
if (new_w < d_w) {
|
||||
new_w = d_w;
|
||||
new_h = d_w / sh->aspect;
|
||||
}
|
||||
if (abs(d_w - new_w) >= 4 || abs(d_h - new_h) >= 4) {
|
||||
d_w = new_w;
|
||||
d_h = new_h;
|
||||
mp_tmsg(MSGT_CPLAYER, MSGL_V, "Aspect ratio is %.2f:1 - "
|
||||
"scaling to correct movie aspect.\n", sh->aspect);
|
||||
}
|
||||
|
||||
vf_set_dar(&p.d_w, &p.d_h, p.w, p.h, sh->aspect);
|
||||
if (abs(p.d_w - p.w) >= 4 || abs(p.d_h - p.h) >= 4) {
|
||||
mp_tmsg(MSGT_CPLAYER, MSGL_V, "Aspect ratio is %.2f:1 - "
|
||||
"scaling to correct movie aspect.\n", sh->aspect);
|
||||
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", sh->aspect);
|
||||
} else {
|
||||
p.d_w = p.w;
|
||||
p.d_h = p.h;
|
||||
}
|
||||
|
||||
p.d_w = d_w;
|
||||
p.d_h = d_h;
|
||||
|
||||
// Apply user overrides
|
||||
if (opts->requested_colorspace != MP_CSP_AUTO)
|
||||
p.colorspace = opts->requested_colorspace;
|
||||
@ -158,9 +144,8 @@ int mpcodecs_reconfig_vo(sh_video_t *sh, const struct mp_image_params *params)
|
||||
vocfg_flags = (flip ? VOFLAG_FLIPPING : 0);
|
||||
|
||||
// Time to config libvo!
|
||||
mp_msg(MSGT_CPLAYER, MSGL_V,
|
||||
"VO Config (%dx%d->%dx%d,flags=%d,0x%X)\n", sh->disp_w,
|
||||
sh->disp_h, d_w, d_h, vocfg_flags, p.imgfmt);
|
||||
mp_msg(MSGT_CPLAYER, MSGL_V, "VO Config (%dx%d->%dx%d,flags=%d,0x%X)\n",
|
||||
p.w, p.h, p.d_w, p.d_h, vocfg_flags, p.imgfmt);
|
||||
|
||||
if (vf_reconfig_wrapper(vf, &p, vocfg_flags) < 0) {
|
||||
mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "FATAL: Cannot initialize video driver.\n");
|
||||
|
@ -587,6 +587,21 @@ void vf_rescale_dsize(int *d_width, int *d_height, int old_w, int old_h,
|
||||
*d_height = *d_height * new_h / old_h;
|
||||
}
|
||||
|
||||
// Set *d_width/*d_height to display aspect ratio with the givem source size
|
||||
void vf_set_dar(int *d_w, int *d_h, int w, int h, double dar)
|
||||
{
|
||||
*d_w = w;
|
||||
*d_h = h;
|
||||
if (dar > 0.01) {
|
||||
*d_w = h * dar;
|
||||
// we don't like horizontal downscale
|
||||
if (*d_w < w) {
|
||||
*d_w = w;
|
||||
*d_h = w / dar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vf_detc_init_pts_buf(struct vf_detc_pts_buf *p)
|
||||
{
|
||||
p->inpts_prev = MP_NOPTS_VALUE;
|
||||
|
@ -150,6 +150,7 @@ void vf_print_filter_chain(int msglevel, struct vf_instance *vf);
|
||||
|
||||
void vf_rescale_dsize(int *d_width, int *d_height, int old_w, int old_h,
|
||||
int new_w, int new_h);
|
||||
void vf_set_dar(int *d_width, int *d_height, int w, int h, double dar);
|
||||
|
||||
static inline int norm_qscale(int qscale, int type)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user