1;******************************************************************************
2;* Vorbis x86 optimizations
3;* Copyright (C) 2006 Loren Merritt <lorenm@u.washington.edu>
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_RODATA
25
26pdw_80000000: times 4 dd 0x80000000
27
28SECTION .text
29
30INIT_XMM sse
31cglobal vorbis_inverse_coupling, 3, 3, 6, mag, ang, block_size
32    mova                     m5, [pdw_80000000]
33    shl             block_sized, 2
34    add                    magq, block_sizeq
35    add                    angq, block_sizeq
36    neg             block_sizeq
37
38align 16
39.loop:
40    mova                     m0, [magq+block_sizeq]
41    mova                     m1, [angq+block_sizeq]
42    xorps                    m2, m2
43    xorps                    m3, m3
44    cmpleps                  m2, m0     ; m <= 0.0
45    cmpleps                  m3, m1     ; a <= 0.0
46    andps                    m2, m5     ; keep only the sign bit
47    xorps                    m1, m2
48    mova                     m4, m3
49    andps                    m3, m1
50    andnps                   m4, m1
51    addps                    m3, m0     ; a = m + ((a < 0) & (a ^ sign(m)))
52    subps                    m0, m4     ; m = m + ((a > 0) & (a ^ sign(m)))
53    mova     [angq+block_sizeq], m3
54    mova     [magq+block_sizeq], m0
55    add             block_sizeq, mmsize
56    jl .loop
57    RET
58