📄 headerdecoder.java
字号:
} if (cComp >= nComp) { throw new CorruptedCodestreamException("Invalid component index "+ "in QCC marker"); } // Scoc (block style) int origcstyle = cstyle = ehs.readUnsignedByte(); if( (cstyle&SCOX_PRECINCT_PARTITION) != 0 ){ precinctPartitionIsUsed = true; // Remove flag cstyle &= ~(SCOX_PRECINCT_PARTITION); } else { precinctPartitionIsUsed = false; } // SPcoc // decomposition levels int mrl = ehs.readUnsignedByte(); // Read the code-blocks dimensions cblk = new Integer[2]; cblk[0] = new Integer(1<<(ehs.readUnsignedByte()+2)); if ( cblk[0].intValue() < StdEntropyCoderOptions.MIN_CB_DIM || cblk[0].intValue() > StdEntropyCoderOptions.MAX_CB_DIM ) { errMsg = "Non-valid code-block width in SPcod field, "+ "COC marker"; throw new CorruptedCodestreamException(errMsg); } cblk[1] = new Integer(1<<(ehs.readUnsignedByte()+2)); if ( cblk[1].intValue() < StdEntropyCoderOptions.MIN_CB_DIM || cblk[1].intValue() > StdEntropyCoderOptions.MAX_CB_DIM ) { errMsg = "Non-valid code-block height in SPcod field, "+ "COC marker"; throw new CorruptedCodestreamException(errMsg); } if ( (cblk[0].intValue()*cblk[1].intValue()) > StdEntropyCoderOptions.MAX_CB_AREA ) { errMsg = "Non-valid code-block area in SPcod field, "+ "COC marker"; throw new CorruptedCodestreamException(errMsg); } if ( mainh ) { decSpec.cblks.setCompDef(cComp, cblk); } else { decSpec.cblks.setTileCompVal(tileIdx, cComp, cblk); } // Read entropy block mode options // NOTE: currently OPT_SEG_MARKERS is not included here ecOptions = ehs.readUnsignedByte(); if ((ecOptions & ~(OPT_BYPASS|OPT_RESET_MQ|OPT_REG_TERM| OPT_VERT_STR_CAUSAL|OPT_ER_TERM|OPT_SEG_MARKERS)) != 0){ throw new CorruptedCodestreamException("Unknown \"code-block "+ "context\" in SPcoc field, "+ "COC marker: 0x"+ Integer. toHexString(ecOptions)); } // Read wavelet filter for tile or image hfilters = new SynWTFilter[1]; vfilters = new SynWTFilter[1]; hfilters[0] = readFilter(ehs); vfilters[0] = hfilters[0]; // Fill the filter spec // If this is the main header, set the default value, if it is the // tile header, set default for this tile SynWTFilter[][] hvfilters = new SynWTFilter[2][]; hvfilters[0]=hfilters; hvfilters[1]=vfilters; // Get precinct partition sizes Vector v[] = new Vector[2]; v[0] = new Vector(); v[1] = new Vector(); int val = PRECINCT_PARTITION_DEF_SIZE; if ( !precinctPartitionIsUsed ) { Integer w, h; w = new Integer(1<<(val & 0x000F)); v[0].addElement(w); h = new Integer(1<<(((val & 0x00F0)>>4))); v[1].addElement(h); } else { for ( int rl=mrl ; rl>=0 ; rl-- ) { Integer w, h; val = ehs.readUnsignedByte(); w = new Integer(1<<(val & 0x000F)); v[0].insertElementAt(w, 0); h = new Integer(1<<(((val & 0x00F0)>>4))); v[1].insertElementAt(h, 0); } } if ( mainh ) { decSpec.pss.setCompDef(cComp, v); } else { decSpec.pss.setTileCompVal(tileIdx, cComp, v); } precinctPartitionIsUsed = true; // Check marker length checkMarkerLength(ehs,"COD marker"); if(mainh){ decSpec.wfs.setCompDef(cComp,hvfilters); decSpec.dls.setCompDef(cComp,new Integer(mrl)); decSpec.ecopts.setCompDef(cComp,new Integer(ecOptions)); } else{ decSpec.wfs.setTileCompVal(tileIdx,cComp,hvfilters); decSpec.dls.setTileCompVal(tileIdx,cComp,new Integer(mrl)); decSpec.ecopts.setTileCompVal(tileIdx,cComp, new Integer(ecOptions)); } if(printHeader){ hdStr += " --- COC("+cComp+") ---\n"; hdStr += " Coding style : "+origcstyle+"\n"; hdStr += " Num. of levels: "+ (((Integer)decSpec.dls.getDefault()).intValue())+"\n"; hdStr += " Cblk width : "+cblk[0]+"\n"; hdStr += " Cblk height : "+cblk[1]+"\n"; hdStr += " EC options : "+ecOptions+"\n"; hdStr += " Filter : "+hfilters[0]+"\n"; hdStr += " Precincts : w:"+v[0]+", h:"+v[1]+"\n"; } } /** * Reads the POC marker segment and realigns the codestream where the next * marker should be found. * * @param ehs The encoder header stream. * * @param mainh Flag indicating whether or not the main header is read * * @param t The index of the current tile * * @exception IOException If an I/O error occurs while reading from the * encoder header stream * */ private void readPOC(DataInputStream ehs,boolean mainh, int t) throws IOException { boolean useShort = (nComp>=256) ? true : false; // Lpos int lpos = ehs.readUnsignedShort(); // Compute the number of progression changes // nChg = (lpos - Lpos(2)) / (RSpos(1) + CSpos(2) + // LYEpos(2) + REpos(1) + CEpos(2) + Ppos (1) ) int nChg = (lpos-2)/(5+ (useShort?4:2)); int[][] change = new int[nChg][6]; for(int chg=0; chg<nChg; chg++){ // RSpos change[chg][0] = ehs.readUnsignedByte(); // CSpos if(useShort) change[chg][1] = ehs.readUnsignedShort(); else change[chg][1] = ehs.readUnsignedByte(); // LYEpos change[chg][2] = ehs.readUnsignedShort(); // REpos change[chg][3] = ehs.readUnsignedByte(); // CEpos if(useShort) change[chg][4] = ehs.readUnsignedShort(); else change[chg][4] = ehs.readUnsignedByte(); // Ppos change[chg][5] = ehs.readUnsignedByte(); } // Check marker length checkMarkerLength(ehs,"POC marker"); // Register specifications if(mainh){ decSpec.pcs.setDefault(change); } else{ decSpec.pcs.setTileDef(t,change); } if(printHeader){ hdStr += " --- POC ---\n"; hdStr += " Chg_idx RSpos CSpos LYEpos REpos CEpos Cpos\n"; for(int chg=0;chg<nChg;chg++) hdStr += " "+chg +" "+change[chg][0] +" "+change[chg][1] +" "+change[chg][2] +" "+change[chg][3] +" "+change[chg][4] +" "+change[chg][5]; } } /** * Reads TLM marker segment and realigns the codestream where the next * marker should be found. Informations stored in these fields are * currently NOT taken into account. * * @param ehs The encoder header stream. * * @exception IOException If an I/O error occurs while reading from the * encoder header stream * */ private void readTLM(DataInputStream ehs) throws IOException { int length; length = ehs.readUnsignedShort(); //Ignore all informations contained ehs.skipBytes(length-2); FacilityManager.getMsgLogger(). printmsg(MsgLogger.INFO,"Skipping unsupported TLM marker"); } /** * Reads PLM marker segment and realigns the codestream where the next * marker should be found. Informations stored in these fields are * currently not taken into account. * * @param ehs The encoder header stream. * * @exception IOException If an I/O error occurs while reading from the * encoder header stream * */ private void readPLM(DataInputStream ehs) throws IOException{ int length; length = ehs.readUnsignedShort(); //Ignore all informations contained ehs.skipBytes(length-2); FacilityManager.getMsgLogger(). printmsg(MsgLogger.INFO,"Skipping unsupported PLM marker"); } /** * Reads the PLT fields and realigns the codestream where the next marker * should be found. Informations stored in these fields are currently NOT * taken into account. * * @param ehs The encoder header stream. * * @exception IOException If an I/O error occurs while reading from the * encoder header stream * */ private void readPLTFields(DataInputStream ehs) throws IOException{ int length; length = ehs.readUnsignedShort(); //Ignore all informations contained ehs.skipBytes(length-2); FacilityManager.getMsgLogger(). printmsg(MsgLogger.INFO,"Skipping unsupported PLT marker"); } /** * Reads the RGN marker segment of the codestream header. * * <P>May be used in tile or main header. If used in main header, it * refers to the maxshift value of a component in all tiles. When used in * tile header, only the particular tile-component is affected. * * @param ehs The encoder header stream. * * @param mainh Flag indicating whether or not the main header is read * * @param tileIdx The index of the current tile * * @exception IOException If an I/O error occurs while reading from the * encoder header stream * */ private void readRGN(DataInputStream ehs, boolean mainh, int tileIdx) throws IOException{ int roiType; int curMarkSegLen; // Current marker length int comp; // ROI component int i; // loop variable int tempComp; // Component for int val; // The roi scaling value // Lrgn (marker length) curMarkSegLen = ehs.readUnsignedShort(); // Read component comp = (nComp < 257) ? ehs.readUnsignedByte(): ehs.readUnsignedShort(); if (comp >= nComp) { throw new CorruptedCodestreamException("Invalid component "+ "index in RGN marker"+ comp); } // Read type of RGN.(Srgn) roiType = ehs.readUnsignedByte(); // Check that we can handle it. if(roiType != SRGN_IMPLICIT) throw new CorruptedCodestreamException("Unknown or unsupported "+ "Srgn parameter in ROI "+ "marker"); // SPrgn if(decSpec.rois == null){ // No maxshift spec defined // Create needed ModuleSpec decSpec.rois=new MaxShiftSpec(nTiles, nComp, ModuleSpec.SPEC_TYPE_TILE_COMP); } if(mainh){ val = ehs.readUnsignedByte(); decSpec.rois.setCompDef(comp, new Integer(val)); } else{ val = ehs.readUnsignedByte(); decSpec.rois.setTileCompVal(tileIdx,comp,new Integer(val)); } // Check marker length checkMarkerLength(ehs,"RGN marker"); if(printHeader){ hdStr += " --- RGN("+comp+") ---\n"; hdStr += " ROI scaling value: "+val+"\n"; } } /** * Reads the PPM marker segment of the main header. * * @param ehs The encoder header stream. * * @exception IOException If an I/O error occurs while reading from the * encoder header stream * */ private void readPPM(DataInputStream ehs) throws IOException{ int curMarkSegLen; int i,indx,len,off; int remSegLen; byte[] b; if(unsortedPkdPktHeaders == null){ tileOfTileParts = new Vector(); unsortedPkdPktHeaders = new Vector(); decSpec.pphs.setDefault(new Boolean(true)); } // Lppm (marker length) curMarkSegLen = ehs.readUnsignedShort(); remSegLen = curMarkSegLen - 3; // Zppm (index of PPM marker) indx = ehs.readUnsignedByte(); // Nppm (lengths of individual tileparts packed headers) while( remSegLen > 0 ){ // If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -