1 ;******************************************************************************
2 ;* x86 optimized Format Conversion Utils
3 ;* Copyright (c) 2008 Loren Merritt
5 ;* This file is part of Libav.
7 ;* Libav is free software; you can redistribute it and/or
8 ;* modify it under the terms of the GNU Lesser General Public
9 ;* License as published by the Free Software Foundation; either
10 ;* version 2.1 of the License, or (at your option) any later version.
12 ;* Libav is distributed in the hope that it will be useful,
13 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;* Lesser General Public License for more details.
17 ;* You should have received a copy of the GNU Lesser General Public
18 ;* License along with Libav; if not, write to the Free Software
19 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 ;******************************************************************************
23 %include "x86util.asm"
27 ;------------------------------------------------------------------------------
28 ; void ff_float_to_int16(int16_t *dst, const float *src, long len);
29 ;------------------------------------------------------------------------------
30 %macro FLOAT_TO_INT16 2
31 cglobal float_to_int16_%1, 3,3,%2, dst, src, len
33 lea srcq, [srcq+2*lenq]
38 cvtps2dq m0, [srcq+2*lenq ]
39 cvtps2dq m1, [srcq+2*lenq+16]
43 cvtps2pi m0, [srcq+2*lenq ]
44 cvtps2pi m1, [srcq+2*lenq+ 8]
45 cvtps2pi m2, [srcq+2*lenq+16]
46 cvtps2pi m3, [srcq+2*lenq+24]
50 mova [dstq+lenq+8], m2
61 FLOAT_TO_INT16 sse2, 2
64 %define cvtps2pi pf2id
65 FLOAT_TO_INT16 3dnow, 0
78 %macro FLOAT_TO_INT16_INTERLEAVE6 1
79 ; void float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len)
80 cglobal float_to_int16_interleave6_%1, 2,7,0, dst, src, src1, src2, src3, src4, src5
85 %define lend dword r2m
87 mov src1q, [srcq+1*gprsize]
88 mov src2q, [srcq+2*gprsize]
89 mov src3q, [srcq+3*gprsize]
90 mov src4q, [srcq+4*gprsize]
91 mov src5q, [srcq+5*gprsize]
100 cvtps2pi mm1, [srcq+src1q]
101 cvtps2pi mm2, [srcq+src2q]
102 cvtps2pi mm3, [srcq+src3q]
103 cvtps2pi mm4, [srcq+src4q]
104 cvtps2pi mm5, [srcq+src5q]
125 %endmacro ; FLOAT_TO_INT16_INTERLEAVE6
127 %define pswapd PSWAPD_SSE
128 FLOAT_TO_INT16_INTERLEAVE6 sse
129 %define cvtps2pi pf2id
130 %define pswapd PSWAPD_3DN1
131 FLOAT_TO_INT16_INTERLEAVE6 3dnow
133 FLOAT_TO_INT16_INTERLEAVE6 3dn2
136 ;-----------------------------------------------------------------------------
137 ; void ff_float_interleave6(float *dst, const float **src, unsigned int len);
138 ;-----------------------------------------------------------------------------
140 %macro FLOAT_INTERLEAVE6 2
141 cglobal float_interleave6_%1, 2,7,%2, dst, src, src1, src2, src3, src4, src5
146 %define lend dword r2m
148 mov src1q, [srcq+1*gprsize]
149 mov src2q, [srcq+2*gprsize]
150 mov src3q, [srcq+3*gprsize]
151 mov src4q, [srcq+4*gprsize]
152 mov src5q, [srcq+5*gprsize]
162 movaps m1, [srcq+src1q]
163 movaps m2, [srcq+src2q]
164 movaps m3, [srcq+src3q]
165 movaps m4, [srcq+src4q]
166 movaps m5, [srcq+src5q]
189 movq m1, [srcq+src1q]
190 movq m2, [srcq+src2q]
191 movq m3, [srcq+src3q]
192 movq m4, [srcq+src4q]
193 movq m5, [srcq+src5q]
195 SBUTTERFLY dq, 0, 1, 6
196 SBUTTERFLY dq, 2, 3, 6
197 SBUTTERFLY dq, 4, 5, 6
216 FLOAT_INTERLEAVE6 mmx, 0
218 FLOAT_INTERLEAVE6 sse, 7
220 ;-----------------------------------------------------------------------------
221 ; void ff_float_interleave2(float *dst, const float **src, unsigned int len);
222 ;-----------------------------------------------------------------------------
224 %macro FLOAT_INTERLEAVE2 2
225 cglobal float_interleave2_%1, 3,4,%2, dst, src, len, src1
226 mov src1q, [srcq+gprsize]
231 MOVPS m1, [srcq+src1q ]
232 MOVPS m3, [srcq +mmsize]
233 MOVPS m4, [srcq+src1q+mmsize]
244 MOVPS [dstq+1*mmsize], m2
245 MOVPS [dstq+2*mmsize], m3
246 MOVPS [dstq+3*mmsize], m1
260 %define PUNPCKLDQ punpckldq
261 %define PUNPCKHDQ punpckhdq
262 FLOAT_INTERLEAVE2 mmx, 0
265 %define PUNPCKLDQ unpcklps
266 %define PUNPCKHDQ unpckhps
267 FLOAT_INTERLEAVE2 sse, 5