1; 2; Copyright (c) 2014 The WebM project authors. All Rights Reserved. 3; 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. 9; 10%include "third_party/x86inc/x86inc.asm" 11 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. 15 16SECTION_RODATA 17 18pw_11585x2: times 8 dw 23170 19pd_8192: times 4 dd 8192 20 21%macro TRANSFORM_COEFFS 2 22pw_%1_%2: dw %1, %2, %1, %2, %1, %2, %1, %2 23pw_%2_m%1: dw %2, -%1, %2, -%1, %2, -%1, %2, -%1 24%endmacro 25 26TRANSFORM_COEFFS 11585, 11585 27TRANSFORM_COEFFS 15137, 6270 28TRANSFORM_COEFFS 16069, 3196 29TRANSFORM_COEFFS 9102, 13623 30 31SECTION .text 32 33%if ARCH_X86_64 34%macro SUM_SUB 3 35 psubw m%3, m%1, m%2 36 paddw m%1, m%2 37 SWAP %2, %3 38%endmacro 39 40; butterfly operation 41%macro MUL_ADD_2X 6 ; dst1, dst2, src, round, coefs1, coefs2 42 pmaddwd m%1, m%3, %5 43 pmaddwd m%2, m%3, %6 44 paddd m%1, %4 45 paddd m%2, %4 46 psrad m%1, 14 47 psrad m%2, 14 48%endmacro 49 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] 53 punpcklwd m%2, m%1 54 MUL_ADD_2X %1, %2, %2, %5, [pw_%4_%3], [pw_%3_m%4] 55 packssdw m%1, m%7 56 packssdw m%2, m%6 57%endmacro 58 59; matrix transpose 60%macro INTERLEAVE_2X 4 61 punpckh%1 m%4, m%2, m%3 62 punpckl%1 m%2, m%3 63 SWAP %3, %4 64%endmacro 65 66%macro TRANSPOSE8X8 9 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 71 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 76 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 81 82 SWAP %2, %5 83 SWAP %4, %7 84%endmacro 85 86; 1D forward 8x8 DCT transform 87%macro FDCT8_1D 1 88 SUM_SUB 0, 7, 9 89 SUM_SUB 1, 6, 9 90 SUM_SUB 2, 5, 9 91 SUM_SUB 3, 4, 9 92 93 SUM_SUB 0, 3, 9 94 SUM_SUB 1, 2, 9 95 SUM_SUB 6, 5, 9 96%if %1 == 0 97 SUM_SUB 0, 1, 9 98%endif 99 100 BUTTERFLY_4X 2, 3, 6270, 15137, m8, 9, 10 101 102 pmulhrsw m6, m12 103 pmulhrsw m5, m12 104%if %1 == 0 105 pmulhrsw m0, m12 106 pmulhrsw m1, m12 107%else 108 BUTTERFLY_4X 1, 0, 11585, 11585, m8, 9, 10 109 SWAP 0, 1 110%endif 111 112 SUM_SUB 4, 5, 9 113 SUM_SUB 7, 6, 9 114 BUTTERFLY_4X 4, 7, 3196, 16069, m8, 9, 10 115 BUTTERFLY_4X 5, 6, 13623, 9102, m8, 9, 10 116 SWAP 1, 4 117 SWAP 3, 6 118%endmacro 119 120%macro DIVIDE_ROUND_2X 4 ; dst1, dst2, tmp1, tmp2 121 psraw m%3, m%1, 15 122 psraw m%4, m%2, 15 123 psubw m%1, m%3 124 psubw m%2, m%4 125 psraw m%1, 1 126 psraw m%2, 1 127%endmacro 128 129INIT_XMM ssse3 130cglobal fdct8x8, 3, 5, 13, input, output, stride 131 132 mova m8, [pd_8192] 133 mova m12, [pw_11585x2] 134 pxor m11, m11 135 136 lea r3, [2 * strideq] 137 lea r4, [4 * strideq] 138 mova m0, [inputq] 139 mova m1, [inputq + r3] 140 lea inputq, [inputq + r4] 141 mova m2, [inputq] 142 mova m3, [inputq + r3] 143 lea inputq, [inputq + r4] 144 mova m4, [inputq] 145 mova m5, [inputq + r3] 146 lea inputq, [inputq + r4] 147 mova m6, [inputq] 148 mova m7, [inputq + r3] 149 150 ; left shift by 2 to increase forward transformation precision 151 psllw m0, 2 152 psllw m1, 2 153 psllw m2, 2 154 psllw m3, 2 155 psllw m4, 2 156 psllw m5, 2 157 psllw m6, 2 158 psllw m7, 2 159 160 ; column transform 161 FDCT8_1D 0 162 TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 163 164 FDCT8_1D 1 165 TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 166 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 171 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 180 181 RET 182%endif 183