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

Diff of /xvidcore/src/quant/x86_asm/quantize_h263_mmx.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.5, Sun Nov 30 16:13:16 2003 UTC
# Line 27  Line 27 
27  ; enable dequant saturate [-2048,2047], test purposes only.  ; enable dequant saturate [-2048,2047], test purposes only.
28  %define SATURATE  %define SATURATE
29    
30  ; data/text alignment  BITS 32
 %define ALIGN 8  
   
 bits 32  
31    
32  %macro cglobal 1  %macro cglobal 1
33         %ifdef PREFIX         %ifdef PREFIX
# Line 41  Line 38 
38          %endif          %endif
39  %endmacro  %endmacro
40    
41  ;***************************************************************************  ;=============================================================================
42  ; Local data  ; Read only Local data
43  ;***************************************************************************  ;=============================================================================
44    
45  %ifdef FORMAT_COFF  %ifdef FORMAT_COFF
46  section .data data  SECTION .rodata data
47  %else  %else
48  section .data data align=16  SECTION .rodata data align=16
49  %endif  %endif
50    
51  align 16  ALIGN 16
52  plus_one:  plus_one:
53          times 8 dw 1          times 8 dw 1
54    
55  ;===========================================================================  ;-----------------------------------------------------------------------------
56  ;  ;
57  ; subtract by Q/2 table  ; subtract by Q/2 table
58  ;  ;
59  ;===========================================================================  ;-----------------------------------------------------------------------------
60    
61  align 16  ALIGN 16
62  mmx_sub:  mmx_sub:
63  %assign quant 1  %assign quant 1
64  %rep 31  %rep 31
# Line 69  Line 66 
66          %assign quant quant+1          %assign quant quant+1
67  %endrep  %endrep
68    
69  ;===========================================================================  ;-----------------------------------------------------------------------------
70  ;  ;
71  ; divide by 2Q table  ; divide by 2Q table
72  ;  ;
# Line 77  Line 74 
74  ; for q=1, _pmulhw_ will overflow so it is treated seperately  ; for q=1, _pmulhw_ will overflow so it is treated seperately
75  ; (3dnow2 provides _pmulhuw_ which wont cause overflow)  ; (3dnow2 provides _pmulhuw_ which wont cause overflow)
76  ;  ;
77  ;===========================================================================  ;-----------------------------------------------------------------------------
78    
79  align 16  ALIGN 16
80  mmx_div:  mmx_div:
81  %assign quant 1  %assign quant 1
82  %rep 31  %rep 31
# Line 87  Line 84 
84          %assign quant quant+1          %assign quant quant+1
85  %endrep  %endrep
86    
87  ;===========================================================================  ;-----------------------------------------------------------------------------
88  ;  ;
89  ; add by (odd(Q) ? Q : Q - 1) table  ; add by (odd(Q) ? Q : Q - 1) table
90  ;  ;
91  ;===========================================================================  ;-----------------------------------------------------------------------------
92    
93  align 16  ALIGN 16
94  mmx_add:  mmx_add:
95  %assign quant 1  %assign quant 1
96  %rep 31  %rep 31
# Line 105  Line 102 
102          %assign quant quant+1          %assign quant quant+1
103  %endrep  %endrep
104    
105  ;===========================================================================  ;-----------------------------------------------------------------------------
106  ;  ;
107  ; multiple by 2Q table  ; multiple by 2Q table
108  ;  ;
109  ;===========================================================================  ;-----------------------------------------------------------------------------
110    
111  align 16  ALIGN 16
112  mmx_mul:  mmx_mul:
113  %assign quant 1  %assign quant 1
114  %rep 31  %rep 31
# Line 119  Line 116 
116          %assign quant quant+1          %assign quant quant+1
117  %endrep  %endrep
118    
119  ;===========================================================================  ;-----------------------------------------------------------------------------
120  ;  ;
121  ; saturation limits  ; saturation limits
122  ;  ;
123  ;===========================================================================  ;-----------------------------------------------------------------------------
124    
125  align 16  ALIGN 16
126  sse2_2047:  sse2_2047:
127          times 8 dw 2047          times 8 dw 2047
128    
129  align 16  ALIGN 16
130  mmx_2047:  mmx_2047:
131          times 4 dw 2047          times 4 dw 2047
132    
133  align 8  ALIGN 8
134  mmx_32768_minus_2048:  mmx_32768_minus_2048:
135          times 4 dw (32768-2048)          times 4 dw (32768-2048)
136    
# Line 141  Line 138 
138          times 4 dw (32767-2047)          times 4 dw (32767-2047)
139    
140    
141  ;***************************************************************************  ;=============================================================================
142  ; Code  ; Code
143  ;***************************************************************************  ;=============================================================================
144    
145  section .text  SECTION .text
146    
147    cglobal quant_h263_intra_mmx
148    cglobal quant_h263_intra_sse2
149    cglobal quant_h263_inter_mmx
150    cglobal quant_h263_inter_sse2
151    cglobal dequant_h263_intra_mmx
152    cglobal dequant_h263_intra_xmm
153    cglobal dequant_h263_intra_sse2
154    cglobal dequant_h263_inter_mmx
155    cglobal dequant_h263_inter_xmm
156    cglobal dequant_h263_inter_sse2
157    
158  ;===========================================================================  ;-----------------------------------------------------------------------------
159  ;  ;
160  ; uint32_t quant_h263_intra_mmx(int16_t * coeff,  ; uint32_t quant_h263_intra_mmx(int16_t * coeff,
161  ;                               const int16_t const * data,  ;                               const int16_t const * data,
162  ;                               const uint32_t quant,  ;                               const uint32_t quant,
163  ;                               const uint32_t dcscalar);  ;                               const uint32_t dcscalar,
164    ;                               const uint16_t *mpeg_matrices);
165  ;  ;
166  ;===========================================================================  ;-----------------------------------------------------------------------------
167    
168  align ALIGN  ALIGN 16
 cglobal quant_h263_intra_mmx  
