summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vf_dsize.c
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2011-12-12 21:16:05 +0100
committerUoti Urpala <uau@mplayer2.org>2011-12-19 02:02:32 +0200
commit4478acd618e0500a6a81ab893a23280824420a57 (patch)
treeb83faa85882fa48aae3edce3a9021c021c3c13d4 /libmpcodecs/vf_dsize.c
parentefe28bf2abaddba6d848581548b165bdde256609 (diff)
downloadmpv-4478acd618e0500a6a81ab893a23280824420a57.tar.bz2
mpv-4478acd618e0500a6a81ab893a23280824420a57.tar.xz
vf_dsize, vf_scale: fix behavior on multiple config() calls
When config() is called multiple times (e.g. aspect ratio changes while the same file is playing), the user settings are not honoured, because config() overwrites them. Don't do that.
Diffstat (limited to 'libmpcodecs/vf_dsize.c')
-rw-r--r--libmpcodecs/vf_dsize.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/libmpcodecs/vf_dsize.c b/libmpcodecs/vf_dsize.c
index 7772b3732d..d46d22ebb2 100644
--- a/libmpcodecs/vf_dsize.c
+++ b/libmpcodecs/vf_dsize.c
@@ -39,29 +39,31 @@ static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
+ int w = vf->priv->w;
+ int h = vf->priv->h;
if (vf->priv->aspect < 0.001) { // did the user input aspect or w,h params
- if (vf->priv->w == 0) vf->priv->w = d_width;
- if (vf->priv->h == 0) vf->priv->h = d_height;
- if (vf->priv->w == -1) vf->priv->w = width;
- if (vf->priv->h == -1) vf->priv->h = height;
- if (vf->priv->w == -2) vf->priv->w = vf->priv->h * (double)d_width / d_height;
- if (vf->priv->w == -3) vf->priv->w = vf->priv->h * (double)width / height;
- if (vf->priv->h == -2) vf->priv->h = vf->priv->w * (double)d_height / d_width;
- if (vf->priv->h == -3) vf->priv->h = vf->priv->w * (double)height / width;
+ if (w == 0) w = d_width;
+ if (h == 0) h = d_height;
+ if (w == -1) w = width;
+ if (h == -1) h = height;
+ if (w == -2) w = h * (double)d_width / d_height;
+ if (w == -3) w = h * (double)width / height;
+ if (h == -2) h = w * (double)d_height / d_width;
+ if (h == -3) h = w * (double)height / width;
if (vf->priv->method > -1) {
double aspect = (vf->priv->method & 2) ? ((double)height / width) : ((double)d_height / d_width);
- if ((vf->priv->h > vf->priv->w * aspect) ^ (vf->priv->method & 1)) {
- vf->priv->h = vf->priv->w * aspect;
+ if ((h > w * aspect) ^ (vf->priv->method & 1)) {
+ h = w * aspect;
} else {
- vf->priv->w = vf->priv->h / aspect;
+ w = h / aspect;
}
}
if (vf->priv->round > 1) { // round up
- vf->priv->w += (vf->priv->round - 1 - (vf->priv->w - 1) % vf->priv->round);
- vf->priv->h += (vf->priv->round - 1 - (vf->priv->h - 1) % vf->priv->round);
+ w += (vf->priv->round - 1 - (w - 1) % vf->priv->round);
+ h += (vf->priv->round - 1 - (h - 1) % vf->priv->round);
}
- d_width = vf->priv->w;
- d_height = vf->priv->h;
+ d_width = w;
+ d_height = h;
} else {
if (vf->priv->aspect * height > width) {
d_width = height * vf->priv->aspect + .5;