From f5bf6c0fb33fb6ff11f3250de708eb6e658772c9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 26 Sep 2013 16:05:46 +0200 Subject: 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. --- video/filter/vf.c | 15 +++++++++++++++ video/filter/vf.h | 1 + 2 files changed, 16 insertions(+) (limited to 'video/filter') diff --git a/video/filter/vf.c b/video/filter/vf.c index 216f3c42f4..1e27c043b5 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -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; diff --git a/video/filter/vf.h b/video/filter/vf.h index ea1246da17..f61bb8be80 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -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) { -- cgit v1.2.3