Skip to content

Commit 78a38d5

Browse files
authored
Revert "fix lz77 bug"
1 parent 8950cac commit 78a38d5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/compress.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int huffman_uncompress(const unsigned char *compressed, unsigned char **original
5959
/// 类型长度
6060
#define LZ77_TYPE_BITS 1
6161
/// 滑动窗口偏移量长度
62-
#define LZ77_WINOFF_BITS 13
62+
#define LZ77_WINOFF_BITS 12
6363
/// 短语标志长度
6464
#define LZ77_BUFLEN_BITS 5
6565
/// 下一个匹配符号长度

source/lz77.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static int compare_win(const unsigned char *window,
7777

7878
int lz77_compress(const unsigned char *original, unsigned char **compressed, int size)
7979
{
80-
unsigned int token;
80+
unsigned long token;
8181
unsigned char window[LZ77_WINDOW_SIZE], buffer[LZ77_BUFFER_SIZE], *comp, *temp, next;
8282
int offset, length, remaining, tbits, hsize, ipos, opos, tpos, i;
8383

@@ -276,11 +276,11 @@ int lz77_uncompress(const unsigned char *compressed, unsigned char **original) {
276276

277277
while (i < length && remaining > 0) {
278278

279-
orig[opos] = window[offset + i - 1];
279+
orig[opos] = window[offset + i];
280280
opos++;
281281

282282
/// 记录前向缓冲区中的符号直到更新入滑动窗口
283-
buffer[i] = window[offset + i - 1];
283+
buffer[i] = window[offset + i];
284284
i++;
285285

286286
/// 更新生于的需要处理的符号数量

0 commit comments

Comments
 (0)