[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.1, Tue Oct 7 13:02:35 2003 UTC revision 1.1.2.5, Sun Nov 30 16:13:16 2003 UTC
# Line 1  Line 1 
1  ;/**************************************************************************  ;/*****************************************************************************
2  ; *  ; *
3  ; *     XVID MPEG-4 VIDEO CODEC  ; *     XVID MPEG-4 VIDEO CODEC
4  ; *     mmx quantization/dequantization  ; *  - MPEG4 Quantization H263 implementation / MMX optimized -
5  ; *  ; *
6  ; *     This program is an implementation of a part of one or more MPEG-4  ; *  Copyright(C) 2001-2003 Peter Ross <pross@xvid.org>
7  ; *     Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  ; *               2002-2003 Pascal Massimino <skal@planet-d.net>
 ; *     to use this software module in hardware or software products are  
 ; *     advised that its use may infringe existing patents or copyrights, and  
 ; *     any such use would be at such party's own risk.  The original  
 ; *     developer of this software module and his/her company, and subsequent  
 ; *     editors and their companies, will have no liability for use of this  
 ; *     software or modifications or derivatives thereof.  
8  ; *  ; *
9  ; *     This program is free software; you can redistribute it and/or modify  ; *     This program is free software; you can redistribute it and/or modify
10  ; *     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 24  Line 18 
18  ; *  ; *
19  ; *     You should have received a copy of the GNU General Public License  ; *     You should have received a copy of the GNU General Public License
20  ; *     along with this program; if not, write to the Free Software  ; *     along with this program; if not, write to the Free Software
21  ; *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22  ; *  ; *
23  ; *************************************************************************/  ; * $Id$
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
 ; *  
 ; * 09.08.2002  sse2 dequant funcs revamped  
 ; * 14.06.2002  mmx+xmm dequant_* funcs revamped  -Skal-  
 ; * 24.02.2002  sse2 quant_intra / dequant_intra (have to use movdqu ???)  
 ; * 17.04.2002  sse2 quant_inter / dequant_inter  
 ; * 26.12.2001  minor bug fixes, dequant saturate, further optimization  
 ; * 19.11.2001  quant_inter_mmx now returns sum of abs. coefficient values  
 ; *     04.11.2001      nasm version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
24  ; *  ; *
25  ; *************************************************************************/  ; ****************************************************************************/
26    
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  
   
 section .data  
   
31    
32  %macro cglobal 1  %macro cglobal 1
33          %ifdef PREFIX          %ifdef PREFIX
# Line 62  Line 38 
38          %endif          %endif
39  %endmacro  %endmacro
40    
41  align 16  ;=============================================================================
42    ; Read only Local data
43    ;=============================================================================
44    
45  plus_one times 8        dw       1  %ifdef FORMAT_COFF
46    SECTION .rodata data
47    %else
48    SECTION .rodata data align=16
49    %endif
50    
51  ;===========================================================================  ALIGN 16
52    plus_one:
53            times 8 dw 1
54    
55    ;-----------------------------------------------------------------------------
56  ;  ;
57  ; subtract by Q/2 table  ; subtract by Q/2 table
58  ;  ;
59  ;===========================================================================  ;-----------------------------------------------------------------------------
60    
61  %macro MMX_SUB  1  ALIGN 16
62  times 4 dw %1 / 2  mmx_sub:
63  %endmacro  %assign quant 1
64    %rep 31
65            times 4 dw  quant / 2
66            %assign quant quant+1
67    %endrep
68    
69  align 16  ;-----------------------------------------------------------------------------
 mmx_sub  
                 MMX_SUB 1  
                 MMX_SUB 2  
                 MMX_SUB 3  
                 MMX_SUB 4  
                 MMX_SUB 5  
                 MMX_SUB 6  
                 MMX_SUB 7  
                 MMX_SUB 8  
                 MMX_SUB 9  
                 MMX_SUB 10  
                 MMX_SUB 11  
                 MMX_SUB 12  
                 MMX_SUB 13  
                 MMX_SUB 14  
                 MMX_SUB 15  
                 MMX_SUB 16  
                 MMX_SUB 17  
                 MMX_SUB 18  
                 MMX_SUB 19  
                 MMX_SUB 20  
                 MMX_SUB 21  
                 MMX_SUB 22  
                 MMX_SUB 23  
                 MMX_SUB 24  
                 MMX_SUB 25  
                 MMX_SUB 26  
                 MMX_SUB 27  
                 MMX_SUB 28  
                 MMX_SUB 29  
                 MMX_SUB 30  
                 MMX_SUB 31  
   
   
   
 ;===========================================================================  
70  ;  ;
71  ; divide by 2Q table  ; divide by 2Q table
72  ;  ;
# Line 120  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  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro MMX_DIV  1  
 times 4 dw  (1 << 16) / (%1 * 2) + 1  
 %endmacro  
78    
79  align 16  ALIGN 16
80  mmx_div  mmx_div:
81                  MMX_DIV 1  %assign quant 1
82                  MMX_DIV 2  %rep 31
83                  MMX_DIV 3          times 4 dw  (1<<16) / (quant*2) + 1
84                  MMX_DIV 4          %assign quant quant+1
85                  MMX_DIV 5  %endrep
                 MMX_DIV 6  
                 MMX_DIV 7  
                 MMX_DIV 8  
                 MMX_DIV 9  
                 MMX_DIV 10  
                 MMX_DIV 11  
                 MMX_DIV 12  
                 MMX_DIV 13  
                 MMX_DIV 14  
                 MMX_DIV 15  
                 MMX_DIV 16  
                 MMX_DIV 17  
                 MMX_DIV 18  
                 MMX_DIV 19  
                 MMX_DIV 20  
                 MMX_DIV 21  
                 MMX_DIV 22  
                 MMX_DIV 23  
                 MMX_DIV 24  
                 MMX_DIV 25  
                 MMX_DIV 26  
                 MMX_DIV 27  
                 MMX_DIV 28  
                 MMX_DIV 29  
                 MMX_DIV 30  
                 MMX_DIV 31  
86    
87    ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
88  ;  ;
89  ; add by (odd(Q) ? Q : Q - 1) table  ; add by (odd(Q) ? Q : Q - 1) table
90  ;  ;
91  ;===========================================================================  ;-----------------------------------------------------------------------------
92    
93  %macro MMX_ADD  1  ALIGN 16
94  %if %1 % 2 != 0  mmx_add:
95  times 4 dw %1  %assign quant 1
96    %rep 31
97            %if quant % 2 != 0
98            times 4 dw  quant
99  %else  %else
100  times 4 dw %1 - 1          times 4 dw quant - 1
101  %endif  %endif
102  %endmacro          %assign quant quant+1
103    %endrep
 align 16  
 mmx_add  
                 MMX_ADD 1  
                 MMX_ADD 2  
                 MMX_ADD 3  
                 MMX_ADD 4  
                 MMX_ADD 5  
                 MMX_ADD 6  
                 MMX_ADD 7  
                 MMX_ADD 8  
                 MMX_ADD 9  
                 MMX_ADD 10  
                 MMX_ADD 11  
                 MMX_ADD 12  
                 MMX_ADD 13  
                 MMX_ADD 14  
                 MMX_ADD 15  
                 MMX_ADD 16  
                 MMX_ADD 17  
                 MMX_ADD 18  
                 MMX_ADD 19  
                 MMX_ADD 20  
                 MMX_ADD 21  
                 MMX_ADD 22  
                 MMX_ADD 23  
                 MMX_ADD 24  
                 MMX_ADD 25  
                 MMX_ADD 26  
                 MMX_ADD 27  
                 MMX_ADD 28  
                 MMX_ADD 29  
                 MMX_ADD 30  
                 MMX_ADD 31  
104    
105    ;-----------------------------------------------------------------------------
 ;===========================================================================  
106  ;  ;
107  ; multiple by 2Q table  ; multiple by 2Q table
108  ;  ;
109  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro MMX_MUL  1  
 times 4 dw %1 * 2  
 %endmacro  
110    
111  align 16  ALIGN 16
112  mmx_mul  mmx_mul:
113                  MMX_MUL 1  %assign quant 1
114                  MMX_MUL 2  %rep 31
115                  MMX_MUL 3          times 4 dw  quant*2
116                  MMX_MUL 4          %assign quant quant+1
117                  MMX_MUL 5  %endrep
                 MMX_MUL 6  
                 MMX_MUL 7  
                 MMX_MUL 8  
                 MMX_MUL 9  
                 MMX_MUL 10  
                 MMX_MUL 11  
                 MMX_MUL 12  
                 MMX_MUL 13  
                 MMX_MUL 14  
                 MMX_MUL 15  
                 MMX_MUL 16  
                 MMX_MUL 17  
                 MMX_MUL 18  
                 MMX_MUL 19  
                 MMX_MUL 20  
                 MMX_MUL 21  
                 MMX_MUL 22  
                 MMX_MUL 23  
                 MMX_MUL 24  
                 MMX_MUL 25  
                 MMX_MUL 26  
                 MMX_MUL 27  
                 MMX_MUL 28  
                 MMX_MUL 29  
                 MMX_MUL 30  
                 MMX_MUL 31  
118    
119    ;-----------------------------------------------------------------------------
 ;===========================================================================  
120  ;  ;
121  ; saturation limits  ; saturation limits
122  ;  ;
123  ;===========================================================================  ;-----------------------------------------------------------------------------
124    
125    ALIGN 16
126    sse2_2047:
127            times 8 dw 2047
128    
129  align 16  ALIGN 16
130  sse2_2047       times 8 dw 2047  mmx_2047:
131            times 4 dw 2047
132    
133  align 16  ALIGN 8
134  mmx_2047        times 4 dw 2047  mmx_32768_minus_2048:
135            times 4 dw (32768-2048)
136    
137  align 8  mmx_32767_minus_2047:
138  mmx_32768_minus_2048                            times 4 dw (32768-2048)          times 4 dw (32767-2047)
 mmx_32767_minus_2047                            times 4 dw (32767-2047)  
139    
140    
141  section .text  ;=============================================================================
142    ; Code
143    ;=============================================================================
144    
145    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  ; void quant_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 302  Line 181 
181                  jz      .q1loop                  jz      .q1loop
182    
183                  movq    mm7, [mmx_div + eax * 8 - 8]                  movq    mm7, [mmx_div + eax * 8 - 8]
184  align ALIGN  
185    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]
189                  pxor    mm1, mm1                ; mm1 = 0                  pxor    mm1, mm1                ; mm1 = 0
190                  pxor    mm4, mm4                ;                  pxor    mm4, mm4                ;
191                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)
# Line 328  Line 208 
208                  jnz     .loop                  jnz     .loop
209    
210  .done  .done
         ; caclulate  data[0] // (int32_t)dcscalar)  
