]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/opusdsp.asm
avcodec: Remove deprecated old encode/decode APIs
[ffmpeg] / libavcodec / x86 / opusdsp.asm
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.
10 ;*
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.
15 ;*
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 ;******************************************************************************
20
21 %include "libavutil/x86/x86util.asm"
22
23 SECTION_RODATA
24
25          ; 0.85..^1    0.85..^2    0.85..^3    0.85..^4
26 tab_st: dd 0x3f599a00, 0x3f38f671, 0x3f1d382a, 0x3f05a32f
27
28 SECTION .text
29
30 INIT_XMM fma3
31 %if UNIX64
32 cglobal opus_deemphasis, 3, 3, 8, out, in, len
33 %else
34 cglobal opus_deemphasis, 4, 4, 8, out, in, coeff, len
35 %endif
36 %if ARCH_X86_32
37     VBROADCASTSS m0, coeffm
38 %elif WIN64
39     shufps m0, m2, m2, 0
40 %else
41     shufps m0, m0, 0
42 %endif
43
44     movaps m4, [tab_st]
45     VBROADCASTSS m5, m4
46     shufps m6, m4, m4, q1111
47     shufps m7, m4, m4, q2222
48
49 .loop:
50     movaps  m1, [inq]                ; x0, x1, x2, x3
51
52     pslldq  m2, m1, 4                ;  0, x0, x1, x2
53     pslldq  m3, m1, 8                ;  0,  0, x0, x1
54
55     fmaddps m2, m2, m5, m1           ; x + c1*x[0-2]
56     pslldq  m1, 12                   ;  0,  0,  0, x0
57
58     fmaddps m2, m3, m6, m2           ; x + c1*x[0-2] + c2*x[0-1]
59     fmaddps m1, m1, m7, m2           ; x + c1*x[0-2] + c2*x[0-1] + c3*x[0]
60     fmaddps m0, m0, m4, m1           ; x + c1*x[0-2] + c2*x[0-1] + c3*x[0] + c*s
61
62     movaps [outq], m0
63     shufps m0, m0, q3333             ; new state
64
65     add inq,  mmsize
66     add outq, mmsize
67     sub lend, mmsize >> 2
68     jg .loop
69
70 %if ARCH_X86_64 == 0
71     movss r0m, m0
72     fld dword r0m
73 %endif
74     RET
75
76
77 INIT_XMM fma3
78 cglobal opus_postfilter, 4, 4, 8, data, period, gains, len
79     VBROADCASTSS m0, [gainsq + 0]
80     VBROADCASTSS m1, [gainsq + 4]
81     VBROADCASTSS m2, [gainsq + 8]
82
83     shl periodd, 2
84     add periodq, 8
85     neg periodq
86
87     movups  m3, [dataq + periodq]
88     mulps   m3, m2
89
90 .loop:
91     movups  m4, [dataq + periodq +  4]
92     movups  m5, [dataq + periodq +  8]
93     movups  m6, [dataq + periodq + 12]
94     movups  m7, [dataq + periodq + 16]
95
96     fmaddps m3, m7, m2, m3
97     addps   m6, m4
98
99     fmaddps m5, m5, m0, [dataq]
100     fmaddps m6, m6, m1, m3
101
102     addps   m5, m6
103     mulps   m3, m7, m2
104
105     movaps  [dataq], m5
106
107     add dataq, mmsize
108     sub lend,  mmsize >> 2
109     jg .loop
110
111     RET