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 11585, 11585
27 TRANSFORM_COEFFS 15137, 6270
28 TRANSFORM_COEFFS 16069, 3196
29 TRANSFORM_COEFFS 9102, 13623
41 %macro MUL_ADD_2X 6 ; dst1, dst2, src, round, coefs1, coefs2
50 %macro BUTTERFLY_4X 7 ; dst1, dst2, coef1, coef2, round, tmp1, tmp2
51 punpckhwd m%6, m%2, m%1
52 MUL_ADD_2X %7, %6, %6, %5, [pw_%4_%3], [pw_%3_m%4]
54 MUL_ADD_2X %1, %2, %2, %5, [pw_%4_%3], [pw_%3_m%4]
60 %macro INTERLEAVE_2X 4
61 punpckh%1 m%4, m%2, m%3
67 INTERLEAVE_2X wd, %1, %2, %9
68 INTERLEAVE_2X wd, %3, %4, %9
69 INTERLEAVE_2X wd, %5, %6, %9
70 INTERLEAVE_2X wd, %7, %8, %9
72 INTERLEAVE_2X dq, %1, %3, %9
73 INTERLEAVE_2X dq, %2, %4, %9
74 INTERLEAVE_2X dq, %5, %7, %9
75 INTERLEAVE_2X dq, %6, %8, %9
77 INTERLEAVE_2X qdq, %1, %5, %9
78 INTERLEAVE_2X qdq, %3, %7, %9
79 INTERLEAVE_2X qdq, %2, %6, %9
80 INTERLEAVE_2X qdq, %4, %8, %9
86 ; 1D forward 8x8 DCT transform
100 BUTTERFLY_4X 2, 3, 6270, 15137, m8, 9, 10
108 BUTTERFLY_4X 1, 0, 11585, 11585, m8, 9, 10
114 BUTTERFLY_4X 4, 7, 3196, 16069, m8, 9, 10
115 BUTTERFLY_4X 5, 6, 13623, 9102, m8, 9, 10
120 %macro DIVIDE_ROUND_2X 4 ; dst1, dst2, tmp1, tmp2
130 cglobal fdct8x8, 3, 5, 13, input, output, stride
133 mova m12, [pw_11585x2]
136 lea r3, [2 * strideq]
137 lea r4, [4 * strideq]
139 mova m1, [inputq + r3]
140 lea inputq, [inputq + r4]
142 mova m3, [inputq + r3]
143 lea inputq, [inputq + r4]
145 mova m5, [inputq + r3]
146 lea inputq, [inputq + r4]
148 mova m7, [inputq + r3]
150 ; left shift by 2 to increase forward transformation precision
162 TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9
165 TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9
167 DIVIDE_ROUND_2X 0, 1, 9, 10
168 DIVIDE_ROUND_2X 2, 3, 9, 10
169 DIVIDE_ROUND_2X 4, 5, 9, 10
170 DIVIDE_ROUND_2X 6, 7, 9, 10
172 mova [outputq + 0], m0
173 mova [outputq + 16], m1
174 mova [outputq + 32], m2
175 mova [outputq + 48], m3
176 mova [outputq + 64], m4
177 mova [outputq + 80], m5
178 mova [outputq + 96], m6
179 mova [outputq + 112], m7