[cvs] / xvidcore / src / quant / x86_asm / quantize_h263_3dne.asm Repository:
ViewVC logotype

Diff of /xvidcore/src/quant/x86_asm/quantize_h263_3dne.asm

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

revision 1.1.2.2, Thu Oct 9 18:50:22 2003 UTC revision 1.1.2.4, Mon Nov 3 15:51:50 2003 UTC
# Line 29  Line 29 
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  
33    
34  %macro cglobal 1  %macro cglobal 1
35          %ifdef PREFIX          %ifdef PREFIX
# Line 43  Line 40 
40          %endif          %endif
41  %endmacro  %endmacro
42    
43  ;***************************************************************************  ;=============================================================================
44  ; Local data  ; Local data
45  ;***************************************************************************  ;=============================================================================
46    
47  %ifdef FORMAT_COFF  %ifdef FORMAT_COFF
48  section .data data  SECTION .rodata data
49  %else  %else
50  section .data data align=16  SECTION .rodata data align=16
51  %endif  %endif
52    
53  align 4  align 4
# Line 62  Line 59 
59          %assign i i+1          %assign i i+1
60  %endrep  %endrep
61    
62  align 16  ALIGN 16
63  plus_one:  plus_one:
64          times 8 dw 1          times 8 dw 1
65    
66  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;  
67  ; subtract by Q/2 table  ; subtract by Q/2 table
68  ;  ;-----------------------------------------------------------------------------
 ;===========================================================================  
69    
70  align 16  ALIGN 16
71  mmx_sub:  mmx_sub:
72  %assign i 1  %assign i 1
73  %rep 31  %rep 31
# Line 81  Line 76 
76  %endrep  %endrep
77    
78    
79  ;===========================================================================  ;-----------------------------------------------------------------------------
80  ;  ;
81  ; divide by 2Q table  ; divide by 2Q table
82  ;  ;
# Line 89  Line 84 
84  ; for q=1, _pmulhw_ will overflow so it is treated seperately  ; for q=1, _pmulhw_ will overflow so it is treated seperately
85  ; (3dnow2 provides _pmulhuw_ which wont cause overflow)  ; (3dnow2 provides _pmulhuw_ which wont cause overflow)
86  ;  ;
87  ;===========================================================================  ;-----------------------------------------------------------------------------
88    
89  align 16  ALIGN 16
90  mmx_div:  mmx_div:
91  %assign i 1  %assign i 1
92  %rep 31  %rep 31
# Line 99  Line 94 
94          %assign i i+1          %assign i i+1
95  %endrep  %endrep
96    
97  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;  
98  ; add by (odd(Q) ? Q : Q - 1) table  ; add by (odd(Q) ? Q : Q - 1) table
99  ;  ;-----------------------------------------------------------------------------
 ;===========================================================================  
100    
101  align 16  ALIGN 16
102  mmx_add:  mmx_add:
103  %assign i 1  %assign i 1
104  %rep 31  %rep 31
# Line 117  Line 110 
110          %assign i i+1          %assign i i+1
111  %endrep  %endrep
112    
113  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;  
114  ; multiple by 2Q table  ; multiple by 2Q table
115  ;  ;-----------------------------------------------------------------------------
 ;===========================================================================  
116    
117  align 16  ALIGN 16
118  mmx_mul:  mmx_mul:
119  %assign i 1  %assign i 1
120  %rep 31  %rep 31
# Line 131  Line 122 
122          %assign i i+1          %assign i i+1
123  %endrep  %endrep
124    
125  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;  
126  ; saturation limits  ; saturation limits
127  ;  ;-----------------------------------------------------------------------------
 ;===========================================================================  
128    
129  align 8  ALIGN 8
130  mmx_32768_minus_2048:  mmx_32768_minus_2048:
131          times 4 dw (32768-2048)          times 4 dw (32768-2048)
132  mmx_32767_minus_2047:  mmx_32767_minus_2047:
133          times 4 dw (32767-2047)          times 4 dw (32767-2047)
134    
135  align 16  ALIGN 16
136  mmx_2047:  mmx_2047:
137          times 4 dw 2047          times 4 dw 2047
138    
139  align 8  ALIGN 8
140  mmzero:  mmzero:
141          dd 0, 0          dd 0, 0
142  int2047:  int2047:
# Line 155  Line 144 
144  int_2048:  int_2048:
145          dd -2048          dd -2048
146    
147  ;***************************************************************************  ;=============================================================================
148  ; Code  ; Code
149  ;***************************************************************************  ;=============================================================================
150    
151  section .text  SECTION .text
152    
153    
154  ;===========================================================================  ;-----------------------------------------------------------------------------
155  ;  ;
156  ; uint32_t quant_h263_intra_3dne(int16_t * coeff,  ; uint32_t quant_h263_intra_3dne(int16_t * coeff,
157  ;                                const int16_t const * data,  ;                                const int16_t const * data,
158  ;                                const uint32_t quant,  ;                                const uint32_t quant,
159  ;                                const uint32_t dcscalar);  ;                                const uint32_t dcscalar);
160  ;  ;
161  ;===========================================================================  ;-----------------------------------------------------------------------------
162  ;This is Athlon-optimized code (ca 70 clk per call)  ;This is Athlon-optimized code (ca 70 clk per call)
163    
164  %macro quant_intra1  1  %macro quant_intra1  1
   
