[svn] / trunk / xvidcore / src / quant / x86_asm / quantize_mmx.asm Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/quant/x86_asm/quantize_mmx.asm

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

revision 135, Wed Apr 24 12:21:43 2002 UTC revision 367, Fri Aug 9 10:45:05 2002 UTC
# Line 32  Line 32 
32  ; *  ; *
33  ; *     History:  ; *     History:
34  ; *  ; *
35    ; * 09.08.2002  sse2 dequant funcs revamped
36    ; * 14.06.2002  mmx+xmm dequant_* funcs revamped  -Skal-
37  ; * 24.02.2002  sse2 quant_intra / dequant_intra (have to use movdqu ???)  ; * 24.02.2002  sse2 quant_intra / dequant_intra (have to use movdqu ???)
38  ; * 17.04.2002  sse2 quant_inter / dequant_inter  ; * 17.04.2002  sse2 quant_inter / dequant_inter
39  ; * 26.12.2001  minor bug fixes, dequant saturate, further optimization  ; * 26.12.2001  minor bug fixes, dequant saturate, further optimization
# Line 64  Line 66 
66    
67  plus_one times 8        dw       1  plus_one times 8        dw       1
68    
   
69  ;===========================================================================  ;===========================================================================
70  ;  ;
71  ; subtract by Q/2 table  ; subtract by Q/2 table
# Line 261  Line 262 
262  ;  ;
263  ;===========================================================================  ;===========================================================================
264    
265  align ALIGN  align 16
266  mmx_32768_minus_2048                            times 4 dw (32768-2048)  sse2_2047       times 8 dw 2047
 mmx_32767_minus_2047                            times 4 dw (32767-2047)  
267    
268  align 16  align 16
269  sse2_pos_2047                                           times 8 dw 2047  mmx_2047        times 4 dw 2047
270  sse2_neg_2048                                           times 8 dw -2048  
271    align 8
272    mmx_32768_minus_2048                            times 4 dw (32768-2048)
273    mmx_32767_minus_2047                            times 4 dw (32767-2047)
274    
275    
276  section .text  section .text
# Line 700  Line 703 
703                  jmp             .qes2_done                  jmp             .qes2_done
704    
705    
   
