⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filebitstreamreaderagent.java

📁 jpeg2000编解码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        if(nrOfTileParts==0) { // The number of tile-part is not specified in            // this tile-part header.            // Assumes that there will be another tile-part in the codestream            // that will indicate the number of tile-parts for this tile)            int nExtraTp;            if(tileParts[tile]==0 || tileParts[tile]==tilePartLen.length ) {                // Then there are two tile-parts (one is the current and the                // other will indicate the number of tile-part for this tile)                nExtraTp = 2;                remainingTileParts += 1;            } else {                // There is already one scheduled extra tile-part. In this                // case just add place for the current one                nExtraTp = 1;            }            tileParts[tile] += nExtraTp;            nrOfTileParts = tileParts[tile];            FacilityManager.getMsgLogger().                printmsg(MsgLogger.WARNING,"Header of tile-part "+tilePart+                         " of tile "+tile+", does not indicate the total"+                         " number of tile-parts. Assuming that there are "+                         nrOfTileParts+" tile-parts for this tile.");            // Increase and re-copy tilePartLen array            int[] tmpA = tilePartLen[tile];            tilePartLen[tile] = new int[nrOfTileParts];            for(int i=0; i<nrOfTileParts-nExtraTp; i++) {                tilePartLen[tile][i] = tmpA[i];            }            // Increase and re-copy tilePartNum array            tmpA = tilePartNum[tile];            tilePartNum[tile] = new int[nrOfTileParts];            for(int i=0; i<nrOfTileParts-nExtraTp; i++) {                tilePartNum[tile][i] = tmpA[i];            }            // Increase and re-copy firsPackOff array            tmpA = firstPackOff[tile];            firstPackOff[tile] = new int[nrOfTileParts];            for(int i=0; i<nrOfTileParts-nExtraTp; i++) {                firstPackOff[tile][i] = tmpA[i];            }            // Increase and re-copy tilePartHeadLen array            tmpA = tilePartHeadLen[tile];            tilePartHeadLen[tile] = new int[nrOfTileParts];            for(int i=0; i<nrOfTileParts-nExtraTp; i++) {                tilePartHeadLen[tile][i] = tmpA[i];            }        } else { // The number of tile-parts is specified in the tile-part            // header            // Check if it is consistant with what was found in previous            // tile-part headers            if(tileParts[tile]==0) { // First tile-part: OK                remainingTileParts += nrOfTileParts- 1;                tileParts[tile] = nrOfTileParts;                tilePartLen[tile] = new int[nrOfTileParts];                tilePartNum[tile] = new int[nrOfTileParts];                firstPackOff[tile] = new int[nrOfTileParts];                tilePartHeadLen[tile] = new int[nrOfTileParts];            } else if(tileParts[tile] > nrOfTileParts ) {                // Already found more tile-parts than signaled here                throw new CorruptedCodestreamException("Invalid number "+                                                       "of tile-parts in"+                                                       " tile "+tile+": "+                                                       nrOfTileParts);            } else { // Signaled number of tile-part fits with number of                // previously found tile-parts                remainingTileParts += nrOfTileParts-tileParts[tile];                if(tileParts[tile]!=nrOfTileParts) {                    // Increase and re-copy tilePartLen array                    int[] tmpA = tilePartLen[tile];                    tilePartLen[tile] = new int[nrOfTileParts];                    for(int i=0; i<tileParts[tile]-1; i++) {                        tilePartLen[tile][i] = tmpA[i];                    }                    // Increase and re-copy tilePartNum array                                    tmpA = tilePartNum[tile];                    tilePartNum[tile] = new int[nrOfTileParts];                    for(int i=0; i<tileParts[tile]-1; i++) {                        tilePartNum[tile][i] = tmpA[i];                    }                                    // Increase and re-copy firstPackOff array                    tmpA = firstPackOff[tile];                    firstPackOff[tile] = new int[nrOfTileParts];                    for(int i=0; i<tileParts[tile]-1; i++) {                        firstPackOff[tile][i] = tmpA[i];                    }                    // Increase and re-copy tilePartHeadLen array                    tmpA = tilePartHeadLen[tile];                    tilePartHeadLen[tile] = new int[nrOfTileParts];                    for(int i=0; i<tileParts[tile]-1; i++) {                        tilePartHeadLen[tile][i] = tmpA[i];                    }                }            }        }        // Other markers        hd.resetHeaderMarkers();        hd.nTileParts[tile] = nrOfTileParts;	// Decode and store the tile-part header (i.e. until a SOD marker is	// found)        do {	    hd.extractTilePartMarkSeg(in.readShort(),in,tile,tilePart);        } while ((hd.getNumFoundMarkSeg() & hd.SOD_FOUND)==0);	// Read each marker segment previously found	hd.readFoundTilePartMarkSeg(tile,tilePart);        tilePartLen[tile][tilePart] = psot;        tilePartNum[tile][tilePart] = totTilePartsRead;        totTilePartsRead++;        // Add to list of which tile each successive tile-part belongs.        // This list is needed if there are PPM markers used        hd.setTileOfTileParts(tile);                return tile;    }    /**      * Reads packets of the current tile according to the     * layer-resolution-component-position 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 readLyResCompPos(int[][] lys,int lye,int ress,int rese,				     int comps,int compe) 	throws IOException {        int minlys = 10000;	for(int c=comps; c<compe; c++) { //loop on components	    // Check if this component exists            if(c>=mdl.length) continue;	    for(int r=ress; r<rese; r++) {//loop on resolution levels		if(lys[c]!=null && r<lys[c].length && lys[c][r]<minlys) {		    minlys = lys[c][r];                }	    }	}        int t = getTileIdx();        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();        int nPrec = 1;        int hlen,plen;        String strInfo = "Tile "+getTileIdx()+" (tile-part:"+curTilePart+            "): offset, length, header length\n";;        boolean pph = false;        if(((Boolean)decSpec.pphs.getTileDef(t)).booleanValue()) {            pph = true;        }        for(int l=minlys; l<lye; l++) { // loop on layers            for(int r=ress; r<rese; r++) { // loop on resolution levels                for(int c=comps; c<compe; c++) { // loop on components                    // Checks if component exists                    if(c>=mdl.length) continue;                    // Checks if resolution level exists                    if(r>=lys[c].length) continue;                    if(r>mdl[c]) continue;                    // Checks if layer exists                    if(l<lys[c][r] || l>=numLayers) continue;                                        nPrec = pktDec.getNumPrecinct(c,r);                    for(int p=0; p<nPrec; p++) { // loop on precincts			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,p,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,p,c,r);			if(status) {                            if(printInfo) {                                FacilityManager.getMsgLogger().                                    printmsg(MsgLogger.INFO,strInfo);                            }			    return true;                        }                        if(!pph) {                            status =                                 pktDec.readPktHead(l,r,c,p,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,p,cbI[c][r],nBytes);                        plen = in.getPos()-start;                        strInfo+= " Pkt l="+l+",r="+r+",c="+c+",p="+p+": "+                            start+", "+plen+", "+hlen+"\n";			if(status) {                            if(printInfo) {                                FacilityManager.getMsgLogger().                                    printmsg(MsgLogger.INFO,strInfo);                            }			    return true;                        }                                            } // end loop on precincts                } // end loop on components            } // end loop on resolution levels        } // end loop on layers        if(printInfo) {            FacilityManager.getMsgLogger().printmsg(MsgLogger.INFO,strInfo);        }	return false; // Decoding rate was not reached    }        /**      * Reads packets of the current tile according to the     * resolution-layer-component-position 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 readResLyCompPos(int lys[][],int lye,int ress,int rese,				     int comps,int compe)         throws IOException {	int t = getTileIdx(); // Current tile index	boolean status=false; // True if decoding rate is reached when        int lastByte = firstPackOff[t][curTilePart]+            tilePartLen[t][curTilePart]-1-            tilePartHeadLen[t][curTilePart];        int minlys = 10000;	for(int c=comps; c<compe; c++) { //loop on components	    // Check if this component exists            if(c>=mdl.length) continue;	    for(int r=ress; r<rese; r++) {//loop on resolution levels                if(r>mdl[c]) continue;		if(lys[c]!=null && r<lys[c].length && lys[c][r]<minlys) {		    minlys = lys[c][r];                }	    }	}        String strInfo = "Tile "+getTileIdx()+" (tile-part:"+curTilePart+            "): offset, length, header length\n";;        int numLayers = ((Integer)decSpec.nls.getTileDef(t)).intValue();        boolean pph = false;        if(((Boolean)decSpec.pphs.getTileDef(t)).booleanValue()) {            pph = true;        }        int nPrec = 1;        int start;        int hlen,plen;        for(int r=ress; r<rese; r++) { // loop on resolution levels            for(int l=minlys; l<lye; l++) { // loop on layers                for(int c=comps; c<compe; c++) { // loop on components                    // Checks if component exists                    if(c>=mdl.length) continue;                    // Checks if resolution level exists                    if(r>mdl[c]) continue;                    if(r>=lys[c].length) continue;                    // Checks if layer exists                    if(l<lys[c][r] || l>=numLayers) continue;                    nPrec = pktDec.getNumPrecinct(c,r);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -