[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.2.2.1, Sat Jul 24 11:38:12 2004 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
49  %else  %else
50  section .data data align=16  SECTION .rodata 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    ;                                const uint16_t *mpeg_matrices);
161  ;  ;
162  ;===========================================================================  ;-----------------------------------------------------------------------------
163  ;This is Athlon-optimized code (ca 70 clk per call)  ;This is Athlon-optimized code (ca 70 clk per call)
164    
165  %macro quant_intra1  1  %macro quant_intra1  1
   
166          psubw   mm1, mm0        ;A3          psubw   mm1, mm0        ;A3
167          psubw   mm3, mm2        ;B3          psubw   mm3, mm2        ;B3
168  %if (%1)  %if (%1)
# Line 181  Line 170 
170          psubw   mm7, mm6        ;D8          psubw   mm7, mm6        ;D8
171  %endif  %endif
172    
173  align 8  ALIGN 8
174          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
175          pmaxsw  mm1, mm0        ;A4          pmaxsw  mm1, mm0        ;A4
176          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 244 
244          psubw   mm7, mm6        ;D8          psubw   mm7, mm6        ;D8
245  %endif  %endif
246    
247  align 8  ALIGN 8
248          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
249          pmaxsw  mm1, mm0        ;A4          pmaxsw  mm1, mm0        ;A4
250          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 311 
311  %endmacro  %endmacro
312    
313    
314  align ALIGN  ALIGN 16
315  cglobal quant_h263_intra_3dne  cglobal quant_h263_intra_3dne
316  quant_h263_intra_3dne:  quant_h263_intra_3dne:
317    
# Line 377  Line 366 
366          xor             eax, eax          xor             eax, eax
367          ret          ret
368    
369          align 16  ALIGN 16
370    
371  .q1loop  .q1loop
372  quant_intra1 0  quant_intra1 0
# Line 416  Line 405 
405    
406    
407    
408  ;===========================================================================  ;-----------------------------------------------------------------------------
409  ;  ;
410  ; uint32_t quant_h263_inter_3dne(int16_t * coeff,  ; uint32_t quant_h263_inter_3dne(int16_t * coeff,
411  ;                                const int16_t const * data,  ;                                const int16_t const * data,
412  ;                                const uint32_t quant);  ;                                const uint32_t quant,
413    ;                                const uint16_t *mpeg_matrices);
414  ;  ;
415  ;===========================================================================  ;-----------------------------------------------------------------------------
416  ;This is Athlon-optimized code (ca 90 clk per call)  ;This is Athlon-optimized code (ca 90 clk per call)
417  ;Optimized by Jaan, 30 Nov 2002  ;Optimized by Jaan, 30 Nov 2002
418    
# Line 497  Line 487 
487          movq    [edx + %1*16+8], mm4          movq    [edx + %1*16+8], mm4
488  %endmacro  %endmacro
489    
490  align ALIGN  ALIGN 16
491  cglobal quant_h263_inter_3dne  cglobal quant_h263_inter_3dne
492  quant_h263_inter_3dne:  quant_h263_inter_3dne:
493          mov             edx, [esp  + 4]         ; coeff          mov             edx, [esp  + 4]         ; coeff
# Line 514  Line 504 
504          lea             eax, [mmzero]          lea             eax, [mmzero]
505          jz              near .q1loop          jz              near .q1loop
506          cmp             esp, esp          cmp             esp, esp
507  align 8  ALIGN 8
508          movq    mm3, [ecx + 120]        ;B1          movq    mm3, [ecx + 120]        ;B1
509          pxor    mm4, mm4                ;B2          pxor    mm4, mm4                ;B2
510          psubw   mm4, mm3                ;B3          psubw   mm4, mm3                ;B3
# Line 545  Line 535 
535    
536          ret          ret
537    
538  align ALIGN  ALIGN 16
539  .q1loop  .q1loop
540          movq mm6, [byte ebx]          movq mm6, [byte ebx]
541    
# Line 568  Line 558 
558    
559          ret          ret
560    
561  ;===========================================================================  ;-----------------------------------------------------------------------------
562  ;  ;
563  ; uint32_t dequant_h263_intra_3dne(int16_t *data,  ; uint32_t dequant_h263_intra_3dne(int16_t *data,
564  ;                                  const int16_t const *coeff,  ;                                  const int16_t const *coeff,
565  ;                                  const uint32_t quant,  ;                                  const uint32_t quant,
566  ;                                  const uint32_t dcscalar);  ;                                  const uint32_t dcscalar,
567    ;                                  const uint16_t *mpeg_matrices);
568  ;  ;
569  ;===========================================================================  ;-----------------------------------------------------------------------------
570    
571    ; this is the same as dequant_inter_3dne, except that we're    ; this is the same as dequant_inter_3dne, except that we're
572    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)
# Line 601  Line 592 
592          movq    mm4, [esi]              ;C1 ;0          movq    mm4, [esi]              ;C1 ;0
593          mov             esp, esp          mov             esp, esp
594          pcmpeqw mm6, [ecx+%1*24]        ;A6 (c ==0) ? -1 : 0 (1st)          pcmpeqw mm6, [ecx+%1*24]        ;A6 (c ==0) ? -1 : 0 (1st)
595  align 4  ALIGN 4
596          psraw   mm1, 15                 ; sign(c)       ;A7 (2nd)          psraw   mm1, 15                 ; sign(c)       ;A7 (2nd)
597  %if (%1)  %if (%1)
598          movq    [edx+%1*24+16-24], mm5  ; C14 (7th) 2later          movq    [edx+%1*24+16-24], mm5  ; C14 (7th) 2later
# Line 647  Line 638 
638  %endmacro  %endmacro
639    
640    
641  align ALIGN  ALIGN 16
642  cglobal dequant_h263_intra_3dne  cglobal dequant_h263_intra_3dne
643  dequant_h263_intra_3dne:  dequant_h263_intra_3dne:
644          mov             ecx, [esp+ 8]                   ; coeff          mov             ecx, [esp+ 8]                   ; coeff
# Line 674  Line 665 
665          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)
666          mov             edx, [esp+ 4+16]                ; data          mov             edx, [esp+ 4+16]                ; data
667    
668  align 8  ALIGN 8
669          dequant 0          dequant 0
670    
671          cmp             ebp, -2048          cmp             ebp, -2048
# Line 718  Line 709 
709          xor             eax, eax          xor             eax, eax
710          ret          ret
711    
712  ;===========================================================================  ;-----------------------------------------------------------------------------
713  ;  ;
714  ; uint32_t dequant_h263_inter_3dne(int16_t * data,  ; uint32_t dequant_h263_inter_3dne(int16_t * data,
715  ;                                  const int16_t * const coeff,  ;                                  const int16_t * const coeff,
716  ;                                  const uint32_t quant);  ;                                  const uint32_t quant,
717    ;                                  const uint16_t *mpeg_matrices);
718  ;  ;
719  ;===========================================================================  ;-----------------------------------------------------------------------------
720    
721  ; this is the same as dequant_inter_3dne,  ; this is the same as dequant_inter_3dne,
722  ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)  ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)
723  ; This is Athlon-optimized code (ca 100 clk per call)  ; This is Athlon-optimized code (ca 100 clk per call)
724    
725  align ALIGN  ALIGN 16
726  cglobal dequant_h263_inter_3dne  cglobal dequant_h263_inter_3dne
727  dequant_h263_inter_3dne:  dequant_h263_inter_3dne:
728          mov             ecx, [esp+ 8]                   ; coeff          mov             ecx, [esp+ 8]                   ; coeff
# Line 753  Line 745 
745          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)          psraw   mm3, 15                         ; sign(c)       ;B7 (2nd)
746          mov             edx, [dword esp+ 4+12]          ; data          mov             edx, [dword esp+ 4+12]          ; data
747    
748  align 8  ALIGN 8
749    
750          dequant 0          dequant 0
751          dequant 1          dequant 1

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

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