📄 headerdecoder.java
字号:
decSpec.dls.setCompDef(cComp,new Integer(mrl)); decSpec.ecopts.setCompDef(cComp,new Integer(ecOptions)); } else { hi.coc.put("t"+tileIdx+"_c"+cComp,ms); decSpec.wfs.setTileCompVal(tileIdx,cComp,hvfilters); decSpec.dls.setTileCompVal(tileIdx,cComp,new Integer(mrl)); decSpec.ecopts.setTileCompVal(tileIdx,cComp, new Integer(ecOptions)); } } /** * 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 this marker segment is read * from the main header. * * @param t The index of the current tile * * @param tpIdx Tile-part index * * @exception IOException If an I/O error occurs while reading from the * encoder header stream * */ private void readPOC(DataInputStream ehs,boolean mainh,int t,int tpIdx) throws IOException { boolean useShort = (nComp>=256) ? true : false; int tmp; int nOldChg = 0; HeaderInfo.POC ms; if(mainh || hi.poc.get("t"+t)==null) { ms = hi.getNewPOC(); } else { ms = (HeaderInfo.POC)hi.poc.get("t"+t); nOldChg = ms.rspoc.length; } // Lpoc ms.lpoc = ehs.readUnsignedShort(); // Compute the number of new progression changes // newChg = (lpoc - Lpoc(2)) / (RSpoc(1) + CSpoc(2) + // LYEpoc(2) + REpoc(1) + CEpoc(2) + Ppoc (1) ) int newChg = (ms.lpoc-2)/(5+ (useShort?4:2)); int ntotChg = nOldChg+newChg; int[][] change; if(nOldChg!=0) { // Creates new arrays change = new int[ntotChg][6]; int[] tmprspoc = new int[ntotChg]; int[] tmpcspoc = new int[ntotChg]; int[] tmplyepoc = new int[ntotChg]; int[] tmprepoc = new int[ntotChg]; int[] tmpcepoc = new int[ntotChg]; int[] tmpppoc = new int[ntotChg]; // Copy old values int[][] prevChg = (int[][])decSpec.pcs.getTileDef(t); for(int chg=0; chg<nOldChg; chg++) { change[chg] = prevChg[chg]; tmprspoc[chg] = ms.rspoc[chg]; tmpcspoc[chg] = ms.cspoc[chg]; tmplyepoc[chg] = ms.lyepoc[chg]; tmprepoc[chg] = ms.repoc[chg]; tmpcepoc[chg] = ms.cepoc[chg]; tmpppoc[chg] = ms.ppoc[chg]; } ms.rspoc = tmprspoc; ms.cspoc = tmpcspoc; ms.lyepoc = tmplyepoc; ms.repoc = tmprepoc; ms.cepoc = tmpcepoc; ms.ppoc = tmpppoc; } else { change = new int[newChg][6]; ms.rspoc = new int[newChg]; ms.cspoc = new int[newChg]; ms.lyepoc = new int[newChg]; ms.repoc = new int[newChg]; ms.cepoc = new int[newChg]; ms.ppoc = new int[newChg]; } for(int chg=nOldChg; chg<ntotChg; chg++) { // RSpoc change[chg][0] = ms.rspoc[chg] = ehs.readUnsignedByte(); // CSpoc if(useShort) { change[chg][1] = ms.cspoc[chg] = ehs.readUnsignedShort(); } else { change[chg][1] = ms.cspoc[chg] = ehs.readUnsignedByte(); } // LYEpoc change[chg][2] = ms.lyepoc[chg] = ehs.readUnsignedShort(); if(change[chg][2]<1) { throw new CorruptedCodestreamException ("LYEpoc value must be greater than 1 in POC marker "+ "segment of tile "+t+", tile-part "+tpIdx); } // REpoc change[chg][3] = ms.repoc[chg] = ehs.readUnsignedByte(); if(change[chg][3]<=change[chg][0]) { throw new CorruptedCodestreamException ("REpoc value must be greater than RSpoc in POC marker "+ "segment of tile "+t+", tile-part "+tpIdx); } // CEpoc if(useShort) { change[chg][4] = ms.cepoc[chg] = ehs.readUnsignedShort(); } else { tmp = ms.cepoc[chg] = ehs.readUnsignedByte(); if(tmp==0) { change[chg][4] = 0; } else { change[chg][4] = tmp; } } if(change[chg][4]<=change[chg][1]) { throw new CorruptedCodestreamException ("CEpoc value must be greater than CSpoc in POC marker "+ "segment of tile "+t+", tile-part "+tpIdx); } // Ppoc change[chg][5] = ms.ppoc[chg] = ehs.readUnsignedByte(); } // Check marker length checkMarkerLength(ehs,"POC marker"); // Register specifications if(mainh) { hi.poc.put("main",ms); decSpec.pcs.setDefault(change); } else { hi.poc.put("t"+t,ms); decSpec.pcs.setTileDef(t,change); } } /** * 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.</p> * * @param ehs The encoder header stream. * * @param mainh Flag indicating whether or not this marker segment is read * from the main header. * * @param tileIdx The index of the current tile * * @param tpIdx Tile-part index * * @exception IOException If an I/O error occurs while reading from the * encoder header stream * */ private void readRGN(DataInputStream ehs, boolean mainh, int tileIdx, int tpIdx) throws IOException { int comp; // ROI component int i; // loop variable int tempComp; // Component for HeaderInfo.RGN ms = hi.getNewRGN(); // Lrgn (marker length) ms.lrgn = ehs.readUnsignedShort(); // Read component ms.crgn = 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) ms.srgn = ehs.readUnsignedByte(); // Check that we can handle it. if(ms.srgn != SRGN_IMPLICIT) throw new CorruptedCodestreamException("Unknown or unsupported "+ "Srgn parameter in ROI "+ "marker"); if(decSpec.rois==null) { // No maxshift spec defined // Create needed ModuleSpec decSpec.rois=new MaxShiftSpec(nTiles,nComp, ModuleSpec.SPEC_TYPE_TILE_COMP); } // SPrgn ms.sprgn = ehs.readUnsignedByte(); if(mainh) { hi.rgn.put("main_c"+comp,ms); decSpec.rois.setCompDef(comp, new Integer(ms.sprgn)); } else { hi.rgn.put("t"+tileIdx+"_c"+comp,ms); decSpec.rois.setTileCompVal(tileIdx,comp,new Integer(ms.sprgn)); } // Check marker length checkMarkerLength(ehs,"RGN marker"); } /** * 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 first time readPPM method is called allocate arrays for packed // packet data if(pPMMarkerData==null) { pPMMarkerData = new byte[nPPMMarkSeg][]; tileOfTileParts = 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(); // Read Nppm and Ippm data pPMMarkerData[indx] = new byte[remSegLen]; ehs.read(pPMMarkerData[indx],0,remSegLen); // Check marker length checkMarkerLength(ehs,"PPM marker"); } /** * Reads the PPT marker segment of the main header. * * @param ehs The encoder header stream. * * @param tile The tile to which the current tile part belongs * * @param tpIdx Tile-part index * * @exception IOException If an I/O error occurs while reading from the * encoder header stream * */ private void readPPT(DataInputStream ehs,int tile,int tpIdx) throws IOException { int curMarkSegLen; int indx,len=0; byte[] temp; if(tilePartPkdPktHeaders == null){ tilePartPkdPktHeaders = new byte[nTiles][][][]; } if(tilePartPkdPktHeaders[tile] == null){ tilePartPkdPktHeaders[tile] = new byte[nTileParts[tile]][][]; } if(tilePartPkdPktHeaders[tile][tpIdx] == null){ tilePartPkdPktHeaders[tile][tpIdx] = new byte[nPPTMarkSeg[tile][tpIdx]][]; } // Lppt (marker length) curMarkSegLen = ehs.readUnsignedShort(); // Zppt (index of PPT marker) indx = ehs.readUnsignedByte(); // Ippt (packed packet headers) temp = new byte[curMarkSegLen-3]; ehs.read(temp); tilePartPkdPktHeaders[tile][tpIdx][indx]=temp; // Check marker length checkMarkerLength(ehs,"PPT marker"); decSpec.pphs.setTileDef(tile, new Boolean(true)); } /** * This method extract a marker segment from the main header and stores it * into a byte buffer for the second pass. The marker segment is first * identified. Then its flag is activated. Finally, its content is * buffered into a byte array stored in
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -