Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | ; |
michael@0 | 2 | ; Copyright (c) 2010 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 |vp8cx_pack_tokens_into_partitions_armv5| |
michael@0 | 13 | IMPORT |vp8_validate_buffer_arm| |
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 |
michael@0 | 22 | |
michael@0 | 23 | ; macro for validating write buffer position |
michael@0 | 24 | ; needs vp8_writer in r0 |
michael@0 | 25 | ; start shall not be in r1 |
michael@0 | 26 | MACRO |
michael@0 | 27 | VALIDATE_POS $start, $pos |
michael@0 | 28 | push {r0-r3, r12, lr} ; rest of regs are preserved by subroutine call |
michael@0 | 29 | ldr r2, [r0, #vp8_writer_buffer_end] |
michael@0 | 30 | ldr r3, [r0, #vp8_writer_error] |
michael@0 | 31 | mov r1, $pos |
michael@0 | 32 | mov r0, $start |
michael@0 | 33 | bl vp8_validate_buffer_arm |
michael@0 | 34 | pop {r0-r3, r12, lr} |
michael@0 | 35 | MEND |
michael@0 | 36 | |
michael@0 | 37 | ; r0 VP8_COMP *cpi |
michael@0 | 38 | ; r1 unsigned char *cx_data |
michael@0 | 39 | ; r2 const unsigned char *cx_data_end |
michael@0 | 40 | ; r3 int num_part |
michael@0 | 41 | ; s0 vp8_coef_encodings |
michael@0 | 42 | ; s1 vp8_extra_bits, |
michael@0 | 43 | ; s2 const vp8_tree_index * |
michael@0 | 44 | |
michael@0 | 45 | |vp8cx_pack_tokens_into_partitions_armv5| PROC |
michael@0 | 46 | push {r4-r12, lr} |
michael@0 | 47 | sub sp, sp, #40 |
michael@0 | 48 | |
michael@0 | 49 | ; Compute address of cpi->common.mb_rows |
michael@0 | 50 | ldr r4, _VP8_COMP_common_ |
michael@0 | 51 | ldr r6, _VP8_COMMON_MBrows_ |
michael@0 | 52 | add r4, r0, r4 |
michael@0 | 53 | |
michael@0 | 54 | ldr r5, [r4, r6] ; load up mb_rows |
michael@0 | 55 | |
michael@0 | 56 | str r5, [sp, #36] ; save mb_rows |
michael@0 | 57 | str r1, [sp, #24] ; save ptr = cx_data |
michael@0 | 58 | str r3, [sp, #20] ; save num_part |
michael@0 | 59 | str r2, [sp, #8] ; save cx_data_end |
michael@0 | 60 | |
michael@0 | 61 | ldr r4, _VP8_COMP_tplist_ |
michael@0 | 62 | add r4, r0, r4 |
michael@0 | 63 | ldr r7, [r4, #0] ; dereference cpi->tp_list |
michael@0 | 64 | str r7, [sp, #32] ; store start of cpi->tp_list |
michael@0 | 65 | |
michael@0 | 66 | ldr r11, _VP8_COMP_bc_ ; load up vp8_writer out of cpi |
michael@0 | 67 | add r0, r0, r11 |
michael@0 | 68 | |
michael@0 | 69 | mov r11, #0 |
michael@0 | 70 | str r11, [sp, #28] ; i |
michael@0 | 71 | |
michael@0 | 72 | numparts_loop |
michael@0 | 73 | ldr r2, _vp8_writer_sz_ ; load up sizeof(vp8_writer) |
michael@0 | 74 | add r0, r2 ; bc[i + 1] |
michael@0 | 75 | |
michael@0 | 76 | ldr r10, [sp, #24] ; ptr |
michael@0 | 77 | ldr r5, [sp, #36] ; move mb_rows to the counting section |
michael@0 | 78 | subs r5, r5, r11 ; move start point with each partition |
michael@0 | 79 | ; mb_rows starts at i |
michael@0 | 80 | str r5, [sp, #12] |
michael@0 | 81 | |
michael@0 | 82 | ; Reset all of the VP8 Writer data for each partition that |
michael@0 | 83 | ; is processed. |
michael@0 | 84 | ; start_encode |
michael@0 | 85 | |
michael@0 | 86 | ldr r3, [sp, #8] |
michael@0 | 87 | str r3, [r0, #vp8_writer_buffer_end] |
michael@0 | 88 | |
michael@0 | 89 | mov r2, #0 ; vp8_writer_lowvalue |
michael@0 | 90 | mov r5, #255 ; vp8_writer_range |
michael@0 | 91 | mvn r3, #23 ; vp8_writer_count |
michael@0 | 92 | |
michael@0 | 93 | str r2, [r0, #vp8_writer_pos] |
michael@0 | 94 | str r10, [r0, #vp8_writer_buffer] |
michael@0 | 95 | |
michael@0 | 96 | ble end_partition ; if (mb_rows <= 0) end partition |
michael@0 | 97 | |
michael@0 | 98 | mb_row_loop |
michael@0 | 99 | |
michael@0 | 100 | ldr r1, [r7, #tokenlist_start] |
michael@0 | 101 | ldr r9, [r7, #tokenlist_stop] |
michael@0 | 102 | str r9, [sp, #0] ; save stop for later comparison |
michael@0 | 103 | str r7, [sp, #16] ; tokenlist address for next time |
michael@0 | 104 | |
michael@0 | 105 | b check_p_lt_stop |
michael@0 | 106 | |
michael@0 | 107 | ; actual work gets done here! |
michael@0 | 108 | |
michael@0 | 109 | while_p_lt_stop |
michael@0 | 110 | ldrb r6, [r1, #tokenextra_token] ; t |
michael@0 | 111 | ldr r4, [sp, #80] ; vp8_coef_encodings |
michael@0 | 112 | mov lr, #0 |
michael@0 | 113 | add r4, r4, r6, lsl #3 ; a = vp8_coef_encodings + t |
michael@0 | 114 | ldr r9, [r1, #tokenextra_context_tree] ; pp |
michael@0 | 115 | |
michael@0 | 116 | ldrb r7, [r1, #tokenextra_skip_eob_node] |
michael@0 | 117 | |
michael@0 | 118 | ldr r6, [r4, #vp8_token_value] ; v |
michael@0 | 119 | ldr r8, [r4, #vp8_token_len] ; n |
michael@0 | 120 | |
michael@0 | 121 | ; vp8 specific skip_eob_node |
michael@0 | 122 | cmp r7, #0 |
michael@0 | 123 | movne lr, #2 ; i = 2 |
michael@0 | 124 | subne r8, r8, #1 ; --n |
michael@0 | 125 | |
michael@0 | 126 | rsb r4, r8, #32 ; 32-n |
michael@0 | 127 | ldr r10, [sp, #88] ; vp8_coef_tree |
michael@0 | 128 | |
michael@0 | 129 | ; v is kept in r12 during the token pack loop |
michael@0 | 130 | lsl r12, r6, r4 ; r12 = v << 32 - n |
michael@0 | 131 | |
michael@0 | 132 | ; loop start |
michael@0 | 133 | token_loop |
michael@0 | 134 | ldrb r4, [r9, lr, asr #1] ; pp [i>>1] |
michael@0 | 135 | sub r7, r5, #1 ; range-1 |
michael@0 | 136 | |
michael@0 | 137 | ; Decisions are made based on the bit value shifted |
michael@0 | 138 | ; off of v, so set a flag here based on this. |
michael@0 | 139 | ; This value is refered to as "bb" |
michael@0 | 140 | lsls r12, r12, #1 ; bb = v >> n |
michael@0 | 141 | mul r6, r4, r7 ; ((range-1) * pp[i>>1])) |
michael@0 | 142 | |
michael@0 | 143 | ; bb can only be 0 or 1. So only execute this statement |
michael@0 | 144 | ; if bb == 1, otherwise it will act like i + 0 |
michael@0 | 145 | addcs lr, lr, #1 ; i + bb |
michael@0 | 146 | |
michael@0 | 147 | mov r7, #1 |
michael@0 | 148 | ldrsb lr, [r10, lr] ; i = vp8_coef_tree[i+bb] |
michael@0 | 149 | add r4, r7, r6, lsr #8 ; 1 + (((range-1) * pp[i>>1]) >> 8) |
michael@0 | 150 | |
michael@0 | 151 | addcs r2, r2, r4 ; if (bb) lowvalue += split |
michael@0 | 152 | subcs r4, r5, r4 ; if (bb) range = range-split |
michael@0 | 153 | |
michael@0 | 154 | ; Counting the leading zeros is used to normalize range. |
michael@0 | 155 | clz r6, r4 |
michael@0 | 156 | sub r6, r6, #24 ; shift |
michael@0 | 157 | |
michael@0 | 158 | ; Flag is set on the sum of count. This flag is used later |
michael@0 | 159 | ; to determine if count >= 0 |
michael@0 | 160 | adds r3, r3, r6 ; count += shift |
michael@0 | 161 | lsl r5, r4, r6 ; range <<= shift |
michael@0 | 162 | bmi token_count_lt_zero ; if(count >= 0) |
michael@0 | 163 | |
michael@0 | 164 | sub r6, r6, r3 ; offset = shift - count |
michael@0 | 165 | sub r4, r6, #1 ; offset-1 |
michael@0 | 166 | lsls r4, r2, r4 ; if((lowvalue<<(offset-1)) & 0x80000000 ) |
michael@0 | 167 | bpl token_high_bit_not_set |
michael@0 | 168 | |
michael@0 | 169 | ldr r4, [r0, #vp8_writer_pos] ; x |
michael@0 | 170 | sub r4, r4, #1 ; x = w->pos-1 |
michael@0 | 171 | b token_zero_while_start |
michael@0 | 172 | token_zero_while_loop |
michael@0 | 173 | mov r10, #0 |
michael@0 | 174 | strb r10, [r7, r4] ; w->buffer[x] =(unsigned char)0 |
michael@0 | 175 | sub r4, r4, #1 ; x-- |
michael@0 | 176 | token_zero_while_start |
michael@0 | 177 | cmp r4, #0 |
michael@0 | 178 | ldrge r7, [r0, #vp8_writer_buffer] |
michael@0 | 179 | ldrb r11, [r7, r4] |
michael@0 | 180 | cmpge r11, #0xff |
michael@0 | 181 | beq token_zero_while_loop |
michael@0 | 182 | |
michael@0 | 183 | ldr r7, [r0, #vp8_writer_buffer] |
michael@0 | 184 | ldrb r10, [r7, r4] ; w->buffer[x] |
michael@0 | 185 | add r10, r10, #1 |
michael@0 | 186 | strb r10, [r7, r4] ; w->buffer[x] + 1 |
michael@0 | 187 | token_high_bit_not_set |
michael@0 | 188 | rsb r4, r6, #24 ; 24-offset |
michael@0 | 189 | ldr r10, [r0, #vp8_writer_buffer] |
michael@0 | 190 | lsr r7, r2, r4 ; lowvalue >> (24-offset) |
michael@0 | 191 | ldr r4, [r0, #vp8_writer_pos] ; w->pos |
michael@0 | 192 | lsl r2, r2, r6 ; lowvalue <<= offset |
michael@0 | 193 | mov r6, r3 ; shift = count |
michael@0 | 194 | add r11, r4, #1 ; w->pos++ |
michael@0 | 195 | bic r2, r2, #0xff000000 ; lowvalue &= 0xffffff |
michael@0 | 196 | str r11, [r0, #vp8_writer_pos] |
michael@0 | 197 | sub r3, r3, #8 ; count -= 8 |
michael@0 | 198 | |
michael@0 | 199 | VALIDATE_POS r10, r11 ; validate_buffer at pos |
michael@0 | 200 | |
michael@0 | 201 | strb r7, [r10, r4] ; w->buffer[w->pos++] |
michael@0 | 202 | |
michael@0 | 203 | ; r10 is used earlier in the loop, but r10 is used as |
michael@0 | 204 | ; temp variable here. So after r10 is used, reload |
michael@0 | 205 | ; vp8_coef_tree_dcd into r10 |
michael@0 | 206 | ldr r10, [sp, #88] ; vp8_coef_tree |
michael@0 | 207 | |
michael@0 | 208 | token_count_lt_zero |
michael@0 | 209 | lsl r2, r2, r6 ; lowvalue <<= shift |
michael@0 | 210 | |
michael@0 | 211 | subs r8, r8, #1 ; --n |
michael@0 | 212 | bne token_loop |
michael@0 | 213 | |
michael@0 | 214 | ldrb r6, [r1, #tokenextra_token] ; t |
michael@0 | 215 | ldr r7, [sp, #84] ; vp8_extra_bits |
michael@0 | 216 | ; Add t * sizeof (vp8_extra_bit_struct) to get the desired |
michael@0 | 217 | ; element. Here vp8_extra_bit_struct == 16 |
michael@0 | 218 | add r12, r7, r6, lsl #4 ; b = vp8_extra_bits + t |
michael@0 | 219 | |
michael@0 | 220 | ldr r4, [r12, #vp8_extra_bit_struct_base_val] |
michael@0 | 221 | cmp r4, #0 |
michael@0 | 222 | beq skip_extra_bits |
michael@0 | 223 | |
michael@0 | 224 | ; if( b->base_val) |
michael@0 | 225 | ldr r8, [r12, #vp8_extra_bit_struct_len] ; L |
michael@0 | 226 | ldrsh lr, [r1, #tokenextra_extra] ; e = p->Extra |
michael@0 | 227 | cmp r8, #0 ; if( L) |
michael@0 | 228 | beq no_extra_bits |
michael@0 | 229 | |
michael@0 | 230 | ldr r9, [r12, #vp8_extra_bit_struct_prob] |
michael@0 | 231 | asr r7, lr, #1 ; v=e>>1 |
michael@0 | 232 | |
michael@0 | 233 | ldr r10, [r12, #vp8_extra_bit_struct_tree] |
michael@0 | 234 | str r10, [sp, #4] ; b->tree |
michael@0 | 235 | |
michael@0 | 236 | rsb r4, r8, #32 |
michael@0 | 237 | lsl r12, r7, r4 |
michael@0 | 238 | |
michael@0 | 239 | mov lr, #0 ; i = 0 |
michael@0 | 240 | |
michael@0 | 241 | extra_bits_loop |
michael@0 | 242 | ldrb r4, [r9, lr, asr #1] ; pp[i>>1] |
michael@0 | 243 | sub r7, r5, #1 ; range-1 |
michael@0 | 244 | lsls r12, r12, #1 ; v >> n |
michael@0 | 245 | mul r6, r4, r7 ; (range-1) * pp[i>>1] |
michael@0 | 246 | addcs lr, lr, #1 ; i + bb |
michael@0 | 247 | |
michael@0 | 248 | mov r7, #1 |
michael@0 | 249 | ldrsb lr, [r10, lr] ; i = b->tree[i+bb] |
michael@0 | 250 | add r4, r7, r6, lsr #8 ; split = 1 + (((range-1) * pp[i>>1]) >> 8) |
michael@0 | 251 | |
michael@0 | 252 | addcs r2, r2, r4 ; if (bb) lowvalue += split |
michael@0 | 253 | subcs r4, r5, r4 ; if (bb) range = range-split |
michael@0 | 254 | |
michael@0 | 255 | clz r6, r4 |
michael@0 | 256 | sub r6, r6, #24 |
michael@0 | 257 | |
michael@0 | 258 | adds r3, r3, r6 ; count += shift |
michael@0 | 259 | lsl r5, r4, r6 ; range <<= shift |
michael@0 | 260 | bmi extra_count_lt_zero ; if(count >= 0) |
michael@0 | 261 | |
michael@0 | 262 | sub r6, r6, r3 ; offset= shift - count |
michael@0 | 263 | sub r4, r6, #1 ; offset-1 |
michael@0 | 264 | lsls r4, r2, r4 ; if((lowvalue<<(offset-1)) & 0x80000000 ) |
michael@0 | 265 | bpl extra_high_bit_not_set |
michael@0 | 266 | |
michael@0 | 267 | ldr r4, [r0, #vp8_writer_pos] ; x |
michael@0 | 268 | sub r4, r4, #1 ; x = w->pos - 1 |
michael@0 | 269 | b extra_zero_while_start |
michael@0 | 270 | extra_zero_while_loop |
michael@0 | 271 | mov r10, #0 |
michael@0 | 272 | strb r10, [r7, r4] ; w->buffer[x] =(unsigned char)0 |
michael@0 | 273 | sub r4, r4, #1 ; x-- |
michael@0 | 274 | extra_zero_while_start |
michael@0 | 275 | cmp r4, #0 |
michael@0 | 276 | ldrge r7, [r0, #vp8_writer_buffer] |
michael@0 | 277 | ldrb r11, [r7, r4] |
michael@0 | 278 | cmpge r11, #0xff |
michael@0 | 279 | beq extra_zero_while_loop |
michael@0 | 280 | |
michael@0 | 281 | ldr r7, [r0, #vp8_writer_buffer] |
michael@0 | 282 | ldrb r10, [r7, r4] |
michael@0 | 283 | add r10, r10, #1 |
michael@0 | 284 | strb r10, [r7, r4] |
michael@0 | 285 | extra_high_bit_not_set |
michael@0 | 286 | rsb r4, r6, #24 ; 24-offset |
michael@0 | 287 | ldr r10, [r0, #vp8_writer_buffer] |
michael@0 | 288 | lsr r7, r2, r4 ; lowvalue >> (24-offset) |
michael@0 | 289 | ldr r4, [r0, #vp8_writer_pos] |
michael@0 | 290 | lsl r2, r2, r6 ; lowvalue <<= offset |
michael@0 | 291 | mov r6, r3 ; shift = count |
michael@0 | 292 | add r11, r4, #1 ; w->pos++ |
michael@0 | 293 | bic r2, r2, #0xff000000 ; lowvalue &= 0xffffff |
michael@0 | 294 | str r11, [r0, #vp8_writer_pos] |
michael@0 | 295 | sub r3, r3, #8 ; count -= 8 |
michael@0 | 296 | |
michael@0 | 297 | VALIDATE_POS r10, r11 ; validate_buffer at pos |
michael@0 | 298 | |
michael@0 | 299 | strb r7, [r10, r4] ; w->buffer[w->pos++]=(lowvalue >> (24-offset)) |
michael@0 | 300 | ldr r10, [sp, #4] ; b->tree |
michael@0 | 301 | extra_count_lt_zero |
michael@0 | 302 | lsl r2, r2, r6 |
michael@0 | 303 | |
michael@0 | 304 | subs r8, r8, #1 ; --n |
michael@0 | 305 | bne extra_bits_loop ; while (n) |
michael@0 | 306 | |
michael@0 | 307 | no_extra_bits |
michael@0 | 308 | ldr lr, [r1, #4] ; e = p->Extra |
michael@0 | 309 | add r4, r5, #1 ; range + 1 |
michael@0 | 310 | tst lr, #1 |
michael@0 | 311 | lsr r4, r4, #1 ; split = (range + 1) >> 1 |
michael@0 | 312 | addne r2, r2, r4 ; lowvalue += split |
michael@0 | 313 | subne r4, r5, r4 ; range = range-split |
michael@0 | 314 | tst r2, #0x80000000 ; lowvalue & 0x80000000 |
michael@0 | 315 | lsl r5, r4, #1 ; range <<= 1 |
michael@0 | 316 | beq end_high_bit_not_set |
michael@0 | 317 | |
michael@0 | 318 | ldr r4, [r0, #vp8_writer_pos] |
michael@0 | 319 | mov r7, #0 |
michael@0 | 320 | sub r4, r4, #1 |
michael@0 | 321 | b end_zero_while_start |
michael@0 | 322 | end_zero_while_loop |
michael@0 | 323 | strb r7, [r6, r4] |
michael@0 | 324 | sub r4, r4, #1 ; x-- |
michael@0 | 325 | end_zero_while_start |
michael@0 | 326 | cmp r4, #0 |
michael@0 | 327 | ldrge r6, [r0, #vp8_writer_buffer] |
michael@0 | 328 | ldrb r12, [r6, r4] |
michael@0 | 329 | cmpge r12, #0xff |
michael@0 | 330 | beq end_zero_while_loop |
michael@0 | 331 | |
michael@0 | 332 | ldr r6, [r0, #vp8_writer_buffer] |
michael@0 | 333 | ldrb r7, [r6, r4] |
michael@0 | 334 | add r7, r7, #1 |
michael@0 | 335 | strb r7, [r6, r4] |
michael@0 | 336 | end_high_bit_not_set |
michael@0 | 337 | adds r3, r3, #1 ; ++count |
michael@0 | 338 | lsl r2, r2, #1 ; lowvalue <<= 1 |
michael@0 | 339 | bne end_count_zero |
michael@0 | 340 | |
michael@0 | 341 | ldr r4, [r0, #vp8_writer_pos] |
michael@0 | 342 | mvn r3, #7 ; count = -8 |
michael@0 | 343 | ldr r7, [r0, #vp8_writer_buffer] |
michael@0 | 344 | lsr r6, r2, #24 ; lowvalue >> 24 |
michael@0 | 345 | add r12, r4, #1 ; w->pos++ |
michael@0 | 346 | bic r2, r2, #0xff000000 ; lowvalue &= 0xffffff |
michael@0 | 347 | str r12, [r0, #vp8_writer_pos] |
michael@0 | 348 | |
michael@0 | 349 | VALIDATE_POS r7, r12 ; validate_buffer at pos |
michael@0 | 350 | |
michael@0 | 351 | strb r6, [r7, r4] |
michael@0 | 352 | end_count_zero |
michael@0 | 353 | skip_extra_bits |
michael@0 | 354 | add r1, r1, #TOKENEXTRA_SZ ; ++p |
michael@0 | 355 | check_p_lt_stop |
michael@0 | 356 | ldr r4, [sp, #0] ; stop |
michael@0 | 357 | cmp r1, r4 ; while( p < stop) |
michael@0 | 358 | bcc while_p_lt_stop |
michael@0 | 359 | |
michael@0 | 360 | ldr r10, [sp, #20] ; num_parts |
michael@0 | 361 | mov r1, #TOKENLIST_SZ |
michael@0 | 362 | mul r1, r10, r1 |
michael@0 | 363 | |
michael@0 | 364 | ldr r6, [sp, #12] ; mb_rows |
michael@0 | 365 | ldr r7, [sp, #16] ; tokenlist address |
michael@0 | 366 | subs r6, r6, r10 |
michael@0 | 367 | add r7, r7, r1 ; next element in the array |
michael@0 | 368 | str r6, [sp, #12] |
michael@0 | 369 | bgt mb_row_loop |
michael@0 | 370 | |
michael@0 | 371 | end_partition |
michael@0 | 372 | mov r12, #32 |
michael@0 | 373 | |
michael@0 | 374 | stop_encode_loop |
michael@0 | 375 | sub r7, r5, #1 ; range-1 |
michael@0 | 376 | |
michael@0 | 377 | mov r4, r7, lsl #7 ; ((range-1) * 128) |
michael@0 | 378 | |
michael@0 | 379 | mov r7, #1 |
michael@0 | 380 | add r4, r7, r4, lsr #8 ; 1 + (((range-1) * 128) >> 8) |
michael@0 | 381 | |
michael@0 | 382 | ; Counting the leading zeros is used to normalize range. |
michael@0 | 383 | clz r6, r4 |
michael@0 | 384 | sub r6, r6, #24 ; shift |
michael@0 | 385 | |
michael@0 | 386 | ; Flag is set on the sum of count. This flag is used later |
michael@0 | 387 | ; to determine if count >= 0 |
michael@0 | 388 | adds r3, r3, r6 ; count += shift |
michael@0 | 389 | lsl r5, r4, r6 ; range <<= shift |
michael@0 | 390 | bmi token_count_lt_zero_se ; if(count >= 0) |
michael@0 | 391 | |
michael@0 | 392 | sub r6, r6, r3 ; offset = shift - count |
michael@0 | 393 | sub r4, r6, #1 ; offset-1 |
michael@0 | 394 | lsls r4, r2, r4 ; if((lowvalue<<(offset-1)) & 0x80000000 ) |
michael@0 | 395 | bpl token_high_bit_not_set_se |
michael@0 | 396 | |
michael@0 | 397 | ldr r4, [r0, #vp8_writer_pos] ; x |
michael@0 | 398 | sub r4, r4, #1 ; x = w->pos-1 |
michael@0 | 399 | b token_zero_while_start_se |
michael@0 | 400 | token_zero_while_loop_se |
michael@0 | 401 | mov r10, #0 |
michael@0 | 402 | strb r10, [r7, r4] ; w->buffer[x] =(unsigned char)0 |
michael@0 | 403 | sub r4, r4, #1 ; x-- |
michael@0 | 404 | token_zero_while_start_se |
michael@0 | 405 | cmp r4, #0 |
michael@0 | 406 | ldrge r7, [r0, #vp8_writer_buffer] |
michael@0 | 407 | ldrb r11, [r7, r4] |
michael@0 | 408 | cmpge r11, #0xff |
michael@0 | 409 | beq token_zero_while_loop_se |
michael@0 | 410 | |
michael@0 | 411 | ldr r7, [r0, #vp8_writer_buffer] |
michael@0 | 412 | ldrb r10, [r7, r4] ; w->buffer[x] |
michael@0 | 413 | add r10, r10, #1 |
michael@0 | 414 | strb r10, [r7, r4] ; w->buffer[x] + 1 |
michael@0 | 415 | token_high_bit_not_set_se |
michael@0 | 416 | rsb r4, r6, #24 ; 24-offset |
michael@0 | 417 | ldr r10, [r0, #vp8_writer_buffer] |
michael@0 | 418 | lsr r7, r2, r4 ; lowvalue >> (24-offset) |
michael@0 | 419 | ldr r4, [r0, #vp8_writer_pos] ; w->pos |
michael@0 | 420 | lsl r2, r2, r6 ; lowvalue <<= offset |
michael@0 | 421 | mov r6, r3 ; shift = count |
michael@0 | 422 | add r11, r4, #1 ; w->pos++ |
michael@0 | 423 | bic r2, r2, #0xff000000 ; lowvalue &= 0xffffff |
michael@0 | 424 | str r11, [r0, #vp8_writer_pos] |
michael@0 | 425 | sub r3, r3, #8 ; count -= 8 |
michael@0 | 426 | |
michael@0 | 427 | VALIDATE_POS r10, r11 ; validate_buffer at pos |
michael@0 | 428 | |
michael@0 | 429 | strb r7, [r10, r4] ; w->buffer[w->pos++] |
michael@0 | 430 | |
michael@0 | 431 | token_count_lt_zero_se |
michael@0 | 432 | lsl r2, r2, r6 ; lowvalue <<= shift |
michael@0 | 433 | |
michael@0 | 434 | subs r12, r12, #1 |
michael@0 | 435 | bne stop_encode_loop |
michael@0 | 436 | |
michael@0 | 437 | ldr r4, [r0, #vp8_writer_pos] ; w->pos |
michael@0 | 438 | ldr r12, [sp, #24] ; ptr |
michael@0 | 439 | add r12, r12, r4 ; ptr += w->pos |
michael@0 | 440 | str r12, [sp, #24] |
michael@0 | 441 | |
michael@0 | 442 | ldr r11, [sp, #28] ; i |
michael@0 | 443 | ldr r10, [sp, #20] ; num_parts |
michael@0 | 444 | |
michael@0 | 445 | add r11, r11, #1 ; i++ |
michael@0 | 446 | str r11, [sp, #28] |
michael@0 | 447 | |
michael@0 | 448 | ldr r7, [sp, #32] ; cpi->tp_list[i] |
michael@0 | 449 | mov r1, #TOKENLIST_SZ |
michael@0 | 450 | add r7, r7, r1 ; next element in cpi->tp_list |
michael@0 | 451 | str r7, [sp, #32] ; cpi->tp_list[i+1] |
michael@0 | 452 | |
michael@0 | 453 | cmp r10, r11 |
michael@0 | 454 | bgt numparts_loop |
michael@0 | 455 | |
michael@0 | 456 | add sp, sp, #40 |
michael@0 | 457 | pop {r4-r12, pc} |
michael@0 | 458 | ENDP |
michael@0 | 459 | |
michael@0 | 460 | _VP8_COMP_common_ |
michael@0 | 461 | DCD vp8_comp_common |
michael@0 | 462 | _VP8_COMMON_MBrows_ |
michael@0 | 463 | DCD vp8_common_mb_rows |
michael@0 | 464 | _VP8_COMP_tplist_ |
michael@0 | 465 | DCD vp8_comp_tplist |
michael@0 | 466 | _VP8_COMP_bc_ |
michael@0 | 467 | DCD vp8_comp_bc |
michael@0 | 468 | _vp8_writer_sz_ |
michael@0 | 469 | DCD vp8_writer_sz |
michael@0 | 470 | |
michael@0 | 471 | END |