[svn] / branches / release-1_2-branch / xvidcore / src / quant / x86_asm / quantize_mpeg_xmm.asm Repository:
ViewVC logotype

Diff of /branches/release-1_2-branch/xvidcore/src/quant/x86_asm/quantize_mpeg_xmm.asm

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

revision 1540, Sun Aug 29 10:02:38 2004 UTC revision 1793, Tue Nov 11 20:46:24 2008 UTC
# Line 20  Line 20 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22  ; *  ; *
23  ; * $Id: quantize_mpeg_xmm.asm,v 1.5 2004-08-29 10:02:38 edgomez Exp $  ; * $Id: quantize_mpeg_xmm.asm,v 1.8 2008-11-11 20:46:24 Isibaar Exp $
24  ; *  ; *
25  ; ***************************************************************************/  ; ***************************************************************************/
26    
# Line 36  Line 36 
36                  %ifdef MARK_FUNCS                  %ifdef MARK_FUNCS
37                          global _%1:function %1.endfunc-%1                          global _%1:function %1.endfunc-%1
38                          %define %1 _%1:function %1.endfunc-%1                          %define %1 _%1:function %1.endfunc-%1
39                            %define ENDFUNC .endfunc
40                  %else                  %else
41                          global _%1                          global _%1
42                          %define %1 _%1                          %define %1 _%1
43                            %define ENDFUNC
44                  %endif                  %endif
45          %else          %else
46                  %ifdef MARK_FUNCS                  %ifdef MARK_FUNCS
47                          global %1:function %1.endfunc-%1                          global %1:function %1.endfunc-%1
48                            %define ENDFUNC .endfunc
49                  %else                  %else
50                          global %1                          global %1
51                            %define ENDFUNC
52                  %endif                  %endif
53          %endif          %endif
54  %endmacro  %endmacro
# Line 165  Line 169 
169    
170  SECTION .text  SECTION .text
171    
 cglobal quant_mpeg_intra_xmm  
