Alien-FreeImage
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
src/Source/LibJXR/image/decode/strdec.c view on Meta::CPAN
//================================================================
Int readIndexTable(CWMImageStrCodec * pSC)
{
BitIOInfo* pIO = pSC->pIOHeader;
readIS_L1(pSC, pIO);
if(pSC->cNumBitIO > 0){
size_t *pTable = pSC->pIndexTable;
U32 iEntry = (U32)pSC->cNumBitIO * (pSC->WMISCP.cNumOfSliceMinus1H + 1), i;
// read index table header [0x0001] - 2 bytes
if (getBit32(pIO, 16) != 1)
return ICERR_ERROR;
//iBits = getBit16(pIO, 5) + 1; // how many bits per entry
for(i = 0; i < iEntry; i ++){
readIS_L1(pSC, pIO);
pTable[i] = GetVLWordEsc(pIO, NULL); // escape handling is not important since the respective band is not accessed
}
}
pSC->cHeaderSize = GetVLWordEsc(pIO, NULL); // escape handling is not important
flushToByte(pIO);
pSC->cHeaderSize += getPosRead(pSC->pIOHeader); // get header length
return ICERR_OK;
}
Int StrIODecInit(CWMImageStrCodec* pSC)
{
if(allocateBitIOInfo(pSC) != ICERR_OK){
return ICERR_ERROR;
}
attachISRead(pSC->pIOHeader, pSC->WMISCP.pWStream, pSC);
readIndexTable(pSC);
if(pSC->WMISCP.bVerbose){
U32 i, j;
printf("\n%d horizontal tiles:\n", pSC->WMISCP.cNumOfSliceMinus1H + 1);
for(i = 0; i <= pSC->WMISCP.cNumOfSliceMinus1H; i ++){
printf(" offset of tile %d in MBs: %d\n", i, pSC->WMISCP.uiTileY[i]);
}
printf("\n%d vertical tiles:\n", pSC->WMISCP.cNumOfSliceMinus1V + 1);
for(i = 0; i <= pSC->WMISCP.cNumOfSliceMinus1V; i ++){
printf(" offset of tile %d in MBs: %d\n", i, pSC->WMISCP.uiTileX[i]);
}
if(pSC->WMISCP.bfBitstreamFormat == SPATIAL){
printf("\nSpatial order bitstream\n");
}
else{
printf("\nFrequency order bitstream\n");
}
if(!pSC->m_param.bIndexTable){
printf("\nstreaming mode, no index table.\n");
}
else if(pSC->WMISCP.bfBitstreamFormat == SPATIAL){
for(j = 0; j <= pSC->WMISCP.cNumOfSliceMinus1H; j ++){
for(i = 0; i <= pSC->WMISCP.cNumOfSliceMinus1V; i ++){
size_t * p = &pSC->pIndexTable[j * (pSC->WMISCP.cNumOfSliceMinus1V + 1) + i];
if(i + j != pSC->WMISCP.cNumOfSliceMinus1H + pSC->WMISCP.cNumOfSliceMinus1V){
printf("bitstream size for tile (%d, %d): %d.\n", j, i, (int) (p[1] - p[0]));
}
else{
printf("bitstream size for tile (%d, %d): unknown.\n", j, i);
}
}
}
}
else{
for(j = 0; j <= pSC->WMISCP.cNumOfSliceMinus1H; j ++){
for(i = 0; i <= pSC->WMISCP.cNumOfSliceMinus1V; i ++){
size_t * p = &pSC->pIndexTable[(j * (pSC->WMISCP.cNumOfSliceMinus1V + 1) + i) * 4];
if(i + j != pSC->WMISCP.cNumOfSliceMinus1H + pSC->WMISCP.cNumOfSliceMinus1V){
printf("bitstream size of (DC, LP, AC, FL) for tile (%d, %d): %d %d %d %d.\n", j, i,
(int) (p[1] - p[0]), (int) (p[2] - p[1]), (int) (p[3] - p[2]), (int) (p[4] - p[3]));
}
else{
printf("bitstream size of (DC, LP, AC, FL) for tile (%d, %d): %d %d %d unknown.\n", j, i,
(int) (p[1] - p[0]), (int) (p[2] - p[1]), (int) (p[3] - p[2]));
}
}
}
}
}
return 0;
}
Int StrIODecTerm(CWMImageStrCodec* pSC)
{
detachISRead(pSC, pSC->pIOHeader);
free(pSC->m_ppBitIO);
free(pSC->pIndexTable);
return 0;
}
Int initLookupTables(CWMImageStrCodec* pSC)
{
static const U8 cbChannels[BDB_MAX] = {1, 1, 2, 2, 2, 4, 4, 4, (U8) -1, (U8) -1, (U8) -1 };
CWMImageInfo * pII = &pSC->WMII;
size_t cStrideX, cStrideY;
size_t w, h, i, iFirst = 0;
Bool bReverse;
// lookup tables for rotation and flipping
if(pSC->m_Dparam->cThumbnailScale > 1) // thumbnail
w = pII->cThumbnailWidth, h = pII->cThumbnailHeight;
else
w = pII->cWidth, h = pII->cHeight;
w += (pSC->m_Dparam->cROILeftX + pSC->m_Dparam->cThumbnailScale - 1) / pSC->m_Dparam->cThumbnailScale;
h += (pSC->m_Dparam->cROITopY + pSC->m_Dparam->cThumbnailScale - 1) / pSC->m_Dparam->cThumbnailScale;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.616 second using v1.00-cache-2.02-grep-82fe00e-cpan-2cc899e4a130 )