[x265] [PATCH] optimize and remove Pow() in processRowEncoder() to avoid VS2008 build error 'ambiguous...'

chen chenm003 at 163.com
Thu Jul 3 22:02:14 CEST 2014


At 2014-07-04 03:56:12,"Derek Buitenhuis" <derek.buitenhuis at gmail.com> wrote:
>On 7/3/2014 8:29 PM, chen wrote:
>> At 2014-07-04 03:00:31,"Derek Buitenhuis" <derek.buitenhuis at gmail.com> wrote:
>>> On 7/3/2014 7:40 PM, Min Chen wrote:
>>>>  -            double scale = pow((double)2, g_maxCUSize / 16);
>>>>  +            static const uint32_t scaleTable[] = {2, 4, 16};
>>>>  +            uint32_t scaleIndex = (g_convertToBit[g_maxCUSize] + 2 - 4);
>>>>  +            double scale = (double)scaleTable[scaleIndex];
>>>>  +            X265_CHECK(pow((double)2, (int)(g_maxCUSize >> 4)) == scale, "Failed on scale!\n");
>>>
>>> Any reason you cant just use 1<<N ?
>> In here, you need (1 << (1 << N)), it is more operators
>
>Uh? Do yo perhaps mean:
>
>    double scale = (double)(1 >> (g_maxCUSize / 16)); // Yes, every compiler can figure out that /16 is >>4. Seriously.
>
>So, two operations one var access.
>
>Yous has one operation, two table accesses, one var access.
>My money is that it is *possibly* slower due to cache misses, but that is
>just wild speculation by me.
>
>Just my 1 cents on micro-optimzation via obfuscation.
>
>- Derek

You are right!
use (1 << (g_maxCUSize/16)) is faster, I will make a new patch soon, thanks


More information about the x265-devel mailing list