]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/hevc_idct.asm
Merge commit '6f9e34baea4f6f484392e4e67f606a0835d07b73'
[ffmpeg] / libavcodec / x86 / hevc_idct.asm
1 ;*******************************************************************************
2 ;* SIMD-optimized IDCT functions for HEVC decoding
3 ;* Copyright (c) 2014 Pierre-Edouard LEPERE
4 ;* Copyright (c) 2014 James Almer
5 ;*
6 ;* This file is part of FFmpeg.
7 ;*
8 ;* FFmpeg is free software; you can redistribute it and/or
9 ;* modify it under the terms of the GNU Lesser General Public
10 ;* License as published by the Free Software Foundation; either
11 ;* version 2.1 of the License, or (at your option) any later version.
12 ;*
13 ;* FFmpeg is distributed in the hope that it will be useful,
14 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ;* Lesser General Public License for more details.
17 ;*
18 ;* You should have received a copy of the GNU Lesser General Public
19 ;* License along with FFmpeg; if not, write to the Free Software
20 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 ;******************************************************************************
22
23 %include "libavutil/x86/x86util.asm"
24
25 SECTION .text
26
27 ; void ff_hevc_idct_HxW_dc_{8,10}_<opt>(int16_t *coeffs)
28 ; %1 = HxW
29 ; %2 = number of loops
30 ; %3 = bitdepth
31 %macro IDCT_DC 3
32 cglobal hevc_idct_%1x%1_dc_%3, 1, 2, 1, coeff, tmp
33     movsx             tmpd, word [coeffq]
34     add               tmpd, (1 << (14 - %3)) + 1
35     sar               tmpd, (15 - %3)
36     movd               xm0, tmpd
37     SPLATW              m0, xm0
38     DEFINE_ARGS coeff, cnt
39     mov               cntd, %2
40 .loop:
41     mova [coeffq+mmsize*0], m0
42     mova [coeffq+mmsize*1], m0
43     mova [coeffq+mmsize*2], m0
44     mova [coeffq+mmsize*3], m0
45     add  coeffq, mmsize*8
46     mova [coeffq+mmsize*-4], m0
47     mova [coeffq+mmsize*-3], m0
48     mova [coeffq+mmsize*-2], m0
49     mova [coeffq+mmsize*-1], m0
50     dec  cntd
51     jg  .loop
52     RET
53 %endmacro
54
55 ; %1 = HxW
56 ; %2 = bitdepth
57 %macro IDCT_DC_NL 2 ; No loop
58 cglobal hevc_idct_%1x%1_dc_%2, 1, 2, 1, coeff, tmp
59     movsx             tmpd, word [coeffq]
60     add               tmpd, (1 << (14 - %2)) + 1
61     sar               tmpd, (15 - %2)
62     movd                m0, tmpd
63     SPLATW              m0, xm0
64     mova [coeffq+mmsize*0], m0
65     mova [coeffq+mmsize*1], m0
66     mova [coeffq+mmsize*2], m0
67     mova [coeffq+mmsize*3], m0
68 %if mmsize == 16
69     mova [coeffq+mmsize*4], m0
70     mova [coeffq+mmsize*5], m0
71     mova [coeffq+mmsize*6], m0
72     mova [coeffq+mmsize*7], m0
73 %endif
74     RET
75 %endmacro
76
77 ; 8-bit
78 INIT_MMX mmxext
79 IDCT_DC_NL  4,      8
80 IDCT_DC     8,  2,  8
81
82 INIT_XMM sse2
83 IDCT_DC_NL  8,      8
84 IDCT_DC    16,  4,  8
85 IDCT_DC    32, 16,  8
86
87 %if HAVE_AVX2_EXTERNAL
88 INIT_YMM avx2
89 IDCT_DC    16,  2,  8
90 IDCT_DC    32,  8,  8
91 %endif ;HAVE_AVX2_EXTERNAL
92
93 ; 10-bit
94 INIT_MMX mmxext
95 IDCT_DC_NL  4,     10
96 IDCT_DC     8,  2, 10
97
98 INIT_XMM sse2
99 IDCT_DC_NL  8,     10
100 IDCT_DC    16,  4, 10
101 IDCT_DC    32, 16, 10
102
103 %if HAVE_AVX2_EXTERNAL
104 INIT_YMM avx2
105 IDCT_DC    16,  2, 10
106 IDCT_DC    32,  8, 10
107 %endif ;HAVE_AVX2_EXTERNAL
108
109 ; 12-bit
110 INIT_MMX mmxext
111 IDCT_DC_NL  4,     12
112 IDCT_DC     8,  2, 12
113
114 INIT_XMM sse2
115 IDCT_DC_NL  8,     12
116 IDCT_DC    16,  4, 12
117 IDCT_DC    32, 16, 12
118
119 %if HAVE_AVX2_EXTERNAL
120 INIT_YMM avx2
121 IDCT_DC    16,  2, 12
122 IDCT_DC    32,  8, 12
123 %endif ;HAVE_AVX2_EXTERNAL