diff --git a/libcelt/arch.h b/libcelt/arch.h index e4015f1f7029acacf28e84e661253682634c90a8..68da0debdaf3d24c8ec4dbe2ec57f52171859099 100644 --- a/libcelt/arch.h +++ b/libcelt/arch.h @@ -199,6 +199,7 @@ typedef float celt_mask; #define SATURATE(x,a) (x) #define ROUND16(a,shift) (a) +#define HALF16(x) (.5f*(x)) #define HALF32(x) (.5f*(x)) #define ADD16(a,b) ((a)+(b)) diff --git a/libcelt/fixed_debug.h b/libcelt/fixed_debug.h index ddf5695187d400bf53d7cce89f36e76015ae86cb..7992fa217f362b36a4cf2b5a5b1d9178f8ba3f43 100644 --- a/libcelt/fixed_debug.h +++ b/libcelt/fixed_debug.h @@ -180,6 +180,7 @@ static inline int SHL32(long long a, int shift) #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) #define ROUND16(x,a) (celt_mips--,EXTRACT16(PSHR32((x),(a)))) +#define HALF16(x) (SHR16(x,1)) #define HALF32(x) (SHR32(x,1)) //#define SHR(a,shift) ((a) >> (shift)) diff --git a/libcelt/fixed_generic.h b/libcelt/fixed_generic.h index 069070fa4ecf471994f2dd91565fdeae75d2ae4f..c39ada41f456ffec6e2d847fdbce17e44bfab4d2 100644 --- a/libcelt/fixed_generic.h +++ b/libcelt/fixed_generic.h @@ -93,6 +93,7 @@ /** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */ #define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a)))) /** Divide by two */ +#define HALF16(x) (SHR16(x,1)) #define HALF32(x) (SHR32(x,1)) /** Add two 16-bit values */ diff --git a/libcelt/vq.c b/libcelt/vq.c index 5c743511c913d440399ad77fda73d744f224c896..74aba5391983c038d3bfcbd4ac65ed24b09a7de2 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -87,8 +87,7 @@ static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int factor = SPREAD_FACTOR[spread-1]; gain = celt_div((celt_word32)MULT16_16(Q15_ONE,len),(celt_word32)(len+factor*K)); - /* FIXME: Make that HALF16 instead of HALF32 */ - theta = HALF32(MULT16_16_Q15(gain,gain)); + theta = HALF16(MULT16_16_Q15(gain,gain)); c = celt_cos_norm(EXTEND32(theta)); s = celt_cos_norm(EXTEND32(SUB16(Q15ONE,theta))); /* sin(theta) */