annotate x86/dsputilenc_yasm.asm @ 12497:c5ffa8b81f9c libavcodec

Move sse16_sse2() from inline asm to yasm. It is one of the functions causing Win64/FATE issues.
author rbultje
date Fri, 17 Sep 2010 01:44:17 +0000
parents
children c997f09d1e10
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12497
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
1 ;*****************************************************************************
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
2 ;* MMX optimized DSP utils
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
3 ;*****************************************************************************
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
4 ;* Copyright (c) 2000, 2001 Fabrice Bellard
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
5 ;* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
6 ;*
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
7 ;* This file is part of FFmpeg.
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
8 ;*
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
9 ;* FFmpeg is free software; you can redistribute it and/or
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
10 ;* modify it under the terms of the GNU Lesser General Public
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
11 ;* License as published by the Free Software Foundation; either
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
12 ;* version 2.1 of the License, or (at your option) any later version.
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
13 ;*
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
14 ;* FFmpeg is distributed in the hope that it will be useful,
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
15 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
16 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
17 ;* Lesser General Public License for more details.
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
18 ;*
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
19 ;* You should have received a copy of the GNU Lesser General Public
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
20 ;* License along with FFmpeg; if not, write to the Free Software
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
21 ;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
22 ;*****************************************************************************
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
23
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
24 %include "x86inc.asm"
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
25 %include "x86util.asm"
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
26
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
27 SECTION .text
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
28
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
29 INIT_XMM
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
30 ; sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
31 cglobal sse16_sse2, 5, 5, 8
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
32 shr r4, 1
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
33 pxor m0, m0 ; mm0 = 0
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
34 pxor m7, m7 ; mm7 holds the sum
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
35
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
36 .next2lines ; FIXME why are these unaligned movs? pix1[] is aligned
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
37 movu m1, [r1 ] ; mm1 = pix1[0][0-15]
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
38 movu m2, [r2 ] ; mm2 = pix2[0][0-15]
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
39 movu m3, [r1+r3] ; mm3 = pix1[1][0-15]
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
40 movu m4, [r2+r3] ; mm4 = pix2[1][0-15]
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
41
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
42 ; todo: mm1-mm2, mm3-mm4
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
43 ; algo: subtract mm1 from mm2 with saturation and vice versa
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
44 ; OR the result to get the absolute difference
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
45 mova m5, m1
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
46 mova m6, m3
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
47 psubusb m1, m2
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
48 psubusb m3, m4
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
49 psubusb m2, m5
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
50 psubusb m4, m6
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
51
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
52 por m2, m1
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
53 por m4, m3
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
54
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
55 ; now convert to 16-bit vectors so we can square them
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
56 mova m1, m2
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
57 mova m3, m4
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
58
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
59 punpckhbw m2, m0
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
60 punpckhbw m4, m0
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
61 punpcklbw m1, m0 ; mm1 not spread over (mm1,mm2)
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
62 punpcklbw m3, m0 ; mm4 not spread over (mm3,mm4)
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
63
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
64 pmaddwd m2, m2
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
65 pmaddwd m4, m4
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
66 pmaddwd m1, m1
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
67 pmaddwd m3, m3
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
68
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
69 lea r1, [r1+r3*2] ; pix1 += 2*line_size
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
70 lea r2, [r2+r3*2] ; pix2 += 2*line_size
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
71
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
72 paddd m1, m2
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
73 paddd m3, m4
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
74 paddd m7, m1
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
75 paddd m7, m3
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
76
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
77 dec r4
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
78 jnz .next2lines
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
79
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
80 mova m1, m7
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
81 psrldq m7, 8 ; shift hi qword to lo
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
82 paddd m7, m1
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
83 mova m1, m7
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
84 psrldq m7, 4 ; shift hi dword to lo
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
85 paddd m7, m1
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
86 movd eax, m7 ; return value
c5ffa8b81f9c Move sse16_sse2() from inline asm to yasm. It is one of the functions causing
rbultje
parents:
diff changeset
87 RET