]> git.sesse.net Git - x264/commitdiff
Fix x264_clz on inputs > 1<<31
authorLoren Merritt <pengvado@akuvian.org>
Thu, 14 Jan 2010 03:07:30 +0000 (03:07 +0000)
committerLoren Merritt <pengvado@akuvian.org>
Thu, 14 Jan 2010 03:08:15 +0000 (03:08 +0000)
(though x264 never generates such inputs)

common/osdep.h

index 14f06a85bc56ad748795e2d986fec7de35c0f65b..0c8623ec947fa4b882761384fd28f6261b19f52c 100644 (file)
@@ -203,7 +203,7 @@ static ALWAYS_INLINE uint16_t endian_fix16( uint16_t x )
 static int ALWAYS_INLINE x264_clz( uint32_t x )
 {
     static uint8_t lut[16] = {4,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0};
-    int y, z = ((x - 0x10000) >> 27) & 16;
+    int y, z = (((x >> 16) - 1) >> 27) & 16;
     x >>= z^16;
     z += y = ((x - 0x100) >> 28) & 8;
     x >>= y^8;