211    
212        ; caclulate  data[0] // (int32_t)dcscalar)
213                  mov     ecx, [esp + 12 + 16]    ; dcscalar                  mov     ecx, [esp + 12 + 16]    ; dcscalar
214                  mov     edx, ecx                  mov     edx, ecx
215                  movsx   eax, word [esi] ; data[0]                  movsx   eax, word [esi] ; data[0]
# Line 339  Line 219 
219    
220                  sub             eax, edx                  sub             eax, edx
221                  jmp             short .mul                  jmp             short .mul
222    
223  .gtzero  .gtzero
224                  add             eax, edx                  add             eax, edx
225  .mul  .mul
226                  cdq                             ; expand eax -> edx:eax                  cdq                             ; expand eax -> edx:eax
227                  idiv    ecx                     ; eax = edx:eax / dcscalar                  idiv    ecx                     ; eax = edx:eax / dcscalar
   
228                  mov     [edi], ax               ; coeff[0] = ax                  mov     [edi], ax               ; coeff[0] = ax
229    
230      xor eax, eax      ; return(0);
231                  pop     edi                  pop     edi
232                  pop     esi                  pop     esi
233                  pop     ecx                  pop     ecx
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]
241                  pxor    mm1, mm1                ; mm1 = 0                  pxor    mm1, mm1                ; mm1 = 0
242                  pxor    mm4, mm4                ;                  pxor    mm4, mm4                ;
243                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)
# Line 368  Line 249 
249                  psrlw   mm0, 1                  ; mm0 >>= 1   (/2)                  psrlw   mm0, 1                  ; mm0 >>= 1   (/2)
250                  psrlw   mm3, 1                  ;                  psrlw   mm3, 1                  ;
251                  pxor    mm0, mm1                ; mm0 *= sign(mm0)                  pxor    mm0, mm1                ; mm0 *= sign(mm0)
252                  pxor    mm3, mm4        ;    pxor mm3, mm4
253                  psubw   mm0, mm1                ; undisplace                  psubw   mm0, mm1                ; undisplace
254                  psubw   mm3, mm4                ;                  psubw   mm3, mm4                ;
255                  movq    [edi + 8*ecx], mm0                  movq    [edi + 8*ecx], mm0
# Line 381  Line 262 
262    
263    
264    
265  ;===========================================================================  ;-----------------------------------------------------------------------------
266  ;  ;
267  ; void quant_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 410  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 445  Line 326 
326    
327                  sub             eax, edx                  sub             eax, edx
328                  jmp             short .qas2_mul                  jmp             short .qas2_mul
329    
330  .qas2_gtzero  .qas2_gtzero
331                  add             eax, edx                  add             eax, edx
332    
333  .qas2_mul  .qas2_mul
334                  cdq                  cdq
335                  idiv    ecx                  idiv    ecx
336    
337                  mov             [edi], ax                  mov             [edi], ax
338    
339      xor eax, eax      ; return(0);
340                  pop             edi                  pop             edi
341                  pop             esi                  pop             esi
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 486  Line 370 
370    
371    
372    
373  ;===========================================================================  ;-----------------------------------------------------------------------------
374  ;  ;
375  ; uint32_t quant_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 516  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]
407                  pxor    mm1, mm1                ; mm1 = 0                  pxor    mm1, mm1                ; mm1 = 0
408                  pxor    mm4, mm4                ;                  pxor    mm4, mm4                ;
409                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)
# Line 550  Line 434 
434                  movq    mm0, mm5                  movq    mm0, mm5
435                  psrlq   mm5, 32                  psrlq   mm5, 32
436                  paddd   mm0, mm5                  paddd   mm0, mm5
                 movd    eax, mm0                ; return sum  
