2 ; Copyright (c) 2014 The WebM project authors. All Rights Reserved.
4 ; Use of this source code is governed by a BSD-style license
5 ; that can be found in the LICENSE file in the root of the source
6 ; tree. An additional intellectual property rights grant can be found
7 ; in the file PATENTS. All contributing project authors may
8 ; be found in the AUTHORS file in the root of the source tree.
10 %include "third_party/x86inc/x86inc.asm"
12 ; This file provides SSSE3 version of the forward transformation. Part
13 ; of the macro definitions are originally derived from the ffmpeg project.
14 ; The current version applies to x86 64-bit only.
18 pw_11585x2: times 8 dw 23170
19 pd_8192: times 4 dd 8192
21 %macro TRANSFORM_COEFFS 2
22 pw_%1_%2: dw %1, %2, %1, %2, %1, %2, %1, %2
23 pw_%2_m%1: dw %2, -%1, %2, -%1, %2, -%1, %2, -%1
26 TRANSFORM_COEFFS 15137, 6270
27 TRANSFORM_COEFFS 16069, 3196
28 TRANSFORM_COEFFS 9102, 13623
40 %macro MUL_ADD_2X 6 ; dst1, dst2, src, round, coefs1, coefs2
49 %macro BUTTERFLY_4X 7 ; dst1, dst2, coef1, coef2, round, tmp1, tmp2
50 punpckhwd m%6, m%2, m%1
51 MUL_ADD_2X %7, %6, %6, %5, [pw_%4_%3], [pw_%3_m%4]
53 MUL_ADD_2X %1, %2, %2, %5, [pw_%4_%3], [pw_%3_m%4]
59 %macro INTERLEAVE_2X 4
60 punpckh%1 m%4, m%2, m%3
66 INTERLEAVE_2X wd, %1, %2, %9
67 INTERLEAVE_2X wd, %3, %4, %9
68 INTERLEAVE_2X wd, %5, %6, %9
69 INTERLEAVE_2X wd, %7, %8, %9
71 INTERLEAVE_2X dq, %1, %3, %9
72 INTERLEAVE_2X dq, %2, %4, %9
73 INTERLEAVE_2X dq, %5, %7, %9
74 INTERLEAVE_2X dq, %6, %8, %9
76 INTERLEAVE_2X qdq, %1, %5, %9
77 INTERLEAVE_2X qdq, %3, %7, %9
78 INTERLEAVE_2X qdq, %2, %6, %9
79 INTERLEAVE_2X qdq, %4, %8, %9
85 ; 1D forward 8x8 DCT transform
97 BUTTERFLY_4X 2, 3, 6270, 15137, m8, 9, 10
106 BUTTERFLY_4X 4, 7, 3196, 16069, m8, 9, 10
107 BUTTERFLY_4X 5, 6, 13623, 9102, m8, 9, 10
112 %macro DIVIDE_ROUND_2X 4 ; dst1, dst2, tmp1, tmp2
122 cglobal fdct8x8, 3, 5, 13, input, output, stride
125 mova m12, [pw_11585x2]
128 lea r3, [2 * strideq]
129 lea r4, [4 * strideq]
131 mova m1, [inputq + r3]
132 lea inputq, [inputq + r4]
134 mova m3, [inputq + r3]
135 lea inputq, [inputq + r4]
137 mova m5, [inputq + r3]
138 lea inputq, [inputq + r4]
140 mova m7, [inputq + r3]
142 ; left shift by 2 to increase forward transformation precision
154 TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9
157 TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9
159 DIVIDE_ROUND_2X 0, 1, 9, 10
160 DIVIDE_ROUND_2X 2, 3, 9, 10
161 DIVIDE_ROUND_2X 4, 5, 9, 10
162 DIVIDE_ROUND_2X 6, 7, 9, 10
164 mova [outputq + 0], m0
165 mova [outputq + 16], m1
166 mova [outputq + 32], m2
167 mova [outputq + 48], m3
168 mova [outputq + 64], m4
169 mova [outputq + 80], m5
170 mova [outputq + 96], m6
171 mova [outputq + 112], m7