172  cglobal quant_mpeg_inter_xmm  cglobal quant_mpeg_inter_xmm
173  cglobal dequant_mpeg_intra_3dne  cglobal dequant_mpeg_intra_3dne
174  cglobal dequant_mpeg_inter_3dne  cglobal dequant_mpeg_inter_3dne
175    
176  ;-----------------------------------------------------------------------------  ;-----------------------------------------------------------------------------
177  ;  ;
 ; uint32_t quant_mpeg_intra_xmm(int16_t * coeff,  
 ;                               const int16_t const * data,  
 ;                               const uint32_t quant,  
 ;                               const uint32_t dcscalar,  
 ;                               const uint16_t *mpeg_matrices);  
 ;  
 ;-----------------------------------------------------------------------------  
   
 ALIGN 16  
 quant_mpeg_intra_xmm:  
   mov eax, [esp  + 8]       ; data  
   mov ecx, [esp  + 12]      ; quant  
   mov edx, [esp  + 4]       ; coeff  
   push esi  
   push edi  
   push ebx  
   nop  
   mov edi, [esp + 12 + 20]              ; mpeg_quant_matrices  
   mov esi, -14  
   pxor mm0, mm0  
   pxor mm3, mm3  
   cmp ecx, byte 1  
   je near .q1loop  
   cmp ecx, byte 19  
   jg near .lloop  
   nop6  
   
 ALIGN 16  
 .loop  
   movq mm1, [eax + 8*esi+112]   ; mm0 = [1st]  
   psubw mm0, mm1                ;-mm1  
   movq mm4, [eax + 8*esi + 120] ;  
   psubw mm3, mm4                ;-mm4  
   pmaxsw mm0, mm1               ;|src|  
   pmaxsw mm3,mm4  
   nop2  
   psraw mm1, 15     ;sign src  
   psraw mm4, 15  
   psllw mm0, 4      ;level << 4 ;  
   psllw mm3, 4  
   paddw mm0, [edi + 128 + 8*esi+112]  
   paddw mm3, [edi + 128 + 8*esi+120]  
   movq mm5, [edi + 384 + 8*esi+112]  
   movq mm7, [edi + 384 + 8*esi+120]  
   pmulhuw mm5, mm0  
   pmulhuw mm7, mm3  
   mov esp, esp  
   movq mm2, [edi + 8*esi+112]  
   movq mm6, [edi + 8*esi+120]  
   pmullw mm2, mm5  
   pmullw mm6, mm7  
   psubw mm0, mm2  
   psubw mm3, mm6  
   nop4  
   movq mm2, [quantd + ecx * 8 - 8]  
   movq mm6, [mmx_divs + ecx * 8 - 8]  
   paddw mm5, mm2  
   paddw mm7, mm2  
   mov esp, esp  
   pmulhuw mm0, [edi + 256 + 8*esi+112]  
   pmulhuw mm3, [edi + 256 + 8*esi+120]  
   paddw mm5, mm0  
   paddw mm7, mm3  
   pxor mm0, mm0  
   pxor mm3, mm3  
   pmulhuw mm5, mm6      ; mm0 = (mm0 / 2Q) >> 16  
   pmulhuw mm7, mm6      ;  (level + quantd) / quant (0<quant<32)  
   pxor mm5, mm1         ; mm0 *= sign(mm0)  
   pxor mm7, mm4         ;  
   psubw mm5, mm1        ; undisplace  
   psubw mm7, mm4        ;  
   movq [edx + 8*esi+112], mm5  
   movq [edx + 8*esi +120], mm7  
   add esi, byte 2  
   jng near .loop  
   
 .done  
 ; calculate  data[0] // (int32_t)dcscalar)  
   mov esi, [esp + 12 + 16]  ; dcscalar  
   movsx ecx, word [eax]  
   mov edi, ecx  
   mov edx, [esp + 12 + 16]  
   shr edx, 1            ; ebx = dcscalar /2  
   sar edi, 31           ; cdq is vectorpath  
   xor edx, edi          ; ebx = eax V -eax -1  
   sub ecx, edi  
   add ecx, edx  
   mov edx, [dword esp + 12 + 4]  
   mov esi, [int_div+4*esi]  
   imul ecx, esi  
   sar ecx, 17  
   lea ebx, [byte ecx + 1]  
   cmovs ecx, ebx  
   ; idiv    cx          ; ecx = edi:ecx / dcscalar  
   
   mov ebx, [esp]  
   mov edi, [esp+4]  
   mov esi, [esp+8]  
   add esp, byte 12  
   mov [edx], cx     ; coeff[0] = ax  
   
   xor eax, eax  
   ret  
   
 ALIGN 16  
 .q1loop  
   movq mm1, [eax + 8*esi+112]               ; mm0 = [1st]  
   psubw mm0, mm1                            ;-mm1  
   movq mm4, [eax + 8*esi+120]               ;  
   psubw mm3, mm4                            ;-mm4  
   pmaxsw mm0, mm1                           ;|src|  
   pmaxsw mm3, mm4  
   nop2  
   psraw mm1, 15                             ;sign src  
   psraw mm4, 15  
   psllw mm0, 4                              ; level << 4  
   psllw mm3, 4  
   paddw mm0, [edi + 128 + 8*esi+112]    ;mm0 is to be divided  
   paddw mm3, [edi + 128 + 8*esi+120]    ;intra1 contains fix for division by 1  
   movq mm5, [edi + 384 + 8*esi+112] ;with rounding down  
   movq mm7, [edi + 384 + 8*esi+120]  
   pmulhuw mm5, mm0  
   pmulhuw mm7, mm3      ;mm7: first approx of division  
   mov esp, esp  
   movq mm2, [edi + 8*esi+112]  
   movq mm6, [edi + 8*esi+120]      ; divs for q<=16  
   pmullw mm2, mm5       ;test value <= original  
   pmullw mm6, mm7  
   psubw mm0, mm2        ;mismatch  
   psubw mm3, mm6  
   nop4  
   movq mm2, [quantd + ecx * 8 - 8]  
   paddw mm5, mm2        ;first approx with quantd  
   paddw mm7, mm2  
   mov esp, esp  
   pmulhuw mm0, [edi + 256 + 8*esi+112]   ;correction  
   pmulhuw mm3, [edi + 256 + 8*esi+120]  
   paddw mm5, mm0        ;final result with quantd  
   paddw mm7, mm3  
   pxor mm0, mm0  
   pxor mm3, mm3  
   mov esp, esp  
   psrlw mm5, 1          ;  (level + quantd) /2  (quant = 1)  
   psrlw mm7, 1  
   pxor mm5, mm1         ; mm0 *= sign(mm0)  
   pxor mm7, mm4         ;  
   psubw mm5, mm1        ; undisplace  
   psubw mm7, mm4        ;  
   movq [edx + 8*esi+112], mm5  
   movq [edx + 8*esi +120], mm7  
   add esi, byte 2  
   jng near .q1loop  
   jmp near .done  
   
 ALIGN 8  
 .lloop  
   movq mm1, [eax + 8*esi+112]       ; mm0 = [1st]  
   psubw mm0, mm1        ;-mm1  
   movq mm4, [eax + 8*esi+120]  
   psubw mm3, mm4        ;-mm4  
   pmaxsw mm0, mm1       ;|src|  
   pmaxsw mm3, mm4  
   nop2  
   psraw mm1, 15         ;sign src  
   psraw mm4, 15  
   psllw mm0, 4          ; level << 4  
   psllw mm3, 4          ;  
   paddw mm0, [edi + 128 + 8*esi+112] ;mm0 is to be divided intra1 contains fix for division by 1  
   paddw mm3, [edi + 128 + 8*esi+120]  
   movq mm5, [edi + 384 + 8*esi+112]  
   movq mm7, [edi + 384 + 8*esi+120]  
   pmulhuw mm5, mm0  
   pmulhuw mm7, mm3      ;mm7: first approx of division  
   mov esp, esp  
   movq mm2, [edi + 8*esi+112]  
   movq mm6, [edi + 8*esi+120]  
   pmullw mm2, mm5       ;test value <= original  
   pmullw mm6, mm7  
   psubw mm0, mm2        ;mismatch  
   psubw mm3, mm6  
   nop4  
   movq mm2, [quantd + ecx * 8 - 8]  
   movq mm6, [mmx_div + ecx * 8 - 8] ; divs for q<=16  
   paddw mm5, mm2        ;first approx with quantd  
   paddw mm7, mm2  
   mov esp, esp  
   pmulhuw mm0, [edi + 256 + 8*esi+112] ;correction  
   pmulhuw mm3, [edi + 256 + 8*esi+120]  
   paddw mm5, mm0        ;final result with quantd  
   paddw mm7, mm3  
   pxor mm0, mm0  
   pxor mm3, mm3  
   mov esp, esp  
   pmulhuw mm5, mm6      ; mm0 = (mm0 / 2Q) >> 16  
   pmulhuw mm7, mm6      ;  (level + quantd) / quant (0<quant<32)  
   psrlw mm5, 1          ; (level + quantd) / (2*quant)  
   psrlw mm7, 1  
   pxor mm5, mm1         ; mm0 *= sign(mm0)  
   pxor mm7, mm4         ;  
   psubw mm5, mm1        ; undisplace  
   psubw mm7, mm4        ;  
   movq [edx + 8*esi+112], mm5  
   movq [edx + 8*esi +120], mm7  
   add esi,byte 2  
   jng near .lloop  
   jmp near .done  
 .endfunc  
   
 ;-----------------------------------------------------------------------------  
 ;  
