📄 filebitstreamreaderagent.java
字号:
// Get precinct information (number,distance between two consecutive // precincts in the reference grid) in each component and resolution // level int t = getTileIdx(); // Current tile index PrecInfo prec; // temporary variable int p; // Current precinct index int gcd_x = 0; // Horiz. distance between 2 precincts in the ref. grid int gcd_y = 0; // Vert. distance between 2 precincts in the ref. grid int nPrec = 0; // Total number of found precincts int[][] nextPrec = new int [compe][]; // Next precinct index in each // component and resolution level int minlys = 100000; // minimum layer start index of each component int minx = tx1; // Horiz. offset of the second precinct in the // reference grid int miny = ty1; // Vert. offset of the second precinct in the // reference grid. int maxx = tx0; // Max. horiz. offset of precincts in the ref. grid int maxy = ty0; // Max. vert. offset of precincts in the ref. grid Coord numPrec; for(int c=comps; c<compe; c++) { // components for(int r=ress; r<rese; r++) { // resolution levels if(c>=mdl.length) continue; if(r>mdl[c]) continue; nextPrec[c] = new int[mdl[c]+1]; if (lys[c]!=null && r<lys[c].length && lys[c][r]<minlys) { minlys = lys[c][r]; } p = pktDec.getNumPrecinct(c,r)-1; for(; p>=0; p--) { prec = pktDec.getPrecInfo(c,r,p); if(prec.rgulx!=tx0) { if(prec.rgulx<minx) minx = prec.rgulx; if(prec.rgulx>maxx) maxx = prec.rgulx; } if(prec.rguly!=ty0) { if(prec.rguly<miny) miny = prec.rguly; if(prec.rguly>maxy) maxy = prec.rguly; } if(nPrec==0) { gcd_x = prec.rgw; gcd_y = prec.rgh; } else { gcd_x = MathUtil.gcd(gcd_x,prec.rgw); gcd_y = MathUtil.gcd(gcd_y,prec.rgh); } nPrec++; } // precincts } // resolution levels } // components if(nPrec==0) { throw new Error("Image cannot have no precinct"); } int pyend = (maxy-miny)/gcd_y+1; int pxend = (maxx-minx)/gcd_x+1; int hlen,plen; int start; boolean status = false; int lastByte = firstPackOff[t][curTilePart]+ tilePartLen[t][curTilePart]-1- tilePartHeadLen[t][curTilePart]; int numLayers = ((Integer)decSpec.nls.getTileDef(t)).intValue(); String strInfo = "Tile "+getTileIdx()+" (tile-part:"+curTilePart+ "): offset, length, header length\n";; boolean pph = false; if(((Boolean)decSpec.pphs.getTileDef(t)).booleanValue()) { pph = true; } int y = ty0; int x = tx0; for(int py=0; py<=pyend; py++) { // Vertical precincts for(int px=0; px<=pxend; px++) { // Horiz. precincts for(int c=comps; c<compe; c++) { // Components if(c>=mdl.length) continue; for(int r=ress; r<rese; r++) { // Resolution levels if(r>mdl[c]) continue; if(nextPrec[c][r]>=pktDec.getNumPrecinct(c,r)) { continue; } prec = pktDec.getPrecInfo(c,r,nextPrec[c][r]); if((prec.rgulx!=x) || (prec.rguly!=y)) { continue; } for(int l=minlys; l<lye; l++) { // Layers if(r>=lys[c].length) continue; if(l<lys[c][r] || l>=numLayers) continue; start = in.getPos(); // If packed packet headers are used, there is no // need to check that there are bytes enough to // read header if(pph) { pktDec.readPktHead(l,r,c,nextPrec[c][r], cbI[c][r],nBytes); } // If we are about to read outside of tile-part, // skip to next tile-part if(start>lastByte && curTilePart<firstPackOff[t].length-1) { curTilePart++; in.seek(firstPackOff[t][curTilePart]); lastByte = in.getPos()+ tilePartLen[t][curTilePart]-1- tilePartHeadLen[t][curTilePart]; } // Read SOP marker segment if necessary status = pktDec.readSOPMarker(nBytes, nextPrec[c][r],c,r); if(status) { if(printInfo) { FacilityManager.getMsgLogger(). printmsg(MsgLogger.INFO,strInfo); } return true; } if(!pph) { status = pktDec.readPktHead(l,r,c, nextPrec[c][r], cbI[c][r],nBytes); } if(status) { if(printInfo) { FacilityManager.getMsgLogger(). printmsg(MsgLogger.INFO,strInfo); } return true; } // Store packet's head length hlen = in.getPos()-start; pktHL.addElement(new Integer(hlen)); // Reads packet's body status = pktDec.readPktBody(l,r,c,nextPrec[c][r], cbI[c][r],nBytes); plen = in.getPos()-start; strInfo+= " Pkt l="+l+",r="+r+",c="+c+",p="+ nextPrec[c][r]+": "+ start+", "+plen+", "+hlen+"\n"; if(status) { if(printInfo) { FacilityManager.getMsgLogger(). printmsg(MsgLogger.INFO,strInfo); } return true; } } // layers nextPrec[c][r]++; } // Resolution levels } // Components if(px!=pxend) { x = minx+px*gcd_x; } else { x = tx0; } } // Horizontal precincts if(py!=pyend) { y = miny+py*gcd_y; } else { y = ty0; } } // Vertical precincts if(printInfo) { FacilityManager.getMsgLogger().printmsg(MsgLogger.INFO,strInfo); } return false; // Decoding rate was not reached } /** * Reads packets of the current tile according to the * component-position-resolution-layer progressiveness. * * @param lys Index of the first layer for each component and resolution. * * @param lye Index of the last layer. * * @param ress Index of the first resolution level. * * @param rese Index of the last resolution level. * * @param comps Index of the first component. * * @param compe Index of the last component. * * @return True if rate has been reached. * */ private boolean readCompPosResLy(int lys[][],int lye,int ress,int rese, int comps,int compe) throws IOException { Coord nTiles = getNumTiles(null); Coord tileI = getTile(null); int x0siz = hd.getImgULX(); int y0siz = hd.getImgULY(); int xsiz = x0siz + hd.getImgWidth(); int ysiz = y0siz + hd.getImgHeight(); int xt0siz = getTilePartULX(); int yt0siz = getTilePartULY(); int xtsiz = getNomTileWidth(); int ytsiz = getNomTileHeight(); int tx0 = (tileI.x==0) ? x0siz : xt0siz+tileI.x*xtsiz; int ty0 = (tileI.y==0) ? y0siz : yt0siz+tileI.y*ytsiz; int tx1 = (tileI.x!=nTiles.x-1) ? xt0siz+(tileI.x+1)*xtsiz : xsiz; int ty1 = (tileI.y!=nTiles.y-1) ? yt0siz+(tileI.y+1)*ytsiz : ysiz; // Get precinct information (number,distance between two consecutive // precincts in the reference grid) in each component and resolution // level int t = getTileIdx(); // Current tile index PrecInfo prec; // temporary variable int p; // Current precinct index int gcd_x = 0; // Horiz. distance between 2 precincts in the ref. grid int gcd_y = 0; // Vert. distance between 2 precincts in the ref. grid int nPrec = 0; // Total number of found precincts int[][] nextPrec = new int [compe][]; // Next precinct index in each // component and resolution level int minlys = 100000; // minimum layer start index of each component int minx = tx1; // Horiz. offset of the second precinct in the // reference grid int miny = ty1; // Vert. offset of the second precinct in the // reference grid. int maxx = tx0; // Max. horiz. offset of precincts in the ref. grid int maxy = ty0; // Max. vert. offset of precincts in the ref. grid Coord numPrec; for(int c=comps; c<compe; c++) { // components for(int r=ress; r<rese; r++) { // resolution levels if(c>=mdl.length) continue; if(r>mdl[c]) continue; nextPrec[c] = new int[mdl[c]+1]; if (lys[c]!=null && r<lys[c].length && lys[c][r]<minlys) { minlys = lys[c][r]; } p = pktDec.getNumPrecinct(c,r)-1; for(; p>=0; p--) { prec = pktDec.getPrecInfo(c,r,p); if(prec.rgulx!=tx0) { if(prec.rgulx<minx) minx = prec.rgulx; if(prec.rgulx>maxx) maxx = prec.rgulx; } if(prec.rguly!=ty0) { if(prec.rguly<miny) miny = prec.rguly; if(prec.rguly>maxy) maxy = prec.rguly; } if(nPrec==0) { gcd_x = prec.rgw; gcd_y = prec.rgh; } else { gcd_x = MathUtil.gcd(gcd_x,prec.rgw); gcd_y = MathUtil.gcd(gcd_y,prec.rgh); } nPrec++; } // precincts } // resolution levels } // components if(nPrec==0) { throw new Error("Image cannot have no precinct"); } int pyend = (maxy-miny)/gcd_y+1; int pxend = (maxx-minx)/gcd_x+1; int hlen,plen; int start; boolean status = false; int lastByte = firstPackOff[t][curTilePart]+ tilePartLen[t][curTilePart]-1- tilePartHeadLen[t][curTilePart]; int numLayers = ((Integer)decSpec.nls.getTileDef(t)).intValue(); String strInfo = "Tile "+getTileIdx()+" (tile-part:"+curTilePart+ "): offset, length, header length\n";; boolean pph = false; if(((Boolean)decSpec.pphs.getTileDef(t)).booleanValue()) { pph = true; } int x,y; for(int c=comps; c<compe; c++) { // components if(c>=mdl.length) continue; y = ty0; x = tx0; for(int py=0; py<=pyend; py++) { // Vertical precincts for(int px=0; px<=pxend; px++) { // Horiz. precincts for(int r=ress; r<rese; r++) { // Resolution levels if(r>mdl[c]) continue; if(nextPrec[c][r]>=pktDec.getNumPrecinct(c,r)) { continue; } prec = pktDec.getPrecInfo(c,r,nextPrec[c][r]); if((prec.rgulx!=x) || (prec.rguly!=y)) { continue; } for(int l=minlys; l<lye; l++) { // Layers if(r>=lys[c].length) continue; if(l<lys[c][r]) continue; start = in.getPos(); // If packed packet headers are used, there is no // need to check that there are bytes enough to // read header if(pph) { pktDec.readPktHead(l,r,c,nextPrec[c][r], cbI[c][r],nBytes); } // If we are about to read outside of tile-part, // skip to next tile-part if(start>lastByte && curTilePart<firstPackOff[t].length-1) { curTilePart++; in.seek(firstPackOff[t][curTilePart]); lastByte = in.getPos()+ tilePartLen[t][curTilePart]-1- tilePartHeadLen[t][curTilePart];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -