Algorithm 版 (精华区)
发信人: lofe ()感激生活(), 信区: Algorithm
标 题: ar002--decode.c
发信站: 哈工大紫丁香 (Sun Sep 3 08:27:18 2000), 转信
/***********************************************************
decode.c
***********************************************************/
#include "ar.h"
static int j; /* remaining bytes to copy */
void decode_start(void)
{
huf_decode_start();
j = 0;
}
void decode(uint count, uchar buffer[])
/* The calling function must keep the number of
bytes to be processed. This function decodes
either 'count' bytes or 'DICSIZ' bytes, whichever
is smaller, into the array 'buffer[]' of size
'DICSIZ' or more.
Call decode_start() once for each new file
before calling this function. */
{
static uint i;
uint r, c;
r = 0;
while (--j >= 0) {
buffer[r] = buffer[i];
i = (i + 1) & (DICSIZ - 1);
if (++r == count) return;
}
for ( ; ; ) {
c = decode_c();
if (c <= UCHAR_MAX) {
buffer[r] = c;
if (++r == count) return;
} else {
j = c - (UCHAR_MAX + 1 - THRESHOLD);
i = (r - decode_p() - 1) & (DICSIZ - 1);
while (--j >= 0) {
buffer[r] = buffer[i];
i = (i + 1) & (DICSIZ - 1);
if (++r == count) return;
}
}
}
}
--
We Are the World!
infosite@263.net
※ 修改:.haojs 于 Sep 3 08:24:54 修改本文.[FROM: bbs.hit.edu.cn]
--
※ 转寄:.武汉白云黄鹤站 bbs.whnet.edu.cn.[FROM: bbs.hit.edu.cn]
--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: haojs.bbs@bbs.whnet.]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.791毫秒