x86.c (292588) | x86.c (312518) |
---|---|
1/////////////////////////////////////////////////////////////////////////////// 2// 3/// \file x86.c 4/// \brief Filter for x86 binaries (BCJ filter) 5/// 6// Authors: Igor Pavlov 7// Lasse Collin 8// 9// This file has been put into the public domain. 10// You can do whatever you want with this file. 11// 12/////////////////////////////////////////////////////////////////////////////// 13 14#include "simple_private.h" 15 16 17#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF) 18 19 | 1/////////////////////////////////////////////////////////////////////////////// 2// 3/// \file x86.c 4/// \brief Filter for x86 binaries (BCJ filter) 5/// 6// Authors: Igor Pavlov 7// Lasse Collin 8// 9// This file has been put into the public domain. 10// You can do whatever you want with this file. 11// 12/////////////////////////////////////////////////////////////////////////////// 13 14#include "simple_private.h" 15 16 17#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF) 18 19 |
20struct lzma_simple_s { | 20typedef struct { |
21 uint32_t prev_mask; 22 uint32_t prev_pos; | 21 uint32_t prev_mask; 22 uint32_t prev_pos; |
23}; | 23} lzma_simple_x86; |
24 25 26static size_t | 24 25 26static size_t |
27x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder, | 27x86_code(void *simple_ptr, uint32_t now_pos, bool is_encoder, |
28 uint8_t *buffer, size_t size) 29{ 30 static const bool MASK_TO_ALLOWED_STATUS[8] 31 = { true, true, true, false, true, false, false, false }; 32 33 static const uint32_t MASK_TO_BIT_NUMBER[8] 34 = { 0, 1, 2, 2, 3, 3, 3, 3 }; 35 | 28 uint8_t *buffer, size_t size) 29{ 30 static const bool MASK_TO_ALLOWED_STATUS[8] 31 = { true, true, true, false, true, false, false, false }; 32 33 static const uint32_t MASK_TO_BIT_NUMBER[8] 34 = { 0, 1, 2, 2, 3, 3, 3, 3 }; 35 |
36 lzma_simple_x86 *simple = simple_ptr; |
|
36 uint32_t prev_mask = simple->prev_mask; 37 uint32_t prev_pos = simple->prev_pos; 38 39 if (size < 5) 40 return 0; 41 42 if (now_pos - prev_pos > 5) 43 prev_pos = now_pos - 5; --- 78 unchanged lines hidden (view full) --- 122} 123 124 125static lzma_ret 126x86_coder_init(lzma_next_coder *next, const lzma_allocator *allocator, 127 const lzma_filter_info *filters, bool is_encoder) 128{ 129 const lzma_ret ret = lzma_simple_coder_init(next, allocator, filters, | 37 uint32_t prev_mask = simple->prev_mask; 38 uint32_t prev_pos = simple->prev_pos; 39 40 if (size < 5) 41 return 0; 42 43 if (now_pos - prev_pos > 5) 44 prev_pos = now_pos - 5; --- 78 unchanged lines hidden (view full) --- 123} 124 125 126static lzma_ret 127x86_coder_init(lzma_next_coder *next, const lzma_allocator *allocator, 128 const lzma_filter_info *filters, bool is_encoder) 129{ 130 const lzma_ret ret = lzma_simple_coder_init(next, allocator, filters, |
130 &x86_code, sizeof(lzma_simple), 5, 1, is_encoder); | 131 &x86_code, sizeof(lzma_simple_x86), 5, 1, is_encoder); |
131 132 if (ret == LZMA_OK) { | 132 133 if (ret == LZMA_OK) { |
133 next->coder->simple->prev_mask = 0; 134 next->coder->simple->prev_pos = (uint32_t)(-5); | 134 lzma_simple_coder *coder = next->coder; 135 lzma_simple_x86 *simple = coder->simple; 136 simple->prev_mask = 0; 137 simple->prev_pos = (uint32_t)(-5); |
135 } 136 137 return ret; 138} 139 140 141extern lzma_ret 142lzma_simple_x86_encoder_init(lzma_next_coder *next, --- 14 unchanged lines hidden --- | 138 } 139 140 return ret; 141} 142 143 144extern lzma_ret 145lzma_simple_x86_encoder_init(lzma_next_coder *next, --- 14 unchanged lines hidden --- |