Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | ; |
michael@0 | 2 | ; Copyright (c) 2011 The WebM project authors. All Rights Reserved. |
michael@0 | 3 | ; |
michael@0 | 4 | ; Use of this source code is governed by a BSD-style license |
michael@0 | 5 | ; that can be found in the LICENSE file in the root of the source |
michael@0 | 6 | ; tree. An additional intellectual property rights grant can be found |
michael@0 | 7 | ; in the file PATENTS. All contributing project authors may |
michael@0 | 8 | ; be found in the AUTHORS file in the root of the source tree. |
michael@0 | 9 | ; |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | EXPORT |vp8_fast_quantize_b_neon| |
michael@0 | 13 | EXPORT |vp8_fast_quantize_b_pair_neon| |
michael@0 | 14 | |
michael@0 | 15 | INCLUDE vp8_asm_enc_offsets.asm |
michael@0 | 16 | |
michael@0 | 17 | ARM |
michael@0 | 18 | REQUIRE8 |
michael@0 | 19 | PRESERVE8 |
michael@0 | 20 | |
michael@0 | 21 | AREA ||.text||, CODE, READONLY, ALIGN=4 |
michael@0 | 22 | |
michael@0 | 23 | ;vp8_fast_quantize_b_pair_neon(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2); |
michael@0 | 24 | |vp8_fast_quantize_b_pair_neon| PROC |
michael@0 | 25 | |
michael@0 | 26 | stmfd sp!, {r4-r9} |
michael@0 | 27 | vstmdb sp!, {q4-q7} |
michael@0 | 28 | |
michael@0 | 29 | ldr r4, [r0, #vp8_block_coeff] |
michael@0 | 30 | ldr r5, [r0, #vp8_block_quant_fast] |
michael@0 | 31 | ldr r6, [r0, #vp8_block_round] |
michael@0 | 32 | |
michael@0 | 33 | vld1.16 {q0, q1}, [r4@128] ; load z |
michael@0 | 34 | |
michael@0 | 35 | ldr r7, [r2, #vp8_blockd_qcoeff] |
michael@0 | 36 | |
michael@0 | 37 | vabs.s16 q4, q0 ; calculate x = abs(z) |
michael@0 | 38 | vabs.s16 q5, q1 |
michael@0 | 39 | |
michael@0 | 40 | ;right shift 15 to get sign, all 0 if it is positive, all 1 if it is negative |
michael@0 | 41 | vshr.s16 q2, q0, #15 ; sz |
michael@0 | 42 | vshr.s16 q3, q1, #15 |
michael@0 | 43 | |
michael@0 | 44 | vld1.s16 {q6, q7}, [r6@128] ; load round_ptr [0-15] |
michael@0 | 45 | vld1.s16 {q8, q9}, [r5@128] ; load quant_ptr [0-15] |
michael@0 | 46 | |
michael@0 | 47 | ldr r4, [r1, #vp8_block_coeff] |
michael@0 | 48 | |
michael@0 | 49 | vadd.s16 q4, q6 ; x + Round |
michael@0 | 50 | vadd.s16 q5, q7 |
michael@0 | 51 | |
michael@0 | 52 | vld1.16 {q0, q1}, [r4@128] ; load z2 |
michael@0 | 53 | |
michael@0 | 54 | vqdmulh.s16 q4, q8 ; y = ((Round+abs(z)) * Quant) >> 16 |
michael@0 | 55 | vqdmulh.s16 q5, q9 |
michael@0 | 56 | |
michael@0 | 57 | vabs.s16 q10, q0 ; calculate x2 = abs(z_2) |
michael@0 | 58 | vabs.s16 q11, q1 |
michael@0 | 59 | vshr.s16 q12, q0, #15 ; sz2 |
michael@0 | 60 | vshr.s16 q13, q1, #15 |
michael@0 | 61 | |
michael@0 | 62 | ;modify data to have its original sign |
michael@0 | 63 | veor.s16 q4, q2 ; y^sz |
michael@0 | 64 | veor.s16 q5, q3 |
michael@0 | 65 | |
michael@0 | 66 | vadd.s16 q10, q6 ; x2 + Round |
michael@0 | 67 | vadd.s16 q11, q7 |
michael@0 | 68 | |
michael@0 | 69 | ldr r8, [r2, #vp8_blockd_dequant] |
michael@0 | 70 | |
michael@0 | 71 | vqdmulh.s16 q10, q8 ; y2 = ((Round+abs(z)) * Quant) >> 16 |
michael@0 | 72 | vqdmulh.s16 q11, q9 |
michael@0 | 73 | |
michael@0 | 74 | vshr.s16 q4, #1 ; right shift 1 after vqdmulh |
michael@0 | 75 | vshr.s16 q5, #1 |
michael@0 | 76 | |
michael@0 | 77 | vld1.s16 {q6, q7}, [r8@128] ;load dequant_ptr[i] |
michael@0 | 78 | |
michael@0 | 79 | vsub.s16 q4, q2 ; x1=(y^sz)-sz = (y^sz)-(-1) (2's complement) |
michael@0 | 80 | vsub.s16 q5, q3 |
michael@0 | 81 | |
michael@0 | 82 | vshr.s16 q10, #1 ; right shift 1 after vqdmulh |
michael@0 | 83 | vshr.s16 q11, #1 |
michael@0 | 84 | |
michael@0 | 85 | ldr r9, [r2, #vp8_blockd_dqcoeff] |
michael@0 | 86 | |
michael@0 | 87 | veor.s16 q10, q12 ; y2^sz2 |
michael@0 | 88 | veor.s16 q11, q13 |
michael@0 | 89 | |
michael@0 | 90 | vst1.s16 {q4, q5}, [r7] ; store: qcoeff = x1 |
michael@0 | 91 | |
michael@0 | 92 | |
michael@0 | 93 | vsub.s16 q10, q12 ; x2=(y^sz)-sz = (y^sz)-(-1) (2's complement) |
michael@0 | 94 | vsub.s16 q11, q13 |
michael@0 | 95 | |
michael@0 | 96 | ldr r6, [r3, #vp8_blockd_qcoeff] |
michael@0 | 97 | |
michael@0 | 98 | vmul.s16 q2, q6, q4 ; x * Dequant |
michael@0 | 99 | vmul.s16 q3, q7, q5 |
michael@0 | 100 | |
michael@0 | 101 | adr r0, inv_zig_zag ; load ptr of inverse zigzag table |
michael@0 | 102 | |
michael@0 | 103 | vceq.s16 q8, q8 ; set q8 to all 1 |
michael@0 | 104 | |
michael@0 | 105 | vst1.s16 {q10, q11}, [r6] ; store: qcoeff = x2 |
michael@0 | 106 | |
michael@0 | 107 | vmul.s16 q12, q6, q10 ; x2 * Dequant |
michael@0 | 108 | vmul.s16 q13, q7, q11 |
michael@0 | 109 | |
michael@0 | 110 | vld1.16 {q6, q7}, [r0@128] ; load inverse scan order |
michael@0 | 111 | |
michael@0 | 112 | vtst.16 q14, q4, q8 ; now find eob |
michael@0 | 113 | vtst.16 q15, q5, q8 ; non-zero element is set to all 1 |
michael@0 | 114 | |
michael@0 | 115 | vst1.s16 {q2, q3}, [r9] ; store dqcoeff = x * Dequant |
michael@0 | 116 | |
michael@0 | 117 | ldr r7, [r3, #vp8_blockd_dqcoeff] |
michael@0 | 118 | |
michael@0 | 119 | vand q0, q6, q14 ; get all valid numbers from scan array |
michael@0 | 120 | vand q1, q7, q15 |
michael@0 | 121 | |
michael@0 | 122 | vst1.s16 {q12, q13}, [r7] ; store dqcoeff = x * Dequant |
michael@0 | 123 | |
michael@0 | 124 | vtst.16 q2, q10, q8 ; now find eob |
michael@0 | 125 | vtst.16 q3, q11, q8 ; non-zero element is set to all 1 |
michael@0 | 126 | |
michael@0 | 127 | vmax.u16 q0, q0, q1 ; find maximum value in q0, q1 |
michael@0 | 128 | |
michael@0 | 129 | vand q10, q6, q2 ; get all valid numbers from scan array |
michael@0 | 130 | vand q11, q7, q3 |
michael@0 | 131 | vmax.u16 q10, q10, q11 ; find maximum value in q10, q11 |
michael@0 | 132 | |
michael@0 | 133 | vmax.u16 d0, d0, d1 |
michael@0 | 134 | vmax.u16 d20, d20, d21 |
michael@0 | 135 | vmovl.u16 q0, d0 |
michael@0 | 136 | vmovl.u16 q10, d20 |
michael@0 | 137 | |
michael@0 | 138 | vmax.u32 d0, d0, d1 |
michael@0 | 139 | vmax.u32 d20, d20, d21 |
michael@0 | 140 | vpmax.u32 d0, d0, d0 |
michael@0 | 141 | vpmax.u32 d20, d20, d20 |
michael@0 | 142 | |
michael@0 | 143 | ldr r4, [r2, #vp8_blockd_eob] |
michael@0 | 144 | ldr r5, [r3, #vp8_blockd_eob] |
michael@0 | 145 | |
michael@0 | 146 | vst1.8 {d0[0]}, [r4] ; store eob |
michael@0 | 147 | vst1.8 {d20[0]}, [r5] ; store eob |
michael@0 | 148 | |
michael@0 | 149 | vldmia sp!, {q4-q7} |
michael@0 | 150 | ldmfd sp!, {r4-r9} |
michael@0 | 151 | bx lr |
michael@0 | 152 | |
michael@0 | 153 | ENDP |
michael@0 | 154 | |
michael@0 | 155 | ;void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d) |
michael@0 | 156 | |vp8_fast_quantize_b_neon| PROC |
michael@0 | 157 | |
michael@0 | 158 | stmfd sp!, {r4-r7} |
michael@0 | 159 | |
michael@0 | 160 | ldr r3, [r0, #vp8_block_coeff] |
michael@0 | 161 | ldr r4, [r0, #vp8_block_quant_fast] |
michael@0 | 162 | ldr r5, [r0, #vp8_block_round] |
michael@0 | 163 | |
michael@0 | 164 | vld1.16 {q0, q1}, [r3@128] ; load z |
michael@0 | 165 | vorr.s16 q14, q0, q1 ; check if all zero (step 1) |
michael@0 | 166 | ldr r6, [r1, #vp8_blockd_qcoeff] |
michael@0 | 167 | ldr r7, [r1, #vp8_blockd_dqcoeff] |
michael@0 | 168 | vorr.s16 d28, d28, d29 ; check if all zero (step 2) |
michael@0 | 169 | |
michael@0 | 170 | vabs.s16 q12, q0 ; calculate x = abs(z) |
michael@0 | 171 | vabs.s16 q13, q1 |
michael@0 | 172 | |
michael@0 | 173 | ;right shift 15 to get sign, all 0 if it is positive, all 1 if it is negative |
michael@0 | 174 | vshr.s16 q2, q0, #15 ; sz |
michael@0 | 175 | vmov r2, r3, d28 ; check if all zero (step 3) |
michael@0 | 176 | vshr.s16 q3, q1, #15 |
michael@0 | 177 | |
michael@0 | 178 | vld1.s16 {q14, q15}, [r5@128]; load round_ptr [0-15] |
michael@0 | 179 | vld1.s16 {q8, q9}, [r4@128] ; load quant_ptr [0-15] |
michael@0 | 180 | |
michael@0 | 181 | vadd.s16 q12, q14 ; x + Round |
michael@0 | 182 | vadd.s16 q13, q15 |
michael@0 | 183 | |
michael@0 | 184 | adr r0, inv_zig_zag ; load ptr of inverse zigzag table |
michael@0 | 185 | |
michael@0 | 186 | vqdmulh.s16 q12, q8 ; y = ((Round+abs(z)) * Quant) >> 16 |
michael@0 | 187 | vqdmulh.s16 q13, q9 |
michael@0 | 188 | |
michael@0 | 189 | vld1.16 {q10, q11}, [r0@128]; load inverse scan order |
michael@0 | 190 | |
michael@0 | 191 | vceq.s16 q8, q8 ; set q8 to all 1 |
michael@0 | 192 | |
michael@0 | 193 | ldr r4, [r1, #vp8_blockd_dequant] |
michael@0 | 194 | |
michael@0 | 195 | vshr.s16 q12, #1 ; right shift 1 after vqdmulh |
michael@0 | 196 | vshr.s16 q13, #1 |
michael@0 | 197 | |
michael@0 | 198 | ldr r5, [r1, #vp8_blockd_eob] |
michael@0 | 199 | |
michael@0 | 200 | orr r2, r2, r3 ; check if all zero (step 4) |
michael@0 | 201 | cmp r2, #0 ; check if all zero (step 5) |
michael@0 | 202 | beq zero_output ; check if all zero (step 6) |
michael@0 | 203 | |
michael@0 | 204 | ;modify data to have its original sign |
michael@0 | 205 | veor.s16 q12, q2 ; y^sz |
michael@0 | 206 | veor.s16 q13, q3 |
michael@0 | 207 | |
michael@0 | 208 | vsub.s16 q12, q2 ; x1=(y^sz)-sz = (y^sz)-(-1) (2's complement) |
michael@0 | 209 | vsub.s16 q13, q3 |
michael@0 | 210 | |
michael@0 | 211 | vld1.s16 {q2, q3}, [r4@128] ; load dequant_ptr[i] |
michael@0 | 212 | |
michael@0 | 213 | vtst.16 q14, q12, q8 ; now find eob |
michael@0 | 214 | vtst.16 q15, q13, q8 ; non-zero element is set to all 1 |
michael@0 | 215 | |
michael@0 | 216 | vst1.s16 {q12, q13}, [r6@128]; store: qcoeff = x1 |
michael@0 | 217 | |
michael@0 | 218 | vand q10, q10, q14 ; get all valid numbers from scan array |
michael@0 | 219 | vand q11, q11, q15 |
michael@0 | 220 | |
michael@0 | 221 | |
michael@0 | 222 | vmax.u16 q0, q10, q11 ; find maximum value in q0, q1 |
michael@0 | 223 | vmax.u16 d0, d0, d1 |
michael@0 | 224 | vmovl.u16 q0, d0 |
michael@0 | 225 | |
michael@0 | 226 | vmul.s16 q2, q12 ; x * Dequant |
michael@0 | 227 | vmul.s16 q3, q13 |
michael@0 | 228 | |
michael@0 | 229 | vmax.u32 d0, d0, d1 |
michael@0 | 230 | vpmax.u32 d0, d0, d0 |
michael@0 | 231 | |
michael@0 | 232 | vst1.s16 {q2, q3}, [r7@128] ; store dqcoeff = x * Dequant |
michael@0 | 233 | |
michael@0 | 234 | vst1.8 {d0[0]}, [r5] ; store eob |
michael@0 | 235 | |
michael@0 | 236 | ldmfd sp!, {r4-r7} |
michael@0 | 237 | bx lr |
michael@0 | 238 | |
michael@0 | 239 | zero_output |
michael@0 | 240 | strb r2, [r5] ; store eob |
michael@0 | 241 | vst1.s16 {q0, q1}, [r6@128] ; qcoeff = 0 |
michael@0 | 242 | vst1.s16 {q0, q1}, [r7@128] ; dqcoeff = 0 |
michael@0 | 243 | |
michael@0 | 244 | ldmfd sp!, {r4-r7} |
michael@0 | 245 | bx lr |
michael@0 | 246 | |
michael@0 | 247 | ENDP |
michael@0 | 248 | |
michael@0 | 249 | ; default inverse zigzag table is defined in vp8/common/entropy.c |
michael@0 | 250 | ALIGN 16 ; enable use of @128 bit aligned loads |
michael@0 | 251 | inv_zig_zag |
michael@0 | 252 | DCW 0x0001, 0x0002, 0x0006, 0x0007 |
michael@0 | 253 | DCW 0x0003, 0x0005, 0x0008, 0x000d |
michael@0 | 254 | DCW 0x0004, 0x0009, 0x000c, 0x000e |
michael@0 | 255 | DCW 0x000a, 0x000b, 0x000f, 0x0010 |
michael@0 | 256 | |
michael@0 | 257 | END |
michael@0 | 258 |