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

📄 ebcotrateallocator.java

📁 jpeg2000算法实现
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		if(lys[c][r]<minlys)		    minlys = lys[c][r];	    }	}	for(int l=minlys; l<lye; l++){ //loop on layers	    threshold = layers[l].rdThreshold;	    for(int r=rs; r<re; r++) {//loop on resolution levels		for(int c=cs; c<ce; c++){ //loop on components                                        // if no more decomposition levels for this component		    if(r>mrl[t][c]) continue;		    		    if(l<lys[c][r]) continue;		    precinctIdxA = new int[numComps][numLvls][numLayers];		    		    xys = packetEnc.getSotEotArrayMax(t,c);		    x0 = xys[0].x;		    y0 = xys[0].y;		    x1 = xys[1].x;		    y1 = xys[1].y;		    		    xyInc = packetEnc.getIncArrayMax(t, c);		    x_inc = xyInc.x;		    y_inc = xyInc.y;		    		    xyInc = packetEnc.getIncArray(t,c,r);		    x_inc_rl = xyInc.x;		    y_inc_rl = xyInc.y;		    		    xys = packetEnc.getSotEotArray(t,c,r);		    x0_rl = xys[0].x;		    y0_rl = xys[0].y;		    		    for(int yr=y0 ; yr<y1 ; yr+=y_inc )			for(int xr=x0 ; xr<x1 ; xr+=x_inc )			    if ( ( (xr==x0) || (xr%x_inc_rl==0) ) &&				 ( (yr==y0) || (yr%y_inc_rl==0) ) ){								precinctIdx = precinctIdxA[c][r][l];				                                if(precinctIdxA[c][r][l]>=                                   maxNumPrec[t][c][r].x*maxNumPrec[t][c][r].y)                                    continue;				// set boolean sopUsed here (SOP				// markers)				sopUsed = ((String)encSpec.sops.					   getTileDef(t)).equals("on");								// set boolean ephUsed here (EPH				// markers)				ephUsed = ((String)encSpec.ephs.					   getTileDef(t)).equals("on");								sb = src.getSubbandTree(t,c);				for(int i=numLvls-1; i>r; i--){				    sb = sb.subb_LL;				}				findTruncIndices(l,c,r,t,sb,threshold,						 precinctIdx);								hBuff = packetEnc.				    encodePacket(l+1,c,r,t,						 cblks[t][c][r],						 truncIdxs[t][l][c][r], 						 hBuff,bBuff,precinctIdx);					                                    if( packetEnc.isPacketWritable() ){                                    bsWriter.                                        writePacketHead(hBuff.getBuffer(),                                                        hBuff.getLength(),                                                         false,sopUsed,ephUsed);                                    bsWriter.                                        writePacketBody(packetEnc.                                                        getLastBodyBuf(),                                                        packetEnc.                                                        getLastBodyLen(),                                                        false,                                                        packetEnc.isROIinPkt(),                                                        packetEnc.getROILen());                                }				precinctIdxA[c][r][l]++;			    } // End loop on precincts		} // End loop on components	    } // End loop on resolution levels	} // End loop on layers    }    /**      * Write a piece of bit stream according to the     * COMP_POS_RES_LY_PROG progression mode and between given bounds     *     * @param t Tile index     *     * @param rs First resolution level index     *     * @param re Last resolution level index     *     * @param cs First component index     *     * @param ce Last component index     *     * @param lys First layer index for each component and resolution     *     * @param lye Index of the last layer     * */    public void writePosCompResLy(int t,int rs,int re,int cs,int ce,				  int[][] lys,int lye) throws IOException{        boolean sopUsed; // Should SOP markers be used ?        boolean ephUsed; // Should EPH markers be used ?	int[][] mrl = packetEnc.getMRL();        int numComps = src.getNumComps();	int x0, y0, x1, y1;	int x_inc, y_inc, x_inc_rl, y_inc_rl;	int x0_rl, y0_rl, precinctIdx;	int precinctIdxA[][][];	Coord xys[],xyInc;        SubbandAn sb;        float threshold;        BitOutputBuffer hBuff = null;        byte[] bBuff = null;	// Max number of decomposition levels in each tile	int numLvls = mrl[t][0];	for(int c=0; c < numComps; c++)	    if(mrl[t][c]>numLvls)		numLvls = mrl[t][c];	numLvls++;		precinctIdxA = new int[numComps][numLvls][numLayers];		// Coord[] xys = packetEnc.getSotEotArrayMax(t, c);	xys = packetEnc.getSotEotArrayMax(t,0);	x0 = xys[0].x;	y0 = xys[0].y;	x1 = xys[1].x;	y1 = xys[1].y;		// Coord xyInc = packetEnc.getIncArrayMax(t, c);	xyInc = packetEnc.getIncArrayMax(t,0);	x_inc = xyInc.x;	y_inc = xyInc.y;		for(int yr=y0 ; yr<y1 ; yr+=y_inc){	    for(int xr=x0 ; xr<x1 ; xr+=x_inc ){				// Loop on each component		for(int c=cs; c<ce; c++ ){		    // set boolean sopUsed here (SOP markers)		    sopUsed = ((String)encSpec.sops.getTileDef(t)).			equalsIgnoreCase("on");		    // set boolean ephUsed here (EPH markers)		    ephUsed = ((String)encSpec.ephs.getTileDef(t)).			equalsIgnoreCase("on");						    // Loop on each resolution level		    for(int r=rs ; r<re ; r++){			if(r>mrl[t][c]) continue;						sb = src.getSubbandTree(t,c);			numLvls = sb.resLvl+1;			for(int i=numLvls-1; i>r; i--){			    sb = sb.subb_LL;			}						xyInc = packetEnc.getIncArray(t,c,r);			x_inc_rl = xyInc.x;			y_inc_rl = xyInc.y;			xys = packetEnc.getSotEotArray(t,c,r);			x0_rl = xys[0].x;			y0_rl = xys[0].y;						if( ( (xr==x0) || (xr%x_inc_rl==0) ) &&			    ( (yr==y0) || (yr%y_inc_rl==0) ) ){			    			    //loop on layers			    for(int l=lys[c][r];l<lye;l++){                                if(precinctIdxA[c][r][l]>=                                   maxNumPrec[t][c][r].x*maxNumPrec[t][c][r].y)                                    continue;				precinctIdx = precinctIdxA[c][r][l];								threshold = layers[l].rdThreshold;				findTruncIndices(l,c,r,t,sb, 						 threshold,precinctIdx);				hBuff = packetEnc.				    encodePacket(l+1,c,r,t,cblks[t][c][r],						 truncIdxs[t][l][c][r],						 hBuff, bBuff, precinctIdx);								if( packetEnc.isPacketWritable() ){				    bsWriter.					writePacketHead(hBuff.getBuffer(),							hBuff.getLength(), 							false,sopUsed,ephUsed);				    bsWriter.					writePacketBody(packetEnc.							getLastBodyBuf(),							packetEnc.							getLastBodyLen(),                                                        false,packetEnc.                                                        isROIinPkt(),packetEnc.                                                        getROILen());				}				precinctIdxA[c][r][l]++;			    } // End loop on layers			} // test packet		    } // end loop on resolution levels		} // end loop on components	    }	} // end loop on precincts    }    /**      * Write a piece of bit stream according to the     * COMP_POS_RES_LY_PROG progression mode and between given bounds     *     * @param t Tile index     *     * @param rs First resolution level index     *     * @param re Last resolution level index     *     * @param cs First component index     *     * @param ce Last component index     *     * @param lys First layer index for each component and resolution     *     * @param lye Index of the last layer     * */    public void writeCompPosResLy(int t,int rs,int re,int cs,int ce,				  int[][] lys,int lye) throws IOException{        boolean sopUsed; // Should SOP markers be used ?        boolean ephUsed; // Should EPH markers be used ?	int[][] mrl = packetEnc.getMRL();        int numComps = src.getNumComps();	int x0, y0, x1, y1;	int x_inc, y_inc, x_inc_rl, y_inc_rl;	int x0_rl, y0_rl, precinctIdx;	int precinctIdxA[][][];	Coord xys[],xyInc;        SubbandAn sb;        float threshold;        BitOutputBuffer hBuff = null;        byte[] bBuff = null;	int numLvls;	// Loop on each component	for(int c=cs ; c<ce ; c++){	    // set boolean sopUsed here (SOP markers)	    sopUsed = ((String)encSpec.sops.getTileDef(t)).		equalsIgnoreCase("on");	    // set boolean ephUsed here (EPH markers)	    ephUsed = ((String)encSpec.ephs.getTileDef(t)).		equalsIgnoreCase("on");	    	    precinctIdxA = new int[numComps][mrl[t][c]+1][numLayers];	    	    xys = packetEnc.getSotEotArrayMax(t,c);	    x0 = xys[0].x;	    y0 = xys[0].y;	    x1 = xys[1].x;	    y1 = xys[1].y;	    	    xyInc = packetEnc.getIncArrayMax(t,c);	    x_inc = xyInc.x;	    y_inc = xyInc.y;	    	    for(int yr=y0 ; yr<y1 ; yr+=y_inc ){		for(int xr=x0 ; xr<x1 ; xr+=x_inc ){		    		    // Loop on each resolution level		    for(int r=rs ; r<re ; r++){			if(r>mrl[t][c]) continue;			sb = src.getSubbandTree(t,c);			numLvls = sb.resLvl+1;			for(int i=numLvls-1; i>r; i--){			    sb = sb.subb_LL;			}						xyInc = packetEnc.getIncArray(t,c,r);			x_inc_rl = xyInc.x;			y_inc_rl = xyInc.y;			xys = packetEnc.getSotEotArray(t,c,r);			x0_rl = xys[0].x;			y0_rl = xys[0].y;						if( ( (xr==x0) || (xr%x_inc_rl==0) ) &&			    ( (yr==y0) || (yr%y_inc_rl==0) ) ){			    			    for(int l=lys[c][r] ; l<lye ; l++){ //loop on                                //layers				                                if(precinctIdxA[c][r][l]>=                                   maxNumPrec[t][c][r].x*maxNumPrec[t][c][r].y)                                    continue;				precinctIdx = precinctIdxA[c][r][l];								threshold = layers[l].rdThreshold;				findTruncIndices(l,c,r,t,sb,threshold,						 precinctIdx);								hBuff = packetEnc.				    encodePacket(l+1,c,r,t,cblks[t][c][r],						 truncIdxs[t][l][c][r],						 hBuff,bBuff,precinctIdx);								if( packetEnc.isPacketWritable() ){				    bsWriter.					writePacketHead(hBuff.getBuffer(),							hBuff.getLength(), 							false,sopUsed,ephUsed);				    bsWriter.					writePacketBody(packetEnc.							getLastBodyBuf(),							packetEnc.							getLastBodyLen(),                                                        false,packetEnc.                                                        isROIinPkt(),packetEnc.                                                        getROILen());				}				precinctIdxA[c][r][l]++;			    } // End loop on layers			} // test packet		    } // end loop on resolution levels		}	    } // end loop on precincts	} // end loop on components    }    /**      * Write a piece of bit stream according to the     * RES_POS_COMP_LY_PROG progression mode and between given bounds     *     * @param t Tile index     *     * @param rs First resolution level index     *     * @param re Last resolution level index     *     * @param cs First component index     *     * @param ce Last component index     *     * @param lys First layer index for each component and resolution     *     * @param lye Last layer index     * */    public void writeResPosCompLy(int t,int rs,int re,int cs,int ce,				  int[][] lys,int lye) throws IOException{        boolean sopUsed; // Should SOP markers be used ?        boolean ephUsed; // Should EPH markers be used ?	int[][] mrl = packetEnc.getMRL();        int numComps = src.getNumComps();	int x0, y0, x1, y1;	int x_inc, y_inc, x_inc_rl, y_inc_rl;	int x0_rl, y0_rl, precinctIdx;

⌨️ 快捷键说明

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