mirror of
https://github.com/aaronsgiles/JPEGView.git
synced 2024-06-06 21:29:27 +00:00
92bdb55672
These are the sources for the final official release of JPEGView for the Mac, back in 1994.
1 line
2.5 KiB
C
1 line
2.5 KiB
C
/*********************************************************/
|
|
/* This source code copyright (c) 1991-2001, Aaron Giles */
|
|
/* See the Read Me file for licensing information. */
|
|
/* Contact email: mac@aarongiles.com */
|
|
/*********************************************************/
|
|
|
|
// void DecodeDummyRow(GIFDataPtr theData)
|
|
|
|
ushort *parent = (ushort *)theData->tree;
|
|
uchar *code = (uchar *)(parent + 4096);
|
|
short i, j, currentCode, oldCode;
|
|
|
|
if (!theData->dest) {
|
|
theData->charSize = *theData->src++;
|
|
gCodeSize = theData->charSize + 1;
|
|
gStack = theData->stack;
|
|
gBytesLeft = gBitsInBuffer = gBitBuffer = 0;
|
|
gTreeSize = (1 << theData->charSize);
|
|
gClearCode = gTreeSize++;
|
|
gEndCode = gTreeSize++;
|
|
gInput = theData->src;
|
|
theData->theReturn = true;
|
|
return;
|
|
}
|
|
for (i = 0; i < theData->width; i++) {
|
|
if (gStack != theData->stack) {
|
|
--gStack;
|
|
continue;
|
|
}
|
|
while (gCodeSize > gBitsInBuffer) {
|
|
if (!gBytesLeft) {
|
|
gBytesLeft = *gInput++;
|
|
if (!gBytesLeft) {
|
|
theData->theReturn = true;
|
|
return;
|
|
}
|
|
}
|
|
gBytesLeft--;
|
|
gBitBuffer |= (ulong)*gInput++ << gBitsInBuffer;
|
|
gBitsInBuffer += 8;
|
|
}
|
|
currentCode = gBitBuffer & ((1 << gCodeSize) - 1);
|
|
gBitBuffer >>= gCodeSize;
|
|
gBitsInBuffer -= gCodeSize;
|
|
if (currentCode == gEndCode) {
|
|
theData->theReturn = true;
|
|
return;
|
|
} else if (currentCode == gClearCode) {
|
|
gCodeSize = theData->charSize + 1;
|
|
gTreeSize = gEndCode + 1;
|
|
do {
|
|
while (gCodeSize > gBitsInBuffer) {
|
|
if (!gBytesLeft) {
|
|
gBytesLeft = *gInput++;
|
|
if (!gBytesLeft) {
|
|
theData->theReturn = true;
|
|
return;
|
|
}
|
|
}
|
|
gBytesLeft--;
|
|
gBitBuffer |= (ulong)*gInput++ << gBitsInBuffer;
|
|
gBitsInBuffer += 8;
|
|
}
|
|
currentCode = gBitBuffer & ((1 << gCodeSize) - 1);
|
|
gBitBuffer >>= gCodeSize;
|
|
gBitsInBuffer -= gCodeSize;
|
|
} while (currentCode == gClearCode);
|
|
gFirstCode = gLastCode = currentCode;
|
|
continue;
|
|
}
|
|
oldCode = currentCode;
|
|
if (currentCode > gTreeSize) {
|
|
theData->end = nil;
|
|
break;
|
|
} else if (currentCode == gTreeSize) {
|
|
*gStack++ = gFirstCode;
|
|
currentCode = gLastCode;
|
|
}
|
|
for (j = currentCode; j >= gClearCode; j = parent[j]) *gStack++ = code[j];
|
|
gFirstCode = j;
|
|
if (gTreeSize != 4096) {
|
|
code[gTreeSize] = gFirstCode;
|
|
parent[gTreeSize] = gLastCode;
|
|
if ((++gTreeSize >= (1 << gCodeSize)) && (gCodeSize != 12)) gCodeSize++;
|
|
}
|
|
gLastCode = oldCode;
|
|
}
|
|
theData->theReturn = false;
|
|
if (gInput > theData->end) theData->end = nil;
|