From f2dcdca0c2dc5f904323659b65b29a2b6f00fd88 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 22 Jan 2013 13:28:31 +0100 Subject: video: move handling of -x/-y/-xy options to VO Now the calculations of the final display size are done after the filter chain. This makes the difference between display aspect ratio and window size a bit more clear, especially in the -xy case. With an empty filter chain, the behavior of the options should be the same, except that they don't affect vo_image and vo_lavc anymore. --- video/filter/vf.c | 14 +++++--------- video/filter/vf.h | 4 ++-- video/filter/vf_crop.c | 2 +- video/filter/vf_expand.c | 2 +- video/filter/vf_mirror.c | 2 +- video/filter/vf_rotate.c | 2 +- video/filter/vf_scale.c | 4 ---- video/filter/vf_stereo3d.c | 8 ++------ video/filter/vf_sub.c | 2 +- 9 files changed, 14 insertions(+), 26 deletions(-) (limited to 'video/filter') diff --git a/video/filter/vf.c b/video/filter/vf.c index a4b78ab5ab..5b466031c7 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -514,16 +514,12 @@ void vf_uninit_filter_chain(vf_instance_t *vf) } } -// When cropping an image that had old_w/old_h/*d_width/*d_height to the new -// size new_w/new_h, adjust *d_width/*d_height such that the new image has -// the same pixel aspect ratio. -void vf_rescale_dsize(struct vf_instance *vf, int *d_width, int *d_height, - int old_w, int old_h, int new_w, int new_h) +// When changing the size of an image that had old_w/old_h with +// DAR *d_width/*d_height to the new size new_w/new_h, adjust +// *d_width/*d_height such that the new image has the same pixel aspect ratio. +void vf_rescale_dsize(int *d_width, int *d_height, int old_w, int old_h, + int new_w, int new_h) { - // No idea what this is about - if (vf->opts->screen_size_x || vf->opts->screen_size_y) - return; - *d_width = *d_width * new_w / old_w; *d_height = *d_height * new_h / old_h; } diff --git a/video/filter/vf.h b/video/filter/vf.h index 4398abebc7..44b820c04a 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -144,8 +144,8 @@ int vf_config_wrapper(struct vf_instance *vf, unsigned int flags, unsigned int outfmt); void vf_print_filter_chain(int msglevel, struct vf_instance *vf); -void vf_rescale_dsize(struct vf_instance *vf, int *d_width, int *d_height, - int old_w, int old_h, int new_w, int new_h); +void vf_rescale_dsize(int *d_width, int *d_height, int old_w, int old_h, + int new_w, int new_h); static inline int norm_qscale(int qscale, int type) { diff --git a/video/filter/vf_crop.c b/video/filter/vf_crop.c index 6ef0d8d0c1..49b4e7e55b 100644 --- a/video/filter/vf_crop.c +++ b/video/filter/vf_crop.c @@ -63,7 +63,7 @@ static int config(struct vf_instance *vf, mp_tmsg(MSGT_VFILTER, MSGL_WARN, "[CROP] Bad position/width/height - cropped area outside of the original!\n"); return 0; } - vf_rescale_dsize(vf, &d_width, &d_height, width, height, + vf_rescale_dsize(&d_width, &d_height, width, height, vf->priv->crop_w, vf->priv->crop_h); return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt); } diff --git a/video/filter/vf_expand.c b/video/filter/vf_expand.c index ff84d7670c..efe3f9dbb3 100644 --- a/video/filter/vf_expand.c +++ b/video/filter/vf_expand.c @@ -101,7 +101,7 @@ static int config(struct vf_instance *vf, vf->priv->exp_x = MP_ALIGN_DOWN(vf->priv->exp_x, fmt.align_x); vf->priv->exp_y = MP_ALIGN_DOWN(vf->priv->exp_y, fmt.align_y); - vf_rescale_dsize(vf, &d_width, &d_height, width, height, + vf_rescale_dsize(&d_width, &d_height, width, height, vf->priv->exp_w, vf->priv->exp_h); return vf_next_config(vf,vf->priv->exp_w,vf->priv->exp_h,d_width,d_height,flags,outfmt); diff --git a/video/filter/vf_mirror.c b/video/filter/vf_mirror.c index 301583594f..65e467a9cb 100644 --- a/video/filter/vf_mirror.c +++ b/video/filter/vf_mirror.c @@ -34,7 +34,7 @@ static int config(struct vf_instance *vf, int width, int height, { struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt); int a_w = MP_ALIGN_DOWN(width, desc.align_x); - vf_rescale_dsize(vf, &d_width, &d_height, width, height, a_w, height); + vf_rescale_dsize(&d_width, &d_height, width, height, a_w, height); return vf_next_config(vf, a_w, height, d_width, d_height, flags, fmt); } diff --git a/video/filter/vf_rotate.c b/video/filter/vf_rotate.c index 1d80725ba3..9cdbafd94d 100644 --- a/video/filter/vf_rotate.c +++ b/video/filter/vf_rotate.c @@ -77,7 +77,7 @@ static int config(struct vf_instance *vf, int width, int height, struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(outfmt); int a_w = MP_ALIGN_DOWN(width, desc.align_x); int a_h = MP_ALIGN_DOWN(height, desc.align_y); - vf_rescale_dsize(vf, &d_width, &d_height, width, height, a_w, a_h); + vf_rescale_dsize(&d_width, &d_height, width, height, a_w, a_h); return vf_next_config(vf, a_h, a_w, d_height, d_width, flags, outfmt); } diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c index ca06436dd5..a81ed8c0cd 100644 --- a/video/filter/vf_scale.c +++ b/video/filter/vf_scale.c @@ -303,9 +303,6 @@ static int config(struct vf_instance *vf, return 0; } vf->priv->fmt=best; - - if (!opts->screen_size_x && !opts->screen_size_y - && !(opts->screen_size_xy >= 0.001)) { // Compute new d_width and d_height, preserving aspect // while ensuring that both are >= output size in pixels. if (vf->priv->h * d_width > vf->priv->w * d_height) { @@ -317,7 +314,6 @@ static int config(struct vf_instance *vf, } //d_width=d_width*vf->priv->w/width; //d_height=d_height*vf->priv->h/height; - } return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best); } diff --git a/video/filter/vf_stereo3d.c b/video/filter/vf_stereo3d.c index 3e055b22ea..37c66e77d9 100644 --- a/video/filter/vf_stereo3d.c +++ b/video/filter/vf_stereo3d.c @@ -148,8 +148,6 @@ static inline uint8_t ana_convert(int coeff[6], uint8_t left[3], uint8_t right[3 static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { - struct MPOpts *opts = vf->opts; - if ((width & 1) || (height & 1)) { mp_msg(MSGT_VFILTER, MSGL_WARN, "[stereo3d] invalid height or width\n"); return 0; @@ -271,10 +269,8 @@ static int config(struct vf_instance *vf, int width, int height, int d_width, return 0; break; } - if (!opts->screen_size_x && !opts->screen_size_y) { - d_width = d_width * vf->priv->out.width / width; - d_height = d_height * vf->priv->out.height / height; - } + vf_rescale_dsize(&d_width, &d_height, width, height, + vf->priv->out.width, vf->priv->out.height); return vf_next_config(vf, vf->priv->out.width, vf->priv->out.height, d_width, d_height, flags, outfmt); } diff --git a/video/filter/vf_sub.c b/video/filter/vf_sub.c index 49214685ef..a1f25efd6d 100644 --- a/video/filter/vf_sub.c +++ b/video/filter/vf_sub.c @@ -68,7 +68,7 @@ static int config(struct vf_instance *vf, double dar = (double)d_width / d_height; double sar = (double)width / height; - vf_rescale_dsize(vf, &d_width, &d_height, width, height, + vf_rescale_dsize(&d_width, &d_height, width, height, vf->priv->outw, vf->priv->outh); vf->priv->dim = (struct mp_osd_res) { -- cgit v1.2.3