178  ; uint32_t quant_mpeg_inter_xmm(int16_t * coeff,  ; uint32_t quant_mpeg_inter_xmm(int16_t * coeff,
179  ;                               const int16_t const * data,  ;                               const int16_t const * data,
180  ;                               const uint32_t quant,  ;                               const uint32_t quant,
# Line 415  Line 208 
208    nop    nop
209    
210  ALIGN 16  ALIGN 16
211  .loop  .loop:
212    movq mm1, [eax + 8*esi+112]       ; mm0 = [1st]    movq mm1, [eax + 8*esi+112]       ; mm0 = [1st]
213    psubw mm0, mm1 ;-mm1    psubw mm0, mm1 ;-mm1
214    movq mm4, [eax + 8*esi + 120] ;    movq mm4, [eax + 8*esi + 120] ;
# Line 463  Line 256 
256    movq [edx + 8*esi +120-16], mm7    movq [edx + 8*esi +120-16], mm7
257    jng near .loop    jng near .loop
258    
259  .done  .done:
260  ; calculate  data[0] // (int32_t)dcscalar)  ; calculate  data[0] // (int32_t)dcscalar)
261    paddw mm2, [ebx]    paddw mm2, [ebx]
262    mov ebx, [esp+24]    mov ebx, [esp+24]
# Line 479  Line 272 
272    ret    ret
273    
274  ALIGN 16  ALIGN 16
275  .q1loop  .q1loop:
276    movq mm1, [eax + 8*esi+112]       ; mm0 = [1st]    movq mm1, [eax + 8*esi+112]       ; mm0 = [1st]
277    psubw mm0, mm1                    ;-mm1    psubw mm0, mm1                    ;-mm1
278    movq mm4, [eax + 8*esi+120]    movq mm4, [eax + 8*esi+120]
# Line 528  Line 321 
321    jmp near .done    jmp near .done
322    
323  ALIGN 8  ALIGN 8
324  .lloop  .lloop:
325    movq mm1, [eax + 8*esi+112]       ; mm0 = [1st]    movq mm1, [eax + 8*esi+112]       ; mm0 = [1st]
326    psubw mm0,mm1         ;-mm1    psubw mm0,mm1         ;-mm1
327    movq mm4, [eax + 8*esi+120]    movq mm4, [eax + 8*esi+120]
# Line 578  Line 371 
371    movq [edx + 8*esi +120-16], mm7    movq [edx + 8*esi +120-16], mm7
372    jng near .lloop    jng near .lloop
373    jmp near .done    jmp near .done
374  .endfunc  ENDFUNC
375    
376    
377  ;-----------------------------------------------------------------------------  ;-----------------------------------------------------------------------------
# Line 698  Line 491 
491    
492    xor eax, eax    xor eax, eax
493    ret    ret
494  .endfunc  ENDFUNC
495    
496  ;-----------------------------------------------------------------------------  ;-----------------------------------------------------------------------------
497  ;  ;
# Line 733  Line 526 
526    nop4    nop4
527    
528  ALIGN 16  ALIGN 16
529  .loop  .loop:
530    movq mm0, [ecx+8*eax + 7*16   ]   ; mm0 = coeff[i]    movq mm0, [ecx+8*eax + 7*16   ]   ; mm0 = coeff[i]
531    pcmpgtw mm1, mm0  ; mm1 = sgn(c)    (preserved)    pcmpgtw mm1, mm0  ; mm1 = sgn(c)    (preserved)
532    movq mm2, [ecx+8*eax + 7*16 +8]   ; mm2 = coeff[i+1]    movq mm2, [ecx+8*eax + 7*16 +8]   ; mm2 = coeff[i+1]
# Line 813  Line 606 
606    
607    xor eax, eax    xor eax, eax
608    ret    ret
609  .endfunc  ENDFUNC
610    
611    
612    %ifidn __OUTPUT_FORMAT__,elf
613    section ".note.GNU-stack" noalloc noexec nowrite progbits
614    %endif
615    

Legend:
Removed from v.1540  
changed lines
  Added in v.1793

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