169  quant_h263_intra_mmx:  quant_h263_intra_mmx:
170    
171          push    ecx          push    ecx
# Line 175  Line 182 
182    
183          movq    mm7, [mmx_div + eax * 8 - 8]          movq    mm7, [mmx_div + eax * 8 - 8]
184    
185  align ALIGN  ALIGN 16
186  .loop  .loop
187          movq    mm0, [esi + 8*ecx]      ; mm0 = [1st]          movq    mm0, [esi + 8*ecx]      ; mm0 = [1st]
188          movq    mm3, [esi + 8*ecx + 8]          movq    mm3, [esi + 8*ecx + 8]
# Line 227  Line 234 
234    
235          ret          ret
236    
237  align ALIGN  ALIGN 16
238  .q1loop  .q1loop
239          movq    mm0, [esi + 8*ecx]      ; mm0 = [1st]          movq    mm0, [esi + 8*ecx]      ; mm0 = [1st]
240          movq    mm3, [esi + 8*ecx + 8]          movq    mm3, [esi + 8*ecx + 8]
# Line 255  Line 262 
262    
263    
264    
265  ;===========================================================================  ;-----------------------------------------------------------------------------
266  ;  ;
267  ; uint32_t quant_h263_intra_sse2(int16_t * coeff,  ; uint32_t quant_h263_intra_sse2(int16_t * coeff,
268  ;                                const int16_t const * data,  ;                                const int16_t const * data,
269  ;                                const uint32_t quant,  ;                                const uint32_t quant,
270  ;                                const uint32_t dcscalar);  ;                                const uint32_t dcscalar,
271    ;                                const uint16_t *mpeg_matrices);
272  ;  ;
273  ;===========================================================================  ;-----------------------------------------------------------------------------
274    
275  align ALIGN  ALIGN 16
 cglobal quant_h263_intra_sse2  
276  quant_h263_intra_sse2:  quant_h263_intra_sse2:
277    
278          push    esi          push    esi
# Line 284  Line 291 
291          movq2dq xmm7, mm7          movq2dq xmm7, mm7
292          movlhps xmm7, xmm7          movlhps xmm7, xmm7
293    
294  align 16  ALIGN 16
295  .qas2_loop  .qas2_loop
296          movdqa  xmm0, [esi + ecx*8]                ; xmm0 = [1st]          movdqa  xmm0, [esi + ecx*8]                ; xmm0 = [1st]
297          movdqa  xmm3, [esi + ecx*8 + 16]           ; xmm3 = [2nd]          movdqa  xmm3, [esi + ecx*8 + 16]           ; xmm3 = [2nd]
# Line 335  Line 342 
342    
343          ret          ret
344    
345  align 16  ALIGN 16
346  .qas2_q1loop  .qas2_q1loop
347          movdqa  xmm0, [esi + ecx*8]         ; xmm0 = [1st]          movdqa  xmm0, [esi + ecx*8]         ; xmm0 = [1st]
348          movdqa  xmm3, [esi + ecx*8 + 16]    ; xmm3 = [2nd]          movdqa  xmm3, [esi + ecx*8 + 16]    ; xmm3 = [2nd]
# Line 363  Line 370 
370    
371    
372    
373  ;===========================================================================  ;-----------------------------------------------------------------------------
374  ;  ;
375  ; uint32_t quant_h263_inter_mmx(int16_t * coeff,  ; uint32_t quant_h263_inter_mmx(int16_t * coeff,
376  ;                               const int16_t const * data,  ;                               const int16_t const * data,
377  ;                               const uint32_t quant);  ;                               const uint32_t quant,
378    ;                               const uint16_t *mpeg_matrices);
379  ;  ;
380  ;===========================================================================  ;-----------------------------------------------------------------------------
381    
382  align ALIGN  ALIGN 16
 cglobal quant_h263_inter_mmx  
