2 ; Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 ; Use of this source code is governed by a BSD-style license and patent
5 ; grant that can be found in the LICENSE file in the root of the source
6 ; tree. All contributing project authors may be found in the AUTHORS
7 ; file in the root of the source tree.
11 %include "vpx_ports/x86_abi_support.asm"
12 %include "vp9_asm_enc_offsets.asm"
15 ; void vp9_regular_quantize_b_sse4 | arg
19 global sym(vp9_regular_quantize_b_sse4)
20 sym(vp9_regular_quantize_b_sse4):
34 %ifidn __OUTPUT_FORMAT__,x64
43 mov rdi, arg(0) ; BLOCK *b
44 mov rsi, arg(1) ; BLOCKD *d
46 %ifidn __OUTPUT_FORMAT__,x64
47 mov rdi, rcx ; BLOCK *b
48 mov rsi, rdx ; BLOCKD *d
50 ;mov rdi, rdi ; BLOCK *b
51 ;mov rsi, rsi ; BLOCKD *d
55 mov rax, [rdi + vp9_block_coeff]
56 mov rcx, [rdi + vp9_block_zbin]
57 mov rdx, [rdi + vp9_block_round]
58 movd xmm7, [rdi + vp9_block_zbin_extra]
62 movdqa xmm1, [rax + 16]
64 ; duplicate zbin_oq_value
85 movdqa xmm5, [rcx + 16]
87 ; *zbin_ptr + zbin_oq_value
94 ; x - (*zbin_ptr + zbin_oq_value)
100 movdqa xmm5, [rdx + 16]
102 mov rax, [rdi + vp9_block_quant_shift]
103 mov rcx, [rdi + vp9_block_quant]
104 mov rdx, [rdi + vp9_block_zrun_zbin_boost]
112 movdqa xmm5, [rcx + 16]
114 ; y = x * quant_ptr >> 16
124 movdqa [rsp + qcoeff], xmm4
125 movdqa [rsp + qcoeff + 16], xmm4
141 sub cx, WORD PTR[rdx] ; x - zbin
142 lea rdx, [rdx + 2] ; zbin_boost_ptr++
143 jl .rq_zigzag_loop_%1 ; x < zbin
145 pextrw edi, %3, %2 ; y
147 ; downshift by quant_shift[rc]
148 pextrb ecx, xmm5, %1 ; quant_shift[rc]
149 sar edi, cl ; also sets Z bit
150 je .rq_zigzag_loop_%1 ; !y
152 mov WORD PTR[rsp + qcoeff + %1 *2], di
154 pinsrw %5, edi, %2 ; qcoeff[rc]
156 mov rdx, rax ; reset to b->zrun_zbin_boost
159 ; in vp9_default_zig_zag1d order: see vp9/common/entropy.c
160 ZIGZAG_LOOP 0, 0, xmm2, xmm6, xmm4
161 ZIGZAG_LOOP 1, 1, xmm2, xmm6, xmm4
162 ZIGZAG_LOOP 4, 4, xmm2, xmm6, xmm4
163 ZIGZAG_LOOP 8, 0, xmm3, xmm7, xmm8
164 ZIGZAG_LOOP 5, 5, xmm2, xmm6, xmm4
165 ZIGZAG_LOOP 2, 2, xmm2, xmm6, xmm4
166 ZIGZAG_LOOP 3, 3, xmm2, xmm6, xmm4
167 ZIGZAG_LOOP 6, 6, xmm2, xmm6, xmm4
168 ZIGZAG_LOOP 9, 1, xmm3, xmm7, xmm8
169 ZIGZAG_LOOP 12, 4, xmm3, xmm7, xmm8
170 ZIGZAG_LOOP 13, 5, xmm3, xmm7, xmm8
171 ZIGZAG_LOOP 10, 2, xmm3, xmm7, xmm8
172 ZIGZAG_LOOP 7, 7, xmm2, xmm6, xmm4
173 ZIGZAG_LOOP 11, 3, xmm3, xmm7, xmm8
174 ZIGZAG_LOOP 14, 6, xmm3, xmm7, xmm8
175 ZIGZAG_LOOP 15, 7, xmm3, xmm7, xmm8
177 mov rcx, [rsi + vp9_blockd_dequant]
178 mov rdi, [rsi + vp9_blockd_dqcoeff]
181 movdqa xmm4, [rsp + qcoeff]
182 movdqa xmm5, [rsp + qcoeff + 16]
196 movdqa xmm1, [rcx + 16]
198 mov rcx, [rsi + vp9_blockd_qcoeff]
205 movdqa [rcx + 16], xmm5
209 movdqa [rdi + 16], xmm1
211 ; select the last value (in zig_zag order) for EOB
217 pshufb xmm4, [GLOBAL(zig_zag1d)]
228 mov [rsi + vp9_blockd_eob], eax
241 %ifidn __OUTPUT_FORMAT__,x64
252 ; vp9/common/entropy.c: vp9_default_zig_zag1d
254 db 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15