Deleted Added
sdiff udiff text old ( 292588 ) new ( 312518 )
full compact
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
20typedef struct {
21 uint32_t prev_mask;
22 uint32_t prev_pos;
23} lzma_simple_x86;
24
25
26static size_t
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
36 lzma_simple_x86 *simple = simple_ptr;
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,
131 &x86_code, sizeof(lzma_simple_x86), 5, 1, is_encoder);
132
133 if (ret == LZMA_OK) {
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);
138 }
139
140 return ret;
141}
142
143
144extern lzma_ret
145lzma_simple_x86_encoder_init(lzma_next_coder *next,

--- 14 unchanged lines hidden ---