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

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

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

revision 1174, Tue Oct 7 13:02:35 2003 UTC revision 1192, Tue Oct 28 22:23:03 2003 UTC
# Line 1  Line 1 
1  ;/**************************************************************************  ;/*****************************************************************************
2  ; *  ; *
3  ; *     XVID MPEG-4 VIDEO CODEC  ; *     XVID MPEG-4 VIDEO CODEC
4  ; *     mmx quantization/dequantization  ; *  - 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: quantize_h263_mmx.asm,v 1.1.2.3 2003-10-28 22:23:03 edgomez Exp $
   
 ;/**************************************************************************  
 ; *  
 ; *     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    SECTION .rodata
46    
47  plus_one times 8        dw       1  ALIGN 16
48    plus_one:
49            times 8 dw 1
50    
51  ;===========================================================================  ;-----------------------------------------------------------------------------
52  ;  ;
53  ; subtract by Q/2 table  ; subtract by Q/2 table
54  ;  ;
55  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro MMX_SUB  1  
 times 4 dw %1 / 2  
 %endmacro  
56    
57  align 16  ALIGN 16
58  mmx_sub  mmx_sub:
59                  MMX_SUB 1  %assign quant 1
60                  MMX_SUB 2  %rep 31
61                  MMX_SUB 3          times 4 dw  quant / 2
62                  MMX_SUB 4          %assign quant quant+1
63                  MMX_SUB 5  %endrep
                 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  
64    
65    ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
66  ;  ;
67  ; divide by 2Q table  ; divide by 2Q table
68  ;  ;
# Line 120  Line 70 
70  ; for q=1, _pmulhw_ will overflow so it is treated seperately  ; for q=1, _pmulhw_ will overflow so it is treated seperately
71  ; (3dnow2 provides _pmulhuw_ which wont cause overflow)  ; (3dnow2 provides _pmulhuw_ which wont cause overflow)
72  ;  ;
73  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro MMX_DIV  1  
 times 4 dw  (1 << 16) / (%1 * 2) + 1  
 %endmacro  
74    
75  align 16  ALIGN 16
76  mmx_div  mmx_div:
77                  MMX_DIV 1  %assign quant 1
78                  MMX_DIV 2  %rep 31
79                  MMX_DIV 3          times 4 dw  (1<<16) / (quant*2) + 1
80                  MMX_DIV 4          %assign quant quant+1
81                  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  
82    
83    ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
84  ;  ;
85  ; add by (odd(Q) ? Q : Q - 1) table  ; add by (odd(Q) ? Q : Q - 1) table
86  ;  ;
87  ;===========================================================================  ;-----------------------------------------------------------------------------
88    
89  %macro MMX_ADD  1  ALIGN 16
90  %if %1 % 2 != 0  mmx_add:
91  times 4 dw %1  %assign quant 1
92    %rep 31
93            %if quant % 2 != 0
94            times 4 dw  quant
95  %else  %else
96  times 4 dw %1 - 1          times 4 dw quant - 1
97  %endif  %endif
98  %endmacro          %assign quant quant+1
99    %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  
100    
101    ;-----------------------------------------------------------------------------
 ;===========================================================================  
102  ;  ;
103  ; multiple by 2Q table  ; multiple by 2Q table
104  ;  ;
105  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro MMX_MUL  1  
 times 4 dw %1 * 2  
 %endmacro  
106    
107  align 16  ALIGN 16
108  mmx_mul  mmx_mul:
109                  MMX_MUL 1  %assign quant 1
110                  MMX_MUL 2  %rep 31
111                  MMX_MUL 3          times 4 dw  quant*2
112                  MMX_MUL 4          %assign quant quant+1
113                  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  
114    
115    ;-----------------------------------------------------------------------------
 ;===========================================================================  
116  ;  ;
117  ; saturation limits  ; saturation limits
118  ;  ;
119  ;===========================================================================  ;-----------------------------------------------------------------------------
120    
121    ALIGN 16
122    sse2_2047:
123            times 8 dw 2047
124    
125  align 16  ALIGN 16
126  sse2_2047       times 8 dw 2047  mmx_2047:
127            times 4 dw 2047
128    
129  align 16  ALIGN 8
130  mmx_2047        times 4 dw 2047  mmx_32768_minus_2048:
131            times 4 dw (32768-2048)
132    
133  align 8  mmx_32767_minus_2047:
134  mmx_32768_minus_2048                            times 4 dw (32768-2048)          times 4 dw (32767-2047)
 mmx_32767_minus_2047                            times 4 dw (32767-2047)  
135    
136    
137  section .text  ;=============================================================================
138    ; Code
139    ;=============================================================================
140    
141    SECTION .text
142    
143  ;===========================================================================  cglobal quant_h263_intra_mmx
144    cglobal quant_h263_intra_sse2
145    cglobal quant_h263_inter_mmx
146    cglobal quant_h263_inter_sse2
147    cglobal dequant_h263_intra_mmx
148    cglobal dequant_h263_intra_xmm
149    cglobal dequant_h263_intra_sse2
150    cglobal dequant_h263_inter_mmx
151    cglobal dequant_h263_inter_xmm
152    cglobal dequant_h263_inter_sse2
153    
154    ;-----------------------------------------------------------------------------
155  ;  ;
156  ; void quant_intra_mmx(int16_t * coeff,  ; uint32_t quant_h263_intra_mmx(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    
163  align ALIGN  ALIGN 16
 cglobal quant_h263_intra_mmx  
164  quant_h263_intra_mmx:  quant_h263_intra_mmx:
165    
166                  push    ecx                  push    ecx
# Line 302  Line 176 
176                  jz      .q1loop                  jz      .q1loop
177    
178                  movq    mm7, [mmx_div + eax * 8 - 8]                  movq    mm7, [mmx_div + eax * 8 - 8]
179  align ALIGN  
180    ALIGN 16
181  .loop  .loop
182                  movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]                  movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]
183                  movq    mm3, [esi + 8*ecx + 8]  ;    movq mm3, [esi + 8*ecx + 8]
184                  pxor    mm1, mm1                ; mm1 = 0                  pxor    mm1, mm1                ; mm1 = 0
185                  pxor    mm4, mm4                ;                  pxor    mm4, mm4                ;
186                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)
# Line 328  Line 203 
203                  jnz     .loop                  jnz     .loop
204    
205  .done  .done
         ; caclulate  data[0] // (int32_t)dcscalar)  
206    
207        ; caclulate  data[0] // (int32_t)dcscalar)
208                  mov     ecx, [esp + 12 + 16]    ; dcscalar                  mov     ecx, [esp + 12 + 16]    ; dcscalar
209                  mov     edx, ecx                  mov     edx, ecx
210                  movsx   eax, word [esi] ; data[0]                  movsx   eax, word [esi] ; data[0]
# Line 339  Line 214 
214    
215                  sub             eax, edx                  sub             eax, edx
216                  jmp             short .mul                  jmp             short .mul
217    
218  .gtzero  .gtzero
219                  add             eax, edx                  add             eax, edx
220  .mul  .mul
221                  cdq                             ; expand eax -> edx:eax                  cdq                             ; expand eax -> edx:eax
222                  idiv    ecx                     ; eax = edx:eax / dcscalar                  idiv    ecx                     ; eax = edx:eax / dcscalar
   
223                  mov     [edi], ax               ; coeff[0] = ax                  mov     [edi], ax               ; coeff[0] = ax
224    
225      xor eax, eax      ; return(0);
226                  pop     edi                  pop     edi
227                  pop     esi                  pop     esi
228                  pop     ecx                  pop     ecx
229    
230                  ret                  ret
231    
232  align ALIGN  ALIGN 16
233  .q1loop  .q1loop
234                  movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]                  movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]
235                  movq    mm3, [esi + 8*ecx + 8]  ;    movq mm3, [esi + 8*ecx + 8]
236                  pxor    mm1, mm1                ; mm1 = 0                  pxor    mm1, mm1                ; mm1 = 0
237                  pxor    mm4, mm4                ;                  pxor    mm4, mm4                ;
238                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)
# Line 368  Line 244 
244                  psrlw   mm0, 1                  ; mm0 >>= 1   (/2)                  psrlw   mm0, 1                  ; mm0 >>= 1   (/2)
245                  psrlw   mm3, 1                  ;                  psrlw   mm3, 1                  ;
246                  pxor    mm0, mm1                ; mm0 *= sign(mm0)                  pxor    mm0, mm1                ; mm0 *= sign(mm0)
247                  pxor    mm3, mm4        ;    pxor mm3, mm4
248                  psubw   mm0, mm1                ; undisplace                  psubw   mm0, mm1                ; undisplace
249                  psubw   mm3, mm4                ;                  psubw   mm3, mm4                ;
250                  movq    [edi + 8*ecx], mm0                  movq    [edi + 8*ecx], mm0
# Line 381  Line 257 
257    
258    
259    
260  ;===========================================================================  ;-----------------------------------------------------------------------------
261  ;  ;
262  ; void quant_intra_sse2(int16_t * coeff,  ; uint32_t quant_h263_intra_sse2(int16_t * coeff,
263  ;                                       const int16_t const * data,  ;                                       const int16_t const * data,
264  ;                                       const uint32_t quant,  ;                                       const uint32_t quant,
265  ;                                       const uint32_t dcscalar);  ;                                       const uint32_t dcscalar);
266  ;  ;
267  ;===========================================================================  ;-----------------------------------------------------------------------------
268    
269  align ALIGN  ALIGN 16
 cglobal quant_h263_intra_sse2  
270  quant_h263_intra_sse2:  quant_h263_intra_sse2:
271    
272                  push    esi                  push    esi
# Line 410  Line 285 
285                  movq2dq xmm7, mm7                  movq2dq xmm7, mm7
286                  movlhps xmm7, xmm7                  movlhps xmm7, xmm7
287    
288  align 16  ALIGN 16
289  .qas2_loop  .qas2_loop
290                  movdqa  xmm0, [esi + ecx*8]                     ; xmm0 = [1st]                  movdqa  xmm0, [esi + ecx*8]                     ; xmm0 = [1st]
291                  movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]                  movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]
# Line 445  Line 320 
320    
321                  sub             eax, edx                  sub             eax, edx
322                  jmp             short .qas2_mul                  jmp             short .qas2_mul
323    
324  .qas2_gtzero  .qas2_gtzero
325                  add             eax, edx                  add             eax, edx
326    
327  .qas2_mul  .qas2_mul
328                  cdq                  cdq
329                  idiv    ecx                  idiv    ecx
330    
331                  mov             [edi], ax                  mov             [edi], ax
332    
333      xor eax, eax      ; return(0);
334                  pop             edi                  pop             edi
335                  pop             esi                  pop             esi
336    
337                  ret                  ret
338    
339  align 16  ALIGN 16
340  .qas2_q1loop  .qas2_q1loop
341                  movdqa  xmm0, [esi + ecx*8]                     ; xmm0 = [1st]                  movdqa  xmm0, [esi + ecx*8]                     ; xmm0 = [1st]
342                  movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]                  movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]
# Line 486  Line 364 
364    
365    
366    
367  ;===========================================================================  ;-----------------------------------------------------------------------------
368  ;  ;
369  ; uint32_t quant_inter_mmx(int16_t * coeff,  ; uint32_t quant_h263_inter_mmx(int16_t * coeff,
370  ;                                       const int16_t const * data,  ;                                       const int16_t const * data,
371  ;                                       const uint32_t quant);  ;                                       const uint32_t quant);
372  ;  ;
373  ;===========================================================================  ;-----------------------------------------------------------------------------
374    
375  align ALIGN  ALIGN 16
 cglobal quant_h263_inter_mmx  
376  quant_h263_inter_mmx:  quant_h263_inter_mmx:
377    
378                  push    ecx                  push    ecx
# Line 516  Line 393 
393    
394                  movq    mm7, [mmx_div + eax * 8 - 8]    ; divider                  movq    mm7, [mmx_div + eax * 8 - 8]    ; divider
395    
396  align ALIGN  ALIGN 8
397  .loop  .loop
398                  movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]                  movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]
399                  movq    mm3, [esi + 8*ecx + 8]  ;    movq mm3, [esi + 8*ecx + 8]
400                  pxor    mm1, mm1                ; mm1 = 0                  pxor    mm1, mm1                ; mm1 = 0
401                  pxor    mm4, mm4                ;                  pxor    mm4, mm4                ;
402                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)
# Line 550  Line 427 
427                  movq    mm0, mm5                  movq    mm0, mm5
428                  psrlq   mm5, 32                  psrlq   mm5, 32
429                  paddd   mm0, mm5                  paddd   mm0, mm5
                 movd    eax, mm0                ; return sum  
430    
431      movd eax, mm0     ; return sum
432                  pop     edi                  pop     edi
433                  pop     esi                  pop     esi
434                  pop ecx                  pop ecx
435    
436                  ret                  ret
437    
438  align ALIGN  ALIGN 8
439  .q1loop  .q1loop
440                  movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]                  movq    mm0, [esi + 8*ecx]              ; mm0 = [1st]
441                  movq    mm3, [esi + 8*ecx+ 8]           ;                  movq    mm3, [esi + 8*ecx+ 8]           ;
# Line 591  Line 468 
468    
469    
470    
471  ;===========================================================================  ;-----------------------------------------------------------------------------
472  ;  ;
473  ; uint32_t quant_inter_sse2(int16_t * coeff,  ; uint32_t quant_h263_inter_sse2(int16_t * coeff,
474  ;                                       const int16_t const * data,  ;                                       const int16_t const * data,
475  ;                                       const uint32_t quant);  ;                                       const uint32_t quant);
476  ;  ;
477  ;===========================================================================  ;-----------------------------------------------------------------------------
478    
479  align 16  ALIGN 16
 cglobal quant_h263_inter_sse2  
480  quant_h263_inter_sse2:  quant_h263_inter_sse2:
481    
482                  push    esi                  push    esi
# Line 626  Line 502 
502                  movq2dq xmm7, mm0                  movq2dq xmm7, mm0
503                  movlhps xmm7, xmm7                  movlhps xmm7, xmm7
504    
505  align 16  ALIGN 16
506  .qes2_loop  .qes2_loop
507                  movdqa  xmm0, [esi + ecx*8]                     ; xmm0 = [1st]                  movdqa  xmm0, [esi + ecx*8]                     ; xmm0 = [1st]
508                  movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]                  movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]
# Line 665  Line 541 
541                  movq    mm5, mm0                  movq    mm5, mm0
542                  psrlq   mm5, 32                  psrlq   mm5, 32
543                  paddd   mm0, mm5                  paddd   mm0, mm5
544    
545                  movd    eax, mm0                                        ; return sum                  movd    eax, mm0                                        ; return sum
546    
547                  pop             edi                  pop             edi
# Line 672  Line 549 
549    
550                  ret                  ret
551    
552  align 16  ALIGN 16
553  .qes2_q1loop  .qes2_q1loop
554                  movdqa  xmm0, [esi + ecx*8]                     ; xmm0 = [1st]                  movdqa  xmm0, [esi + ecx*8]                     ; xmm0 = [1st]
555                  movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]                  movdqa  xmm3, [esi + ecx*8 + 16]        ; xmm3 = [2nd]
# Line 703  Line 580 
580                  jmp             .qes2_done                  jmp             .qes2_done
581    
582    
583  ;===========================================================================  ;-----------------------------------------------------------------------------
584  ;  ;
585  ; void dequant_intra_mmx(int16_t *data,  ; uint32_t dequant_h263_intra_mmx(int16_t *data,
586  ;                                       const int16_t const *coeff,  ;                                       const int16_t const *coeff,
587  ;                                       const uint32_t quant,  ;                                       const uint32_t quant,
588  ;                                       const uint32_t dcscalar);  ;                                       const uint32_t dcscalar);
589  ;  ;
590  ;===========================================================================  ;-----------------------------------------------------------------------------
591    
592    ; note: we only saturate to +2047 *before* restoring the sign.    ; note: we only saturate to +2047 *before* restoring the sign.
593    ; Hence, final clamp really is [-2048,2047]    ; Hence, final clamp really is [-2048,2047]
594    
595  align ALIGN  ALIGN 16
 cglobal dequant_h263_intra_mmx  
596  dequant_h263_intra_mmx:  dequant_h263_intra_mmx:
597    
598    mov    edx, [esp+ 4]        ; data    mov    edx, [esp+ 4]        ; data
# Line 726  Line 602 
602    movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant    movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
603    mov eax, -16    mov eax, -16
604    
605  align ALIGN  ALIGN 16
606  .loop  .loop
607    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
608    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 642 
642    jnz   near .loop    jnz   near .loop
643    
644      ; deal with DC      ; deal with DC
   
645    movd mm0, [ecx]    movd mm0, [ecx]
646    pmullw mm0, [esp+16]    ; dcscalar    pmullw mm0, [esp+16]    ; dcscalar
647    movq mm2, [mmx_32767_minus_2047]    movq mm2, [mmx_32767_minus_2047]
# Line 778  Line 653 
653    movd eax, mm0    movd eax, mm0
654    mov [edx], ax    mov [edx], ax
655    
656      xor eax, eax              ; return(0);
657    ret    ret
658    
659  ;===========================================================================  ;-----------------------------------------------------------------------------
660  ;  ;
661  ; void dequant_intra_xmm(int16_t *data,  ; uint32_t dequant_h263_intra_xmm(int16_t *data,
662  ;                                       const int16_t const *coeff,  ;                                       const int16_t const *coeff,
663  ;                                       const uint32_t quant,  ;                                       const uint32_t quant,
664  ;                                       const uint32_t dcscalar);  ;                                       const uint32_t dcscalar);
665  ;  ;
666  ;===========================================================================  ;-----------------------------------------------------------------------------
667    
668    ; this is the same as dequant_inter_mmx, except that we're    ; this is the same as dequant_inter_mmx, except that we're
669    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)    ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)
670    
671  align ALIGN  ALIGN 16
 cglobal dequant_h263_intra_xmm  
672  dequant_h263_intra_xmm:  dequant_h263_intra_xmm:
673    
674    mov    edx, [esp+ 4]        ; data    mov    edx, [esp+ 4]        ; data
# Line 803  Line 678 
678    movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant    movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
679    mov eax, -16    mov eax, -16
680    
681  align ALIGN  ALIGN 16
682  .loop  .loop
683    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
684    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 716 
716    jnz   near .loop    jnz   near .loop
717    
718      ; deal with DC      ; deal with DC
   
719    movd mm0, [ecx]    movd mm0, [ecx]
720    pmullw mm0, [esp+16]    ; dcscalar    pmullw mm0, [esp+16]    ; dcscalar
721    movq mm2, [mmx_32767_minus_2047]    movq mm2, [mmx_32767_minus_2047]
# Line 853  Line 727 
727    movd eax, mm0    movd eax, mm0
728    mov [edx], ax    mov [edx], ax
729    
730      xor eax, eax
731    ret    ret
732    
733    
734  ;===========================================================================  ;-----------------------------------------------------------------------------
735  ;  ;
736  ; void dequant_intra_sse2(int16_t *data,  ; uint32_t dequant_h263_intra_sse2(int16_t *data,
737  ;                                       const int16_t const *coeff,  ;                                       const int16_t const *coeff,
738  ;                                       const uint32_t quant,  ;                                       const uint32_t quant,
739  ;                                       const uint32_t dcscalar);  ;                                       const uint32_t dcscalar);
740  ;  ;
741  ;===========================================================================  ;-----------------------------------------------------------------------------
742  align ALIGN  
743  cglobal dequant_h263_intra_sse2  ALIGN 16
744  dequant_h263_intra_sse2:  dequant_h263_intra_sse2:
745          mov edx, [esp+ 4]        ; data          mov edx, [esp+ 4]        ; data
746          mov ecx, [esp+ 8]        ; coeff          mov ecx, [esp+ 8]        ; coeff
# Line 878  Line 753 
753          movlhps xmm7, xmm7          movlhps xmm7, xmm7
754          mov eax, -16          mov eax, -16
755    
756  align ALIGN  ALIGN 16
757  .loop  .loop
758          movdqa xmm0, [ecx + 8*16 + 8*eax]      ; c  = coeff[i]          movdqa xmm0, [ecx + 8*16 + 8*eax]      ; c  = coeff[i]
759          movdqa xmm3, [ecx + 8*16 + 8*eax+ 16]          movdqa xmm3, [ecx + 8*16 + 8*eax+ 16]
# Line 927  Line 802 
802          movd eax, mm0          movd eax, mm0
803          mov [edx], ax          mov [edx], ax
804    
805      xor eax, eax
806          ret          ret
807    
808    ;-----------------------------------------------------------------------------
   
   
 ;===========================================================================  
809  ;  ;
810  ; void dequant_inter_mmx(int16_t * data,  ; uint32t dequant_h263_inter_mmx(int16_t * data,
811  ;                                       const int16_t * const coeff,  ;                                       const int16_t * const coeff,
812  ;                                       const uint32_t quant);  ;                                       const uint32_t quant);
813  ;  ;
814  ;===========================================================================  ;-----------------------------------------------------------------------------
815    
816  align ALIGN  ALIGN 16
 cglobal dequant_h263_inter_mmx  
817  dequant_h263_inter_mmx:  dequant_h263_inter_mmx:
818    
819    mov    edx, [esp+ 4]        ; data    mov    edx, [esp+ 4]        ; data
# Line 951  Line 823 
823    movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant    movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
824    mov eax, -16    mov eax, -16
825    
826  align ALIGN  ALIGN 16
827  .loop  .loop
828    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
829    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 847 
847    paddw mm3, mm5 ; + offset    paddw mm3, mm5 ; + offset
848    paddw mm0, mm1 ; negate back    paddw mm0, mm1 ; negate back
849    paddw mm3, mm4 ; negate back    paddw mm3, mm4 ; negate back
   
850      ; saturates to +2047      ; saturates to +2047
851    movq mm2, [mmx_32767_minus_2047]    movq mm2, [mmx_32767_minus_2047]
852    add eax, 2    add eax, 2
# Line 990  Line 861 
861    movq [edx + 8*eax + 8*16+8 - 2*8], mm3    movq [edx + 8*eax + 8*16+8 - 2*8], mm3
862    jnz   near .loop    jnz   near .loop
863    
864      xor eax, eax
865    ret    ret
866    
867  ;===========================================================================  ;-----------------------------------------------------------------------------
868  ;  ;
869  ; void dequant_inter_xmm(int16_t * data,  ; uint32_t dequant_h263_inter_xmm(int16_t * data,
870  ;                                       const int16_t * const coeff,  ;                                       const int16_t * const coeff,
871  ;                                       const uint32_t quant);  ;                                       const uint32_t quant);
872  ;  ;
873  ;===========================================================================  ;-----------------------------------------------------------------------------
874    
875    ; this is the same as dequant_inter_mmx,    ; this is the same as dequant_inter_mmx,
876    ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)    ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)
877    
878  align ALIGN  ALIGN 16
 cglobal dequant_h263_inter_xmm  
879  dequant_h263_inter_xmm:  dequant_h263_inter_xmm:
880    
881    mov    edx, [esp+ 4]        ; data    mov    edx, [esp+ 4]        ; data
# Line 1014  Line 885 
885    movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant    movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
886    mov eax, -16    mov eax, -16
887    
888  align ALIGN  ALIGN 16
889  .loop  .loop
890    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
891    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 909 
909    paddw mm3, mm5 ; + offset    paddw mm3, mm5 ; + offset
910    paddw mm0, mm1 ; start restoring sign    paddw mm0, mm1 ; start restoring sign
911    paddw mm3, mm4 ; start restoring sign    paddw mm3, mm4 ; start restoring sign
   
912        ; saturates to +2047        ; saturates to +2047
913    movq mm2, [mmx_2047]    movq mm2, [mmx_2047]
914    pminsw mm0, mm2    pminsw mm0, mm2
# Line 1051  Line 921 
921    movq [edx + 8*eax + 8*16+8 - 2*8], mm3    movq [edx + 8*eax + 8*16+8 - 2*8], mm3
922    jnz   near .loop    jnz   near .loop
923    
924      xor eax, eax
925    ret    ret
926    
927  ;===========================================================================  ;-----------------------------------------------------------------------------
928  ;  ;
929  ; void dequant_inter_sse2(int16_t * data,  ; uint32_t dequant_h263_inter_sse2(int16_t * data,
930  ;                                       const int16_t * const coeff,  ;                                       const int16_t * const coeff,
931  ;                                       const uint32_t quant);  ;                                       const uint32_t quant);
932  ;  ;
933  ;===========================================================================  ;-----------------------------------------------------------------------------
934  align ALIGN  
935  cglobal dequant_h263_inter_sse2  ALIGN 16
936  dequant_h263_inter_sse2:  dequant_h263_inter_sse2:
937          mov edx, [esp + 4]      ; data          mov edx, [esp + 4]      ; data
938          mov ecx, [esp + 8]      ; coeff          mov ecx, [esp + 8]      ; coeff
# Line 1074  Line 945 
945          movlhps xmm7, xmm7          movlhps xmm7, xmm7
946          mov eax, -16          mov eax, -16
947    
948  align ALIGN  ALIGN 16
949  .loop  .loop
950          movdqa xmm0, [ecx + 8*16 + 8*eax]  ; c  = coeff[i]          movdqa xmm0, [ecx + 8*16 + 8*eax]  ; c  = coeff[i]
951          movdqa xmm3, [ecx + 8*16 + 8*eax + 16]          movdqa xmm3, [ecx + 8*16 + 8*eax + 16]
# Line 1113  Line 984 
984          movdqa [edx + 8*16 - 8*4 + 8*eax + 16], xmm3          movdqa [edx + 8*16 - 8*4 + 8*eax + 16], xmm3
985          jnz     near .loop          jnz     near .loop
986    
987      xor eax, eax
988          ret          ret

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

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