706  ;===========================================================================  ;===========================================================================
707  ;  ;
708  ; void dequant_intra_mmx(int16_t *data,  ; void dequant_intra_mmx(int16_t *data,
# Line 710  Line 712 
712  ;  ;
713  ;===========================================================================  ;===========================================================================
714    
715      ; note: we only saturate to +2047 *before* restoring the sign.
716      ; Hence, final clamp really is [-2048,2047]
717    
718  align ALIGN  align ALIGN
719  cglobal dequant_intra_mmx  cglobal dequant_intra_mmx
720  dequant_intra_mmx  dequant_intra_mmx:
   
                 push    esi  
                 push    edi  
   
                 mov     edi, [esp + 8 + 4]              ; data  
                 mov     esi, [esp + 8 + 8]              ; coeff  
                 mov     eax, [esp + 8 + 12]             ; quant  
721    
722                  movq    mm6, [mmx_add + eax * 8 - 8]    mov    edx, [esp+ 4]        ; data
723                  movq    mm7, [mmx_mul + eax * 8 - 8]    mov    ecx, [esp+ 8]        ; coeff
724                  xor eax, eax    mov    eax, [esp+12]        ; quant
725      movq mm6, [mmx_add + eax*8 - 8]  ; quant or quant-1
726      movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
727      mov eax, -16
728    
729  align ALIGN  align ALIGN
730  .loop  .loop
731                  movq    mm0, [esi + 8*eax]              ; mm0 = [coeff]    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
732                  movq    mm3, [esi + 8*eax + 8]  ;    movq mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]
733                  pxor    mm1, mm1                ; mm1 = 0    pxor mm1, mm1
734                  pxor    mm4, mm4                ;    pxor mm4, mm4
735                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)    pcmpgtw mm1, mm0  ; sign(c)
736                  pcmpgtw mm4, mm3                ;    pcmpgtw mm4, mm3  ; sign(c')
737                  pxor    mm2, mm2                ; mm2 = 0    pxor mm2, mm2
738                  pxor    mm5, mm5                ;    pxor mm5, mm5
739                  pcmpeqw mm2, mm0                ; mm2 = (0 == mm0)    pcmpeqw mm2, mm0  ; c is zero
740                  pcmpeqw mm5, mm3                ;    pcmpeqw mm5, mm3  ; c' is zero
741                  pandn   mm2, mm6                ; mm2 = (iszero ? 0 : add)    pandn mm2, mm6    ; offset = isZero ? 0 : quant_add
742                  pandn   mm5, mm6                ;    pandn mm5, mm6
743                  pxor    mm0, mm1                ; mm0 = |mm0|    pxor mm0, mm1     ; negate if negative
744                  pxor    mm3, mm4                ;    pxor mm3, mm4     ; negate if negative
745                  psubw   mm0, mm1                ; displace    psubw mm0, mm1
                 psubw   mm3, mm4                ;  
                 pmullw  mm0, mm7                ; mm0 *= 2Q  
                 pmullw  mm3, mm7                ;  
                 paddw   mm0, mm2                ; mm0 += mm2 (add)  
                 paddw   mm3, mm5                ;  
                 pxor    mm0, mm1                ; mm0 *= sign(mm0)  
                 pxor    mm3, mm4                ;  
                 psubw   mm0, mm1                ; undisplace  
746                  psubw   mm3, mm4                  psubw   mm3, mm4
747      pmullw mm0, mm7 ; *= 2Q
748      pmullw mm3, mm7 ; *= 2Q
749      paddw mm0, mm2 ; + offset
750      paddw mm3, mm5 ; + offset
751      paddw mm0, mm1 ; negate back
752      paddw mm3, mm4 ; negate back
753    
754  %ifdef SATURATE      ; saturates to +2047
755                  movq mm2, [mmx_32767_minus_2047]                  movq mm2, [mmx_32767_minus_2047]
756                  movq mm4, [mmx_32768_minus_2048]    add eax, 2
757                  paddsw  mm0, mm2                  paddsw  mm0, mm2
758                  paddsw  mm3, mm2                  paddsw  mm3, mm2
759                  psubsw  mm0, mm2                  psubsw  mm0, mm2
760                  psubsw  mm3, mm2                  psubsw  mm3, mm2
                 psubsw  mm0, mm4  
                 psubsw  mm3, mm4  
                 paddsw  mm0, mm4  
                 paddsw  mm3, mm4  
 %endif  
761    
762                  movq    [edi + 8*eax], mm0              ; [data] = mm0    pxor mm0, mm1
763                  movq    [edi + 8*eax + 8], mm3    pxor mm3, mm4
764      movq [edx + 8*eax + 8*16   - 2*8], mm0
765                  add eax, 2    movq [edx + 8*eax + 8*16+8 - 2*8], mm3
                 cmp eax, 16  
766                  jnz     near .loop                  jnz     near .loop
767    
768                  mov     ax, [esi]                                       ; ax = data[0]      ; deal with DC
                 imul ax, [esp + 8 + 16]                 ; eax = data[0] * dcscalar  
769    
770  %ifdef SATURATE    movd mm0, [ecx]
771                  cmp ax, -2048    pmullw mm0, [esp+16]    ; dcscalar
772                  jl .set_n2048    movq mm2, [mmx_32767_minus_2047]
773                  cmp ax, 2047    paddsw mm0, mm2
774                  jg .set_2047    psubsw mm0, mm2
775  %endif    movq mm3, [mmx_32768_minus_2048]
776                  mov     [edi], ax    psubsw mm0, mm3
777      paddsw mm0, mm3
778      movd eax, mm0
779      mov [edx], ax
780    
                 pop     edi  
                 pop     esi  
781                  ret                  ret
782    
783  %ifdef SATURATE  ;===========================================================================
784    ;
785    ; void dequant_intra_xmm(int16_t *data,
786    ;                                       const int16_t const *coeff,
787    ;                                       const uint32_t quant,
788    ;                                       const uint32_t dcscalar);
789    ;
790    ;===========================================================================
791    
792      ; this is the same as dequant_inter_mmx, except that we're
793      ; saturating using 'pminsw' (saves 2 cycles/loop => ~5% faster)
794    
795  align ALIGN  align ALIGN
796  .set_n2048  cglobal dequant_intra_xmm
797                  mov     word [edi], -2048  dequant_intra_xmm:
798                  pop     edi  
799                  pop     esi    mov    edx, [esp+ 4]        ; data
800                  ret    mov    ecx, [esp+ 8]        ; coeff
801      mov    eax, [esp+12]        ; quant
802      movq mm6, [mmx_add + eax*8 - 8]  ; quant or quant-1
803      movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
804      mov eax, -16
805    
806  align ALIGN  align ALIGN
807  .set_2047  .loop
808                  mov     word [edi], 2047    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
809                  pop     edi    movq mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]
810                  pop     esi    pxor mm1, mm1
811                  ret    pxor mm4, mm4
812  %endif    pcmpgtw mm1, mm0  ; sign(c)
813      pcmpgtw mm4, mm3  ; sign(c')
814      pxor mm2, mm2
815      pxor mm5, mm5
816      pcmpeqw mm2, mm0  ; c is zero
817      pcmpeqw mm5, mm3  ; c' is zero
818      pandn mm2, mm6    ; offset = isZero ? 0 : quant_add
819      pandn mm5, mm6
820      pxor mm0, mm1     ; negate if negative
821      pxor mm3, mm4     ; negate if negative
822      psubw mm0, mm1
823      psubw mm3, mm4
824      pmullw mm0, mm7 ; *= 2Q
825      pmullw mm3, mm7 ; *= 2Q
826      paddw mm0, mm2 ; + offset
827      paddw mm3, mm5 ; + offset
828      paddw mm0, mm1 ; negate back
829      paddw mm3, mm4 ; negate back
830    
831        ; saturates to +2047
832      movq mm2, [mmx_2047]
833      pminsw mm0, mm2
834      add eax, 2
835      pminsw mm3, mm2
836    
837      pxor mm0, mm1
838      pxor mm3, mm4
839      movq [edx + 8*eax + 8*16   - 2*8], mm0
840      movq [edx + 8*eax + 8*16+8 - 2*8], mm3
841      jnz   near .loop
842    
843        ; deal with DC
844    
845      movd mm0, [ecx]
846      pmullw mm0, [esp+16]    ; dcscalar
847      movq mm2, [mmx_32767_minus_2047]
848      paddsw mm0, mm2
849      psubsw mm0, mm2
850      movq mm2, [mmx_32768_minus_2048]
851      psubsw mm0, mm2
852      paddsw mm0, mm2
853      movd eax, mm0
854      mov [edx], ax
855    
856      ret
857    
858    
859  ;===========================================================================  ;===========================================================================
# Line 813  Line 864 
864  ;                                       const uint32_t dcscalar);  ;                                       const uint32_t dcscalar);
865  ;  ;
866  ;===========================================================================  ;===========================================================================
867    align ALIGN
 align 16  