437    
438      movd eax, mm0     ; return sum
439                  pop     edi                  pop     edi
440                  pop     esi                  pop     esi
441                  pop ecx                  pop ecx
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 591  Line 475 
475    
476    
477    
478  ;===========================================================================  ;-----------------------------------------------------------------------------
479  ;  ;
480  ; uint32_t quant_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 626  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 665  Line 549 
549                  movq    mm5, mm0                  movq    mm5, mm0
550                  psrlq   mm5, 32                  psrlq   mm5, 32
551                  paddd   mm0, mm5                  paddd   mm0, mm5
552    
553                  movd    eax, mm0                                        ; return sum                  movd    eax, mm0                                        ; return sum
554    
555                  pop             edi                  pop             edi
# Line 672  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 703  Line 588 
588                  jmp             .qes2_done                  jmp             .qes2_done
589    
590    
591  ;===========================================================================  ;-----------------------------------------------------------------------------
592  ;  ;
593  ; void dequant_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 726  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 766  Line 651 
651    jnz   near .loop    jnz   near .loop
652    
653      ; deal with DC      ; deal with DC
   
654    movd mm0, [ecx]    movd mm0, [ecx]
655    pmullw mm0, [esp+16]    ; dcscalar    pmullw mm0, [esp+16]    ; dcscalar
656    movq mm2, [mmx_32767_minus_2047]    movq mm2, [mmx_32767_minus_2047]
# Line 778  Line 662 
662    movd eax, mm0    movd eax, mm0
663    mov [edx], ax    mov [edx], ax
664    
665      xor eax, eax              ; return(0);
666    ret    ret
667    
668  ;===========================================================================  ;-----------------------------------------------------------------------------
669  ;  ;
670  ; void dequant_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 803  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 841  Line 726 
726    jnz   near .loop    jnz   near .loop
727    
728      ; deal with DC      ; deal with DC
   