383  quant_h263_inter_mmx:  quant_h263_inter_mmx:
384    
385          push    ecx          push    ecx
# Line 393  Line 400 
400    
401          movq    mm7, [mmx_div + eax * 8 - 8] ; divider          movq    mm7, [mmx_div + eax * 8 - 8] ; divider
402    
403  align ALIGN  ALIGN 8
404  .loop  .loop
405          movq    mm0, [esi + 8*ecx]      ; mm0 = [1st]          movq    mm0, [esi + 8*ecx]      ; mm0 = [1st]
406          movq    mm3, [esi + 8*ecx + 8]          movq    mm3, [esi + 8*ecx + 8]
# Line 435  Line 442 
442    
443          ret          ret
444    
445  align ALIGN  ALIGN 8
446  .q1loop  .q1loop
447          movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]          movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]
448          movq    mm3, [esi + 8*ecx+ 8]           ;          movq    mm3, [esi + 8*ecx+ 8]           ;
# Line 468  Line 475 
475    
476    
477    
478  ;===========================================================================  ;-----------------------------------------------------------------------------
479  ;  ;
480  ; uint32_t quant_h263_inter_sse2(int16_t * coeff,  ; uint32_t quant_h263_inter_sse2(int16_t * coeff,
481  ;                                const int16_t const * data,  ;                                const int16_t const * data,
482  ;                                const uint32_t quant);  ;                                const uint32_t quant,
483    ;                                const uint16_t *mpeg_matrices);
484  ;  ;
485  ;===========================================================================  ;-----------------------------------------------------------------------------
486    
487  align 16  ALIGN 16
 cglobal quant_h263_inter_sse2  
488  quant_h263_inter_sse2:  quant_h263_inter_sse2:
489    
490          push    esi          push    esi
# Line 503  Line 510 
510          movq2dq xmm7, mm0          movq2dq xmm7, mm0
511          movlhps xmm7, xmm7          movlhps xmm7, xmm7
512    
513  align 16  ALIGN 16
514  .qes2_loop  .qes2_loop
515          movdqa  xmm0, [esi + ecx*8]                ; xmm0 = [1st]          movdqa  xmm0, [esi + ecx*8]                ; xmm0 = [1st]
516          movdqa  xmm3, [esi + ecx*8 + 16]           ; xmm3 = [2nd]          movdqa  xmm3, [esi + ecx*8 + 16]           ; xmm3 = [2nd]
# Line 550  Line 557 
557    
558          ret          ret
559    
560  align 16  ALIGN 16
561  .qes2_q1loop  .qes2_q1loop
562          movdqa  xmm0, [esi + ecx*8]             ; xmm0 = [1st]          movdqa  xmm0, [esi + ecx*8]             ; xmm0 = [1st]
563          movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]          movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]
# Line 581  Line 588 
588          jmp             .qes2_done          jmp             .qes2_done
589    
590    
591  ;===========================================================================  ;-----------------------------------------------------------------------------
592  ;  ;
593  ; uint32_t dequant_h263_intra_mmx(int16_t *data,  ; uint32_t dequant_h263_intra_mmx(int16_t *data,
594  ;                                 const int16_t const *coeff,  ;                                 const int16_t const *coeff,
595  ;                                 const uint32_t quant,  ;                                 const uint32_t quant,
596  ;                                 const uint32_t dcscalar);  ;                                 const uint32_t dcscalar,
597    ;                                 const uint16_t *mpeg_matrices);
598  ;  ;
599  ;===========================================================================  ;-----------------------------------------------------------------------------
600    
601    ; note: we only saturate to +2047 *before* restoring the sign.    ; note: we only saturate to +2047 *before* restoring the sign.
602    ; Hence, final clamp really is [-2048,2047]    ; Hence, final clamp really is [-2048,2047]
603    
604  align ALIGN  ALIGN 16
 cglobal dequant_h263_intra_mmx  
