[XviD-devel] More MMX improvements

carlo.bramix carlo.bramix at libero.it
Sun Jul 17 16:06:45 CEST 2005


Hello,
I did more improvements to:

\xvid_20050712\xvidcore\src\bitstream\x86_asm\cbp_mmx.c

This new version is 6.2% to 7.4% faster if compared to the same source into the CVS.
I attached this new patch here.

Sincerely,

Carlo Bramini




____________________________________________________________
6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di Libero!
Scaricalo su INTERNET GRATIS 6X http://www.libero.it
-------------- next part --------------
Index: src/bitstream/x86_asm/cbp_mmx.asm
===================================================================
RCS file: /xvid/xvidcore/src/bitstream/x86_asm/cbp_mmx.asm,v
retrieving revision 1.12
diff -u -r1.12 cbp_mmx.asm
--- src/bitstream/x86_asm/cbp_mmx.asm	29 Aug 2004 10:02:38 -0000	1.12
+++ src/bitstream/x86_asm/cbp_mmx.asm	17 Jul 2005 13:21:38 -0000
@@ -60,8 +60,10 @@
 
 ALIGN 16
 
+shift_mask:
+    dd 0x00000002, 0x00000002
 ignore_dc:
-	dw 0, -1, -1, -1, -1, -1, -1, -1
+    dw 0, -1, -1, -1
 
 ;=============================================================================
 ; Code
@@ -77,59 +79,78 @@
 
 ALIGN 16
 calc_cbp_mmx:
-  push ebx
-  push esi
-
-  mov esi, [esp + 8 + 4]	; coeff
-  xor eax, eax			; cbp = 0
-  mov edx, (1 << 5)
+  mov eax, [esp + 4]            ; coeff
+  mov edx, 3
 
+  movq mm4, [shift_mask]
+  psubd mm2, mm2                ; used only for comparing
   movq mm7, [ignore_dc]
-
+  psubd mm3, mm3                ; cbp = 0
+; we can get better addressing by increasing 'eax' here because
+; two blocks can be read with near addressing [-128,+127]
+  add eax, 128
 .loop
-  movq mm0, [esi]
-  movq mm1, [esi+8]
+  movq mm0, [eax-128]
+  movq mm1, [eax-128+8]
+  movq mm5, [eax]
+  movq mm6, [eax+8]
   pand mm0, mm7
+  pand mm5, mm7
 
-  por mm0, [esi+16]
-  por mm1, [esi+24]
-
-  por mm0, [esi+32]
-  por mm1, [esi+40]
-
-  por mm0, [esi+48]
-  por mm1, [esi+56]
-
-  por mm0, [esi+64]
-  por mm1, [esi+72]
-
-  por mm0, [esi+80]
-  por mm1, [esi+88]
-
-  por mm0, [esi+96]
-  por mm1, [esi+104]
-
-  por mm0, [esi+112]
-  por mm1, [esi+120]
+  por mm0, [eax-128+16]
+  por mm1, [eax-128+24]
+  por mm5, [eax+16]
+  por mm6, [eax+24]
+
+  por mm0, [eax-128+32]
+  por mm1, [eax-128+40]
+  por mm5, [eax+32]
+  por mm6, [eax+40]
+
+  por mm0, [eax-128+48]
+  por mm1, [eax-128+56]
+  por mm5, [eax+48]
+  por mm6, [eax+56]
+
+  por mm0, [eax-128+64]
+  por mm1, [eax-128+72]
+  por mm5, [eax+64]
+  por mm6, [eax+72]
+
+  por mm0, [eax-128+80]
+  por mm1, [eax-128+88]
+  por mm5, [eax+80]
+  por mm6, [eax+88]
+
+  por mm0, [eax-128+96]
+  por mm1, [eax-128+104]
+  por mm5, [eax+96]
+  por mm6, [eax+104]
+
+  por mm0, [eax-128+112]
+  por mm1, [eax-128+120]
+  por mm5, [eax+112]
+  por mm6, [eax+120]
 
   por mm0, mm1
-  movq mm1, mm0
-  psrlq mm1, 32
-  lea esi, [esi + 128]
+  por mm5, mm6
+  pcmpgtd mm0, mm2
+  pcmpgtd mm5, mm2
+  pand mm0, mm4
+  psrld mm5, 31
+  add eax,256
+  pslld mm3, 2
+  por mm3, mm0
+  dec edx
+  por mm3, mm5
 
-  por mm0, mm1
-  movd ebx, mm0
+  jnz NEAR .loop
 
-  test ebx, ebx
-  jz .next
-  or eax, edx     ; cbp |= 1 << (5-i)
-
-.next
-  shr edx,1
-  jnc .loop
+  movq mm0, mm3
+  psrlq mm0, 32
 
-  pop esi
-  pop ebx
+  por mm0, mm3
+  movd eax, mm0
 
   ret
 .endfunc


More information about the XviD-devel mailing list