1;******************************************************************************
2;* x86 optimized Format Conversion Utils
3;* Copyright (c) 2008 Loren Merritt
4;*
5;* This file is part of FFmpeg.
6;*
7;* FFmpeg 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.
11;*
12;* FFmpeg 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.
16;*
17;* You should have received a copy of the GNU Lesser General Public
18;* License along with FFmpeg; if not, write to the Free Software
19;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20;******************************************************************************
21
22%include "libavutil/x86/x86util.asm"
23
24SECTION .text
25
26;------------------------------------------------------------------------------
27; void ff_int32_to_float_fmul_scalar(float *dst, const int32_t *src, float mul,
28;                                    int len);
29;------------------------------------------------------------------------------
30%macro INT32_TO_FLOAT_FMUL_SCALAR 1
31%if UNIX64
32cglobal int32_to_float_fmul_scalar, 3, 3, %1, dst, src, len
33%else
34cglobal int32_to_float_fmul_scalar, 4, 4, %1, dst, src, mul, len
35%endif
36%if WIN64
37    SWAP 0, 2
38%elif ARCH_X86_32
39    movss   m0, mulm
40%endif
41    SPLATD  m0
42    shl     lend, 2
43    add     srcq, lenq
44    add     dstq, lenq
45    neg     lenq
46.loop:
47    cvtdq2ps  m1, [srcq+lenq   ]
48    cvtdq2ps  m2, [srcq+lenq+16]
49    mulps     m1, m0
50    mulps     m2, m0
51    mova  [dstq+lenq   ], m1
52    mova  [dstq+lenq+16], m2
53    add     lenq, 32
54    jl .loop
55    RET
56%endmacro
57
58INIT_XMM sse2
59INT32_TO_FLOAT_FMUL_SCALAR 3
60
61;------------------------------------------------------------------------------
62; void ff_int32_to_float_fmul_array8(FmtConvertContext *c, float *dst, const int32_t *src,
63;                                    const float *mul, int len);
64;------------------------------------------------------------------------------
65%macro INT32_TO_FLOAT_FMUL_ARRAY8 0
66cglobal int32_to_float_fmul_array8, 5, 5, 5, c, dst, src, mul, len
67    shl     lend, 2
68    add     srcq, lenq
69    add     dstq, lenq
70    neg     lenq
71.loop:
72    movss     m0, [mulq]
73    SPLATD    m0
74    cvtdq2ps  m1, [srcq+lenq   ]
75    cvtdq2ps  m2, [srcq+lenq+16]
76    mulps     m1, m0
77    mulps     m2, m0
78    mova  [dstq+lenq   ], m1
79    mova  [dstq+lenq+16], m2
80    add     mulq, 4
81    add     lenq, 32
82    jl .loop
83    RET
84%endmacro
85
86INIT_XMM sse2
87INT32_TO_FLOAT_FMUL_ARRAY8
88
89