www.pudn.com > sfalic-03-src.rar.rar > cdf.c


/* program do kompresji - dekompresji obrazow */ 
 
#include "cdftypes.h" 
#include "taskparams.h" 
#include "cdfcmdline.h" 
#include "exitit.h" 
#include "cdfpred.h" 
#include "cfamily.h" 
#include "cdfstat.h" 
#include "headers.h" 
#include "bigendian.h" 
#include "clalloc.h" 
 
#include  
#include  
#include  
#include  
 
 
void decompression(FILE *infile, FILE *outfile) 
{ 
	int fileBYTESpp; 
	BYTE *filerow, *compressedrow; 
	int compressedrowlen=4*(width+1); 
	int eof=0; 
	PIXEL context, *prevrow, *currow, *decorelatedrow; 
	int row; 
	struct bitinstatus bs;		/* struktura stanu dla wejscia bitowego */ 
 
	if (bpp<9) 
		fileBYTESpp=1; 
	else  
		fileBYTESpp=2; 
 
	context=0; 
 
	if (!(compressedrow=(BYTE *)clamalloc(compressedrowlen))) 
		exitit("error compressedrow buffer allocation", 4); 
	if (!(filerow=(BYTE *)clamalloc(width*fileBYTESpp))) 
		exitit("error filerow buffer allocation", 4); 
	if (!(prevrow=(PIXEL *)clamalloc(width*sizeof(PIXEL)))) 
		exitit("error pervrow buffer allocation", 4); 
	if (!(currow=(PIXEL *)clamalloc(width*sizeof(PIXEL)))) 
		exitit("error currow buffer allocation", 4); 
	if (!(decorelatedrow=(PIXEL *)clamalloc(width*sizeof(PIXEL)))) 
		exitit("error decorelatedrow buffer allocation", 4); 
 
	if(!decoronly) 
	{	 
		eof=(compressedrowlen!=fread((void *)compressedrow, 1, compressedrowlen, infile)); 
		bs.readptr=compressedrow; 
		statinitdecoder(bpp, maxclen, evol, width, &bs); 
	} 
 
	for (row=0; row1 && !BEmachine()); 
 
	if (!(compressedrow=(BYTE *)clamalloc(4*(width+1)))) 
		exitit("error compressedrow buffer allocation", 4); 
	if (!(prevrow=(PIXEL *)clamalloc(width*sizeof(PIXEL)))) 
		exitit("error pervrow buffer allocation", 4); 
	if (!(currow=(PIXEL *)clamalloc(width*sizeof(PIXEL)))) 
		exitit("error currow buffer allocation", 4); 
	if (!(decorelatedrow=(PIXEL *)clamalloc(width*sizeof(PIXEL)))) 
		exitit("error decorelatedrow buffer allocation", 4); 
	if(needconvert) 
		if (!(filerow=(BYTE *)clamalloc(width*fileBYTESpp))) 
			exitit("error filerow buffer allocation", 4); 
 
	context=0; 
	bitsused=0; 
 
	for (row=0; row