[MPlayer-dev-eng] [PATCH] vf_scale to x16 values

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Mar 6 11:47:58 CET 2005


Hi,
On Sun, Mar 06, 2005 at 10:19:26AM +0100, Nico Sabbi wrote:
> This patch extends -vf scale so that if w or h is -4
> the resulting scaled value is rounded to closest multiple of 16
> (optimal for encoding).

I would prefer it if you would do it like a flag, e.g. with -10 you get
the result as with -2, just rounded etc. I'm also not sure if "normal" rounding,
rounding up or rounding down is best...
I attached my suggestion, I don't find it perfect, but at least a bit better.
If you think it's okay just apply it, I don't know if I will get around
to it.

Greetings,
Reimar Döffinger
-------------- next part --------------
--- libmpcodecs/vf_scale.c	2005-02-19 15:46:23.000000000 +0100
+++ libmpcodecs/vf_scale.c	2005-03-06 11:40:10.000000000 +0100
@@ -112,6 +112,7 @@
     unsigned int best=find_best_out(vf);
     int vo_flags;
     int int_sws_flags=0;
+    int round_w = 0, round_h = 0;
     SwsFilter *srcFilter, *dstFilter;
     
     if(!best){
@@ -143,6 +144,15 @@
 	}
     }
 
+    if (vf->priv->w < 0 && (-vf->priv->w & 8)) {
+      vf->priv->w = -(-vf->priv->w & ~8);
+      round_w = 1;
+    }
+    if (vf->priv->h < 0 && (-vf->priv->h & 8)) {
+      vf->priv->h = -(-vf->priv->h & ~8);
+      round_h = 1;
+    }
+
     if (vf->priv->w < -3 || vf->priv->h < -3 ||
          (vf->priv->w < -1 && vf->priv->h < -1)) {
       // TODO: establish a direct connection to the user's brain
@@ -172,6 +182,11 @@
     if (vf->priv->h == -2)
       vf->priv->h = vf->priv->w * d_height / d_width;
 
+    if (round_w)
+      vf->priv->w = ((vf->priv->w + 8) / 16) * 16;
+    if (round_h)
+      vf->priv->h = ((vf->priv->h + 8) / 16) * 16;
+
     // calculate the missing parameters:
     switch(best) {
     case IMGFMT_YV12:		/* YV12 needs w & h rounded to 2 */


More information about the MPlayer-dev-eng mailing list