868  cglobal dequant_intra_sse2  cglobal dequant_intra_sse2
869  dequant_intra_sse2  dequant_intra_sse2:
870            mov edx, [esp+ 4]        ; data
871                  push    esi          mov ecx, [esp+ 8]        ; coeff
872                  push    edi          mov eax, [esp+12]        ; quant
   
                 mov             edi, [esp + 8 + 4]                      ; data  
                 mov             esi, [esp + 8 + 8]                      ; coeff  
                 mov             eax, [esp + 8 + 12]                     ; quant  
   
873                  movq    mm6, [mmx_add + eax*8 - 8]                  movq    mm6, [mmx_add + eax*8 - 8]
874                  movq    mm7, [mmx_mul + eax*8 - 8]                  movq    mm7, [mmx_mul + eax*8 - 8]
875                  movq2dq xmm6, mm6                  movq2dq xmm6, mm6
876                  movq2dq xmm7, mm7                  movq2dq xmm7, mm7
877                  movlhps xmm6, xmm6                  movlhps xmm6, xmm6
878                  movlhps xmm7, xmm7                  movlhps xmm7, xmm7
879            mov eax, -16
880    
881                  xor             eax, eax  align ALIGN
882    .loop
883  align 16          movdqa xmm0, [ecx + 8*16 + 8*eax]      ; c  = coeff[i]
884  .das2_loop          movdqa xmm3, [ecx + 8*16 + 8*eax+ 16]
                 movdqa  xmm0, [esi + eax*8]  
                 movdqa  xmm3, [esi + eax*8 + 16]  
