git » fp-git.git » commit 9cb3ebd

temporary broken ;)

author ecalot
2006-02-09 21:19:31 UTC
committer ecalot
2006-02-09 21:19:31 UTC
parent 36be3c10d6b058098d6cb77cb3a866b8df87b7bb

temporary broken ;)

PR/src/lib/compression/lzg_decompress.c +11 -2
PR/src/lib/compression/rlev_decompress.c +11 -7

diff --git a/PR/src/lib/compression/lzg_decompress.c b/PR/src/lib/compression/lzg_decompress.c
index 348b321..20a8319 100644
--- a/PR/src/lib/compression/lzg_decompress.c
+++ b/PR/src/lib/compression/lzg_decompress.c
@@ -53,15 +53,19 @@ int expandLzg(const unsigned char* input, int inputSize,
 	register int           loc;
 	register unsigned char rep, k;
 
+	if (*outputSize) (*outputSize)+=LZG_WINDOW_SIZE; else *outputSize=65000;
+
 	/* initialize the first 1024 bytes of the window with zeros */
 	for(oCursor=0;oCursor<LZG_WINDOW_SIZE;output[oCursor++]=0);
 
 	/* main loop */
-	while (iCursor<inputSize) {
+	while (iCursor<inputSize&&oCursor<(*outputSize)) {
+printf("i=%d o=%d\n",iCursor,oCursor);
 		maskbyte=input[iCursor++];
 		for (k=8;k&&(iCursor<inputSize);k--) {
 			if (popBit(&maskbyte)) {
 				output[oCursor++]=input[iCursor++]; /* copy input to output */
+printf("%02x ",output[oCursor-1]);
 			} else {
 				/*
 				 * loc:
@@ -79,19 +83,24 @@ int expandLzg(const unsigned char* input, int inputSize,
 
 				while (rep--) { /* repeat pattern in output */
 					output[oCursor]=output[oCursor-loc];
-
+printf("%02x ",output[oCursor]);
 					oCursor++;
 				}
 			}
 		}
 	}
 
+	inputSize-=iCursor;
 	/* ignore the first 1024 bytes */
 	*outputSize=oCursor-LZG_WINDOW_SIZE;
 	*output2=(unsigned char*)malloc(*outputSize);
 	for(iCursor=LZG_WINDOW_SIZE;iCursor<oCursor;iCursor++)
 		(*output2)[iCursor-LZG_WINDOW_SIZE]=output[iCursor];
 
+printf("oc=%d os=%d ic=%d is=%d\n",oCursor,(*outputSize),iCursor,inputSize);
+
+	if (oCursor>=(*outputSize)) return inputSize;
+
 	return (!maskbyte)-1;
 	/*return rep?COMPRESS_RESULT_WARNING:COMPRESS_RESULT_SUCCESS;*/
 }
diff --git a/PR/src/lib/compression/rlev_decompress.c b/PR/src/lib/compression/rlev_decompress.c
index f05f79f..6bae68b 100644
--- a/PR/src/lib/compression/rlev_decompress.c
+++ b/PR/src/lib/compression/rlev_decompress.c
@@ -54,7 +54,7 @@ int expandRleC(const unsigned char* input, int inputSize,
 	while (iCursor<inputSize) {
 		rep=(input[iCursor++]);
 printf("o=%d i=%d\n",oCursor,iCursor);
-		if ((oCursor==28800)||(done)||(oCursor%verif)) {
+		if ((done)||(oCursor%verif)) {
 			done=0;
 			if (rep&0x80) { /* repeat */
 				//rep&=~0x80;
@@ -69,20 +69,24 @@ printf("o=%d i=%d\n",oCursor,iCursor);
 				}
 			}
 		} else {
+//printf("aux=%d lineSize=%d (iCursor-aux)=%d\n",aux,lineSize,(iCursor-aux));
 			if (aux)
 				if (lineSize!=(iCursor-aux))
 					printf("Error, line size is wrong: lineSize=%d got=%d\n",lineSize,(iCursor-aux));
 
 			lineSize=rep+256*input[iCursor]+1;
-printf("i=%d o=%d\n",iCursor,oCursor);
+//printf("i=%d aux=%d o=%d\n",iCursor,aux,oCursor);
 			iCursor++;
 			done=1;
 			aux=iCursor;
-			if (oCursor==28800) {
-				printf("error time %02x %02x\n",input[iCursor],input[iCursor+1]);
-				iCursor+=2;
-
-			}
+/*			if (oCursor==28800) {
+				int g;
+				printf("error time: (ls=%d)",lineSize);
+				for (g=-20;g<100;g++)
+					printf(" %02x",input[iCursor+g]);
+				printf("\n");
+				iCursor-=4;
+			}*/
 		}