[MPlayer-dev-eng] [PATCH] deobfuscate vf_scale

Rich Felker dalias at aerifal.cx
Sun Dec 18 01:13:36 CET 2005


On Sat, Dec 17, 2005 at 09:36:33PM +0200, Oded Shimon wrote:
> Just found this old patch I made, this code is completely unnecessarily 
> obfuscated, small patch here makes it much more readable and keeps same 
> behavior.
> The actual behavior preserved here, to all the 0, -1, -2, and -3 options in 
> vf_scale, you can add -8 (so, -8, -9, -10 and -11) to get rounding.
> 
> Is anyone against this?.. Compiled and tested, works fine.
> 
> - ods15

> Index: libmpcodecs/vf_scale.c
> ===================================================================
> RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_scale.c,v
> retrieving revision 1.58
> diff -u -r1.58 vf_scale.c
> --- libmpcodecs/vf_scale.c	6 Mar 2005 21:15:24 -0000	1.58
> +++ libmpcodecs/vf_scale.c	7 Mar 2005 11:48:55 -0000
> @@ -144,12 +144,12 @@
>  	}
>      }
>  
> -    if (vf->priv->w < 0 && (-vf->priv->w & 8)) {
> -      vf->priv->w = -(-vf->priv->w & ~8);
> +    if (vf->priv->w <= -8) {
> +      vf->priv->w += 8;
>        round_w = 1;
>      }
> -    if (vf->priv->h < 0 && (-vf->priv->h & 8)) {
> -      vf->priv->h = -(-vf->priv->h & ~8);
> +    if (vf->priv->h <= -8) {
> +      vf->priv->h += 8;
>        round_h = 1;

This is broken. The idea was to treat 8 as a bitflag so that more
flags could be added in the future. Your senseless change breaks that!

Rich




More information about the MPlayer-dev-eng mailing list