📄 pktencoder.java
字号:
} if (incArrayMax[t][c].y == 0) { sot_eotMax[0].y = 0; sot_eotMax[1].y = 1; incArrayMax[t][c].y = 1; } else { sot_eotMax[0].y = infoSrc.getULY(c); sot_eotMax[1].y = sot_eotMax[0].y + infoSrc.getHeight(); sot_eotMax[0].y &= ~(incArrayMax[t][c].y-1); } } // Create and initialise the increment array for each resolution level for ( l=0 ; l<mrl[t][c]+1 ; l++ ) { if ( sot_eotArray[t][c][l][0]==null ) { sot_eotArray[t][c][l][0] = new Coord(); // start of tile sot_eotArray[t][c][l][1] = new Coord(); // end of tile } else { // Already allocated and filled continue; } sot_eot = sot_eotArray[t][c][l]; // Calculate the start/enf of tile for the resolution l and // associated increment if (incArray[t][c][l].x == 0) { sot_eot[0].x = 0; sot_eot[1].x = 1; incArray[t][c][l].x = 1; } else { sot_eot[0].x = infoSrc.getULX(c); sot_eot[1].x = sot_eot[0].x + infoSrc.getWidth(); sot_eot[0].x &= ~(incArray[t][c][l].x-1); } if (incArray[t][c][l].y == 0) { sot_eot[0].y = 0; sot_eot[1].y = 1; incArray[t][c][l].y = 1; } else { sot_eot[0].y = infoSrc.getULY(c); sot_eot[1].y = sot_eot[0].y + infoSrc.getHeight(); sot_eot[0].y &= ~(incArray[t][c][l].y-1); } } } /** * Builds the lists containing the ulx, uly, width, height and indexes of * the code-blocks and of the precincts for each tile, component, * resolution level and subband. First, we compute the projected anchor * point for the code-block partition. Then, the array containing the * code-blocks coordinates is built. Finally, the array containing the * precincts coordinates is built. * * @param t the tile index * * @param c the component index * * @param ppx the precinct partition width * * @param ppy the precinct partition height * * @param resLvl The resolution level * */ private void buildCblkPrec(int t, int c, int resLvl) { int cn, cm, count, nrcb, tmp; int n, m; // horizontal and vertical indexes of the current code-block int apox, apoy; // projected anchor point for the code-block partition Coord ncblks = null; // Number of code-blocks CBlkCoordInfo cbinf = null; SubbandAn sbtree, sb; int maxsbi, minsbi; int precIdxA[]; // Get subband tree sbtree = savedSbTree[t][c]; precIdxA = new int[subRange[t][c][resLvl][1]+1]; // loop on each subband for(int subIdx=subRange[t][c][resLvl][0]; subIdx <= subRange[t][c][resLvl][1]; subIdx ++){ sb = (SubbandAn)sbtree.getSubbandByIdx(resLvl,subIdx); // Compute the projected anchor point for the code-block partition apox = infoSrc.getPartitionULX(); apoy = infoSrc.getPartitionULY(); SubbandAn sb2; switch (sb.gOrient) { case Subband.WT_ORIENT_LL: // No need to project since all low-pass => nothing to do break; case Subband.WT_ORIENT_HL: // There is at least a high-pass step on the horizontal // decomposition => project to 0 apox = 0; // We need to find out if there has been a high-pass step on // the vertical decomposition sb2 = sb; do { if (sb2.orientation == Subband.WT_ORIENT_HH || sb2.orientation == Subband.WT_ORIENT_LH) { // Vertical high-pass step => project to 0 and done apoy = 0; break; } if (sb2.gOrient == Subband.WT_ORIENT_LL) { // Only low-pass steps left, no need to continue // checking break; } sb2 = (SubbandAn)sb2.getParent(); } while (sb2 != null); break; case Subband.WT_ORIENT_LH: // We need to find out if there has been a high-pass step on // the horizontal decomposition sb2 = sb; do { if (sb2.orientation == Subband.WT_ORIENT_HH || sb2.orientation == Subband.WT_ORIENT_HL) { // Horizontal high-pass step => project to 0 and done apox = 0; break; } if (sb2.gOrient == Subband.WT_ORIENT_LL) { // Only low-pass steps left, no need to continue // checking break; } sb2 = (SubbandAn)sb2.getParent(); } while (sb2 != null); // There is at least a high-pass step on the vertical // decomposition => project to 0 apoy = 0; break; case Subband.WT_ORIENT_HH: // There is at least a high-pass step on the horiz. and // vertical decomposition => project to 0 apox = 0; apoy = 0; break; default: throw new Error("Internal JJ2000 error"); } // end switch // Get number of code-blocks in current subband ncblks = infoSrc.getNumCodeBlocks(sb,ncblks); nrcb = ncblks.x*ncblks.y; if ( nrcb>0 ) { // If there is at least one code-block if ( cbArrayI[t][c][sb.resLvl][sb.sbandIdx]==null ) { cbArrayI[t][c][sb.resLvl][sb.sbandIdx] = new CBlkCoordInfo[nrcb]; } // Deal with code-blocks first count = 0; n = -1; m = 0; do { // Goto next code-block n++; if (n == ncblks.x) { // Got to end of this row of code-blocks n = 0; m++; } cbArrayI[t][c][sb.resLvl][sb.sbandIdx][count] = new CBlkCoordInfo(); cbArrayI[t][c][sb.resLvl][sb.sbandIdx][count].idx = new Coord(n,m); cbinf = cbArrayI[t][c][sb.resLvl][sb.sbandIdx][count]; // Indexes of first code-block overlapping with the // subband cn = (sb.ulcx-apox+sb.nomCBlkW)/sb.nomCBlkW-1; cm = (sb.ulcy-apoy+sb.nomCBlkH)/sb.nomCBlkH-1; // ULX if (n == 0) { // Left-most code-block, starts where subband starts cbinf.ulx = sb.ulx; } else { // Calculate starting canvas coordinate and convert to // subband coords cbinf.ulx = (cn+n)*sb.nomCBlkW - (sb.ulcx-apox)+ sb.ulx; } // ULY if (m == 0) { // Bottom-most code-block, starts where subband starts cbinf.uly = sb.uly; } else { cbinf.uly = (cm+m)*sb.nomCBlkH - (sb.ulcy-apoy) + sb.uly; } // Width if (n < ncblks.x-1) { // Calculate where next code-block starts => width cbinf.w = (cn+n+1)*sb.nomCBlkW - (sb.ulcx-apox) + sb.ulx - cbinf.ulx; } else { // Right-most code-block, ends where subband ends cbinf.w = sb.ulx+sb.w - cbinf.ulx; } // Height if (m < ncblks.y-1) { // Calculate where next code-block starts => height cbinf.h = (cm+m+1)*sb.nomCBlkH - (sb.ulcy-apoy) + sb.uly - cbinf.uly; } else { // Bottom-most code-block, ends where subband ends cbinf.h = sb.uly+sb.h- cbinf.uly; } count++; if ( count == nrcb ) { // we have dealt with all code-blocks break; } } while (true); } // nrcb>0 } // Loop on subbands // ------------------------------------------------- // Now deal with precincts // ------------------------------------------------- int nl, nrpp, ppx, ppy; int x_inc, y_inc; int Px=0; int Py=0; int precIdx = -1; int hIdx, vIdx; boolean incrPrecIdx = false; x_inc = incArray[t][c][resLvl].x; y_inc = incArray[t][c][resLvl].y; // Get the maximum number of precincts for the resolution level Coord numPrecC = maxNumPrec[t][c][resLvl]; nrpp = numPrecC.x * numPrecC.y; for(int subIdx=subRange[t][c][resLvl][0]; subIdx <= subRange[t][c][resLvl][1]; subIdx ++){ if ( nrpp>0 ) { //If there is at least one precinct precArrayI[t][c][resLvl][subIdx] = new PrecCoordInfo[nrpp]; } } for(int yr=sot_eotArrayMax[t][c][0].y;yr<sot_eotArrayMax[t][c][1].y; yr+=incArrayMax[t][c].y){ for(int xr=sot_eotArrayMax[t][c][0].x; xr<sot_eotArrayMax[t][c][1].x; xr+=incArrayMax[t][c].x){ // Loop on highest resolution grid using the smallest // increment if( ( (xr==sot_eotArrayMax[t][c][0].x) || ((xr)%x_inc==0) ) && ( (yr==sot_eotArrayMax[t][c][0].y) || ((yr)%y_inc==0) ) ) { // Precinct exists in the resolution level incrPrecIdx = false; for(int subIdx=subRange[t][c][resLvl][0]; subIdx <= subRange[t][c][resLvl][1]; subIdx ++){ sb = (SubbandAn)sbtree.getSubbandByIdx(resLvl,subIdx); // If precinct is empty, skip this subband if(maxNumPrec[t][c][resLvl].x * maxNumPrec[t][c][resLvl].y == 0) { continue; } if( !infoSrc.precinctPartitionUsed(c, t) ){ // If the precinct partition is not used, create // a precinct that contains all the code-blocks of // the subband precArrayI[t][c][resLvl][subIdx][0] = new PrecCoordInfo(0,0,sb.w,sb.h,xr,yr); } else { // Precinct partition is used // Get precinct partition sizes ppx = infoSrc.getPPX(t,c,resLvl); ppy = infoSrc.getPPY(t,c,resLvl); precIdx = precIdxA[subIdx]; if ( precIdx<0 || precIdx>nrpp-1 ) { // Wrong precinct index continue; } // Calculate horizontal coordinate within subband // (including missing image) if ((xr==sot_eotArrayMax[t][c][0].x) && (sot_eotArrayMax[t][c][0].x != (sot_eotArray[t][c][resLvl][0].x >> (mrl[t][c]-resLvl)))){ if (resLvl==0){ Px=(int)(sot_eotArray[t][c][resLvl][0].x/ Math.pow(2,mrl[t][c]-resLvl)- sb.ulcx); } else { // If resolu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -