[svn] / branches / dev-api-4 / xvidcore / src / quant / x86_asm / quantize_h263_3dne.asm Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/quant/x86_asm/quantize_h263_3dne.asm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1174, Tue Oct 7 13:02:35 2003 UTC revision 1192, Tue Oct 28 22:23:03 2003 UTC
# Line 1  Line 1 
1  ;/**************************************************************************  ;/**************************************************************************
2  ; *  ; *
3  ; *  XVID MPEG-4 VIDEO CODEC  ; *  XVID MPEG-4 VIDEO CODEC
4  ; *  - mmx quantization/dequantization -  ; *  - 3dne Quantization/Dequantization -
5  ; *  ; *
6  ; *  Copyright(C) 2001-2003 XviD Team <xvid-devel@xvid.org>  ; *  Copyright(C) 2002-2003 Jaan Kalda
7  ; *  ; *
8  ; *  This program is free software ; you can redistribute it and/or modify  ; *  This program is free software ; you can redistribute it and/or modify
9  ; *  it under the terms of the GNU General Public License as published by  ; *  it under the terms of the GNU General Public License as published by
# Line 19  Line 19 
19  ; *  along with this program ; if not, write to the Free Software  ; *  along with this program ; if not, write to the Free Software
20  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  ; *  ; *
22  ; * $Id: quantize_h263_3dne.asm,v 1.1.2.1 2003-10-07 13:02:35 edgomez Exp $  ; * $Id: quantize_h263_3dne.asm,v 1.1.2.3 2003-10-28 22:23:03 edgomez Exp $
23  ; *  ; *
24  ; *************************************************************************/  ; *************************************************************************/
25    ;
26  ; these 3dne functions are compatible with iSSE, but are optimized specifically for  ; these 3dne functions are compatible with iSSE, but are optimized specifically for
27  ; K7 pipelines  ; K7 pipelines
 ;  
 ;------------------------------------------------------------------------------  
 ; 09.12.2002  Athlon optimizations contributed by Jaan Kalda  
 ;------------------------------------------------------------------------------  
28    
29  ; enable dequant saturate [-2048,2047], test purposes only.  ; enable dequant saturate [-2048,2047], test purposes only.
30  %define SATURATE  %define SATURATE
31    
32  ; data/text alignment  BITS 32
 %define ALIGN 16  
   
 bits 32  
   
 %ifdef FORMAT_COFF  
 section .data data  
 %else  
 section .data data align=16  
 %endif  
33    
34  %macro cglobal 1  %macro cglobal 1
35          %ifdef PREFIX          %ifdef PREFIX
# Line 51  Line 39 
39                  global %1                  global %1
40          %endif          %endif
41  %endmacro  %endmacro
42    
43    ;=============================================================================
44    ; Local data
45    ;=============================================================================
46    
47    SECTION .rodata
48    
49  align 4  align 4
50  int_div  int_div:
51  dd 0  dd 0
52  %assign i 1  %assign i 1
53  %rep 255  %rep 255
# Line 60  Line 55 
55          %assign i i+1          %assign i i+1
56  %endrep  %endrep
57    
58  align 16  ALIGN 16
59    plus_one:
60  plus_one times 8        dw       1          times 8 dw 1
61    
62  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;  
63  ; subtract by Q/2 table  ; subtract by Q/2 table
64  ;  ;-----------------------------------------------------------------------------
 ;===========================================================================  
   
 %macro MMX_SUB  1  
 times 4 dw %1 / 2  
 %endmacro  
   
65    
66  align 16  ALIGN 16
67  mmx_sub  mmx_sub:
68  %assign i 1  %assign i 1
69  %rep 31  %rep 31
70          times 4 dw i / 2          times 4 dw i / 2
# Line 84  Line 72 
72  %endrep  %endrep
73    
74    
75  ;===========================================================================  ;-----------------------------------------------------------------------------
76  ;  ;
77  ; divide by 2Q table  ; divide by 2Q table
78  ;  ;
# Line 92  Line 80 
80  ; for q=1, _pmulhw_ will overflow so it is treated seperately  ; for q=1, _pmulhw_ will overflow so it is treated seperately
81  ; (3dnow2 provides _pmulhuw_ which wont cause overflow)  ; (3dnow2 provides _pmulhuw_ which wont cause overflow)
82  ;  ;
83  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 align 16  
 mmx_div  
84    
85    ALIGN 16
86    mmx_div:
87  %assign i 1  %assign i 1
88  %rep 31  %rep 31
89          times 4 dw  (1 << 16) / (i * 2) + 1          times 4 dw  (1 << 16) / (i * 2) + 1
90          %assign i i+1          %assign i i+1
91  %endrep  %endrep
92    
93  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;  
94  ; add by (odd(Q) ? Q : Q - 1) table  ; add by (odd(Q) ? Q : Q - 1) table
95  ;  ;-----------------------------------------------------------------------------
 ;===========================================================================  
   
 %macro MMX_ADD  1  
 %if %1 % 2 != 0  
 times 4 dw %1  
 %else  
 times 4 dw %1 - 1  
 %endif  
 %endmacro  
   
 align 16  
 mmx_add  
96    
97    ALIGN 16
98    mmx_add:
99  %assign i 1  %assign i 1
100  %rep 31  %rep 31
101          MMX_ADD i          %if i % 2 != 0
102            times 4 dw i
103            %else
104            times 4 dw i - 1
105            %endif
106          %assign i i+1          %assign i i+1
107  %endrep  %endrep
108    
109  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;  
110  ; multiple by 2Q table  ; multiple by 2Q table
111  ;  ;-----------------------------------------------------------------------------
 ;===========================================================================  
   
 %macro MMX_MUL  1  
 times 4 dw %1 * 2  
 %endmacro  
   
 align 16  
 mmx_mul  
112    
113    ALIGN 16
114    mmx_mul:
115  %assign i 1  %assign i 1
116  %rep 31  %rep 31
117          times 4 dw i * 2          times 4 dw i * 2
118          %assign i i+1          %assign i i+1
119  %endrep  %endrep
120    
121  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;  
122  ; saturation limits  ; saturation limits
123  ;  ;-----------------------------------------------------------------------------
 ;===========================================================================  
124    
125  align 8  ALIGN 8
126  mmx_32768_minus_2048                            times 4 dw (32768-2048)  mmx_32768_minus_2048:
127  mmx_32767_minus_2047                            times 4 dw (32767-2047)          times 4 dw (32768-2048)
128    mmx_32767_minus_2047:
129            times 4 dw (32767-2047)
130    
131  align 16  ALIGN 16
132  mmx_2047 times 4 dw 2047  mmx_2047:
133            times 4 dw 2047
134    
135  align 8  ALIGN 8
136  mmzero dd 0, 0  mmzero:
137  int2047 dd 2047          dd 0, 0
138  int_2048 dd -2048  int2047:
139            dd 2047
140    int_2048:
141            dd -2048
142    
143  section .text  ;=============================================================================
144    ; Code
145    ;=============================================================================
146    
147    SECTION .text
148    
149  ;===========================================================================  
150    ;-----------------------------------------------------------------------------
151  ;  ;
152  ; void quant_intra_3dne(int16_t * coeff,  ; uint32_t quant_h263_intra_3dne(int16_t * coeff,
153  ;                                       const int16_t const * data,  ;                                       const int16_t const * data,
154  ;                                       const uint32_t quant,  ;                                       const uint32_t quant,
155  ;                                       const uint32_t dcscalar);  ;                                       const uint32_t dcscalar);
156  ;  ;
157  ;===========================================================================  ;-----------------------------------------------------------------------------
158  ;This is Athlon-optimized code (ca 70 clk per call)  ;This is Athlon-optimized code (ca 70 clk per call)
 ;Optimized by Jaan, 30 Nov 2002  
159    
160  %macro quant_intra1  1  %macro quant_intra1  1
   
