diff --git a/vp10/common/od_dering.c b/vp10/common/od_dering.c index 8b410e1d03a26b10c77b22156aa5d3516eb04a0f..cc16d7e60762502db2977b964adafef178258ca2 100644 --- a/vp10/common/od_dering.c +++ b/vp10/common/od_dering.c @@ -236,7 +236,7 @@ static void od_compute_thresh(int thresh[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], v1 = OD_MINI(32767, var[by][bx] >> 6); v2 = OD_MINI(32767, sb_var/(OD_BSIZE_MAX*OD_BSIZE_MAX)); thresh[by][bx] = threshold*OD_THRESH_TABLE_Q8[OD_CLAMPI(0, - OD_ILOG(v1*v2) - 9, 17)] >> 8; + OD_ILOG(v1*v2) - 10, 17)] >> 8; } } } diff --git a/vp10/common/odintrin.h b/vp10/common/odintrin.h index 80e6e72ed482266187f27439ac24c999d0c2fb17..38ffa6b289be676c9b8b80be3394aa324d128ee6 100644 --- a/vp10/common/odintrin.h +++ b/vp10/common/odintrin.h @@ -24,11 +24,13 @@ typedef int16_t dering_in; #define OD_MINI VPXMIN #define OD_CLAMPI(min, val, max) clamp((val), (min), (max)) -# define OD_ILOG_NZ(x) get_msb(x) +# define OD_CLZ0 (1) +# define OD_CLZ(x) (-get_msb(x)) +# define OD_ILOG_NZ(x) (OD_CLZ0 - OD_CLZ(x)) /*Note that __builtin_clz is not defined when x == 0, according to the gcc - * documentation (and that of the x86 BSR instruction that implements it), so - * we have to special-case it. - * We define a special version of the macro to use when x can be zero.*/ -# define OD_ILOG(x) ((x) ? OD_ILOG_NZ(x) : 0) + documentation (and that of the x86 BSR instruction that implements it), so + we have to special-case it. + We define a special version of the macro to use when x can be zero.*/ +# define OD_ILOG(x) (OD_ILOG_NZ(x) & -!!(x)) #endif diff --git a/vp10/vp10_common.mk b/vp10/vp10_common.mk index b01ffd47b6be976f0e1287b71e53d34b6dca70c5..92338f5022d8ae1fdcb9b1eea374d6dff11b61d9 100644 --- a/vp10/vp10_common.mk +++ b/vp10/vp10_common.mk @@ -66,6 +66,7 @@ VP10_COMMON_SRCS-yes += common/od_dering.c VP10_COMMON_SRCS-yes += common/od_dering.h VP10_COMMON_SRCS-yes += common/dering.c VP10_COMMON_SRCS-yes += common/dering.h +VP10_COMMON_SRCS-yes += common/odintrin.h ifneq ($(CONFIG_VPX_HIGHBITDEPTH),yes) VP10_COMMON_SRCS-$(HAVE_DSPR2) += common/mips/dspr2/itrans4_dspr2.c