Lines Matching +full:4 +full:- +full:temp
5 * Igor Pavlov <https://7-zip.org/>
22 BCJ_X86 = 4, /* x86 or x86-64 */
37 /* True if we are operating in single-call mode. */
64 * needs to be big enough to hold Alignment + 2 * Look-ahead:
66 * Type Alignment Look-ahead
67 * x86 1 4
68 * PowerPC 4 0
69 * IA-64 16 0
70 * ARM 4 0
71 * ARM-Thumb 2 2
72 * SPARC 4 0
75 } temp; member
96 size_t prev_pos = (size_t)-1; in bcj_x86()
97 uint32_t prev_mask = s->x86_prev_mask; in bcj_x86()
103 if (size <= 4) in bcj_x86()
106 size -= 4; in bcj_x86()
111 prev_pos = i - prev_pos; in bcj_x86()
115 prev_mask = (prev_mask << (prev_pos - 1)) & 7; in bcj_x86()
117 b = buf[i + 4 - mask_to_bit_num[prev_mask]]; in bcj_x86()
129 if (bcj_x86_test_msbyte(buf[i + 4])) { in bcj_x86()
132 dest = src - (s->pos + (uint32_t)i + 5); in bcj_x86()
137 b = (uint8_t)(dest >> (24 - j)); in bcj_x86()
141 src = dest ^ (((uint32_t)1 << (32 - j)) - 1); in bcj_x86()
145 dest |= (uint32_t)0 - (dest & 0x01000000); in bcj_x86()
147 i += 4; in bcj_x86()
153 prev_pos = i - prev_pos; in bcj_x86()
154 s->x86_prev_mask = prev_pos > 3 ? 0 : prev_mask << (prev_pos - 1); in bcj_x86()
165 for (i = 0; i + 4 <= size; i += 4) { in bcj_powerpc()
169 instr -= s->pos + (uint32_t)i; in bcj_powerpc()
186 4, 4, 6, 6, 0, 0, 7, 7, in bcj_ia64()
187 4, 4, 0, 0, 4, 4, 0, 0 in bcj_ia64()
200 /* Instruction slot (0, 1, or 2) in the 128-bit instruction word */ in bcj_ia64()
216 /* 41-bit instruction stored somewhere in the lowest 48 bits */ in bcj_ia64()
241 addr <<= 4; in bcj_ia64()
242 addr -= s->pos + (uint32_t)i; in bcj_ia64()
243 addr >>= 4; in bcj_ia64()
248 << (36 - 20); in bcj_ia64()
250 instr &= (1 << bit_res) - 1; in bcj_ia64()
270 for (i = 0; i + 4 <= size; i += 4) { in bcj_arm()
275 addr -= s->pos + (uint32_t)i + 8; in bcj_arm()
293 for (i = 0; i + 4 <= size; i += 2) { in bcj_armthumb()
301 addr -= s->pos + (uint32_t)i + 4; in bcj_armthumb()
321 for (i = 0; i + 4 <= size; i += 4) { in bcj_sparc()
325 instr -= s->pos + (uint32_t)i; in bcj_sparc()
327 instr = ((uint32_t)0x40000000 - (instr & 0x400000)) in bcj_sparc()
338 * Apply the selected BCJ filter. Update *pos and s->pos to match the amount
351 size -= *pos; in bcj_apply()
353 switch (s->type) { in bcj_apply()
391 s->pos += filtered; in bcj_apply()
395 * Flush pending filtered data from temp to the output buffer.
397 * data to the beginning of temp.
403 copy_size = min_t(size_t, s->temp.filtered, b->out_size - b->out_pos); in bcj_flush()
404 memcpy(b->out + b->out_pos, s->temp.buf, copy_size); in bcj_flush()
405 b->out_pos += copy_size; in bcj_flush()
407 s->temp.filtered -= copy_size; in bcj_flush()
408 s->temp.size -= copy_size; in bcj_flush()
409 memmove(s->temp.buf, s->temp.buf + copy_size, s->temp.size); in bcj_flush()
414 * data in chunks of 1-16 bytes. To hide this issue, this function does
428 if (s->temp.filtered > 0) { in xz_dec_bcj_run()
430 if (s->temp.filtered > 0) in xz_dec_bcj_run()
433 if (s->ret == XZ_STREAM_END) in xz_dec_bcj_run()
439 * temp, copy the unfiltered data from temp to the output buffer in xz_dec_bcj_run()
443 * to temp and rewind the output buffer position accordingly. in xz_dec_bcj_run()
445 * This needs to be always run when temp.size == 0 to handle a special in xz_dec_bcj_run()
449 if (s->temp.size < b->out_size - b->out_pos || s->temp.size == 0) { in xz_dec_bcj_run()
450 out_start = b->out_pos; in xz_dec_bcj_run()
451 memcpy(b->out + b->out_pos, s->temp.buf, s->temp.size); in xz_dec_bcj_run()
452 b->out_pos += s->temp.size; in xz_dec_bcj_run()
454 s->ret = xz_dec_lzma2_run(lzma2, b); in xz_dec_bcj_run()
455 if (s->ret != XZ_STREAM_END in xz_dec_bcj_run()
456 && (s->ret != XZ_OK || s->single_call)) in xz_dec_bcj_run()
457 return s->ret; in xz_dec_bcj_run()
459 bcj_apply(s, b->out, &out_start, b->out_pos); in xz_dec_bcj_run()
466 if (s->ret == XZ_STREAM_END) in xz_dec_bcj_run()
469 s->temp.size = b->out_pos - out_start; in xz_dec_bcj_run()
470 b->out_pos -= s->temp.size; in xz_dec_bcj_run()
471 memcpy(s->temp.buf, b->out + b->out_pos, s->temp.size); in xz_dec_bcj_run()
476 * to try decoding more data to temp. in xz_dec_bcj_run()
478 if (b->out_pos + s->temp.size < b->out_size) in xz_dec_bcj_run()
483 * We have unfiltered data in temp. If the output buffer isn't full in xz_dec_bcj_run()
484 * yet, try to fill the temp buffer by decoding more data from the in xz_dec_bcj_run()
485 * next filter. Apply the BCJ filter on temp. Then we hopefully can in xz_dec_bcj_run()
486 * fill the actual output buffer by copying filtered data from temp. in xz_dec_bcj_run()
487 * A mix of filtered and unfiltered data may be left in temp; it will in xz_dec_bcj_run()
490 if (b->out_pos < b->out_size) { in xz_dec_bcj_run()
491 /* Make b->out{,_pos,_size} temporarily point to s->temp. */ in xz_dec_bcj_run()
492 s->out = b->out; in xz_dec_bcj_run()
493 s->out_pos = b->out_pos; in xz_dec_bcj_run()
494 s->out_size = b->out_size; in xz_dec_bcj_run()
495 b->out = s->temp.buf; in xz_dec_bcj_run()
496 b->out_pos = s->temp.size; in xz_dec_bcj_run()
497 b->out_size = sizeof(s->temp.buf); in xz_dec_bcj_run()
499 s->ret = xz_dec_lzma2_run(lzma2, b); in xz_dec_bcj_run()
501 s->temp.size = b->out_pos; in xz_dec_bcj_run()
502 b->out = s->out; in xz_dec_bcj_run()
503 b->out_pos = s->out_pos; in xz_dec_bcj_run()
504 b->out_size = s->out_size; in xz_dec_bcj_run()
506 if (s->ret != XZ_OK && s->ret != XZ_STREAM_END) in xz_dec_bcj_run()
507 return s->ret; in xz_dec_bcj_run()
509 bcj_apply(s, s->temp.buf, &s->temp.filtered, s->temp.size); in xz_dec_bcj_run()
516 if (s->ret == XZ_STREAM_END) in xz_dec_bcj_run()
517 s->temp.filtered = s->temp.size; in xz_dec_bcj_run()
520 if (s->temp.filtered > 0) in xz_dec_bcj_run()
524 return s->ret; in xz_dec_bcj_run()
531 s->single_call = single_call; in xz_dec_bcj_create()
564 s->type = id; in xz_dec_bcj_reset()
565 s->ret = XZ_OK; in xz_dec_bcj_reset()
566 s->pos = 0; in xz_dec_bcj_reset()
567 s->x86_prev_mask = 0; in xz_dec_bcj_reset()
568 s->temp.filtered = 0; in xz_dec_bcj_reset()
569 s->temp.size = 0; in xz_dec_bcj_reset()