885                  pxor    xmm1, xmm1                  pxor    xmm1, xmm1
886                  pxor    xmm4, xmm4                  pxor    xmm4, xmm4
887                  pcmpgtw xmm1, xmm0          pcmpgtw xmm1, xmm0  ; sign(c)
888                  pcmpgtw xmm4, xmm3                  pcmpgtw xmm4, xmm3
889                  pxor    xmm2, xmm2                  pxor    xmm2, xmm2
890                  pxor    xmm5, xmm5                  pxor    xmm5, xmm5
891                  pcmpeqw xmm2, xmm0          pcmpeqw xmm2, xmm0  ; c is zero
892                  pcmpeqw xmm5, xmm3                  pcmpeqw xmm5, xmm3
893                  pandn   xmm2, xmm6          pandn xmm2, xmm6    ; offset = isZero ? 0 : quant_add
894                  pandn   xmm5, xmm6                  pandn   xmm5, xmm6
895                  pxor    xmm0, xmm1          pxor xmm0, xmm1     ; negate if negative
896                  pxor    xmm3, xmm4                  pxor    xmm3, xmm4
897                  psubw   xmm0, xmm1                  psubw   xmm0, xmm1
898                  psubw   xmm3, xmm4                  psubw   xmm3, xmm4
899                  pmullw  xmm0, xmm7          pmullw xmm0, xmm7 ; *= 2Q
900                  pmullw  xmm3, xmm7                  pmullw  xmm3, xmm7
901                  paddw   xmm0, xmm2          paddw xmm0, xmm2 ; + offset
902                  paddw   xmm3, xmm5                  paddw   xmm3, xmm5
903                  pxor    xmm0, xmm1          paddw xmm0, xmm1 ; negate back
904                  pxor    xmm3, xmm4          paddw xmm3, xmm4
                 psubw   xmm0, xmm1  
                 psubw   xmm3, xmm4  
905    
906  %ifdef SATURATE          ; saturates to +2047
907                  movdqu  xmm2, [sse2_pos_2047]          movdqa xmm2, [sse2_2047]
                 movdqu  xmm4, [sse2_neg_2048]  
908                  pminsw  xmm0, xmm2                  pminsw  xmm0, xmm2
                 pminsw  xmm3, xmm2  
                 pmaxsw  xmm0, xmm4  
                 pmaxsw  xmm3, xmm4  
 %endif  
   
                 movdqa  [edi + eax*8], xmm0  
                 movdqa  [edi + eax*8 + 16], xmm3  
   
909                  add             eax, 4                  add             eax, 4
910                  cmp             eax, 16          pminsw xmm3, xmm2
                 jnz             near .das2_loop  
   
                 mov             ax, [esi]                                       ; ax = data[0]  
                 imul    ax, [esp + 8 + 16]                      ; eax = data[0] * dcscalar  
911    
912  %ifdef SATURATE          pxor xmm0, xmm1
913                  cmp             ax, -2048          pxor xmm3, xmm4
914                  jl              .das2_set_n2048          movdqa [edx + 8*16 - 8*4 + 8*eax], xmm0
915                  cmp             ax, 2047          movdqa [edx + 8*16 - 8*4 + 8*eax + 16], xmm3
916                  jg              .das2_set_2047          jnz     near .loop
 %endif  
                 mov             [edi], ax  
917    
918                  pop             edi          ; deal with DC
919                  pop             esi          movd mm0, [ecx]
920                  ret          pmullw mm0, [esp+16]    ; dcscalar
921            movq mm2, [mmx_32767_minus_2047]
922            paddsw mm0, mm2
923            psubsw mm0, mm2
924            movq mm2, [mmx_32768_minus_2048]
925            psubsw mm0, mm2
926            paddsw mm0, mm2
927            movd eax, mm0
928            mov [edx], ax
929    
 %ifdef SATURATE  
 align 16  
 .das2_set_n2048  
                 mov             word [edi], -2048  
                 pop             edi  
                 pop             esi  
930                  ret                  ret
931    
 align 16  
 .das2_set_2047  
                 mov             word [edi], 2047  
                 pop             edi  
                 pop             esi  
                 ret  
 %endif  