729    movd mm0, [ecx]    movd mm0, [ecx]
730    pmullw mm0, [esp+16]    ; dcscalar    pmullw mm0, [esp+16]    ; dcscalar
731    movq mm2, [mmx_32767_minus_2047]    movq mm2, [mmx_32767_minus_2047]
# Line 853  Line 737 
737    movd eax, mm0    movd eax, mm0
738    mov [edx], ax    mov [edx], ax
739    
740      xor eax, eax
741    ret    ret
742    
743    
744  ;===========================================================================  ;-----------------------------------------------------------------------------
745  ;  ;
746  ; void dequant_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  align ALIGN  
754  cglobal dequant_h263_intra_sse2  ALIGN 16
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 878  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 927  Line 813 
813          movd eax, mm0          movd eax, mm0
814          mov [edx], ax          mov [edx], ax
815    
816      xor eax, eax
817          ret          ret
818    
819    ;-----------------------------------------------------------------------------
   
   
 ;===========================================================================  
820  ;  ;
821  ; void dequant_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 951  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 975  Line 859 
859    paddw mm3, mm5 ; + offset    paddw mm3, mm5 ; + offset
860    paddw mm0, mm1 ; negate back    paddw mm0, mm1 ; negate back
861    paddw mm3, mm4 ; negate back    paddw mm3, mm4 ; negate back
   
