[Asterisk-cvs] asterisk/codecs codec_g726.c, 1.10, 1.11 log2comp.h, 1.2, 1.3

kpfleming at lists.digium.com kpfleming at lists.digium.com
Sat May 14 23:12:47 CDT 2005


Update of /usr/cvsroot/asterisk/codecs
In directory mongoose.digium.com:/tmp/cvs-serv1012/codecs

Modified Files:
	codec_g726.c log2comp.h 
Log Message:
don't define a local function with the same name as a library function (bug #4239)


Index: codec_g726.c
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/codec_g726.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- codec_g726.c	12 May 2005 17:40:44 -0000	1.10
+++ codec_g726.c	15 May 2005 03:18:16 -0000	1.11
@@ -214,7 +214,7 @@
 	int		retval;
 
 	anmag = (an > 0) ? an : ((-an) & 0x1FFF);
-	anexp = log2(anmag) - 5;
+	anexp = ilog2(anmag) - 5;
 	anmant = (anmag == 0) ? 32 :
 	    (anexp >= 0) ? anmag >> anexp : anmag << -anexp;
 	wanexp = anexp + ((srn >> 6) & 0xF) - 13;
@@ -297,7 +297,7 @@
 	 * Compute base 2 log of 'd', and store in 'dl'.
 	 */
 	dqm = abs(d);
-	exp = log2(dqm);
+	exp = ilog2(dqm);
 	if (exp < 0)
 		exp = 0;
 	mant = ((dqm << 7) >> exp) & 0x7F;	/* Fractional portion. */
@@ -515,7 +515,7 @@
 	if (mag == 0) {
 		state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0x20 - 0x400;
 	} else {
-		exp = log2(mag) + 1;
+		exp = ilog2(mag) + 1;
 		state_ptr->dq[0] = (dq >= 0) ?
 		    (exp << 6) + ((mag << 6) >> exp) :
 		    (exp << 6) + ((mag << 6) >> exp) - 0x400;
@@ -530,11 +530,11 @@
 	if (sr == 0) {
 		state_ptr->sr[0] = 0x20;
 	} else if (sr > 0) {
-		exp = log2(sr) + 1;
+		exp = ilog2(sr) + 1;
 		state_ptr->sr[0] = (exp << 6) + ((sr << 6) >> exp);
 	} else if (sr > -0x8000) {
 		mag = -sr;
-		exp = log2(mag) + 1;
+		exp = ilog2(mag) + 1;
 		state_ptr->sr[0] =  (exp << 6) + ((mag << 6) >> exp) - 0x400;
 	} else
 		state_ptr->sr[0] = 0x20 - 0x400;

Index: log2comp.h
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/log2comp.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- log2comp.h	21 Jan 2005 07:06:24 -0000	1.2
+++ log2comp.h	15 May 2005 03:18:16 -0000	1.3
@@ -24,7 +24,7 @@
 #if defined(WANT_ASM) && defined(_MSC_VER) && defined(_M_IX86)
 /* MS C Inline Asm */
 #	pragma warning( disable : 4035 )
-static inline int log2(int val) { __asm
+static inline int ilog2(int val) { __asm
 {
 	xor		eax, eax
 	dec		eax
@@ -33,7 +33,7 @@
 #	pragma warning( default : 4035 )
 #elif defined(WANT_ASM) && defined(__GNUC__) && (defined(__i386__) || defined(i386))
 /* GNU Inline Asm */
-static inline int log2(int val)
+static inline int ilog2(int val)
 {
 	int a;
 	__asm__
@@ -48,12 +48,22 @@
 	);
 	return a;
 }
+#elif defined(WANT_ASM) && defined(__GNUC__) && defined(__powerpc__)
+static inline int ilog2(int val)
+{
+	int a;
+	__asm__ ("cntlzw %0,%1" 
+		 : "=r" (a) 
+		 : "r" (val)
+		 );
+	return 31-a;
+}
 #else
 /* no ASM for this compiler and/or platform */
 /* rather slow base 2 log computation
  * Using looped shift.
  */
-static inline int log2(int val)
+static inline int ilog2(int val)
 {
 	int i;
 	for (i = -1; val; ++i, val >>= 1)




More information about the svn-commits mailing list