1 ;******************************************************************************
2 ;* Copyright (c) 2012 Michael Niedermayer
4 ;* This file is part of FFmpeg.
6 ;* FFmpeg is free software; you can redistribute it and/or
7 ;* modify it under the terms of the GNU Lesser General Public
8 ;* License as published by the Free Software Foundation; either
9 ;* version 2.1 of the License, or (at your option) any later version.
11 ;* FFmpeg is distributed in the hope that it will be useful,
12 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;* Lesser General Public License for more details.
16 ;* You should have received a copy of the GNU Lesser General Public
17 ;* License along with FFmpeg; if not, write to the Free Software
18 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 ;******************************************************************************
21 %include "libavutil/x86/x86inc.asm"
22 %include "libavutil/x86/x86util.asm"
26 flt2pm31: times 8 dd 4.6566129e-10
27 flt2p31 : times 8 dd 2147483648.0
28 flt2p15 : times 8 dd 32768.0
32 %macro INT16_TO_INT32 1
33 cglobal int16_to_int32_%1, 3, 3, 3, dst, src, len
39 jne int16_to_int32_u_int %+ SUFFIX
41 jne int16_to_int32_u_int %+ SUFFIX
43 int16_to_int32_u_int %+ SUFFIX
55 mov%1 [ dstq+2*lenq], m0
56 mov%1 [mmsize + dstq+2*lenq], m1
65 %macro INT32_TO_FLOAT 1
66 cglobal int32_to_float_%1, 3, 3, 3, dst, src, len
72 jne int32_to_float_u_int %+ SUFFIX
74 jne int32_to_float_u_int %+ SUFFIX
76 int32_to_float_u_int %+ SUFFIX
84 cvtdq2ps m0, [ srcq+lenq]
85 cvtdq2ps m1, [mmsize + srcq+lenq]
88 movu m1, [mmsize + srcq+lenq]
94 mov%1 [ dstq+lenq], m0
95 mov%1 [mmsize + dstq+lenq], m1
101 %macro INT16_TO_FLOAT 1
102 cglobal int16_to_float_%1, 3, 3, 4, dst, src, len
108 jne int16_to_float_u_int %+ SUFFIX
110 jne int16_to_float_u_int %+ SUFFIX
112 int16_to_float_u_int %+ SUFFIX
120 mov%1 m2, [srcq+lenq]
129 mov%1 [ dstq+2*lenq], m0
130 mov%1 [mmsize + dstq+2*lenq], m1
136 %macro FLOAT_TO_INT32 1
137 cglobal float_to_int32_%1, 3, 3, 5, dst, src, len
143 jne float_to_int32_u_int %+ SUFFIX
145 jne float_to_int32_u_int %+ SUFFIX
147 float_to_int32_u_int %+ SUFFIX
154 mov%1 m0, [ srcq+lenq]
155 mov%1 m1, [mmsize + srcq+lenq]
164 mov%1 [ dstq+lenq], m0
165 mov%1 [mmsize + dstq+lenq], m1
171 %macro FLOAT_TO_INT16 1
172 cglobal float_to_int16_%1, 3, 3, 3, dst, src, len
178 jne float_to_int16_u_int %+ SUFFIX
180 jne float_to_int16_u_int %+ SUFFIX
182 float_to_int16_u_int %+ SUFFIX
184 lea srcq, [srcq + 2*lenq]
189 mov%1 m0, [ srcq+2*lenq]
190 mov%1 m1, [mmsize + srcq+2*lenq]
196 mov%1 [ dstq+lenq], m0
202 %macro INT32_TO_INT16 1
203 cglobal int32_to_int16_%1, 3, 3, 2, dst, src, len
209 jne int32_to_int16_u_int %+ SUFFIX
211 jne int32_to_int16_u_int %+ SUFFIX
213 int32_to_int16_u_int %+ SUFFIX
215 lea srcq, [srcq + 2*lenq]
219 mov%1 m0, [ srcq+2*lenq]
220 mov%1 m1, [mmsize + srcq+2*lenq]
224 mov%1 [ dstq+lenq], m0