"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xpdf/JPXStream.cc" between
xpdf-4.03.tar.gz and xpdf-4.04.tar.gz

About: Xpdf is a PDF viewer for X.

JPXStream.cc  (xpdf-4.03):JPXStream.cc  (xpdf-4.04)
skipping to change at line 233 skipping to change at line 233
#endif //----- coverage tracking #endif //----- coverage tracking
//------------------------------------------------------------------------ //------------------------------------------------------------------------
JPXStream::JPXStream(Stream *strA): JPXStream::JPXStream(Stream *strA):
FilterStream(strA) FilterStream(strA)
{ {
bufStr = new BufStream(str, 3); bufStr = new BufStream(str, 3);
decoded = gFalse;
nComps = 0; nComps = 0;
bpc = NULL; bpc = NULL;
width = height = 0; width = height = 0;
reduction = 0; reduction = 0;
haveCS = gFalse; haveCS = gFalse;
palette.bpc = NULL; palette.bpc = NULL;
palette.c = NULL; palette.c = NULL;
havePalette = gFalse; havePalette = gFalse;
skipping to change at line 273 skipping to change at line 274
delete bufStr; delete bufStr;
} }
Stream *JPXStream::copy() { Stream *JPXStream::copy() {
return new JPXStream(str->copy()); return new JPXStream(str->copy());
} }
void JPXStream::reset() { void JPXStream::reset() {
img.ySize = 0; img.ySize = 0;
bufStr->reset(); bufStr->reset();
if (readBoxes() == jpxDecodeFatalError) { decoded = gFalse;
// readBoxes reported an error, so we go immediately to EOF
curY = img.ySize >> reduction;
} else {
curY = img.yOffsetR;
}
curX = img.xOffsetR;
curComp = 0;
readBufLen = 0;
} }
void JPXStream::close() { void JPXStream::close() {
JPXTile *tile; JPXTile *tile;
JPXTileComp *tileComp; JPXTileComp *tileComp;
JPXResLevel *resLevel; JPXResLevel *resLevel;
JPXPrecinct *precinct; JPXPrecinct *precinct;
JPXSubband *subband; JPXSubband *subband;
JPXCodeBlock *cb; JPXCodeBlock *cb;
Guint comp, i, k, r, pre, sb; Guint comp, i, k, r, pre, sb;
skipping to change at line 366 skipping to change at line 359
} }
gfree(tile->tileComps); gfree(tile->tileComps);
} }
} }
gfree(img.tiles); gfree(img.tiles);
img.tiles = NULL; img.tiles = NULL;
} }
bufStr->close(); bufStr->close();
} }
void JPXStream::decodeImage() {
if (readBoxes() == jpxDecodeFatalError) {
// readBoxes reported an error, so we go immediately to EOF
curY = img.ySize >> reduction;
} else {
curY = img.yOffsetR;
}
curX = img.xOffsetR;
curComp = 0;
readBufLen = 0;
decoded = gTrue;
}
int JPXStream::getChar() { int JPXStream::getChar() {
int c; int c;
if (!decoded) {
decodeImage();
}
if (readBufLen < 8) { if (readBufLen < 8) {
fillReadBuf(); fillReadBuf();
} }
if (readBufLen == 8) { if (readBufLen == 8) {
c = readBuf & 0xff; c = readBuf & 0xff;
readBufLen = 0; readBufLen = 0;
} else if (readBufLen > 8) { } else if (readBufLen > 8) {
c = (readBuf >> (readBufLen - 8)) & 0xff; c = (readBuf >> (readBufLen - 8)) & 0xff;
readBufLen -= 8; readBufLen -= 8;
} else if (readBufLen == 0) { } else if (readBufLen == 0) {
skipping to change at line 390 skipping to change at line 399
} else { } else {
c = (readBuf << (8 - readBufLen)) & 0xff; c = (readBuf << (8 - readBufLen)) & 0xff;
readBufLen = 0; readBufLen = 0;
} }
return c; return c;
} }
int JPXStream::lookChar() { int JPXStream::lookChar() {
int c; int c;
if (!decoded) {
decodeImage();
}
if (readBufLen < 8) { if (readBufLen < 8) {
fillReadBuf(); fillReadBuf();
} }
if (readBufLen == 8) { if (readBufLen == 8) {
c = readBuf & 0xff; c = readBuf & 0xff;
} else if (readBufLen > 8) { } else if (readBufLen > 8) {
c = (readBuf >> (readBufLen - 8)) & 0xff; c = (readBuf >> (readBufLen - 8)) & 0xff;
} else if (readBufLen == 0) { } else if (readBufLen == 0) {
c = EOF; c = EOF;
} else { } else {
skipping to change at line 423 skipping to change at line 435
return; return;
} }
tileIdx = (((curY << reduction) - img.yTileOffset) / img.yTileSize) tileIdx = (((curY << reduction) - img.yTileOffset) / img.yTileSize)
* img.nXTiles * img.nXTiles
+ ((curX << reduction) - img.xTileOffset) / img.xTileSize; + ((curX << reduction) - img.xTileOffset) / img.xTileSize;
#if 1 //~ ignore the palette, assume the PDF ColorSpace object is valid #if 1 //~ ignore the palette, assume the PDF ColorSpace object is valid
tileComp = &img.tiles[tileIdx].tileComps[curComp]; tileComp = &img.tiles[tileIdx].tileComps[curComp];
#else #else
tileComp = &img.tiles[tileIdx].tileComps[havePalette ? 0 : curComp]; tileComp = &img.tiles[tileIdx].tileComps[havePalette ? 0 : curComp];
#endif #endif
tx = jpxFloorDiv(curX - jpxCeilDivPow2(img.tiles[tileIdx].x0, reduction), tx = jpxFloorDiv(curX, tileComp->hSep);
tileComp->hSep); if (tx < tileComp->x0r) {
ty = jpxFloorDiv(curY - jpxCeilDivPow2(img.tiles[tileIdx].y0, reduction), tx = 0;
tileComp->vSep); } else {
tx -= tileComp->x0r;
}
ty = jpxFloorDiv(curY, tileComp->vSep);
if (ty < tileComp->y0r) {
ty = 0;
} else {
ty -= tileComp->y0r;
}
pix = (int)tileComp->data[ty * tileComp->w + tx]; pix = (int)tileComp->data[ty * tileComp->w + tx];
pixBits = tileComp->prec; pixBits = tileComp->prec;
eol = gFalse; eol = gFalse;
#if 1 //~ ignore the palette, assume the PDF ColorSpace object is valid #if 1 //~ ignore the palette, assume the PDF ColorSpace object is valid
if (++curComp == img.nComps) { if (++curComp == img.nComps) {
#else #else
if (havePalette) { if (havePalette) {
if (pix >= 0 && pix < palette.nEntries) { if (pix >= 0 && pix < palette.nEntries) {
pix = palette.c[pix * palette.nComps + curComp]; pix = palette.c[pix * palette.nComps + curComp];
} else { } else {
skipping to change at line 1064 skipping to change at line 1084
} }
} }
} }
for (r = 0; r <= nDecompLevels; ++r) { for (r = 0; r <= nDecompLevels; ++r) {
if (style & 0x01) { if (style & 0x01) {
cover(91); cover(91);
if (!readUByte(&precinctSize)) { if (!readUByte(&precinctSize)) {
error(errSyntaxError, getPos(), "Error in JPX COD marker segment"); error(errSyntaxError, getPos(), "Error in JPX COD marker segment");
return jpxDecodeFatalError; return jpxDecodeFatalError;
} }
if (r > 0 && ((precinctSize & 0x0f) == 0 ||
(precinctSize & 0xf0) == 0)) {
error(errSyntaxError, getPos(),
"Invalid precinct size in JPX COD marker segment");
return jpxDecodeFatalError;
}
img.tiles[0].tileComps[0].resLevels[r].precinctWidth = img.tiles[0].tileComps[0].resLevels[r].precinctWidth =
precinctSize & 0x0f; precinctSize & 0x0f;
img.tiles[0].tileComps[0].resLevels[r].precinctHeight = img.tiles[0].tileComps[0].resLevels[r].precinctHeight =
(precinctSize >> 4) & 0x0f; (precinctSize >> 4) & 0x0f;
} else { } else {
img.tiles[0].tileComps[0].resLevels[r].precinctWidth = 15; img.tiles[0].tileComps[0].resLevels[r].precinctWidth = 15;
img.tiles[0].tileComps[0].resLevels[r].precinctHeight = 15; img.tiles[0].tileComps[0].resLevels[r].precinctHeight = 15;
} }
} }
for (i = 0; i < img.nXTiles * img.nYTiles; ++i) { for (i = 0; i < img.nXTiles * img.nYTiles; ++i) {
skipping to change at line 1138 skipping to change at line 1164
for (r = 0; r <= nDecompLevels; ++r) { for (r = 0; r <= nDecompLevels; ++r) {
img.tiles[i].tileComps[comp].resLevels[r].precincts = NULL; img.tiles[i].tileComps[comp].resLevels[r].precincts = NULL;
} }
} }
for (r = 0; r <= nDecompLevels; ++r) { for (r = 0; r <= nDecompLevels; ++r) {
if (style & 0x01) { if (style & 0x01) {
if (!readUByte(&precinctSize)) { if (!readUByte(&precinctSize)) {
error(errSyntaxError, getPos(), "Error in JPX COD marker segment"); error(errSyntaxError, getPos(), "Error in JPX COD marker segment");
return jpxDecodeFatalError; return jpxDecodeFatalError;
} }
if (r > 0 && ((precinctSize & 0x0f) == 0 ||
(precinctSize & 0xf0) == 0)) {
error(errSyntaxError, getPos(),
"Invalid precinct size in JPX COD marker segment");
return jpxDecodeFatalError;
}
img.tiles[0].tileComps[comp].resLevels[r].precinctWidth = img.tiles[0].tileComps[comp].resLevels[r].precinctWidth =
precinctSize & 0x0f; precinctSize & 0x0f;
img.tiles[0].tileComps[comp].resLevels[r].precinctHeight = img.tiles[0].tileComps[comp].resLevels[r].precinctHeight =
(precinctSize >> 4) & 0x0f; (precinctSize >> 4) & 0x0f;
} else { } else {
img.tiles[0].tileComps[comp].resLevels[r].precinctWidth = 15; img.tiles[0].tileComps[comp].resLevels[r].precinctWidth = 15;
img.tiles[0].tileComps[comp].resLevels[r].precinctHeight = 15; img.tiles[0].tileComps[comp].resLevels[r].precinctHeight = 15;
} }
} }
for (i = 1; i < img.nXTiles * img.nYTiles; ++i) { for (i = 1; i < img.nXTiles * img.nYTiles; ++i) {
skipping to change at line 1582 skipping to change at line 1614
for (r = 0; r <= nDecompLevels; ++r) { for (r = 0; r <= nDecompLevels; ++r) {
img.tiles[tileIdx].tileComps[comp].resLevels[r].precincts = NULL; img.tiles[tileIdx].tileComps[comp].resLevels[r].precincts = NULL;
} }
} }
for (r = 0; r <= nDecompLevels; ++r) { for (r = 0; r <= nDecompLevels; ++r) {
if (style & 0x01) { if (style & 0x01) {
if (!readUByte(&precinctSize)) { if (!readUByte(&precinctSize)) {
error(errSyntaxError, getPos(), "Error in JPX COD marker segment"); error(errSyntaxError, getPos(), "Error in JPX COD marker segment");
return gFalse; return gFalse;
} }
if (r > 0 && ((precinctSize & 0x0f) == 0 ||
(precinctSize & 0xf0) == 0)) {
error(errSyntaxError, getPos(),
"Invalid precinct size in JPX COD marker segment");
return gFalse;
}
img.tiles[tileIdx].tileComps[0].resLevels[r].precinctWidth = img.tiles[tileIdx].tileComps[0].resLevels[r].precinctWidth =
precinctSize & 0x0f; precinctSize & 0x0f;
img.tiles[tileIdx].tileComps[0].resLevels[r].precinctHeight = img.tiles[tileIdx].tileComps[0].resLevels[r].precinctHeight =
(precinctSize >> 4) & 0x0f; (precinctSize >> 4) & 0x0f;
} else { } else {
img.tiles[tileIdx].tileComps[0].resLevels[r].precinctWidth = 15; img.tiles[tileIdx].tileComps[0].resLevels[r].precinctWidth = 15;
img.tiles[tileIdx].tileComps[0].resLevels[r].precinctHeight = 15; img.tiles[tileIdx].tileComps[0].resLevels[r].precinctHeight = 15;
} }
} }
for (comp = 1; comp < img.nComps; ++comp) { for (comp = 1; comp < img.nComps; ++comp) {
skipping to change at line 1646 skipping to change at line 1684
sizeof(JPXResLevel)); sizeof(JPXResLevel));
for (r = 0; r <= nDecompLevels; ++r) { for (r = 0; r <= nDecompLevels; ++r) {
img.tiles[tileIdx].tileComps[comp].resLevels[r].precincts = NULL; img.tiles[tileIdx].tileComps[comp].resLevels[r].precincts = NULL;
} }
for (r = 0; r <= nDecompLevels; ++r) { for (r = 0; r <= nDecompLevels; ++r) {
if (style & 0x01) { if (style & 0x01) {
if (!readUByte(&precinctSize)) { if (!readUByte(&precinctSize)) {
error(errSyntaxError, getPos(), "Error in JPX COD marker segment"); error(errSyntaxError, getPos(), "Error in JPX COD marker segment");
return gFalse; return gFalse;
} }
if (r > 0 && ((precinctSize & 0x0f) == 0 ||
(precinctSize & 0xf0) == 0)) {
error(errSyntaxError, getPos(),
"Invalid precinct size in JPX COD marker segment");
return gFalse;
}
img.tiles[tileIdx].tileComps[comp].resLevels[r].precinctWidth = img.tiles[tileIdx].tileComps[comp].resLevels[r].precinctWidth =
precinctSize & 0x0f; precinctSize & 0x0f;
img.tiles[tileIdx].tileComps[comp].resLevels[r].precinctHeight = img.tiles[tileIdx].tileComps[comp].resLevels[r].precinctHeight =
(precinctSize >> 4) & 0x0f; (precinctSize >> 4) & 0x0f;
} else { } else {
img.tiles[tileIdx].tileComps[comp].resLevels[r].precinctWidth = 15; img.tiles[tileIdx].tileComps[comp].resLevels[r].precinctWidth = 15;
img.tiles[tileIdx].tileComps[comp].resLevels[r].precinctHeight = 15; img.tiles[tileIdx].tileComps[comp].resLevels[r].precinctHeight = 15;
} }
} }
break; break;
skipping to change at line 1889 skipping to change at line 1933
if (segLen > 2) { if (segLen > 2) {
bufStr->discardChars(segLen - 2); bufStr->discardChars(segLen - 2);
} }
break; break;
} }
} while (!haveSOD); } while (!haveSOD);
for (comp = 0; comp < img.nComps; ++comp) { for (comp = 0; comp < img.nComps; ++comp) {
tileComp = &img.tiles[tileIdx].tileComps[comp]; tileComp = &img.tiles[tileIdx].tileComps[comp];
qStyle = tileComp->quantStyle & 0x1f; qStyle = tileComp->quantStyle & 0x1f;
if ((qStyle == 0 && tileComp->nQuantSteps < 3 * tileComp->nDecompLevels) || if ((qStyle == 0 && tileComp->nQuantSteps < 3 * tileComp->nDecompLevels + 1) ||
(qStyle == 1 && tileComp->nQuantSteps < 1) || (qStyle == 1 && tileComp->nQuantSteps < 1) ||
(qStyle == 2 && tileComp->nQuantSteps < 3 * tileComp->nDecompLevels)) { (qStyle == 2 && tileComp->nQuantSteps < 3 * tileComp->nDecompLevels + 1)) {
error(errSyntaxError, getPos(), "Too few quant steps in JPX tile part"); error(errSyntaxError, getPos(), "Too few quant steps in JPX tile part");
return gFalse; return gFalse;
} }
} }
//----- initialize the tile, precincts, and code-blocks //----- initialize the tile, precincts, and code-blocks
if (tilePartIdx == 0) { if (tilePartIdx == 0) {
tile = &img.tiles[tileIdx]; tile = &img.tiles[tileIdx];
i = tileIdx / img.nXTiles; i = tileIdx / img.nXTiles;
j = tileIdx % img.nXTiles; j = tileIdx % img.nXTiles;
skipping to change at line 1920 skipping to change at line 1964
} }
if ((tile->y1 = img.yTileOffset + (i + 1) * img.yTileSize) > img.ySize) { if ((tile->y1 = img.yTileOffset + (i + 1) * img.yTileSize) > img.ySize) {
tile->y1 = img.ySize; tile->y1 = img.ySize;
} }
tile->comp = 0; tile->comp = 0;
tile->res = 0; tile->res = 0;
tile->precinct = 0; tile->precinct = 0;
tile->layer = 0; tile->layer = 0;
tile->done = gFalse; tile->done = gFalse;
tile->maxNDecompLevels = 0; tile->maxNDecompLevels = 0;
tile->maxNPrecincts = 0;
for (comp = 0; comp < img.nComps; ++comp) { for (comp = 0; comp < img.nComps; ++comp) {
tileComp = &tile->tileComps[comp]; tileComp = &tile->tileComps[comp];
if (tileComp->nDecompLevels > tile->maxNDecompLevels) { if (tileComp->nDecompLevels > tile->maxNDecompLevels) {
tile->maxNDecompLevels = tileComp->nDecompLevels; tile->maxNDecompLevels = tileComp->nDecompLevels;
} }
tileComp->x0 = jpxCeilDiv(tile->x0, tileComp->hSep); tileComp->x0 = jpxCeilDiv(tile->x0, tileComp->hSep);
tileComp->y0 = jpxCeilDiv(tile->y0, tileComp->vSep); tileComp->y0 = jpxCeilDiv(tile->y0, tileComp->vSep);
tileComp->x1 = jpxCeilDiv(tile->x1, tileComp->hSep); tileComp->x1 = jpxCeilDiv(tile->x1, tileComp->hSep);
tileComp->y1 = jpxCeilDiv(tile->y1, tileComp->vSep); tileComp->y1 = jpxCeilDiv(tile->y1, tileComp->vSep);
tileComp->w = jpxCeilDivPow2(tileComp->x1, reduction) tileComp->x0r = jpxCeilDivPow2(tileComp->x0, reduction);
- jpxCeilDivPow2(tileComp->x0, reduction); tileComp->w = jpxCeilDivPow2(tileComp->x1, reduction) - tileComp->x0r;
tileComp->h = jpxCeilDivPow2(tileComp->y1, reduction) tileComp->y0r = jpxCeilDivPow2(tileComp->y0, reduction);
- jpxCeilDivPow2(tileComp->y0, reduction); tileComp->h = jpxCeilDivPow2(tileComp->y1, reduction) - tileComp->y0r;
if (tileComp->w == 0 || tileComp->h == 0) { if (tileComp->w == 0 || tileComp->h == 0 ||
tileComp->w > INT_MAX / tileComp->h) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Invalid tile size or sample separation in JPX stream"); "Invalid tile size or sample separation in JPX stream");
return gFalse; return gFalse;
} }
tileComp->data = (int *)gmallocn(tileComp->w * tileComp->h, sizeof(int)); tileComp->data = (int *)gmallocn(tileComp->w * tileComp->h, sizeof(int));
if (tileComp->x1 - tileComp->x0 > tileComp->y1 - tileComp->y0) { if (tileComp->x1 - tileComp->x0 > tileComp->y1 - tileComp->y0) {
n = tileComp->x1 - tileComp->x0; n = tileComp->x1 - tileComp->x0;
} else { } else {
n = tileComp->y1 - tileComp->y0; n = tileComp->y1 - tileComp->y0;
} }
skipping to change at line 2011 skipping to change at line 2057
(resLevel->bx0[2] == resLevel->bx1[2] || (resLevel->bx0[2] == resLevel->bx1[2] ||
resLevel->by0[2] == resLevel->by1[2]); resLevel->by0[2] == resLevel->by1[2]);
} }
preCol0 = jpxFloorDivPow2(resLevel->x0, resLevel->precinctWidth); preCol0 = jpxFloorDivPow2(resLevel->x0, resLevel->precinctWidth);
preCol1 = jpxCeilDivPow2(resLevel->x1, resLevel->precinctWidth); preCol1 = jpxCeilDivPow2(resLevel->x1, resLevel->precinctWidth);
preRow0 = jpxFloorDivPow2(resLevel->y0, resLevel->precinctHeight); preRow0 = jpxFloorDivPow2(resLevel->y0, resLevel->precinctHeight);
preRow1 = jpxCeilDivPow2(resLevel->y1, resLevel->precinctHeight); preRow1 = jpxCeilDivPow2(resLevel->y1, resLevel->precinctHeight);
resLevel->nPrecincts = (preCol1 - preCol0) * (preRow1 - preRow0); resLevel->nPrecincts = (preCol1 - preCol0) * (preRow1 - preRow0);
resLevel->precincts = (JPXPrecinct *)gmallocn(resLevel->nPrecincts, resLevel->precincts = (JPXPrecinct *)gmallocn(resLevel->nPrecincts,
sizeof(JPXPrecinct)); sizeof(JPXPrecinct));
if (resLevel->nPrecincts > tile->maxNPrecincts) {
tile->maxNPrecincts = resLevel->nPrecincts;
}
for (pre = 0; pre < resLevel->nPrecincts; ++pre) { for (pre = 0; pre < resLevel->nPrecincts; ++pre) {
resLevel->precincts[pre].subbands = NULL; resLevel->precincts[pre].subbands = NULL;
} }
precinct = resLevel->precincts; precinct = resLevel->precincts;
for (preRow = preRow0; preRow < preRow1; ++preRow) { for (preRow = preRow0; preRow < preRow1; ++preRow) {
for (preCol = preCol0; preCol < preCol1; ++preCol) { for (preCol = preCol0; preCol < preCol1; ++preCol) {
precinct->subbands = precinct->subbands =
(JPXSubband *)gmallocn(nSBs, sizeof(JPXSubband)); (JPXSubband *)gmallocn(nSBs, sizeof(JPXSubband));
for (sb = 0; sb < nSBs; ++sb) { for (sb = 0; sb < nSBs; ++sb) {
precinct->subbands[sb].inclusion = NULL; precinct->subbands[sb].inclusion = NULL;
skipping to change at line 2172 skipping to change at line 2221
JPXResLevel *resLevel; JPXResLevel *resLevel;
JPXPrecinct *precinct; JPXPrecinct *precinct;
JPXSubband *subband; JPXSubband *subband;
JPXCodeBlock *cb; JPXCodeBlock *cb;
Guint ttVal; Guint ttVal;
Guint bits, cbX, cbY, nx, ny, i, j, n, sb; Guint bits, cbX, cbY, nx, ny, i, j, n, sb;
int level; int level;
tile = &img.tiles[tileIdx]; tile = &img.tiles[tileIdx];
// if the tile is finished, just skip this tile part
if (tile->done) {
bufStr->discardChars(tilePartLen);
return gTrue;
}
// read all packets from this tile-part // read all packets from this tile-part
while (1) { while (1) {
// if the tile is finished, skip any remaining data
if (tile->done) {
bufStr->discardChars(tilePartLen);
return gTrue;
}
if (tilePartToEOC) { if (tilePartToEOC) {
//~ peek for an EOC marker //~ peek for an EOC marker
cover(93); cover(93);
} else if (tilePartLen == 0) { } else if (tilePartLen == 0) {
break; break;
} }
tileComp = &tile->tileComps[tile->comp]; tileComp = &tile->tileComps[tile->comp];
resLevel = &tileComp->resLevels[tile->res]; resLevel = &tileComp->resLevels[tile->res];
precinct = &resLevel->precincts[tile->precinct]; precinct = &resLevel->precincts[tile->precinct];
skipping to change at line 2428 skipping to change at line 2478
} }
} }
} }
//----- next packet //----- next packet
nextPacket: nextPacket:
switch (tile->progOrder) { switch (tile->progOrder) {
case 0: // layer, resolution level, component, precinct case 0: // layer, resolution level, component, precinct
cover(58); cover(58);
resLevel = &tile->tileComps[tile->comp].resLevels[tile->res]; do {
if (++tile->precinct == resLevel->nPrecincts) { if (++tile->precinct == tile->maxNPrecincts) {
tile->precinct = 0; tile->precinct = 0;
if (++tile->comp == img.nComps) { if (++tile->comp == img.nComps) {
tile->comp = 0; tile->comp = 0;
if (++tile->res == tile->maxNDecompLevels + 1) { if (++tile->res == tile->maxNDecompLevels + 1) {
tile->res = 0; tile->res = 0;
if (++tile->layer == tile->nLayers) { if (++tile->layer == tile->nLayers) {
tile->layer = 0; tile->layer = 0;
tile->done = gTrue; tile->done = gTrue;
}
} }
} }
} }
} } while (!tile->done &&
(tile->res > tile->tileComps[tile->comp].nDecompLevels ||
tile->precinct >= tile->tileComps[tile->comp]
.resLevels[tile->res].nPrecincts));
break; break;
case 1: // resolution level, layer, component, precinct case 1: // resolution level, layer, component, precinct
cover(59); cover(59);
resLevel = &tile->tileComps[tile->comp].resLevels[tile->res]; do {
if (++tile->precinct == resLevel->nPrecincts) { if (++tile->precinct == tile->maxNPrecincts) {
tile->precinct = 0; tile->precinct = 0;
if (++tile->comp == img.nComps) { if (++tile->comp == img.nComps) {
tile->comp = 0; tile->comp = 0;
if (++tile->layer == tile->nLayers) { if (++tile->layer == tile->nLayers) {
tile->layer = 0; tile->layer = 0;
if (++tile->res == tile->maxNDecompLevels + 1) { if (++tile->res == tile->maxNDecompLevels + 1) {
tile->res = 0; tile->res = 0;
tile->done = gTrue; tile->done = gTrue;
}
} }
} }
} }
} } while (!tile->done &&
(tile->res > tile->tileComps[tile->comp].nDecompLevels ||
tile->precinct >= tile->tileComps[tile->comp]
.resLevels[tile->res].nPrecincts));
break; break;
case 2: // resolution level, precinct, component, layer case 2: // resolution level, precinct, component, layer
cover(60); cover(60);
//~ this is incorrect if there are subsampled components (?) //~ this is incorrect if there are subsampled components (?)
if (++tile->layer == tile->nLayers) { do {
tile->layer = 0; if (++tile->layer == tile->nLayers) {
if (++tile->comp == img.nComps) { tile->layer = 0;
tile->comp = 0; if (++tile->comp == img.nComps) {
resLevel = &tile->tileComps[tile->comp].resLevels[tile->res]; tile->comp = 0;
if (++tile->precinct == resLevel->nPrecincts) { if (++tile->precinct == tile->maxNPrecincts) {
tile->precinct = 0; tile->precinct = 0;
if (++tile->res == tile->maxNDecompLevels + 1) { if (++tile->res == tile->maxNDecompLevels + 1) {
tile->res = 0; tile->res = 0;
tile->done = gTrue; tile->done = gTrue;
}
} }
} }
} }
} } while (!tile->done &&
(tile->res > tile->tileComps[tile->comp].nDecompLevels ||
tile->precinct >= tile->tileComps[tile->comp]
.resLevels[tile->res].nPrecincts));
break; break;
case 3: // precinct, component, resolution level, layer case 3: // precinct, component, resolution level, layer
cover(61); cover(61);
//~ this is incorrect if there are subsampled components (?) //~ this is incorrect if there are subsampled components (?)
if (++tile->layer == tile->nLayers) { do {
tile->layer = 0; if (++tile->layer == tile->nLayers) {
if (++tile->res == tile->maxNDecompLevels + 1) { tile->layer = 0;
tile->res = 0; if (++tile->res == tile->maxNDecompLevels + 1) {
if (++tile->comp == img.nComps) { tile->res = 0;
tile->comp = 0; if (++tile->comp == img.nComps) {
resLevel = &tile->tileComps[tile->comp].resLevels[tile->res]; tile->comp = 0;
if (++tile->precinct == resLevel->nPrecincts) { if (++tile->precinct == tile->maxNPrecincts) {
tile->precinct = 0; tile->precinct = 0;
tile->done = gTrue; tile->done = gTrue;
}
} }
} }
} }
} } while (!tile->done &&
(tile->res > tile->tileComps[tile->comp].nDecompLevels ||
tile->precinct >= tile->tileComps[tile->comp]
.resLevels[tile->res].nPrecincts));
break; break;
case 4: // component, precinct, resolution level, layer case 4: // component, precinct, resolution level, layer
cover(62); cover(62);
if (++tile->layer == tile->nLayers) { do {
tile->layer = 0; if (++tile->layer == tile->nLayers) {
if (++tile->res == tile->maxNDecompLevels + 1) { tile->layer = 0;
tile->res = 0; if (++tile->res == tile->maxNDecompLevels + 1) {
resLevel = &tile->tileComps[tile->comp].resLevels[tile->res]; tile->res = 0;
if (++tile->precinct == resLevel->nPrecincts) { if (++tile->precinct == tile->maxNPrecincts) {
tile->precinct = 0; tile->precinct = 0;
if (++tile->comp == img.nComps) { if (++tile->comp == img.nComps) {
tile->comp = 0; tile->comp = 0;
tile->done = gTrue; tile->done = gTrue;
}
} }
} }
} }
} } while (!tile->done &&
(tile->res > tile->tileComps[tile->comp].nDecompLevels ||
tile->precinct >= tile->tileComps[tile->comp]
.resLevels[tile->res].nPrecincts));
break; break;
} }
} }
return gTrue; return gTrue;
err: err:
error(errSyntaxError, getPos(), "Error in JPX stream"); error(errSyntaxError, getPos(), "Error in JPX stream");
return gFalse; return gFalse;
} }
 End of changes. 27 change blocks. 
81 lines changed or deleted 151 lines changed or added

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