862      ; saturates to +2047      ; saturates to +2047
863    movq mm2, [mmx_32767_minus_2047]    movq mm2, [mmx_32767_minus_2047]
864    add eax, 2    add eax, 2
# Line 990  Line 873 
873    movq [edx + 8*eax + 8*16+8 - 2*8], mm3    movq [edx + 8*eax + 8*16+8 - 2*8], mm3
874    jnz   near .loop    jnz   near .loop
875    
876      xor eax, eax
877    ret    ret
878    
879  ;===========================================================================  ;-----------------------------------------------------------------------------
880  ;  ;
881  ; void dequant_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 1014  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 1038  Line 922 
922    paddw mm3, mm5 ; + offset    paddw mm3, mm5 ; + offset
923    paddw mm0, mm1 ; start restoring sign    paddw mm0, mm1 ; start restoring sign
924    paddw mm3, mm4 ; start restoring sign    paddw mm3, mm4 ; start restoring sign
   
925        ; saturates to +2047        ; saturates to +2047
926    movq mm2, [mmx_2047]    movq mm2, [mmx_2047]
927    pminsw mm0, mm2    pminsw mm0, mm2
# Line 1051  Line 934 
934    movq [edx + 8*eax + 8*16+8 - 2*8], mm3    movq [edx + 8*eax + 8*16+8 - 2*8], mm3
935    jnz   near .loop    jnz   near .loop
936    
937      xor eax, eax
938    ret    ret
939    
940  ;===========================================================================  ;-----------------------------------------------------------------------------
941  ;  ;
942  ; void dequant_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  align ALIGN  
949  cglobal dequant_h263_inter_sse2  ALIGN 16
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 1074  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]
# Line 1113  Line 998 
998          movdqa [edx + 8*16 - 8*4 + 8*eax + 16], xmm3          movdqa [edx + 8*16 - 8*4 + 8*eax + 16], xmm3
999          jnz     near .loop          jnz     near .loop
1000    
1001      xor eax, eax
1002          ret          ret

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

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