private void getAllCodeBlocks()
{
int numComps, numTiles; // numBytes removed
int c, r, t, s, sidx, k;
//int slope;
SubbandAn subb;
CBlkRateDistStats ccb = null;
Coord ncblks = null;
int last_sidx;
float fslope;
#if DO_TIMING
long stime = 0L;
#endif
maxSlope = 0f;
minSlope = System.Single.MaxValue;
//Get the number of components and tiles
numComps = src.NumComps;
numTiles = src.getNumTiles();
SubbandAn root, sb;
int cblkToEncode = 0;
//Get all coded code-blocks Goto first tile
src.setTile(0, 0);
for (t = 0; t < numTiles; t++)
{
//loop on tiles
cblkToEncode = 0;
for (c = 0; c < numComps; c++)
{
root = src.getAnSubbandTree(t, c);
for (r = 0; r <= root.resLvl; r++)
{
if (r == 0)
{
sb = (SubbandAn) root.getSubbandByIdx(0, 0);
if (sb != null)
cblkToEncode += sb.numCb.x * sb.numCb.y;
}
else
{
sb = (SubbandAn) root.getSubbandByIdx(r, 1);
if (sb != null)
cblkToEncode += sb.numCb.x * sb.numCb.y;
sb = (SubbandAn) root.getSubbandByIdx(r, 2);
if (sb != null)
cblkToEncode += sb.numCb.x * sb.numCb.y;
sb = (SubbandAn) root.getSubbandByIdx(r, 3);
if (sb != null)
cblkToEncode += sb.numCb.x * sb.numCb.y;
}
}
}
for (c = 0; c < numComps; c++)
{
//loop on components
//Get next coded code-block coordinates
while ((ccb = src.getNextCodeBlock(c, ccb)) != null)
{
#if DO_TIMING
stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
#endif
subb = ccb.sb;
//Get the coded code-block resolution level index
r = subb.resLvl;
//Get the coded code-block subband index
s = subb.sbandIdx;
//Get the number of blocks in the current subband
ncblks = subb.numCb;
// Add code-block contribution to summary R-D table
// RDSlopesRates
last_sidx = - 1;
for (k = ccb.nVldTrunc - 1; k >= 0; k--)
{
fslope = ccb.truncSlopes[k];
if (fslope > maxSlope)
maxSlope = fslope;
if (fslope < minSlope)
minSlope = fslope;
sidx = getLimitedSIndexFromSlope(fslope);
for (; sidx > last_sidx; sidx--)
{
RDSlopesRates[sidx] += ccb.truncRates[ccb.truncIdxs[k]];
}
last_sidx = getLimitedSIndexFromSlope(fslope);
}
//Fills code-blocks array
cblks[t][c][r][s][(ccb.m * ncblks.x) + ccb.n] = ccb;
ccb = null;
#if DO_TIMING
initTime += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
#endif
}
}
//Goto next tile
if (t < numTiles - 1)
//not at last tile
src.nextTile();
}
}