[sldev] [patch] OpenJPEG fix_mul() optimization

Dzonatas dzonatas at dzonux.net
Wed Apr 4 15:01:17 PDT 2007


Hello,

Attached is a simple change that gives up to 10% extra performance in 
DWT time.

It removes an extra bit shift in fix_mul().

I tested it also to make sure gives the same results.

Enjoy!
-------------- next part --------------
Index: libopenjpeg/fix.h
===================================================================
--- libopenjpeg/fix.h	(revision 369)
+++ libopenjpeg/fix.h	(working copy)
@@ -54,8 +54,9 @@
 @return Returns a * b
 */
 static INLINE int fix_mul(int a, int b) {
-    int64 temp = (int64) a * (int64) b >> 12;
-    return (int) ((temp >> 1) + (temp & 1)) ;
+    int64 temp = (int64) a * (int64) b ;
+    temp += temp & 4096;
+    return (int) (temp >> 13) ;
 }
 
 /*@}*/


More information about the SLDev mailing list