165          psubw   mm1, mm0        ;A3          psubw   mm1, mm0        ;A3
166          psubw   mm3, mm2        ;B3          psubw   mm3, mm2        ;B3
167  %if (%1)  %if (%1)
# Line 181  Line 169 
169          psubw   mm7, mm6        ;D8          psubw   mm7, mm6        ;D8
170  %endif  %endif
171    
172  align 8  ALIGN 8
173          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
174          pmaxsw  mm1, mm0        ;A4          pmaxsw  mm1, mm0        ;A4
175          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 255  Line 243 
243          psubw   mm7, mm6        ;D8          psubw   mm7, mm6        ;D8
244  %endif  %endif
245    
246  align 8  ALIGN 8
247          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
248          pmaxsw  mm1, mm0        ;A4          pmaxsw  mm1, mm0        ;A4
249          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 322  Line 310 
310  %endmacro  %endmacro
311    
312    
313  align ALIGN  ALIGN 16
314  cglobal quant_h263_intra_3dne  cglobal quant_h263_intra_3dne
315  quant_h263_intra_3dne:  quant_h263_intra_3dne:
316    
# Line 377  Line 365 
365          xor             eax, eax          xor             eax, eax
366          ret          ret
367    
368          align 16  ALIGN 16
369    
370  .q1loop  .q1loop
371  quant_intra1 0  quant_intra1 0
# Line 416  Line 404 
404    
405    
406    
407  ;===========================================================================  ;-----------------------------------------------------------------------------
408  ;  ;
409  ; uint32_t quant_h263_inter_3dne(int16_t * coeff,  ; uint32_t quant_h263_inter_3dne(int16_t * coeff,
410  ;                                const int16_t const * data,  ;                                const int16_t const * data,
411  ;                                const uint32_t quant);  ;                                const uint32_t quant);
412  ;  ;
413  ;===========================================================================  ;-----------------------------------------------------------------------------
414  ;This is Athlon-optimized code (ca 90 clk per call)  ;This is Athlon-optimized code (ca 90 clk per call)
415  ;Optimized by Jaan, 30 Nov 2002  ;Optimized by Jaan, 30 Nov 2002
416    
# Line 497  Line 485 
485          movq    [edx + %1*16+8], mm4          movq    [edx + %1*16+8], mm4
486  %endmacro  %endmacro
487    
488  align ALIGN  ALIGN 16
489  cglobal quant_h263_inter_3dne  cglobal quant_h263_inter_3dne
490  quant_h263_inter_3dne:  quant_h263_inter_3dne:
491          mov             edx, [esp  + 4]         ; coeff          mov             edx, [esp  + 4]         ; coeff
# Line 514  Line 502 
502          lea             eax, [mmzero]          lea             eax, [mmzero]
503          jz              near .q1loop          jz              near .q1loop
504          cmp             esp, esp          cmp             esp, esp
505  align 8  ALIGN 8
506          movq    mm3, [ecx + 120]        ;B1          movq    mm3, [ecx + 120]        ;B1
507          pxor    mm4, mm4                ;B2          pxor    mm4, mm4                ;B2
508          psubw   mm4, mm3                ;B3          psubw   mm4, mm3                ;B3
# Line 545  Line 533 
533    
534          ret          ret
535    
536  align ALIGN  ALIGN 16
537  .q1loop  .q1loop
538          movq mm6, [byte ebx]          movq mm6, [byte ebx]
539    
# Line 568  Line 556 
556    
557          ret          ret
558    
559  ;===========================================================================  ;-----------------------------------------------------------------------------
560  ;  ;
561  ; uint32_t dequant_h263_intra_3dne(int16_t *data,  ; uint32_t dequant_h263_intra_3dne(int16_t *data,
562  ;                                  const int16_t const *coeff,  ;                                  const int16_t const *coeff,
563  ;                                  const uint32_t quant,  ;                                  const uint32_t quant,
564  ;                                  const uint32_t dcscalar);  ;                                  const uint32_t dcscalar);
565  ;  ;
566  ;===========================================================================  ;-----------------------------------------------------------------------------
567    
568    ; this is the same as dequant_inter_3dne, except that we're    ; this is the same as dequant_inter_3dne, except that we're
569    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)
# Line 601  Line 589 
589          movq    mm4, [esi]              ;C1 ;0          movq    mm4, [esi]              ;C1 ;0
590          mov             esp, esp          mov             esp, esp
591          pcmpeqw mm6, [ecx+%1*24]        ;A6 (c ==0) ? -1 : 0 (1st)          pcmpeqw mm6, [ecx+%1*24]        ;A6 (c ==0) ? -1 : 0 (1st)
592  align 4  ALIGN 4
593          psraw   mm1, 15                 ; sign(c)       ;A7 (2nd)          psraw   mm1, 15                 ; sign(c)       ;A7 (2nd)
594  %if (%1)  %if (%1)
595          movq    [edx+%1*24+16-24], mm5  ; C14 (7th) 2later          movq    [edx+%1*24+16-24], mm5  ; C14 (7th) 2later
# Line 647  Line 635 
635  %endmacro  %endmacro
636    
637    
638  align ALIGN  ALIGN 16
639  cglobal dequant_h263_intra_3dne  cglobal dequant_h263_intra_3dne
640  dequant_h263_intra_3dne:  dequant_h263_intra_3dne:
641          mov             ecx, [esp+ 8]                   ; coeff          mov             ecx, [esp+ 8]                   ; coeff
# Line 674  Line 662 
662          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)
663          mov             edx, [esp+ 4+16]                ; data          mov             edx, [esp+ 4+16]                ; data
664    
665  align 8  ALIGN 8
666          dequant 0          dequant 0
667    
668          cmp             ebp, -2048          cmp             ebp, -2048
# Line 718  Line 706 
706          xor             eax, eax          xor             eax, eax
707          ret          ret
708    
709  ;===========================================================================  ;-----------------------------------------------------------------------------
710  ;  ;
711  ; uint32_t dequant_h263_inter_3dne(int16_t * data,  ; uint32_t dequant_h263_inter_3dne(int16_t * data,
712  ;                                  const int16_t * const coeff,  ;                                  const int16_t * const coeff,
713  ;                                  const uint32_t quant);  ;                                  const uint32_t quant);
714  ;  ;
715  ;===========================================================================  ;-----------------------------------------------------------------------------
716    
717  ; this is the same as dequant_inter_3dne,  ; this is the same as dequant_inter_3dne,
718  ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)  ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)
719  ; This is Athlon-optimized code (ca 100 clk per call)  ; This is Athlon-optimized code (ca 100 clk per call)
720    
721  align ALIGN  ALIGN 16
722  cglobal dequant_h263_inter_3dne  cglobal dequant_h263_inter_3dne
723  dequant_h263_inter_3dne:  dequant_h263_inter_3dne:
724          mov             ecx, [esp+ 8]                   ; coeff          mov             ecx, [esp+ 8]                   ; coeff
# Line 753  Line 741 
741          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)
742          mov             edx, [dword esp+ 4+12]          ; data          mov             edx, [dword esp+ 4+12]          ; data
743    
744  align 8  ALIGN 8
745    
746          dequant 0          dequant 0
747          dequant 1          dequant 1

Legend:
Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.4

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