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

The Wanderer inverseparadox at comcast.net
Sun Dec 18 01:20:32 CET 2005


On 12/17/2005 07:13 PM, Rich Felker wrote:

> 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.
> 
>> 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!

I wouldn't call it senseless; it improves readability, which is usually
a positive thing. It may still be a bad idea, by the reasoning you give,
but that doesn't make it senseless.

-- 
       The Wanderer

Warning: Simply because I argue an issue does not mean I agree with any
side of it.

Secrecy is the beginning of tyranny.




More information about the MPlayer-dev-eng mailing list