Beispiel #1
0
static void
Cputprim(		/* put out compressed primary from scanline */
	COLR	*scn,
	int	pri
)
{
	register int	c;
	register int	x;
	int	lastc, cnt;

	lastc = -1; cnt = 0;
	for (x = 0; x < xmax; x++) {
		if (pri == GRY)
			c = normbright(scn[x]) + 2;
		else
			c = scn[x][pri] + 2;
		if (c > 255) c = 255;
		c = code[c>>2];
		if (c == lastc && cnt < MAXRUN)
			cnt++;
		else {
			putrle(cnt, lastc);
			lastc = c;
			cnt = 1;
		}
	}
	putrle(cnt, lastc);
}
Beispiel #2
0
static uae_s32 ARCunsqueeze(struct zfile *in, struct zfile *out, struct rledata *rled)
{
	uae_s32 err = 0;
	uae_s32 i, numnodes;
	uae_s16 *node;
	struct fout io;

	io.zf = in;
	io.xio_BitBuf = 0;
	io.xio_BitNum = 0;
	io.err = 0;

	if((node = (uae_s16 *) xcalloc(uae_s16, 2*ARCSQNUMVALS)))
	{
		numnodes = xadIOGetBitsLow(&io, 16);

		if(numnodes < 0 || numnodes >= ARCSQNUMVALS)
			err = XADERR_DECRUNCH;
		else
		{  /* initialize for possible empty tree (SPEOF only) */
			node[0] = node[1] = -(ARCSQSPEOF + 1);

			numnodes *= 2; i = 0;
			while(i < numnodes && !io.err)       /* get decoding tree from file */
			{
				node[i++] = xadIOGetBitsLow(&io, 16);
				node[i++] = xadIOGetBitsLow(&io, 16);
			}

			do
			{
				/* follow bit stream in tree to a leaf */
				i = 0;
				while(i >= 0 && !io.err)
					i = node[2*i + xadIOGetBitsLow(&io, 1)];

				i = -(i + 1); /* decode fake node index to original data value */

				if(i != ARCSQSPEOF)
					putrle (i, out, rled);
			} while(i != ARCSQSPEOF);
		}
		xfree(node);
	}
	else
		err = XADERR_NOMEMORY;

	return err;
}