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
38 jne int16_to_int32_u_int %+ SUFFIX
40 jne int16_to_int32_u_int %+ SUFFIX
42 int16_to_int32_u_int %+ SUFFIX
54 mov%1 [ dstq+2*lenq], m0
55 mov%1 [mmsize + dstq+2*lenq], m1
64 %macro INT32_TO_FLOAT 1
65 cglobal int32_to_float_%1, 3, 3, 3, dst, src, len
70 jne int32_to_float_u_int %+ SUFFIX
72 jne int32_to_float_u_int %+ SUFFIX
74 int32_to_float_u_int %+ SUFFIX
82 cvtdq2ps m0, [ srcq+lenq]
83 cvtdq2ps m1, [mmsize + srcq+lenq]
86 movu m1, [mmsize + srcq+lenq]
92 mov%1 [ dstq+lenq], m0
93 mov%1 [mmsize + dstq+lenq], m1
99 %macro INT16_TO_FLOAT 1
100 cglobal int16_to_float_%1, 3, 3, 4, dst, src, len
105 jne int16_to_float_u_int %+ SUFFIX
107 jne int16_to_float_u_int %+ SUFFIX
109 int16_to_float_u_int %+ SUFFIX
117 mov%1 m2, [srcq+lenq]
126 mov%1 [ dstq+2*lenq], m0
127 mov%1 [mmsize + dstq+2*lenq], m1
133 %macro FLOAT_TO_INT32 1
134 cglobal float_to_int32_%1, 3, 3, 5, dst, src, len
139 jne float_to_int32_u_int %+ SUFFIX
141 jne float_to_int32_u_int %+ SUFFIX
143 float_to_int32_u_int %+ SUFFIX
150 mov%1 m0, [ srcq+lenq]
151 mov%1 m1, [mmsize + srcq+lenq]
160 mov%1 [ dstq+lenq], m0
161 mov%1 [mmsize + dstq+lenq], m1
167 %macro FLOAT_TO_INT16 1
168 cglobal float_to_int16_%1, 3, 3, 3, dst, src, len
173 jne float_to_int16_u_int %+ SUFFIX
175 jne float_to_int16_u_int %+ SUFFIX
177 float_to_int16_u_int %+ SUFFIX
179 lea srcq, [srcq + 2*lenq]
184 mov%1 m0, [ srcq+2*lenq]
185 mov%1 m1, [mmsize + srcq+2*lenq]
191 mov%1 [ dstq+lenq], m0
197 %macro INT32_TO_INT16 1
198 cglobal int32_to_int16_%1, 3, 3, 2, dst, src, len
203 jne int32_to_int16_u_int %+ SUFFIX
205 jne int32_to_int16_u_int %+ SUFFIX
207 int32_to_int16_u_int %+ SUFFIX
209 lea srcq, [srcq + 2*lenq]
213 mov%1 m0, [ srcq+2*lenq]
214 mov%1 m1, [mmsize + srcq+2*lenq]
218 mov%1 [ dstq+lenq], m0