161          psubw   mm1, mm0        ;A3          psubw   mm1, mm0        ;A3
162          psubw   mm3, mm2        ;B3          psubw   mm3, mm2        ;B3
163  %if (%1)  %if (%1)
# Line 186  Line 165 
165          psubw   mm7, mm6        ;D8          psubw   mm7, mm6        ;D8
166  %endif  %endif
167    
168  align 8  ALIGN 8
169          db      0Fh, 6Fh, 64h, 21h, (%1 * 32 +16)       ;movq   mm4, [ecx + %1 * 32 +16+32]     ;C1          db      0Fh, 6Fh, 64h, 21h, (%1 * 32 +16)       ;movq   mm4, [ecx + %1 * 32 +16+32]     ;C1
170          pmaxsw  mm1, mm0        ;A4          pmaxsw  mm1, mm0        ;A4
171          db      0Fh, 6Fh, 74h, 21h, (%1 * 32 +24)       ;movq   mm6, [ecx + %1 * 32 +24+32]     ;D1          db      0Fh, 6Fh, 74h, 21h, (%1 * 32 +24)       ;movq   mm6, [ecx + %1 * 32 +24+32]     ;D1
# Line 260  Line 239 
239          psubw   mm7, mm6        ;D8          psubw   mm7, mm6        ;D8
240  %endif  %endif
241    
242  align 8  ALIGN 8
243          db      0Fh, 6Fh, 64h, 21h, (%1 * 32 +16)       ;movq   mm4, [ecx + %1 * 32 +16+32]     ;C1          db      0Fh, 6Fh, 64h, 21h, (%1 * 32 +16)       ;movq   mm4, [ecx + %1 * 32 +16+32]     ;C1
244          pmaxsw  mm1, mm0        ;A4          pmaxsw  mm1, mm0        ;A4
245          db      0Fh, 6Fh, 74h, 21h, (%1 * 32 +24)       ;movq   mm6, [ecx + %1 * 32 +24+32]     ;D1          db      0Fh, 6Fh, 74h, 21h, (%1 * 32 +24)       ;movq   mm6, [ecx + %1 * 32 +24+32]     ;D1
# Line 327  Line 306 
306  %endmacro  %endmacro
307    
308    
309  align ALIGN  ALIGN 16
310  cglobal quant_h263_intra_3dne  cglobal quant_h263_intra_3dne
311  quant_h263_intra_3dne:  quant_h263_intra_3dne:
312    
# Line 379  Line 358 
358          movq    [edx + 3 * 32 + 16], mm5        ;C9          movq    [edx + 3 * 32 + 16], mm5        ;C9
359          movq    [edx + 3 * 32 + 24], mm7        ;D9          movq    [edx + 3 * 32 + 24], mm7        ;D9
360    
361      xor eax, eax
362          ret          ret
363    
364          align 16  ALIGN 16
365    
366  .q1loop  .q1loop
367  quant_intra1 0  quant_intra1 0
# Line 414  Line 394 
394          movq    [edx + 3 * 32 + 16], mm5        ;C9          movq    [edx + 3 * 32 + 16], mm5        ;C9
395          movq    [edx + 3 * 32 + 24], mm7        ;D9          movq    [edx + 3 * 32 + 24], mm7        ;D9
396    
397      xor eax, eax
398          ret          ret
399    
400    
401    
402    
403  ;===========================================================================  ;-----------------------------------------------------------------------------
404  ;  ;
405  ; uint32_t quant_inter_3dne(int16_t * coeff,  ; uint32_t quant_h263_inter_3dne(int16_t * coeff,
406  ;                                       const int16_t const * data,  ;                                       const int16_t const * data,
407  ;                                       const uint32_t quant);  ;                                       const uint32_t quant);
408  ;  ;
409  ;===========================================================================  ;-----------------------------------------------------------------------------
410  ;This is Athlon-optimized code (ca 90 clk per call)  ;This is Athlon-optimized code (ca 90 clk per call)
411  ;Optimized by Jaan, 30 Nov 2002  ;Optimized by Jaan, 30 Nov 2002
412    
# Line 500  Line 481 
481          movq    [edx + %1*16+8], mm4          movq    [edx + %1*16+8], mm4
482  %endmacro  %endmacro
483    
484  align ALIGN  ALIGN 16
485  cglobal quant_h263_inter_3dne  cglobal quant_h263_inter_3dne
486  quant_h263_inter_3dne:  quant_h263_inter_3dne:
487          mov     edx, [esp  + 4]         ; coeff          mov     edx, [esp  + 4]         ; coeff
# Line 517  Line 498 
498          lea     eax, [mmzero]          lea     eax, [mmzero]
499          jz      near .q1loop          jz      near .q1loop
500          cmp     esp, esp          cmp     esp, esp
501  align 8  ALIGN 8
502          movq    mm3, [ecx + 120]        ;B1          movq    mm3, [ecx + 120]        ;B1
503          pxor    mm4, mm4                ;B2          pxor    mm4, mm4                ;B2
504          psubw   mm4, mm3                ;B3          psubw   mm4, mm3                ;B3
# Line 548  Line 529 
529    
530          ret          ret
531    
532  align ALIGN  ALIGN 16
533  .q1loop  .q1loop
534          movq mm6, [byte ebx]          movq mm6, [byte ebx]
535    
# Line 571  Line 552 
552    
553          ret          ret
554    
555  ;===========================================================================  ;-----------------------------------------------------------------------------
556  ;  ;
557  ; void dequant_intra_3dne(int16_t *data,  ; uint32_t dequant_h263_intra_3dne(int16_t *data,
558  ;                                       const int16_t const *coeff,  ;                                       const int16_t const *coeff,
559  ;                                       const uint32_t quant,  ;                                       const uint32_t quant,
560  ;                                       const uint32_t dcscalar);  ;                                       const uint32_t dcscalar);
561  ;  ;
562  ;===========================================================================  ;-----------------------------------------------------------------------------
563    
564    ; this is the same as dequant_inter_3dne, except that we're    ; this is the same as dequant_inter_3dne, except that we're
565    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)
# Line 604  Line 585 
585          movq    mm4, [esi]              ;C1 ;0          movq    mm4, [esi]              ;C1 ;0
586          mov     esp, esp          mov     esp, esp
587          pcmpeqw mm6, [ecx+%1*24]        ;A6 (c ==0) ? -1 : 0 (1st)          pcmpeqw mm6, [ecx+%1*24]        ;A6 (c ==0) ? -1 : 0 (1st)
588  align 4  ALIGN 4
589          psraw   mm1, 15                 ; sign(c)       ;A7 (2nd)          psraw   mm1, 15                 ; sign(c)       ;A7 (2nd)
590  %if (%1)  %if (%1)
591          movq    [edx+%1*24+16-24], mm5  ; C14 (7th) 2later          movq    [edx+%1*24+16-24], mm5  ; C14 (7th) 2later
# Line 650  Line 631 
631  %endmacro  %endmacro
632    
633    
634  align ALIGN  ALIGN 16
635  cglobal dequant_h263_intra_3dne  cglobal dequant_h263_intra_3dne
636  dequant_h263_intra_3dne:  dequant_h263_intra_3dne:
637          mov     ecx, [esp+ 8]                   ; coeff          mov     ecx, [esp+ 8]                   ; coeff
# Line 677  Line 658 
658          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)
659          mov     edx, [esp+ 4+16]                ; data          mov     edx, [esp+ 4+16]                ; data
660    
661  align 8  ALIGN 8
662          dequant 0          dequant 0
663    
664          cmp     ebp, -2048          cmp     ebp, -2048
# Line 717  Line 698 
698          pxor    mm3, mm2                ;B13 (6th+)          pxor    mm3, mm2                ;B13 (6th+)
699          movq    [edx+4*24+8], mm3       ;B14 (7th)          movq    [edx+4*24+8], mm3       ;B14 (7th)
700          mov     [edx], ax          mov     [edx], ax
701    
702      xor eax, eax
703          ret          ret
704    
705  ;===========================================================================  ;-----------------------------------------------------------------------------
706  ;  ;
707  ; void dequant_inter_3dne(int16_t * data,  ; uint32_t dequant_h263_inter_3dne(int16_t * data,
708  ;                                       const int16_t * const coeff,  ;                                       const int16_t * const coeff,
709  ;                                       const uint32_t quant);  ;                                       const uint32_t quant);
710  ;  ;
711  ;===========================================================================  ;-----------------------------------------------------------------------------
712    
713  ; this is the same as dequant_inter_3dne,  ; this is the same as dequant_inter_3dne,
714  ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)  ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)
715  ;This is Athlon-optimized code (ca 100 clk per call)  ;This is Athlon-optimized code (ca 100 clk per call)
 ;Optimized by Jaan, 30 Nov 2002  
716    
717  align ALIGN  ALIGN 16
718  cglobal dequant_h263_inter_3dne  cglobal dequant_h263_inter_3dne
719  dequant_h263_inter_3dne:  dequant_h263_inter_3dne:
720          mov     ecx, [esp+ 8]                   ; coeff          mov     ecx, [esp+ 8]                   ; coeff
# Line 755  Line 737 
737          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)
738          mov     edx, [dword esp+ 4+12]          ; data          mov     edx, [dword esp+ 4+12]          ; data
739    
740  align 8  ALIGN 8
741    
742          dequant 0          dequant 0
743          dequant 1          dequant 1
# Line 778  Line 760 
760          pxor    mm3, mm2                ;B13 (6th+)          pxor    mm3, mm2                ;B13 (6th+)
761          movq    [edx+4*24+8], mm3       ;B14 (7th)          movq    [edx+4*24+8], mm3       ;B14 (7th)
762    
763      xor eax, eax
764          ret          ret

Legend:
Removed from v.1174  
changed lines
  Added in v.1192

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4