[tremor] [PATCH] reworked bitrev12() for better performance on ARM

Nicolas Pitre nico at cam.org
Wed Sep 11 19:38:57 PDT 2002


The current bitrev12() implementation, although quite elegant, produces 
pretty bad ARM assembly due to the many constants larger than 8 bit wide.  
Attached is a patch for a much faster implementation on ARM and probably 
other processors as well.

<p>Nicolas

-------------- next part --------------
Index: mdct.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/mdct.c,v
retrieving revision 1.3
diff -u -r1.3 mdct.c
--- mdct.c	10 Sep 2002 08:20:40 -0000	1.3
+++ mdct.c	12 Sep 2002 02:20:58 -0000
@@ -329,10 +329,10 @@
 
 }
 
+static unsigned char bitrev[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
+
 STIN int bitrev12(int x){
-  int temp = (x<<8) | (x>>8) | (x & 0x0f0);
-  temp = ((temp & 0xccc) >> 2) | ((temp & 0x333) << 2);
-  return ((temp & 0xaaa) >> 1) | ((temp & 0x555) << 1);
+  return bitrev[x>>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8);
 }
 
 STIN void mdct_bitreverse(mdct_lookup *init, 


More information about the Tremor mailing list