932    
933    
934    
# Line 920  Line 942 
942    
943  align ALIGN  align ALIGN
944  cglobal dequant_inter_mmx  cglobal dequant_inter_mmx
945  dequant_inter_mmx  dequant_inter_mmx:
946    
947                  push    esi    mov    edx, [esp+ 4]        ; data
948                  push    edi    mov    ecx, [esp+ 8]        ; coeff
949      mov    eax, [esp+12]        ; quant
950                  mov     edi, [esp + 8 + 4]      ; data    movq mm6, [mmx_add + eax*8 - 8]  ; quant or quant-1
951                  mov     esi, [esp + 8 + 8]      ; coeff    movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
952                  mov     eax, [esp + 8 + 12]     ; quant    mov eax, -16
                 movq    mm6, [mmx_add + eax * 8 - 8]  
                 movq    mm7, [mmx_mul + eax * 8 - 8]  
   
                 xor eax, eax  
953    
954  align ALIGN  align ALIGN
955  .loop  .loop
956                  movq    mm0, [esi + 8*eax]                      ; mm0 = [coeff]    movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
957                  movq    mm3, [esi + 8*eax + 8]          ;    movq mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]
958                  pxor    mm1, mm1                ; mm1 = 0    pxor mm1, mm1
959                  pxor    mm4, mm4                ;    pxor mm4, mm4
960                  pcmpgtw mm1, mm0                ; mm1 = (0 > mm0)    pcmpgtw mm1, mm0  ; sign(c)
961                  pcmpgtw mm4, mm3                ;    pcmpgtw mm4, mm3  ; sign(c')
962                  pxor    mm2, mm2                ; mm2 = 0    pxor mm2, mm2
963                  pxor    mm5, mm5                ;    pxor mm5, mm5
964                  pcmpeqw mm2, mm0                ; mm2 = (0 == mm0)    pcmpeqw mm2, mm0  ; c is zero
965                  pcmpeqw mm5, mm3                ;    pcmpeqw mm5, mm3  ; c' is zero
966                  pandn   mm2, mm6                ; mm2 = (iszero ? 0 : add)    pandn mm2, mm6    ; offset = isZero ? 0 : quant_add
967                  pandn   mm5, mm6                ;    pandn mm5, mm6
968                  pxor    mm0, mm1                ; mm0 = |mm0|    pxor mm0, mm1     ; negate if negative
969                  pxor    mm3, mm4                ;    pxor mm3, mm4     ; negate if negative
970                  psubw   mm0, mm1                ; displace    psubw mm0, mm1
                 psubw   mm3, mm4                ;  
                 pmullw  mm0, mm7                ; mm0 *= 2Q  
                 pmullw  mm3, mm7                ;  
                 paddw   mm0, mm2                ; mm0 += mm2 (add)  
                 paddw   mm3, mm5                ;  
                 pxor    mm0, mm1                ; mm0 *= sign(mm0)  
                 pxor    mm3, mm4                ;  
                 psubw   mm0, mm1                ; undisplace  
971                  psubw   mm3, mm4                  psubw   mm3, mm4
972      pmullw mm0, mm7 ; *= 2Q
973      pmullw mm3, mm7 ; *= 2Q
974      paddw mm0, mm2 ; + offset
975      paddw mm3, mm5 ; + offset
976      paddw mm0, mm1 ; negate back
977      paddw mm3, mm4 ; negate back
978    
979  %ifdef SATURATE      ; saturates to +2047
980                  movq mm2, [mmx_32767_minus_2047]                  movq mm2, [mmx_32767_minus_2047]
981                  movq mm4, [mmx_32768_minus_2048]    add eax, 2
982                  paddsw  mm0, mm2                  paddsw  mm0, mm2
983                  paddsw  mm3, mm2                  paddsw  mm3, mm2
984                  psubsw  mm0, mm2                  psubsw  mm0, mm2
985                  psubsw  mm3, mm2                  psubsw  mm3, mm2
                 psubsw  mm0, mm4  
                 psubsw  mm3, mm4  
                 paddsw  mm0, mm4  
                 paddsw  mm3, mm4  
 %endif  
986    
987                  movq    [edi + 8*eax], mm0    pxor mm0, mm1
988                  movq    [edi + 8*eax + 8], mm3    pxor mm3, mm4
989      movq [edx + 8*eax + 8*16   - 2*8], mm0
990      movq [edx + 8*eax + 8*16+8 - 2*8], mm3
991      jnz   near .loop
992    
993      ret
994    
995    ;===========================================================================
996    ;
997    ; void dequant_inter_xmm(int16_t * data,
998    ;                                       const int16_t * const coeff,
999    ;                                       const uint32_t quant);
1000    ;
1001    ;===========================================================================
1002    
1003      ; this is the same as dequant_inter_mmx,
1004      ; except that we're saturating using 'pminsw' (saves 2 cycles/loop)
1005    
1006    align ALIGN
1007    cglobal dequant_inter_xmm
1008    dequant_inter_xmm:
1009    
1010      mov    edx, [esp+ 4]        ; data
1011      mov    ecx, [esp+ 8]        ; coeff
1012      mov    eax, [esp+12]        ; quant
1013      movq mm6, [mmx_add + eax*8 - 8]  ; quant or quant-1
1014      movq mm7, [mmx_mul + eax*8 - 8]  ; 2*quant
1015      mov eax, -16
1016    
1017    align ALIGN
1018    .loop
1019      movq mm0, [ecx+8*eax+8*16]      ; c  = coeff[i]
1020      movq mm3, [ecx+8*eax+8*16 + 8]  ; c' = coeff[i+1]
1021      pxor mm1, mm1
1022      pxor mm4, mm4
1023      pcmpgtw mm1, mm0  ; sign(c)
1024      pcmpgtw mm4, mm3  ; sign(c')
1025      pxor mm2, mm2
1026      pxor mm5, mm5
1027      pcmpeqw mm2, mm0  ; c is zero
1028      pcmpeqw mm5, mm3  ; c' is zero
1029      pandn mm2, mm6    ; offset = isZero ? 0 : quant_add
1030      pandn mm5, mm6
1031      pxor mm0, mm1     ; negate if negative
1032      pxor mm3, mm4     ; negate if negative
1033      psubw mm0, mm1
1034      psubw mm3, mm4
1035      pmullw mm0, mm7 ; *= 2Q
1036      pmullw mm3, mm7 ; *= 2Q
1037      paddw mm0, mm2 ; + offset
1038      paddw mm3, mm5 ; + offset
1039      paddw mm0, mm1 ; start restoring sign
1040      paddw mm3, mm4 ; start restoring sign
1041    
1042          ; saturates to +2047
1043      movq mm2, [mmx_2047]
1044      pminsw mm0, mm2
1045                  add eax, 2                  add eax, 2
1046                  cmp eax, 16    pminsw mm3, mm2
                 jnz     near .loop  
1047    
1048                  pop     edi    pxor mm0, mm1 ; finish restoring sign
1049                  pop     esi    pxor mm3, mm4 ; finish restoring sign
1050      movq [edx + 8*eax + 8*16   - 2*8], mm0
1051      movq [edx + 8*eax + 8*16+8 - 2*8], mm3
1052      jnz   near .loop
1053    
1054                  ret                  ret
1055    
   
1056  ;===========================================================================  ;===========================================================================
1057  ;  ;
1058  ; void dequant_inter_sse2(int16_t * data,  ; void dequant_inter_sse2(int16_t * data,
# Line 993  Line 1060 
1060  ;                                       const uint32_t quant);  ;                                       const uint32_t quant);
1061  ;  ;
1062  ;===========================================================================  ;===========================================================================
1063    align ALIGN
 align 16  
1064  cglobal dequant_inter_sse2  cglobal dequant_inter_sse2
1065  dequant_inter_sse2  dequant_inter_sse2
1066            mov edx, [esp + 4]      ; data
1067                  push    esi          mov ecx, [esp + 8]      ; coeff
1068                  push    edi          mov eax, [esp + 12]     ; quant
   
                 mov     edi, [esp + 8 + 4]      ; data  
                 mov     esi, [esp + 8 + 8]      ; coeff  
                 mov     eax, [esp + 8 + 12]     ; quant  
1069                  movq    mm6, [mmx_add + eax * 8 - 8]                  movq    mm6, [mmx_add + eax * 8 - 8]
1070                  movq    mm7, [mmx_mul + eax * 8 - 8]                  movq    mm7, [mmx_mul + eax * 8 - 8]
   
1071                  movq2dq xmm6, mm6                  movq2dq xmm6, mm6
1072                  movq2dq xmm7, mm7                  movq2dq xmm7, mm7
1073                  movlhps xmm6, xmm6                  movlhps xmm6, xmm6
1074                  movlhps xmm7, xmm7                  movlhps xmm7, xmm7
1075            mov eax, -16
1076    
1077                  xor eax, eax  align ALIGN
1078    .loop
1079            movdqa xmm0, [ecx + 8*16 + 8*eax]  ; c  = coeff[i]
1080            movdqa xmm3, [ecx + 8*16 + 8*eax + 16]
1081    
 align 16  
 .des2_loop  
                 movdqa  xmm0, [esi + eax*8]                     ; xmm0 = [coeff]  
                 movdqa  xmm3, [esi + eax*8 + 16]  
1082                  pxor    xmm1, xmm1                  pxor    xmm1, xmm1
1083                  pxor    xmm4, xmm4                  pxor    xmm4, xmm4
1084                  pcmpgtw xmm1, xmm0          pcmpgtw xmm1, xmm0  ; sign(c)
1085                  pcmpgtw xmm4, xmm3                  pcmpgtw xmm4, xmm3
1086                  pxor    xmm2, xmm2                  pxor    xmm2, xmm2
1087                  pxor    xmm5, xmm5                  pxor    xmm5, xmm5
1088                  pcmpeqw xmm2, xmm0          pcmpeqw xmm2, xmm0  ; c is zero
1089                  pcmpeqw xmm5, xmm3                  pcmpeqw xmm5, xmm3
1090                  pandn   xmm2, xmm6                  pandn   xmm2, xmm6
1091                  pandn   xmm5, xmm6                  pandn   xmm5, xmm6
1092                  pxor    xmm0, xmm1          pxor xmm0, xmm1  ; negate if negative
1093                  pxor    xmm3, xmm4                  pxor    xmm3, xmm4
1094                  psubw   xmm0, xmm1                  psubw   xmm0, xmm1
1095                  psubw   xmm3, xmm4                  psubw   xmm3, xmm4
1096                  pmullw  xmm0, xmm7          pmullw xmm0, xmm7  ; *= 2Q
1097                  pmullw  xmm3, xmm7                  pmullw  xmm3, xmm7
1098                  paddw   xmm0, xmm2          paddw xmm0, xmm2  ; + offset
1099                  paddw   xmm3, xmm5                  paddw   xmm3, xmm5
                 pxor    xmm0, xmm1  
                 pxor    xmm3, xmm4  
                 psubw   xmm0, xmm1  
                 psubw   xmm3, xmm4  
   
 %ifdef SATURATE  
                 movdqu  xmm2, [sse2_pos_2047]  
                 movdqu  xmm4, [sse2_neg_2048]  
                 pminsw  xmm0, xmm2  
                 pminsw  xmm3, xmm2  
                 pmaxsw  xmm0, xmm4  
                 pmaxsw  xmm3, xmm4  
 %endif  
1100    
1101                  movdqa  [edi + eax*8], xmm0          paddw xmm0, xmm1  ; start restoring sign
1102                  movdqa  [edi + eax*8 + 16], xmm3          paddw xmm3, xmm4
1103    
1104            ; saturates to +2047
1105            movdqa xmm2, [sse2_2047]
1106            pminsw xmm0, xmm2
1107                  add eax, 4                  add eax, 4
1108                  cmp eax, 16          pminsw xmm3, xmm2
                 jnz     near .des2_loop  
1109    
1110                  pop     edi          pxor xmm0, xmm1 ; finish restoring sign
1111                  pop     esi          pxor xmm3, xmm4
1112            movdqa [edx + 8*16 - 8*4 + 8*eax], xmm0
1113            movdqa [edx + 8*16 - 8*4 + 8*eax + 16], xmm3
1114            jnz     near .loop
1115    
1116                  ret                  ret

Legend:
Removed from v.135  
changed lines
  Added in v.367

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