/// <summary> Reads all tiles headers and keep offset of their first /// packet. Finally it calls the rate allocation method. /// /// </summary> /// <param name="hd">HeaderDecoder of the codestream. /// /// </param> /// <param name="ehs">The input stream where to read bit-stream. /// /// </param> /// <param name="decSpec">The decoder specifications /// /// </param> /// <param name="pl">The ParameterList instance created from the /// command-line arguments. /// /// </param> /// <param name="cdstrInfo">Whether or not to print information found in /// codestream. /// /// </param> /// <seealso cref="allocateRate"> /// /// </seealso> public FileBitstreamReaderAgent(HeaderDecoder hd, RandomAccessIO ehs, DecoderSpecs decSpec, ParameterList pl, bool cdstrInfo, HeaderInfo hi):base(hd, decSpec) { this.pl = pl; this.printInfo = cdstrInfo; this.hi = hi; // Check whether quit conditiosn used usePOCQuit = pl.getBooleanParameter("poc_quit"); // Get decoding rate bool rateInBytes; bool parsing = pl.getBooleanParameter("parsing"); try { trate = pl.getFloatParameter("rate"); if (trate == - 1) { trate = System.Single.MaxValue; } } catch (System.FormatException) { throw new System.ApplicationException("Invalid value in 'rate' option: " + pl.getParameter("rate")); } catch (System.ArgumentException) { throw new System.ApplicationException("'rate' option is missing"); } try { tnbytes = pl.getIntParameter("nbytes"); } catch (System.FormatException) { throw new System.ApplicationException("Invalid value in 'nbytes' option: " + pl.getParameter("nbytes")); } catch (System.ArgumentException) { throw new System.ApplicationException("'nbytes' option is missing"); } // Check that '-rate' and '-nbytes' are not used at the same time ParameterList defaults = pl.DefaultParameterList; if (tnbytes != defaults.getFloatParameter("nbytes")) { rateInBytes = true; } else { rateInBytes = false; } if (rateInBytes) { trate = tnbytes * 8f / hd.MaxCompImgWidth / hd.MaxCompImgHeight; } else { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" tnbytes = (int) (trate * hd.MaxCompImgWidth * hd.MaxCompImgHeight) / 8; if (tnbytes < 0) tnbytes = int.MaxValue; } isTruncMode = !pl.getBooleanParameter("parsing"); // Check if quit conditions are being used int ncbQuit; try { ncbQuit = pl.getIntParameter("ncb_quit"); } catch (System.FormatException) { throw new System.ApplicationException("Invalid value in 'ncb_quit' option: " + pl.getParameter("ncb_quit")); } catch (System.ArgumentException) { throw new System.ApplicationException("'ncb_quit' option is missing"); } if (ncbQuit != - 1 && !isTruncMode) { throw new System.ApplicationException("Cannot use -parsing and -ncb_quit condition at " + "the same time."); } try { lQuit = pl.getIntParameter("l_quit"); } catch (System.FormatException) { throw new System.ApplicationException("Invalid value in 'l_quit' option: " + pl.getParameter("l_quit")); } catch (System.ArgumentException) { throw new System.ApplicationException("'l_quit' option is missing"); } // initializations in_Renamed = ehs; pktDec = new PktDecoder(decSpec, hd, ehs, this, isTruncMode, ncbQuit); tileParts = new int[nt]; totTileLen = new int[nt]; tilePartLen = new int[nt][]; tilePartNum = new int[nt][]; firstPackOff = new int[nt][]; tilePartsRead = new int[nt]; totTileHeadLen = new int[nt]; tilePartHeadLen = new int[nt][]; nBytes = new int[nt]; baknBytes = new int[nt]; hd.nTileParts = new int[nt]; // CONVERSION PROBLEM? //this.isTruncMode = isTruncMode; int t = 0, pos, tp = 0, tptot = 0; // Keeps main header's length, takes file format overhead into account int cdstreamStart = hd.mainHeadOff; // Codestream offset in the file mainHeadLen = in_Renamed.Pos - cdstreamStart; headLen = mainHeadLen; // If ncb and lbody quit conditions are used, headers are not counted if (ncbQuit == - 1) { anbytes = mainHeadLen; } else { anbytes = 0; } // If cannot even read the first tile-part if (anbytes > tnbytes) { throw new System.ApplicationException("Requested bitrate is too small."); } // Read all tile-part headers from all tiles. int tilePartStart; bool rateReached = false; int mdl; //int numtp = 0; totAllTileLen = 0; remainingTileParts = nt; // at least as many tile-parts as tiles int maxTP = nt; // If maximum 1 tile part per tile specified try { while (remainingTileParts != 0) { tilePartStart = in_Renamed.Pos; // Read tile-part header try { t = readTilePartHeader(); if (isEOCFound) { // Some tiles are missing but the // codestream is OK break; } tp = tilePartsRead[t]; if (isPsotEqualsZero) { // Psot may equals zero for the // last tile-part: it is assumed that this tile-part // contain all data until EOC tilePartLen[t][tp] = in_Renamed.length() - 2 - tilePartStart; } } catch (System.IO.EndOfStreamException e) { firstPackOff[t][tp] = in_Renamed.length(); throw e; } pos = in_Renamed.Pos; // In truncation mode, if target decoding rate is reached in // tile-part header, skips the tile-part and stop reading // unless the ncb and lbody quit condition is in use if (isTruncMode && ncbQuit == - 1) { if ((pos - cdstreamStart) > tnbytes) { firstPackOff[t][tp] = in_Renamed.length(); rateReached = true; break; } } // Set tile part position and header length firstPackOff[t][tp] = pos; tilePartHeadLen[t][tp] = (pos - tilePartStart); // Update length counters totTileLen[t] += tilePartLen[t][tp]; totTileHeadLen[t] += tilePartHeadLen[t][tp]; totAllTileLen += tilePartLen[t][tp]; if (isTruncMode) { if (anbytes + tilePartLen[t][tp] > tnbytes) { anbytes += tilePartHeadLen[t][tp]; headLen += tilePartHeadLen[t][tp]; rateReached = true; nBytes[t] += (tnbytes - anbytes); break; } else { anbytes += tilePartHeadLen[t][tp]; headLen += tilePartHeadLen[t][tp]; nBytes[t] += (tilePartLen[t][tp] - tilePartHeadLen[t][tp]); } } else { if (anbytes + tilePartHeadLen[t][tp] > tnbytes) { break; } else { anbytes += tilePartHeadLen[t][tp]; headLen += tilePartHeadLen[t][tp]; } } // If this is first tile-part, remember header length if (tptot == 0) firstTilePartHeadLen = tilePartHeadLen[t][tp]; // Go to the beginning of next tile part tilePartsRead[t]++; in_Renamed.seek(tilePartStart + tilePartLen[t][tp]); remainingTileParts--; maxTP--; tptot++; // If Psot of the current tile-part was equal to zero, it is // assumed that it contains all data until the EOC marker if (isPsotEqualsZero) { if (remainingTileParts != 0) { FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Some tile-parts have not " + "been found. The codestream may be corrupted."); } break; } } } catch (System.IO.EndOfStreamException) { if (printInfo) { } FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Codestream truncated in tile " + t); // Set specified rate to end of file if valid int fileLen = in_Renamed.length(); if (fileLen < tnbytes) { tnbytes = fileLen; trate = tnbytes * 8f / hd.MaxCompImgWidth / hd.MaxCompImgHeight; } // Bit-rate allocation if (!isTruncMode) { allocateRate(); } // Update 'res' value once all tile-part headers are read if (pl.getParameter("res") == null) { targetRes = decSpec.dls.Min; } else { try { targetRes = pl.getIntParameter("res"); if (targetRes < 0) { throw new System.ArgumentException("Specified negative " + "resolution level " + "index: " + targetRes); } } catch (System.FormatException) { throw new System.ArgumentException("Invalid resolution level " + "index ('-res' option) " + pl.getParameter("res")); } } // Verify reduction in resolution level mdl = decSpec.dls.Min; if (targetRes > mdl) { FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Specified resolution level (" + targetRes + ") is larger" + " than the maximum value. Setting it to " + mdl + " (maximum value)"); targetRes = mdl; } // Backup nBytes for (int tIdx = 0; tIdx < nt; tIdx++) { baknBytes[tIdx] = nBytes[tIdx]; } return ; } remainingTileParts = 0; // Update 'res' value once all tile-part headers are read if (pl.getParameter("res") == null) { targetRes = decSpec.dls.Min; } else { try { targetRes = pl.getIntParameter("res"); if (targetRes < 0) { throw new System.ArgumentException("Specified negative " + "resolution level index: " + targetRes); } } catch (System.FormatException) { throw new System.ArgumentException("Invalid resolution level " + "index ('-res' option) " + pl.getParameter("res")); } } // Verify reduction in resolution level mdl = decSpec.dls.Min; if (targetRes > mdl) { FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Specified resolution level (" + targetRes + ") is larger" + " than the maximum possible. Setting it to " + mdl + " (maximum possible)"); targetRes = mdl; } if (printInfo) { } // Check presence of EOC marker is decoding rate not reached or if // this marker has not been found yet if (!isEOCFound && !isPsotEqualsZero) { try { short eocCheck = 0; if (in_Renamed.Pos + sizeof(short) <= in_Renamed.length()) eocCheck = in_Renamed.readShort(); if (!rateReached && !isPsotEqualsZero && eocCheck != CSJ2K.j2k.codestream.Markers.EOC) { FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "EOC marker not found. " + "Codestream is corrupted."); } } catch (System.IO.EndOfStreamException) { FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "EOC marker is missing"); } } // Bit-rate allocation if (!isTruncMode) { allocateRate(); } else { // Take EOC into account if rate is not reached if (in_Renamed.Pos >= tnbytes) anbytes += 2; } // Backup nBytes for (int tIdx = 0; tIdx < nt; tIdx++) { baknBytes[tIdx] = nBytes[tIdx]; if (printInfo) { FacilityManager.getMsgLogger().println("" + hi.toStringTileHeader(tIdx, tilePartLen[tIdx].Length), 2, 2); } } }
/// <summary> Creates a HeaderDecoder instance and read in two passes the main header /// of the codestream. The first and last marker segments shall be /// respectively SOC and SOT. /// /// </summary> /// <param name="ehs">The encoded header stream where marker segments are /// extracted. /// /// </param> /// <param name="pl">The ParameterList object of the decoder /// /// </param> /// <param name="hi">The HeaderInfo holding information found in marker segments /// /// </param> /// <exception cref="IOException">If an I/O error occurs while reading from the /// encoded header stream. /// </exception> /// <exception cref="EOFException">If the end of the encoded header stream is /// reached before getting all the data. /// </exception> /// <exception cref="CorruptedCodestreamException">If invalid data is found in the /// codestream main header. /// /// </exception> public HeaderDecoder(RandomAccessIO ehs, ParameterList pl, HeaderInfo hi) { this.hi = hi; // CONVERSION PROBLEM? //this.verbose = verbose; pl.checkList(OPT_PREFIX, ParameterList.toNameArray(pinfo)); mainHeadOff = ehs.Pos; if (((short) ehs.readShort()) != CSJ2K.j2k.codestream.Markers.SOC) { throw new CorruptedCodestreamException("SOC marker segment not " + " found at the " + "beginning of the " + "codestream."); } // First Pass: Decode and store main header information until the SOT // marker segment is found nfMarkSeg = 0; do { extractMainMarkSeg(ehs.readShort(), ehs); } while ((nfMarkSeg & SOT_FOUND) == 0); //Stop when SOT is found ehs.seek(ehs.Pos - 2); // Realign codestream on SOT marker // Second pass: Read each marker segment previously found readFoundMainMarkSeg(); }
/// <summary> Construct a ColorSpecificationBox from an input image.</summary> /// <param name="in">RandomAccessIO jp2 image /// </param> /// <param name="boxStart">offset to the start of the box in the image /// </param> /// <exception cref="IOException,">ColorSpaceException /// /// </exception> public ColorSpecificationBox(RandomAccessIO in_Renamed, int boxStart):base(in_Renamed, boxStart) { readBox(); }
/// <summary> 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 an hashTable. /// /// <p>If the marker is not recognized, it prints a warning and skips it /// according to its length.</p> /// /// <p>SIZ marker segment shall be the first encountered marker segment.</p> /// /// </summary> /// <param name="marker">The marker segment to process /// /// </param> /// <param name="ehs">The encoded header stream /// /// </param> private void extractMainMarkSeg(short marker, RandomAccessIO ehs) { if (nfMarkSeg == 0) { // First non-delimiting marker of the header // JPEG 2000 part 1 specify that it must be SIZ if (marker != CSJ2K.j2k.codestream.Markers.SIZ) { throw new CorruptedCodestreamException("First marker after " + "SOC " + "must be SIZ " + System.Convert.ToString(marker, 16)); } } System.String htKey = ""; // Name used as a key for the hash-table if (ht == null) { ht = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable()); } switch (marker) { case CSJ2K.j2k.codestream.Markers.SIZ: if ((nfMarkSeg & SIZ_FOUND) != 0) { throw new CorruptedCodestreamException("More than one SIZ marker " + "segment found in main " + "header"); } nfMarkSeg |= SIZ_FOUND; htKey = "SIZ"; break; case CSJ2K.j2k.codestream.Markers.SOD: throw new CorruptedCodestreamException("SOD found in main header"); case CSJ2K.j2k.codestream.Markers.EOC: throw new CorruptedCodestreamException("EOC found in main header"); case CSJ2K.j2k.codestream.Markers.SOT: if ((nfMarkSeg & SOT_FOUND) != 0) { throw new CorruptedCodestreamException("More than one SOT " + "marker " + "found right after " + "main " + "or tile header"); } nfMarkSeg |= SOT_FOUND; return ; case CSJ2K.j2k.codestream.Markers.COD: if ((nfMarkSeg & COD_FOUND) != 0) { throw new CorruptedCodestreamException("More than one COD " + "marker " + "found in main header"); } nfMarkSeg |= COD_FOUND; htKey = "COD"; break; case CSJ2K.j2k.codestream.Markers.COC: nfMarkSeg |= COC_FOUND; htKey = "COC" + (nCOCMarkSeg++); break; case CSJ2K.j2k.codestream.Markers.QCD: if ((nfMarkSeg & QCD_FOUND) != 0) { throw new CorruptedCodestreamException("More than one QCD " + "marker " + "found in main header"); } nfMarkSeg |= QCD_FOUND; htKey = "QCD"; break; case CSJ2K.j2k.codestream.Markers.QCC: nfMarkSeg |= QCC_FOUND; htKey = "QCC" + (nQCCMarkSeg++); break; case CSJ2K.j2k.codestream.Markers.RGN: nfMarkSeg |= RGN_FOUND; htKey = "RGN" + (nRGNMarkSeg++); break; case CSJ2K.j2k.codestream.Markers.COM: nfMarkSeg |= COM_FOUND; htKey = "COM" + (nCOMMarkSeg++); break; case CSJ2K.j2k.codestream.Markers.CRG: if ((nfMarkSeg & CRG_FOUND) != 0) { throw new CorruptedCodestreamException("More than one CRG " + "marker " + "found in main header"); } nfMarkSeg |= CRG_FOUND; htKey = "CRG"; break; case CSJ2K.j2k.codestream.Markers.PPM: nfMarkSeg |= PPM_FOUND; htKey = "PPM" + (nPPMMarkSeg++); break; case CSJ2K.j2k.codestream.Markers.TLM: if ((nfMarkSeg & TLM_FOUND) != 0) { throw new CorruptedCodestreamException("More than one TLM " + "marker " + "found in main header"); } nfMarkSeg |= TLM_FOUND; break; case CSJ2K.j2k.codestream.Markers.PLM: if ((nfMarkSeg & PLM_FOUND) != 0) { throw new CorruptedCodestreamException("More than one PLM " + "marker " + "found in main header"); } FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "PLM marker segment found but " + "not used by by JJ2000 decoder."); nfMarkSeg |= PLM_FOUND; htKey = "PLM"; break; case CSJ2K.j2k.codestream.Markers.POC: if ((nfMarkSeg & POC_FOUND) != 0) { throw new CorruptedCodestreamException("More than one POC " + "marker segment found " + "in main header"); } nfMarkSeg |= POC_FOUND; htKey = "POC"; break; case CSJ2K.j2k.codestream.Markers.PLT: throw new CorruptedCodestreamException("PLT found in main header"); case CSJ2K.j2k.codestream.Markers.PPT: throw new CorruptedCodestreamException("PPT found in main header"); default: htKey = "UNKNOWN"; FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Non recognized marker segment (0x" + System.Convert.ToString(marker, 16) + ") in main header!"); break; } if (marker < unchecked((short)0xffffff30) || marker > unchecked((short)0xffffff3f)) { // Read marker segment length and create corresponding byte buffer int markSegLen = ehs.readUnsignedShort(); byte[] buf = new byte[markSegLen]; // Copy data (after re-insertion of the marker segment length); buf[0] = (byte) ((markSegLen >> 8) & 0xFF); buf[1] = (byte) (markSegLen & 0xFF); ehs.readFully(buf, 2, markSegLen - 2); if (!htKey.Equals("UNKNOWN")) { // Store array in hashTable ht[htKey] = buf; } } }
/// <summary> This method extracts a marker segment in a tile-part header and stores /// it into a byte buffer for the second pass. The marker is first /// recognized, then its flag is activated and, finally, its content is /// buffered in an element of byte arrays accessible thanks to a hashTable. /// If a marker segment is not recognized, it prints a warning and skip it /// according to its length. /// /// </summary> /// <param name="marker">The marker to process /// /// </param> /// <param name="ehs">The encoded header stream /// /// </param> /// <param name="tileIdx">The index of the current tile /// /// </param> /// <param name="tilePartIdx">The index of the current tile part /// /// </param> public virtual void extractTilePartMarkSeg(short marker, RandomAccessIO ehs, int tileIdx, int tilePartIdx) { System.String htKey = ""; // Name used as a hash-table key if (ht == null) { ht = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable()); } switch (marker) { case CSJ2K.j2k.codestream.Markers.SOT: throw new CorruptedCodestreamException("Second SOT marker " + "segment found in tile-" + "part header"); case CSJ2K.j2k.codestream.Markers.SIZ: throw new CorruptedCodestreamException("SIZ found in tile-part" + " header"); case CSJ2K.j2k.codestream.Markers.EOC: throw new CorruptedCodestreamException("EOC found in tile-part" + " header"); case CSJ2K.j2k.codestream.Markers.TLM: throw new CorruptedCodestreamException("TLM found in tile-part" + " header"); case CSJ2K.j2k.codestream.Markers.PLM: throw new CorruptedCodestreamException("PLM found in tile-part" + " header"); case CSJ2K.j2k.codestream.Markers.PPM: throw new CorruptedCodestreamException("PPM found in tile-part" + " header"); case CSJ2K.j2k.codestream.Markers.COD: if ((nfMarkSeg & COD_FOUND) != 0) { throw new CorruptedCodestreamException("More than one COD " + "marker " + "found in tile-part" + " header"); } nfMarkSeg |= COD_FOUND; htKey = "COD"; break; case CSJ2K.j2k.codestream.Markers.COC: nfMarkSeg |= COC_FOUND; htKey = "COC" + (nCOCMarkSeg++); break; case CSJ2K.j2k.codestream.Markers.QCD: if ((nfMarkSeg & QCD_FOUND) != 0) { throw new CorruptedCodestreamException("More than one QCD " + "marker " + "found in tile-part" + " header"); } nfMarkSeg |= QCD_FOUND; htKey = "QCD"; break; case CSJ2K.j2k.codestream.Markers.QCC: nfMarkSeg |= QCC_FOUND; htKey = "QCC" + (nQCCMarkSeg++); break; case CSJ2K.j2k.codestream.Markers.RGN: nfMarkSeg |= RGN_FOUND; htKey = "RGN" + (nRGNMarkSeg++); break; case CSJ2K.j2k.codestream.Markers.COM: nfMarkSeg |= COM_FOUND; htKey = "COM" + (nCOMMarkSeg++); break; case CSJ2K.j2k.codestream.Markers.CRG: throw new CorruptedCodestreamException("CRG marker found in " + "tile-part header"); case CSJ2K.j2k.codestream.Markers.PPT: nfMarkSeg |= PPT_FOUND; if (nPPTMarkSeg == null) { nPPTMarkSeg = new int[nTiles][]; } if (nPPTMarkSeg[tileIdx] == null) { nPPTMarkSeg[tileIdx] = new int[nTileParts[tileIdx]]; } htKey = "PPT" + (nPPTMarkSeg[tileIdx][tilePartIdx]++); break; case CSJ2K.j2k.codestream.Markers.SOD: nfMarkSeg |= SOD_FOUND; return ; case CSJ2K.j2k.codestream.Markers.POC: if ((nfMarkSeg & POC_FOUND) != 0) throw new CorruptedCodestreamException("More than one POC " + "marker segment found " + "in tile-part" + " header"); nfMarkSeg |= POC_FOUND; htKey = "POC"; break; case CSJ2K.j2k.codestream.Markers.PLT: if ((nfMarkSeg & PLM_FOUND) != 0) { throw new CorruptedCodestreamException("PLT marker found even" + "though PLM marker " + "found in main header"); } FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "PLT marker segment found but " + "not used by JJ2000 decoder."); htKey = "UNKNOWN"; break; default: htKey = "UNKNOWN"; FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Non recognized marker segment (0x" + System.Convert.ToString(marker, 16) + ") in tile-part header" + " of tile " + tileIdx + " !"); break; } // Read marker segment length and create corresponding byte buffer int markSegLen = ehs.readUnsignedShort(); byte[] buf = new byte[markSegLen]; // Copy data (after re-insertion of marker segment length); buf[0] = (byte) ((markSegLen >> 8) & 0xFF); buf[1] = (byte) (markSegLen & 0xFF); ehs.readFully(buf, 2, markSegLen - 2); if (!htKey.Equals("UNKNOWN")) { // Store array in hashTable ht[htKey] = buf; } }
/// <summary> The constructor of the FileFormatReader /// /// </summary> /// <param name="in">The RandomAccessIO from which to read the file format /// /// </param> public FileFormatReader(RandomAccessIO in_Renamed) { this.in_Renamed = in_Renamed; }
/// <summary> Creates an empty PktDecoder object associated with given decoder /// specifications and HeaderDecoder. This object must be initialized /// thanks to the restart method before being used. /// /// </summary> /// <param name="decSpec">The decoder specifications. /// /// </param> /// <param name="hd">The HeaderDecoder instance. /// /// </param> /// <param name="ehs">The stream where to read data from. /// /// </param> /// <param name="src">The bit stream reader agent. /// /// </param> /// <param name="isTruncMode">Whether or not truncation mode is required. /// /// </param> /// <param name="maxCB">The maximum number of code-blocks to read before ncbquit /// /// /// </param> public PktDecoder(DecoderSpecs decSpec, HeaderDecoder hd, RandomAccessIO ehs, BitstreamReaderAgent src, bool isTruncMode, int maxCB) { this.decSpec = decSpec; this.hd = hd; this.ehs = ehs; this.isTruncMode = isTruncMode; bin = new PktHeaderBitReader(ehs); this.src = src; ncb = 0; ncbQuit = false; this.maxCB = maxCB; }
/// <summary> Construct a ColorSpecificationBox from an input image.</summary> /// <param name="in">RandomAccessIO jp2 image /// </param> /// <param name="boxStart">offset to the start of the box in the image /// </param> /// <exception cref="IOException,">ColorSpaceException /// /// </exception> public ColorSpecificationBox(RandomAccessIO in_Renamed, int boxStart) : base(in_Renamed, boxStart) { readBox(); }
/// <summary> Creates a bit stream reader of the correct type that works on the /// provided RandomAccessIO, with the special parameters from the parameter /// list. /// /// </summary> /// <param name="in">The RandomAccessIO source from which to read the bit stream. /// /// </param> /// <param name="hd">Header of the codestream. /// /// </param> /// <param name="pl">The parameter list containing parameters applicable to the /// bit stream read (other parameters may also be present). /// /// </param> /// <param name="decSpec">The decoder specifications /// /// </param> /// <param name="cdstrInfo">Whether or not to print information found in /// codestream. /// /// </param> /// <param name="hi">Reference to the HeaderInfo instance. /// /// </param> /// <exception cref="IOException">If an I/O error occurs while reading initial /// data from the bit stream. /// </exception> /// <exception cref="IllegalArgumentException">If an unrecognised bit stream /// reader option is present. /// /// </exception> public static BitstreamReaderAgent createInstance(RandomAccessIO in_Renamed, HeaderDecoder hd, ParameterList pl, DecoderSpecs decSpec, bool cdstrInfo, HeaderInfo hi) { // Check parameters pl.checkList(BitstreamReaderAgent.OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(BitstreamReaderAgent.ParameterInfo)); return new FileBitstreamReaderAgent(hd, in_Renamed, decSpec, pl, cdstrInfo, hi); }
/// <summary> Instantiates a 'PktHeaderBitReader' that gets the byte data from the /// given source. /// /// </summary> /// <param name="in">The source of byte data /// /// </param> internal PktHeaderBitReader(RandomAccessIO in_Renamed) { this.in_Renamed = in_Renamed; usebais = false; }
/// <summary> Sets the underlying byte based input to the given object. This method /// discards any currently buffered bits and gets ready to start reading /// bits from 'in'. /// /// <p>This method is equivalent to creating a new 'PktHeaderBitReader' /// object.</p> /// /// </summary> /// <param name="in">The source of byte data /// /// </param> internal virtual void setInput(RandomAccessIO in_Renamed) { this.in_Renamed = in_Renamed; bbuf = 0; bpos = 0; }