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/x86util.asm"
25 flt2pm31: times 8 dd 4.6566129e-10
26 flt2p31 : times 8 dd 2147483648.0
27 flt2p15 : times 8 dd 32768.0
29 word_unpack_shuf : db 0, 1, 4, 5, 8, 9,12,13, 2, 3, 6, 7,10,11,14,15
34 ;to, from, a/u, log2_outsize, log_intsize, const
36 cglobal pack_2ch_%2_to_%1_%3, 3, 4, 6, dst, src, len, src2
37 mov src2q , [srcq+gprsize]
42 jne pack_2ch_%2_to_%1_u_int %+ SUFFIX
44 jne pack_2ch_%2_to_%1_u_int %+ SUFFIX
46 jne pack_2ch_%2_to_%1_u_int %+ SUFFIX
48 pack_2ch_%2_to_%1_u_int %+ SUFFIX
50 lea srcq , [srcq + (1<<%5)*lenq]
51 lea src2q, [src2q + (1<<%5)*lenq]
52 lea dstq , [dstq + (2<<%4)*lenq]
57 mov%3 m0, [ srcq +(1<<%5)*lenq]
59 mov%3 m2, [ src2q+(1<<%5)*lenq]
69 mov%3 m0, [ srcq +(1<<%5)*lenq]
70 mov%3 m1, [mmsize + srcq +(1<<%5)*lenq]
71 mov%3 m2, [ src2q+(1<<%5)*lenq]
72 mov%3 m3, [mmsize + src2q+(1<<%5)*lenq]
79 mov%3 [ dstq+(2<<%4)*lenq], m0
80 mov%3 [ mmsize + dstq+(2<<%4)*lenq], m1
82 mov%3 [2*mmsize + dstq+(2<<%4)*lenq], m2
83 mov%3 [3*mmsize + dstq+(2<<%4)*lenq], m3
84 add lenq, 4*mmsize/(2<<%4)
86 add lenq, 2*mmsize/(2<<%4)
93 cglobal unpack_2ch_%2_to_%1_%3, 3, 4, 7, dst, src, len, dst2
94 mov dst2q , [dstq+gprsize]
99 jne unpack_2ch_%2_to_%1_u_int %+ SUFFIX
101 jne unpack_2ch_%2_to_%1_u_int %+ SUFFIX
103 jne unpack_2ch_%2_to_%1_u_int %+ SUFFIX
105 unpack_2ch_%2_to_%1_u_int %+ SUFFIX
107 lea srcq , [srcq + (2<<%5)*lenq]
108 lea dstq , [dstq + (1<<%4)*lenq]
109 lea dst2q, [dst2q + (1<<%4)*lenq]
112 mova m6, [word_unpack_shuf]
114 mov%3 m0, [ srcq +(2<<%5)*lenq]
115 mov%3 m2, [ mmsize + srcq +(2<<%5)*lenq]
117 %ifidn SUFFIX, _ssse3
138 shufps m0, m2, 10001000b
139 shufps m1, m2, 11011101b
142 mov%3 m2, [2*mmsize + srcq +(2<<%5)*lenq]
144 mov%3 m4, [3*mmsize + srcq +(2<<%5)*lenq]
145 shufps m2, m4, 10001000b
146 shufps m3, m4, 11011101b
150 mov%3 [ dstq+(1<<%4)*lenq], m0
152 mov%3 [ dst2q+(1<<%4)*lenq], m2
153 mov%3 [ mmsize + dstq+(1<<%4)*lenq], m1
154 mov%3 [ mmsize + dst2q+(1<<%4)*lenq], m3
155 add lenq, 2*mmsize/(1<<%4)
157 mov%3 [ dst2q+(1<<%4)*lenq], m1
158 add lenq, mmsize/(1<<%4)
165 cglobal %2_to_%1_%3, 3, 3, 6, dst, src, len
170 jne %2_to_%1_u_int %+ SUFFIX
172 jne %2_to_%1_u_int %+ SUFFIX
174 %2_to_%1_u_int %+ SUFFIX
176 lea srcq , [srcq + (1<<%5)*lenq]
177 lea dstq , [dstq + (1<<%4)*lenq]
181 mov%3 m0, [ srcq +(1<<%5)*lenq]
182 mov%3 m1, [ mmsize + srcq +(1<<%5)*lenq]
184 mov%3 m2, [2*mmsize + srcq +(1<<%5)*lenq]
185 mov%3 m3, [3*mmsize + srcq +(1<<%5)*lenq]
188 mov%3 [ dstq+(1<<%4)*lenq], m0
189 mov%3 [ mmsize + dstq+(1<<%4)*lenq], m1
191 mov%3 [2*mmsize + dstq+(1<<%4)*lenq], m2
192 mov%3 [3*mmsize + dstq+(1<<%4)*lenq], m3
193 add lenq, 4*mmsize/(1<<%4)
195 add lenq, 2*mmsize/(1<<%4)
202 cglobal pack_6ch_%2_to_%1_%3, 2,8,7, dst, src, src1, src2, src3, src4, src5, len
206 %define lend dword r2m
208 mov src1q, [srcq+1*gprsize]
209 mov src2q, [srcq+2*gprsize]
210 mov src3q, [srcq+3*gprsize]
211 mov src4q, [srcq+4*gprsize]
212 mov src5q, [srcq+5*gprsize]
217 jne pack_6ch_%2_to_%1_u_int %+ SUFFIX
219 jne pack_6ch_%2_to_%1_u_int %+ SUFFIX
221 jne pack_6ch_%2_to_%1_u_int %+ SUFFIX
223 jne pack_6ch_%2_to_%1_u_int %+ SUFFIX
225 jne pack_6ch_%2_to_%1_u_int %+ SUFFIX
227 jne pack_6ch_%2_to_%1_u_int %+ SUFFIX
229 pack_6ch_%2_to_%1_u_int %+ SUFFIX
238 mov%3 m1, [srcq+src1q]
239 mov%3 m2, [srcq+src2q]
240 mov%3 m3, [srcq+src3q]
241 mov%3 m4, [srcq+src4q]
242 mov%3 m5, [srcq+src5q]
249 blendps m6, m4, m0, 1100b
252 blendps m2, m5, m1, 1100b
260 mov %+ %3 %+ ps [dstq ], m0
261 mov %+ %3 %+ ps [dstq+16], m6
262 mov %+ %3 %+ ps [dstq+32], m4
263 mov %+ %3 %+ ps [dstq+48], m1
264 mov %+ %3 %+ ps [dstq+64], m2
265 mov %+ %3 %+ ps [dstq+80], m5
267 SBUTTERFLY dq, 0, 1, 6
268 SBUTTERFLY dq, 2, 3, 6
269 SBUTTERFLY dq, 4, 5, 6
290 %macro INT16_TO_INT32_N 6
302 %macro INT32_TO_INT16_N 6
312 %macro INT32_TO_FLOAT_INIT 6
315 %macro INT32_TO_FLOAT_N 6
322 %macro FLOAT_TO_INT32_INIT 6
325 %macro FLOAT_TO_INT32_N 6
336 %macro INT16_TO_FLOAT_INIT 6
339 %macro INT16_TO_FLOAT_N 6
340 INT16_TO_INT32_N %1,%2,%3,%4,%5,%6
351 %macro FLOAT_TO_INT16_INIT 6
354 %macro FLOAT_TO_INT16_N 6
371 CONV int32, int16, u, 2, 1, INT16_TO_INT32_N, NOP_N
372 CONV int32, int16, a, 2, 1, INT16_TO_INT32_N, NOP_N
373 CONV int16, int32, u, 1, 2, INT32_TO_INT16_N, NOP_N
374 CONV int16, int32, a, 1, 2, INT32_TO_INT16_N, NOP_N
376 PACK_6CH float, float, u, 2, 2, NOP_N, NOP_N
377 PACK_6CH float, float, a, 2, 2, NOP_N, NOP_N
380 CONV int32, int16, u, 2, 1, INT16_TO_INT32_N, NOP_N
381 CONV int32, int16, a, 2, 1, INT16_TO_INT32_N, NOP_N
382 CONV int16, int32, u, 1, 2, INT32_TO_INT16_N, NOP_N
383 CONV int16, int32, a, 1, 2, INT32_TO_INT16_N, NOP_N
385 PACK_2CH int16, int16, u, 1, 1, NOP_N, NOP_N
386 PACK_2CH int16, int16, a, 1, 1, NOP_N, NOP_N
387 PACK_2CH int32, int32, u, 2, 2, NOP_N, NOP_N
388 PACK_2CH int32, int32, a, 2, 2, NOP_N, NOP_N
389 PACK_2CH int32, int16, u, 2, 1, INT16_TO_INT32_N, NOP_N
390 PACK_2CH int32, int16, a, 2, 1, INT16_TO_INT32_N, NOP_N
391 PACK_2CH int16, int32, u, 1, 2, INT32_TO_INT16_N, NOP_N
392 PACK_2CH int16, int32, a, 1, 2, INT32_TO_INT16_N, NOP_N
394 UNPACK_2CH int16, int16, u, 1, 1, NOP_N, NOP_N
395 UNPACK_2CH int16, int16, a, 1, 1, NOP_N, NOP_N
396 UNPACK_2CH int32, int32, u, 2, 2, NOP_N, NOP_N
397 UNPACK_2CH int32, int32, a, 2, 2, NOP_N, NOP_N
398 UNPACK_2CH int32, int16, u, 2, 1, INT16_TO_INT32_N, NOP_N
399 UNPACK_2CH int32, int16, a, 2, 1, INT16_TO_INT32_N, NOP_N
400 UNPACK_2CH int16, int32, u, 1, 2, INT32_TO_INT16_N, NOP_N
401 UNPACK_2CH int16, int32, a, 1, 2, INT32_TO_INT16_N, NOP_N
403 CONV float, int32, u, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
404 CONV float, int32, a, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
405 CONV int32, float, u, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
406 CONV int32, float, a, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
407 CONV float, int16, u, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
408 CONV float, int16, a, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
409 CONV int16, float, u, 1, 2, FLOAT_TO_INT16_N, FLOAT_TO_INT16_INIT
410 CONV int16, float, a, 1, 2, FLOAT_TO_INT16_N, FLOAT_TO_INT16_INIT
412 PACK_2CH float, int32, u, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
413 PACK_2CH float, int32, a, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
414 PACK_2CH int32, float, u, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
415 PACK_2CH int32, float, a, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
416 PACK_2CH float, int16, u, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
417 PACK_2CH float, int16, a, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
418 PACK_2CH int16, float, u, 1, 2, FLOAT_TO_INT16_N, FLOAT_TO_INT16_INIT
419 PACK_2CH int16, float, a, 1, 2, FLOAT_TO_INT16_N, FLOAT_TO_INT16_INIT
421 UNPACK_2CH float, int32, u, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
422 UNPACK_2CH float, int32, a, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
423 UNPACK_2CH int32, float, u, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
424 UNPACK_2CH int32, float, a, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
425 UNPACK_2CH float, int16, u, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
426 UNPACK_2CH float, int16, a, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
427 UNPACK_2CH int16, float, u, 1, 2, FLOAT_TO_INT16_N, FLOAT_TO_INT16_INIT
428 UNPACK_2CH int16, float, a, 1, 2, FLOAT_TO_INT16_N, FLOAT_TO_INT16_INIT
432 UNPACK_2CH int16, int16, u, 1, 1, NOP_N, NOP_N
433 UNPACK_2CH int16, int16, a, 1, 1, NOP_N, NOP_N
434 UNPACK_2CH int32, int16, u, 2, 1, INT16_TO_INT32_N, NOP_N
435 UNPACK_2CH int32, int16, a, 2, 1, INT16_TO_INT32_N, NOP_N
436 UNPACK_2CH float, int16, u, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
437 UNPACK_2CH float, int16, a, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
440 PACK_6CH float, float, u, 2, 2, NOP_N, NOP_N
441 PACK_6CH float, float, a, 2, 2, NOP_N, NOP_N
443 PACK_6CH float, int32, u, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
444 PACK_6CH float, int32, a, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
445 PACK_6CH int32, float, u, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
446 PACK_6CH int32, float, a, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
448 %if HAVE_AVX_EXTERNAL
450 PACK_6CH float, float, u, 2, 2, NOP_N, NOP_N
451 PACK_6CH float, float, a, 2, 2, NOP_N, NOP_N
453 PACK_6CH float, int32, u, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
454 PACK_6CH float, int32, a, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
455 PACK_6CH int32, float, u, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
456 PACK_6CH int32, float, a, 2, 2, FLOAT_TO_INT32_N, FLOAT_TO_INT32_INIT
459 CONV float, int32, u, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
460 CONV float, int32, a, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT