"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xpdf/Stream.cc" between
xpdf-4.01.01.tar.gz and xpdf-4.02.tar.gz

About: Xpdf is a PDF viewer for X.

Stream.cc  (xpdf-4.01.01):Stream.cc  (xpdf-4.02)
skipping to change at line 124 skipping to change at line 124
} }
j = (Guint)getBlock(buf, (int)i); j = (Guint)getBlock(buf, (int)i);
count += j; count += j;
if (j != i) { if (j != i) {
break; break;
} }
} }
return count; return count;
} }
GString *Stream::getPSFilter(int psLevel, const char *indent) { GString *Stream::getPSFilter(int psLevel, const char *indent,
GBool okToReadStream) {
return new GString(); return new GString();
} }
Stream *Stream::addFilters(Object *dict, int recursion) { Stream *Stream::addFilters(Object *dict, int recursion) {
Object obj, obj2; Object obj, obj2;
Object params, params2; Object params, params2;
Stream *str; Stream *str;
int i; int i;
str = this; str = this;
dict->dictLookup("Filter", &obj); dict->dictLookup("Filter", &obj, recursion);
if (obj.isNull()) { if (obj.isNull()) {
obj.free(); obj.free();
dict->dictLookup("F", &obj); dict->dictLookup("F", &obj, recursion);
} }
dict->dictLookup("DecodeParms", &params); dict->dictLookup("DecodeParms", &params, recursion);
if (params.isNull()) { if (params.isNull()) {
params.free(); params.free();
dict->dictLookup("DP", &params); dict->dictLookup("DP", &params, recursion);
} }
if (obj.isName()) { if (obj.isName()) {
str = makeFilter(obj.getName(), str, &params, recursion); str = makeFilter(obj.getName(), str, &params, recursion);
} else if (obj.isArray()) { } else if (obj.isArray()) {
for (i = 0; i < obj.arrayGetLength(); ++i) { for (i = 0; i < obj.arrayGetLength(); ++i) {
obj.arrayGet(i, &obj2, recursion); obj.arrayGet(i, &obj2, recursion);
if (params.isArray()) if (params.isArray())
params.arrayGet(i, &params2, recursion); params.arrayGet(i, &params2, recursion);
else else
params2.initNull(); params2.initNull();
skipping to change at line 1098 skipping to change at line 1099
eof = gTrue; eof = gTrue;
x = 0; x = 0;
} else { } else {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Illegal character <{0:02x}> in ASCIIHex stream", c2); "Illegal character <{0:02x}> in ASCIIHex stream", c2);
} }
buf = x & 0xff; buf = x & 0xff;
return buf; return buf;
} }
GString *ASCIIHexStream::getPSFilter(int psLevel, const char *indent) { GString *ASCIIHexStream::getPSFilter(int psLevel, const char *indent,
GBool okToReadStream) {
GString *s; GString *s;
if (psLevel < 2) { if (psLevel < 2) {
return NULL; return NULL;
} }
if (!(s = str->getPSFilter(psLevel, indent))) { if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
return NULL; return NULL;
} }
s->append(indent)->append("/ASCIIHexDecode filter\n"); s->append(indent)->append("/ASCIIHexDecode filter\n");
return s; return s;
} }
GBool ASCIIHexStream::isBinary(GBool last) { GBool ASCIIHexStream::isBinary(GBool last) {
return str->isBinary(gFalse); return str->isBinary(gFalse);
} }
skipping to change at line 1183 skipping to change at line 1185
t = t * 85 + (c[k] - 0x21); t = t * 85 + (c[k] - 0x21);
for (k = 3; k >= 0; --k) { for (k = 3; k >= 0; --k) {
b[k] = (int)(t & 0xff); b[k] = (int)(t & 0xff);
t >>= 8; t >>= 8;
} }
} }
} }
return b[index]; return b[index];
} }
GString *ASCII85Stream::getPSFilter(int psLevel, const char *indent) { GString *ASCII85Stream::getPSFilter(int psLevel, const char *indent,
GBool okToReadStream) {
GString *s; GString *s;
if (psLevel < 2) { if (psLevel < 2) {
return NULL; return NULL;
} }
if (!(s = str->getPSFilter(psLevel, indent))) { if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
return NULL; return NULL;
} }
s->append(indent)->append("/ASCII85Decode filter\n"); s->append(indent)->append("/ASCII85Decode filter\n");
return s; return s;
} }
GBool ASCII85Stream::isBinary(GBool last) { GBool ASCII85Stream::isBinary(GBool last) {
return str->isBinary(gFalse); return str->isBinary(gFalse);
} }
skipping to change at line 1410 skipping to change at line 1413
if ((c = str->getChar()) == EOF) if ((c = str->getChar()) == EOF)
return EOF; return EOF;
inputBuf = (inputBuf << 8) | (c & 0xff); inputBuf = (inputBuf << 8) | (c & 0xff);
inputBits += 8; inputBits += 8;
} }
code = (inputBuf >> (inputBits - nextBits)) & ((1 << nextBits) - 1); code = (inputBuf >> (inputBits - nextBits)) & ((1 << nextBits) - 1);
inputBits -= nextBits; inputBits -= nextBits;
return code; return code;
} }
GString *LZWStream::getPSFilter(int psLevel, const char *indent) { GString *LZWStream::getPSFilter(int psLevel, const char *indent,
GBool okToReadStream) {
GString *s; GString *s;
if (psLevel < 2 || pred) { if (psLevel < 2 || pred) {
return NULL; return NULL;
} }
if (!(s = str->getPSFilter(psLevel, indent))) { if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
return NULL; return NULL;
} }
s->append(indent)->append("<< "); s->append(indent)->append("<< ");
if (!early) { if (!early) {
s->append("/EarlyChange 0 "); s->append("/EarlyChange 0 ");
} }
s->append(">> /LZWDecode filter\n"); s->append(">> /LZWDecode filter\n");
return s; return s;
} }
skipping to change at line 1476 skipping to change at line 1480
if (m > size - n) { if (m > size - n) {
m = size - n; m = size - n;
} }
memcpy(blk + n, bufPtr, m); memcpy(blk + n, bufPtr, m);
bufPtr += m; bufPtr += m;
n += m; n += m;
} }
return n; return n;
} }
GString *RunLengthStream::getPSFilter(int psLevel, const char *indent) { GString *RunLengthStream::getPSFilter(int psLevel, const char *indent,
GBool okToReadStream) {
GString *s; GString *s;
if (psLevel < 2) { if (psLevel < 2) {
return NULL; return NULL;
} }
if (!(s = str->getPSFilter(psLevel, indent))) { if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
return NULL; return NULL;
} }
s->append(indent)->append("/RunLengthDecode filter\n"); s->append(indent)->append("/RunLengthDecode filter\n");
return s; return s;
} }
GBool RunLengthStream::isBinary(GBool last) { GBool RunLengthStream::isBinary(GBool last) {
return str->isBinary(gTrue); return str->isBinary(gTrue);
} }
skipping to change at line 2014 skipping to change at line 2019
} }
} }
if (endOfBlock && gotEOL) { if (endOfBlock && gotEOL) {
code1 = lookBits(12); code1 = lookBits(12);
if (code1 == 0x001) { if (code1 == 0x001) {
eatBits(12); eatBits(12);
if (encoding > 0) { if (encoding > 0) {
lookBits(1); lookBits(1);
eatBits(1); eatBits(1);
} }
if (encoding >= 0) { if (encoding > 0) {
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
code1 = lookBits(12); code1 = lookBits(12);
if (code1 != 0x001) { if (code1 != 0x001) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Bad RTC code in CCITTFax stream"); "Bad RTC code in CCITTFax stream");
++nErrors; ++nErrors;
} }
eatBits(12); eatBits(12);
if (encoding > 0) { if (encoding > 0) {
lookBits(1); lookBits(1);
skipping to change at line 2262 skipping to change at line 2267
// however many bits are available -- we need to return correct // however many bits are available -- we need to return correct
// data in this case // data in this case
return (short)((inputBuf << (n - inputBits)) & (0xffffffff >> (32 - n))); return (short)((inputBuf << (n - inputBits)) & (0xffffffff >> (32 - n)));
} }
inputBuf = (inputBuf << 8) + c; inputBuf = (inputBuf << 8) + c;
inputBits += 8; inputBits += 8;
} }
return (short)((inputBuf >> (inputBits - n)) & (0xffffffff >> (32 - n))); return (short)((inputBuf >> (inputBits - n)) & (0xffffffff >> (32 - n)));
} }
GString *CCITTFaxStream::getPSFilter(int psLevel, const char *indent) { GString *CCITTFaxStream::getPSFilter(int psLevel, const char *indent,
GBool okToReadStream) {
GString *s; GString *s;
char s1[50]; char s1[50];
if (psLevel < 2) { if (psLevel < 2) {
return NULL; return NULL;
} }
if (!(s = str->getPSFilter(psLevel, indent))) { if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
return NULL; return NULL;
} }
s->append(indent)->append("<< "); s->append(indent)->append("<< ");
if (encoding != 0) { if (encoding != 0) {
sprintf(s1, "/K %d ", encoding); sprintf(s1, "/K %d ", encoding);
s->append(s1); s->append(s1);
} }
if (endOfLine) { if (endOfLine) {
s->append("/EndOfLine true "); s->append("/EndOfLine true ");
} }
skipping to change at line 2386 skipping to change at line 2392
for (i = 0; i < lineBufHeight; ++i) { for (i = 0; i < lineBufHeight; ++i) {
lineBufRows[i] = lineBuf + lineBufRows[i] = lineBuf +
i * decomp.out_color_components * decomp.output_width; i * decomp.out_color_components * decomp.output_width;
} }
bufPtr = bufEnd = lineBuf; bufPtr = bufEnd = lineBuf;
// start up the decompression process // start up the decompression process
jpeg_start_decompress(&decomp); jpeg_start_decompress(&decomp);
} }
GBool DCTStream::checkSequentialInterleaved() {
//~ this is unimplemented
return gTrue;
}
void DCTStream::close() { void DCTStream::close() {
// we don't call jpeg_finish_decompress() here because it will report // we don't call jpeg_finish_decompress() here because it will report
// an error if the full image wasn't read // an error if the full image wasn't read
if (setjmp(errorMgr.setjmpBuf)) { if (setjmp(errorMgr.setjmpBuf)) {
goto skip; goto skip;
} }
jpeg_destroy_decompress(&decomp); jpeg_destroy_decompress(&decomp);
skip: skip:
gfree(lineBuf); gfree(lineBuf);
FilterStream::close(); FilterStream::close();
skipping to change at line 2756 skipping to change at line 2767
rowBufPtr = rowBufEnd = rowBuf; rowBufPtr = rowBufEnd = rowBuf;
// initialize counters // initialize counters
y = -mcuHeight; y = -mcuHeight;
restartMarker = 0xd0; restartMarker = 0xd0;
restart(); restart();
} }
} }
GBool DCTStream::checkSequentialInterleaved() {
GBool headerOk;
str->reset();
progressive = interleaved = gFalse;
width = height = 0;
numComps = 0;
numQuantTables = 0;
numDCHuffTables = 0;
numACHuffTables = 0;
gotJFIFMarker = gFalse;
gotAdobeMarker = gFalse;
restartInterval = 0;
headerOk = readHeader(gTrue);
FilterStream::close();
return headerOk && !progressive && interleaved;
}
void DCTStream::close() { void DCTStream::close() {
int i; int i;
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
gfree(frameBuf[i]); gfree(frameBuf[i]);
frameBuf[i] = NULL; frameBuf[i] = NULL;
} }
gfree(rowBuf); gfree(rowBuf);
rowBuf = NULL; rowBuf = NULL;
FilterStream::close(); FilterStream::close();
skipping to change at line 3757 skipping to change at line 3790
inputBuf = c; inputBuf = c;
inputBits = 8; inputBits = 8;
} }
bit = (inputBuf >> (inputBits - 1)) & 1; bit = (inputBuf >> (inputBits - 1)) & 1;
--inputBits; --inputBits;
return bit; return bit;
} }
GBool DCTStream::readHeader(GBool frame) { GBool DCTStream::readHeader(GBool frame) {
GBool doScan; GBool doScan;
int n; int n, i;
int c = 0; int c = 0;
// read headers // read headers
doScan = gFalse; doScan = gFalse;
while (!doScan) { while (!doScan) {
c = readMarker(); c = readMarker();
switch (c) { switch (c) {
case 0xc0: // SOF0 (sequential) case 0xc0: // SOF0 (sequential)
case 0xc1: // SOF1 (extended sequential) case 0xc1: // SOF1 (extended sequential)
if (!frame) { if (!frame) {
skipping to change at line 3852 skipping to change at line 3885
n = read16() - 2; n = read16() - 2;
str->discardChars(n); str->discardChars(n);
} else { } else {
error(errSyntaxError, getPos(), "Unknown DCT marker <{0:02x}>", c); error(errSyntaxError, getPos(), "Unknown DCT marker <{0:02x}>", c);
return gFalse; return gFalse;
} }
break; break;
} }
} }
for (i = 0; i < numComps; ++i) {
if (compInfo[i].quantTable >= numQuantTables) {
error(errSyntaxError, getPos(), "Invalid DCT quant table selector");
return gFalse;
}
}
return gTrue; return gTrue;
} }
GBool DCTStream::readBaselineSOF() { GBool DCTStream::readBaselineSOF() {
int prec; int prec;
int i; int i;
int c; int c;
read16(); // length read16(); // length
prec = str->getChar(); prec = str->getChar();
skipping to change at line 3880 skipping to change at line 3920
if (prec != 8) { if (prec != 8) {
error(errSyntaxError, getPos(), "Bad DCT precision {0:d}", prec); error(errSyntaxError, getPos(), "Bad DCT precision {0:d}", prec);
return gFalse; return gFalse;
} }
for (i = 0; i < numComps; ++i) { for (i = 0; i < numComps; ++i) {
compInfo[i].id = str->getChar(); compInfo[i].id = str->getChar();
c = str->getChar(); c = str->getChar();
compInfo[i].hSample = (c >> 4) & 0x0f; compInfo[i].hSample = (c >> 4) & 0x0f;
compInfo[i].vSample = c & 0x0f; compInfo[i].vSample = c & 0x0f;
compInfo[i].quantTable = str->getChar(); compInfo[i].quantTable = str->getChar();
if (compInfo[i].hSample < 1 || compInfo[i].hSample > 4 || // a sampling factor of 3 is allowed by the spec, but requires
compInfo[i].vSample < 1 || compInfo[i].vSample > 4) { // messy upsampling, and appears not to be used in practice
if (!(compInfo[i].hSample == 1 ||
compInfo[i].hSample == 2 ||
compInfo[i].hSample == 4) ||
!(compInfo[i].vSample == 1 ||
compInfo[i].vSample == 2 ||
compInfo[i].vSample == 4)) {
error(errSyntaxError, getPos(), "Bad DCT sampling factor"); error(errSyntaxError, getPos(), "Bad DCT sampling factor");
return gFalse; return gFalse;
} }
if (compInfo[i].quantTable < 0 || compInfo[i].quantTable > 3) { if (compInfo[i].quantTable < 0 || compInfo[i].quantTable > 3) {
error(errSyntaxError, getPos(), "Bad DCT quant table selector"); error(errSyntaxError, getPos(), "Bad DCT quant table selector");
return gFalse; return gFalse;
} }
} }
progressive = gFalse; progressive = gFalse;
return gTrue; return gTrue;
skipping to change at line 3919 skipping to change at line 3965
if (prec != 8) { if (prec != 8) {
error(errSyntaxError, getPos(), "Bad DCT precision {0:d}", prec); error(errSyntaxError, getPos(), "Bad DCT precision {0:d}", prec);
return gFalse; return gFalse;
} }
for (i = 0; i < numComps; ++i) { for (i = 0; i < numComps; ++i) {
compInfo[i].id = str->getChar(); compInfo[i].id = str->getChar();
c = str->getChar(); c = str->getChar();
compInfo[i].hSample = (c >> 4) & 0x0f; compInfo[i].hSample = (c >> 4) & 0x0f;
compInfo[i].vSample = c & 0x0f; compInfo[i].vSample = c & 0x0f;
compInfo[i].quantTable = str->getChar(); compInfo[i].quantTable = str->getChar();
if (compInfo[i].hSample < 1 || compInfo[i].hSample > 4 || // a sampling factor of 3 is allowed by the spec, but requires
compInfo[i].vSample < 1 || compInfo[i].vSample > 4) { // messy upsampling, and appears not to be used in practice
if (!(compInfo[i].hSample == 1 ||
compInfo[i].hSample == 2 ||
compInfo[i].hSample == 4) ||
!(compInfo[i].vSample == 1 ||
compInfo[i].vSample == 2 ||
compInfo[i].vSample == 4)) {
error(errSyntaxError, getPos(), "Bad DCT sampling factor"); error(errSyntaxError, getPos(), "Bad DCT sampling factor");
return gFalse; return gFalse;
} }
if (compInfo[i].quantTable < 0 || compInfo[i].quantTable > 3) { if (compInfo[i].quantTable < 0 || compInfo[i].quantTable > 3) {
error(errSyntaxError, getPos(), "Bad DCT quant table selector"); error(errSyntaxError, getPos(), "Bad DCT quant table selector");
return gFalse; return gFalse;
} }
} }
progressive = gTrue; progressive = gTrue;
return gTrue; return gTrue;
skipping to change at line 4184 skipping to change at line 4236
if ((c1 = str->getChar()) == EOF) if ((c1 = str->getChar()) == EOF)
return EOF; return EOF;
if ((c2 = str->getChar()) == EOF) if ((c2 = str->getChar()) == EOF)
return EOF; return EOF;
return (c1 << 8) + c2; return (c1 << 8) + c2;
} }
#endif // HAVE_JPEGLIB #endif // HAVE_JPEGLIB
GString *DCTStream::getPSFilter(int psLevel, const char *indent) { GString *DCTStream::getPSFilter(int psLevel, const char *indent,
GBool okToReadStream) {
GString *s; GString *s;
if (psLevel < 2) { if (psLevel < 2) {
return NULL; return NULL;
} }
if (!(s = str->getPSFilter(psLevel, indent))) { if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
return NULL;
}
if (okToReadStream && !checkSequentialInterleaved()) {
// PostScript does not allow progressive or interleaved JPEG
delete s;
return NULL; return NULL;
} }
s->append(indent)->append("<< >> /DCTDecode filter\n"); s->append(indent)->append("<< >> /DCTDecode filter\n");
return s; return s;
} }
GBool DCTStream::isBinary(GBool last) { GBool DCTStream::isBinary(GBool last) {
return str->isBinary(gTrue); return str->isBinary(gTrue);
} }
skipping to change at line 4984 skipping to change at line 5042
} }
while (remain && n < size) { while (remain && n < size) {
blk[n++] = buf[index]; blk[n++] = buf[index];
index = (index + 1) & flateMask; index = (index + 1) & flateMask;
--remain; --remain;
} }
} }
return n; return n;
} }
GString *FlateStream::getPSFilter(int psLevel, const char *indent) { GString *FlateStream::getPSFilter(int psLevel, const char *indent,
GBool okToReadStream) {
GString *s; GString *s;
if (psLevel < 3 || pred) { if (psLevel < 3 || pred) {
return NULL; return NULL;
} }
if (!(s = str->getPSFilter(psLevel, indent))) { if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
return NULL; return NULL;
} }
s->append(indent)->append("<< >> /FlateDecode filter\n"); s->append(indent)->append("<< >> /FlateDecode filter\n");
return s; return s;
} }
GBool FlateStream::isBinary(GBool last) { GBool FlateStream::isBinary(GBool last) {
return str->isBinary(gTrue); return str->isBinary(gTrue);
} }
 End of changes. 26 change blocks. 
25 lines changed or deleted 84 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)