605  dequant_h263_intra_mmx:  dequant_h263_intra_mmx:
606    
607          mov             edx, [esp+ 4]                   ; data          mov             edx, [esp+ 4]                   ; data
# Line 604  Line 611 
611          movq    mm7, [mmx_mul + eax*8 - 8]      ; 2*quant          movq    mm7, [mmx_mul + eax*8 - 8]      ; 2*quant
612          mov             eax, -16          mov             eax, -16
613    
614  align ALIGN  ALIGN 16
615  .loop  .loop
616          movq    mm0, [ecx+8*eax+8*16]           ; c  = coeff[i]          movq    mm0, [ecx+8*eax+8*16]           ; c  = coeff[i]
617          movq    mm3, [ecx+8*eax+8*16 + 8]       ; c' = coeff[i+1]          movq    mm3, [ecx+8*eax+8*16 + 8]       ; c' = coeff[i+1]
# Line 658  Line 665 
665          xor              eax, eax                               ; return(0);          xor              eax, eax                               ; return(0);
666          ret          ret
667    
668  ;===========================================================================  ;-----------------------------------------------------------------------------
669  ;  ;
670  ; uint32_t dequant_h263_intra_xmm(int16_t *data,  ; uint32_t dequant_h263_intra_xmm(int16_t *data,
671  ;                                 const int16_t const *coeff,  ;                                 const int16_t const *coeff,
672  ;                                 const uint32_t quant,  ;                                 const uint32_t quant,
673  ;                                 const uint32_t dcscalar);  ;                                 const uint32_t dcscalar,
674    ;                                 const uint16_t *mpeg_matrices);
675  ;  ;
676  ;===========================================================================  ;-----------------------------------------------------------------------------
677    
678    ; this is the same as dequant_inter_mmx, except that we're    ; this is the same as dequant_inter_mmx, except that we're
679    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)
680    
681  align ALIGN  ALIGN 16
 cglobal dequant_h263_intra_xmm  
682  dequant_h263_intra_xmm:  dequant_h263_intra_xmm:
683    
684          mov             edx, [esp+ 4]        ; data          mov             edx, [esp+ 4]        ; data
# Line 681  Line 688 
688          movq    mm7, [mmx_mul + eax*8 - 8]  ; 2*quant          movq    mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
689          mov             eax, -16          mov             eax, -16
690    
691  align ALIGN  ALIGN 16
692  .loop  .loop
693          movq    mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]          movq    mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
694          movq    mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]          movq    mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]
# Line 734  Line 741 
741          ret          ret
742    
743    
744  ;===========================================================================  ;-----------------------------------------------------------------------------
745  ;  ;
746  ; uint32_t dequant_h263_intra_sse2(int16_t *data,  ; uint32_t dequant_h263_intra_sse2(int16_t *data,
747  ;                                  const int16_t const *coeff,  ;                                  const int16_t const *coeff,
748  ;                                  const uint32_t quant,  ;                                  const uint32_t quant,
749  ;                                  const uint32_t dcscalar);  ;                                  const uint32_t dcscalar,
750    ;                                  const uint16_t *mpeg_matrices);
751  ;  ;
752  ;===========================================================================  ;-----------------------------------------------------------------------------
753    
754  align ALIGN  ALIGN 16
 cglobal dequant_h263_intra_sse2  
