threadprogress: reorder instructions to fix race.
[ffmpeg.git] / libavcodec / x86 / opusdsp.asm
blob635f59f83ccdc54a7dae4e63d5cf96692291c3b0
1 ;******************************************************************************
2 ;* Opus SIMD functions
3 ;*
4 ;* This file is part of FFmpeg.
5 ;*
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"
23 SECTION_RODATA
25 SECTION .text
27 INIT_XMM fma3
28 %if UNIX64
29 cglobal opus_deemphasis, 4, 4, 8, out, in, weights, len
30 %else
31 cglobal opus_deemphasis, 5, 5, 8, out, in, coeff, weights, len
32 %endif
33 %if ARCH_X86_32
34 VBROADCASTSS m0, coeffm
35 %elif WIN64
36 shufps m0, m2, m2, 0
37 %else
38 shufps m0, m0, 0
39 %endif
41 movaps m4, [weightsq]
42 VBROADCASTSS m5, m4
43 shufps m6, m4, m4, q1111
44 shufps m7, m4, m4, q2222
46 .loop:
47 movaps m1, [inq] ; x0, x1, x2, x3
49 pslldq m2, m1, 4 ; 0, x0, x1, x2
50 pslldq m3, m1, 8 ; 0, 0, x0, x1
52 fmaddps m2, m2, m5, m1 ; x + c1*x[0-2]
53 pslldq m1, 12 ; 0, 0, 0, x0
55 fmaddps m2, m3, m6, m2 ; x + c1*x[0-2] + c2*x[0-1]
56 fmaddps m1, m1, m7, m2 ; x + c1*x[0-2] + c2*x[0-1] + c3*x[0]
57 fmaddps m0, m0, m4, m1 ; x + c1*x[0-2] + c2*x[0-1] + c3*x[0] + c*s
59 movaps [outq], m0
60 shufps m0, m0, q3333 ; new state
62 add inq, mmsize
63 add outq, mmsize
64 sub lend, mmsize >> 2
65 jg .loop
67 %if ARCH_X86_64 == 0
68 movss r0m, m0
69 fld dword r0m
70 %endif
71 RET
74 INIT_XMM fma3
75 cglobal opus_postfilter, 4, 4, 8, data, period, gains, len
76 VBROADCASTSS m0, [gainsq + 0]
77 VBROADCASTSS m1, [gainsq + 4]
78 VBROADCASTSS m2, [gainsq + 8]
80 shl periodd, 2
81 add periodq, 8
82 neg periodq
84 movups m3, [dataq + periodq]
85 mulps m3, m2
87 .loop:
88 movups m4, [dataq + periodq + 4]
89 movups m5, [dataq + periodq + 8]
90 movups m6, [dataq + periodq + 12]
91 movups m7, [dataq + periodq + 16]
93 fmaddps m3, m7, m2, m3
94 addps m6, m4
96 fmaddps m5, m5, m0, [dataq]
97 fmaddps m6, m6, m1, m3
99 addps m5, m6
100 mulps m3, m7, m2
102 movaps [dataq], m5
104 add dataq, mmsize
105 sub lend, mmsize >> 2
106 jg .loop