]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/sbrdsp.asm
x86: yasm: Use complete source path for macro helper %includes
[ffmpeg] / libavcodec / x86 / sbrdsp.asm
1 ;******************************************************************************
2 ;* AAC Spectral Band Replication decoding functions
3 ;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com>
4 ;*
5 ;* This file is part of Libav.
6 ;*
7 ;* Libav 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 ;* Libav 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 Libav; 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
24 ;SECTION_RODATA
25 SECTION .text
26
27 INIT_XMM sse
28 cglobal sbr_sum_square, 2, 3, 6
29     mov         r2, r1
30     xorps       m0, m0
31     xorps       m1, m1
32     sar         r2, 3
33     jz          .prepare
34 .loop:
35     movu        m2, [r0 +  0]
36     movu        m3, [r0 + 16]
37     movu        m4, [r0 + 32]
38     movu        m5, [r0 + 48]
39     mulps       m2, m2
40     mulps       m3, m3
41     mulps       m4, m4
42     mulps       m5, m5
43     addps       m0, m2
44     addps       m1, m3
45     addps       m0, m4
46     addps       m1, m5
47     add         r0, 64
48     dec         r2
49     jnz         .loop
50 .prepare:
51     and         r1, 7
52     sar         r1, 1
53     jz          .end
54 ; len is a multiple of 2, thus there are at least 4 elements to process
55 .endloop:
56     movu        m2, [r0]
57     add         r0, 16
58     mulps       m2, m2
59     dec         r1
60     addps       m0, m2
61     jnz         .endloop
62 .end:
63     addps       m0, m1
64     movhlps     m2, m0
65     addps       m0, m2
66     movss       m1, m0
67     shufps      m0, m0, 1
68     addss       m0, m1
69 %if ARCH_X86_64 == 0
70     movss       r0m,  m0
71     fld         dword r0m
72 %endif
73     RET
74
75 %define STEP  40*4*2
76 cglobal sbr_hf_g_filt, 5, 6, 5
77     lea         r1, [r1 + 8*r4] ; offset by ixh elements into X_high
78     mov         r5, r3
79     and         r3, 0xFC
80     lea         r2, [r2 + r3*4]
81     lea         r0, [r0 + r3*8]
82     neg         r3
83     jz          .loop1
84 .loop4:
85     movlps      m0, [r2 + 4*r3 + 0]
86     movlps      m1, [r2 + 4*r3 + 8]
87     movlps      m2, [r1 + 0*STEP]
88     movlps      m3, [r1 + 2*STEP]
89     movhps      m2, [r1 + 1*STEP]
90     movhps      m3, [r1 + 3*STEP]
91     unpcklps    m0, m0
92     unpcklps    m1, m1
93     mulps       m0, m2
94     mulps       m1, m3
95     movu        [r0 + 8*r3 +  0], m0
96     movu        [r0 + 8*r3 + 16], m1
97     add         r1, 4*STEP
98     add         r3, 4
99     jnz         .loop4
100     and         r5, 3 ; number of single element loops
101     jz          .end
102 .loop1: ; element 0 and 1 can be computed at the same time
103     movss       m0, [r2]
104     movlps      m2, [r1]
105     unpcklps    m0, m0
106     mulps       m2, m0
107     movlps    [r0], m2
108     add         r0, 8
109     add         r2, 4
110     add         r1, STEP
111     dec         r5
112     jnz         .loop1
113 .end:
114     RET