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