755  dequant_h263_intra_sse2:  dequant_h263_intra_sse2:
756          mov             edx, [esp+ 4]        ; data          mov             edx, [esp+ 4]        ; data
757          mov             ecx, [esp+ 8]        ; coeff          mov             ecx, [esp+ 8]        ; coeff
# Line 757  Line 764 
764          movlhps xmm7, xmm7          movlhps xmm7, xmm7
765          mov             eax, -16          mov             eax, -16
766    
767  align ALIGN  ALIGN 16
768  .loop  .loop
769          movdqa  xmm0, [ecx + 8*16 + 8*eax]      ; c  = coeff[i]          movdqa  xmm0, [ecx + 8*16 + 8*eax]      ; c  = coeff[i]
770          movdqa  xmm3, [ecx + 8*16 + 8*eax+ 16]          movdqa  xmm3, [ecx + 8*16 + 8*eax+ 16]
# Line 809  Line 816 
816          xor             eax, eax          xor             eax, eax
817          ret          ret
818    
819  ;===========================================================================  ;-----------------------------------------------------------------------------
820  ;  ;
821  ; uint32t dequant_h263_inter_mmx(int16_t * data,  ; uint32t dequant_h263_inter_mmx(int16_t * data,
822  ;                                const int16_t * const coeff,  ;                                const int16_t * const coeff,
823  ;                                const uint32_t quant);  ;                                const uint32_t quant,
824    ;                                const uint16_t *mpeg_matrices);
825  ;  ;
826  ;===========================================================================  ;-----------------------------------------------------------------------------
827    
828  align ALIGN  ALIGN 16
 cglobal dequant_h263_inter_mmx  
829  dequant_h263_inter_mmx:  dequant_h263_inter_mmx:
830    
831          mov             edx, [esp+ 4]        ; data          mov             edx, [esp+ 4]        ; data
# Line 828  Line 835 
835          movq    mm7, [mmx_mul + eax*8 - 8]  ; 2*quant          movq    mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
836          mov             eax, -16          mov             eax, -16
837    
838  align ALIGN  ALIGN 16
839  .loop  .loop
840          movq    mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]          movq    mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
841          movq    mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]          movq    mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]
# Line 869  Line 876 
876          xor             eax, eax          xor             eax, eax
877          ret          ret
878    
879  ;===========================================================================  ;-----------------------------------------------------------------------------
880  ;  ;
881  ; uint32_t dequant_h263_inter_xmm(int16_t * data,  ; uint32_t dequant_h263_inter_xmm(int16_t * data,
882  ;                                 const int16_t * const coeff,  ;                                 const int16_t * const coeff,
883  ;                                 const uint32_t quant);  ;                                 const uint32_t quant,
884    ;                                 const uint16_t *mpeg_matrices);
885  ;  ;
886  ;===========================================================================  ;-----------------------------------------------------------------------------
887    
888    ; this is the same as dequant_inter_mmx,    ; this is the same as dequant_inter_mmx,
889    ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)    ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)
890    
891  align ALIGN  ALIGN 16
 cglobal dequant_h263_inter_xmm  
892  dequant_h263_inter_xmm:  dequant_h263_inter_xmm:
893    
894          mov             edx, [esp+ 4]        ; data          mov             edx, [esp+ 4]        ; data
# Line 891  Line 898 
898          movq    mm7, [mmx_mul + eax*8 - 8]  ; 2*quant          movq    mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
899          mov             eax, -16          mov             eax, -16
900    
901  align ALIGN  ALIGN 16
902  .loop  .loop
903          movq    mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]          movq    mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
904          movq    mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]          movq    mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]
# Line 930  Line 937 
937          xor             eax, eax          xor             eax, eax
938          ret          ret
939    
940  ;===========================================================================  ;-----------------------------------------------------------------------------
941  ;  ;
942  ; uint32_t dequant_h263_inter_sse2(int16_t * data,  ; uint32_t dequant_h263_inter_sse2(int16_t * data,
943  ;                                  const int16_t * const coeff,  ;                                  const int16_t * const coeff,
944  ;                                  const uint32_t quant);  ;                                  const uint32_t quant,
945    ;                                  const uint16_t *mpeg_matrices);
946  ;  ;
947  ;===========================================================================  ;-----------------------------------------------------------------------------
948    
949  align ALIGN  ALIGN 16
 cglobal dequant_h263_inter_sse2  
950  dequant_h263_inter_sse2:  dequant_h263_inter_sse2:
951          mov             edx, [esp + 4]  ; data          mov             edx, [esp + 4]  ; data
952          mov             ecx, [esp + 8]  ; coeff          mov             ecx, [esp + 8]  ; coeff
# Line 952  Line 959 
959          movlhps xmm7, xmm7          movlhps xmm7, xmm7
960          mov             eax, -16          mov             eax, -16
961    
962  align ALIGN  ALIGN 16
963  .loop  .loop
964          movdqa  xmm0, [ecx + 8*16 + 8*eax]  ; c  = coeff[i]          movdqa  xmm0, [ecx + 8*16 + 8*eax]  ; c  = coeff[i]
965          movdqa  xmm3, [ecx + 8*16 + 8*eax + 16]          movdqa  xmm3, [ecx + 8*16 + 8*eax + 16]

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

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