コード例 #1
0
ファイル: ROIDeScaler.cs プロジェクト: KSLcom/Aurora-LibOMV
		/// <summary> Creates a ROIDeScaler object. The information needed to create the
		/// object is the Entropy decoder used and the parameters.
		/// 
		/// </summary>
		/// <param name="src">The source of data that is to be descaled
		/// 
		/// </param>
		/// <param name="pl">The parameter list (or options).
		/// 
		/// </param>
		/// <param name="decSpec">The decoding specifications
		/// 
		/// </param>
		/// <exception cref="IllegalArgumentException">If an error occurs while parsing
		/// the options in 'pl'
		/// 
		/// </exception>
		public static ROIDeScaler createInstance(CBlkQuantDataSrcDec src, ParameterList pl, DecoderSpecs decSpec)
		{
			System.String noRoi;
			//int i;
			
			// Check parameters
			pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
			
			// Check if no_roi specified in command line or no roi signalled
			// in bit stream
			noRoi = pl.getParameter("Rno_roi");
			if (noRoi != null || decSpec.rois == null)
			{
				// no_roi specified in commandline!
				return new ROIDeScaler(src, null);
			}
			
			return new ROIDeScaler(src, decSpec.rois);
		}
コード例 #2
0
ファイル: AnWTFilterSpec.cs プロジェクト: RavenB/gridsearch
		/// <summary> Constructs a new 'AnWTFilterSpec' for the specified number of
		/// components and tiles.
		/// 
		/// </summary>
		/// <param name="nt">The number of tiles
		/// 
		/// </param>
		/// <param name="nc">The number of components
		/// 
		/// </param>
		/// <param name="type">the type of the specification module i.e. tile specific,
		/// component specific or both.
		/// 
		/// </param>
		/// <param name="qts">Quantization specifications
		/// 
		/// </param>
		/// <param name="pl">The ParameterList
		/// 
		/// </param>
		public AnWTFilterSpec(int nt, int nc, byte type, QuantTypeSpec qts, ParameterList pl):base(nt, nc, type)
		{
			
			// Check parameters
			pl.checkList(AnWTFilter.OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(AnWTFilter.ParameterInfo));
			
			System.String param = pl.getParameter("Ffilters");
			bool isFilterSpecified = true;
			
			// No parameter specified
			if (param == null)
			{
				isFilterSpecified = false;
				
				// If lossless compression, uses the reversible filters in each
				// tile-components 
				if (pl.getBooleanParameter("lossless"))
				{
					setDefault(parseFilters(REV_FILTER_STR));
					return ;
				}
				
				// If no filter is specified through the command-line, use
				// REV_FILTER_STR or NON_REV_FILTER_STR according to the
				// quantization type
				for (int t = nt - 1; t >= 0; t--)
				{
					for (int c = nc - 1; c >= 0; c--)
					{
						switch (qts.getSpecValType(t, c))
						{
							
							case SPEC_DEF: 
								if (getDefault() == null)
								{
									if (pl.getBooleanParameter("lossless"))
										setDefault(parseFilters(REV_FILTER_STR));
									if (((System.String) qts.getDefault()).Equals("reversible"))
									{
										setDefault(parseFilters(REV_FILTER_STR));
									}
									else
									{
										setDefault(parseFilters(NON_REV_FILTER_STR));
									}
								}
								specValType[t][c] = SPEC_DEF;
								break;
							
							case SPEC_COMP_DEF: 
								if (!isCompSpecified(c))
								{
									if (((System.String) qts.getCompDef(c)).Equals("reversible"))
									{
										setCompDef(c, parseFilters(REV_FILTER_STR));
									}
									else
									{
										setCompDef(c, parseFilters(NON_REV_FILTER_STR));
									}
								}
								specValType[t][c] = SPEC_COMP_DEF;
								break;
							
							case SPEC_TILE_DEF: 
								if (!isTileSpecified(t))
								{
									if (((System.String) qts.getTileDef(t)).Equals("reversible"))
									{
										setTileDef(t, parseFilters(REV_FILTER_STR));
									}
									else
									{
										setTileDef(t, parseFilters(NON_REV_FILTER_STR));
									}
								}
								specValType[t][c] = SPEC_TILE_DEF;
								break;
							
							case SPEC_TILE_COMP: 
								if (!isTileCompSpecified(t, c))
								{
									if (((System.String) qts.getTileCompVal(t, c)).Equals("reversible"))
									{
										setTileCompVal(t, c, parseFilters(REV_FILTER_STR));
									}
									else
									{
										setTileCompVal(t, c, parseFilters(NON_REV_FILTER_STR));
									}
								}
								specValType[t][c] = SPEC_TILE_COMP;
								break;
							
							default: 
								throw new System.ArgumentException("Unsupported " + "specification " + "type");
							
						}
					}
				}
				return ;
			}
			
			// Parse argument
			SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
			System.String word; // current word
			byte curSpecType = SPEC_DEF; // Specification type of the
			// current parameter
			bool[] tileSpec = null; // Tiles concerned by the specification
			bool[] compSpec = null; // Components concerned by the specification
			AnWTFilter[][] filter;
			
			while (stk.HasMoreTokens())
			{
				word = stk.NextToken();
				
				switch (word[0])
				{
					
					case 't': 
					// Tiles specification
					case 'T':  // Tiles specification
						tileSpec = parseIdx(word, nTiles);
						if (curSpecType == SPEC_COMP_DEF)
							curSpecType = SPEC_TILE_COMP;
						else
							curSpecType = SPEC_TILE_DEF;
						break;
					
					case 'c': 
					// Components specification
					case 'C':  // Components specification
						compSpec = parseIdx(word, nComp);
						if (curSpecType == SPEC_TILE_DEF)
							curSpecType = SPEC_TILE_COMP;
						else
							curSpecType = SPEC_COMP_DEF;
						break;
					
					case 'w': 
					// WT filters specification
					case 'W':  // WT filters specification
						if (pl.getBooleanParameter("lossless") && word.ToUpper().Equals("w9x7".ToUpper()))
						{
							throw new System.ArgumentException("Cannot use non " + "reversible " + "wavelet transform with" + " '-lossless' option");
						}
						
						filter = parseFilters(word);
						if (curSpecType == SPEC_DEF)
						{
							setDefault(filter);
						}
						else if (curSpecType == SPEC_TILE_DEF)
						{
							for (int i = tileSpec.Length - 1; i >= 0; i--)
								if (tileSpec[i])
								{
									setTileDef(i, filter);
								}
						}
						else if (curSpecType == SPEC_COMP_DEF)
						{
							for (int i = compSpec.Length - 1; i >= 0; i--)
								if (compSpec[i])
								{
									setCompDef(i, filter);
								}
						}
						else
						{
							for (int i = tileSpec.Length - 1; i >= 0; i--)
							{
								for (int j = compSpec.Length - 1; j >= 0; j--)
								{
									if (tileSpec[i] && compSpec[j])
									{
										setTileCompVal(i, j, filter);
									}
								}
							}
						}
						
						// Re-initialize
						curSpecType = SPEC_DEF;
						tileSpec = null;
						compSpec = null;
						break;
					
					
					default: 
						throw new System.ArgumentException("Bad construction for " + "parameter: " + word);
					
				}
			}
			
			// Check that default value has been specified
			if (getDefault() == null)
			{
				int ndefspec = 0;
				for (int t = nt - 1; t >= 0; t--)
				{
					for (int c = nc - 1; c >= 0; c--)
					{
						if (specValType[t][c] == SPEC_DEF)
						{
							ndefspec++;
						}
					}
				}
				
				// If some tile-component have received no specification, it takes
				// the default value defined in ParameterList
				if (ndefspec != 0)
				{
					if (((System.String) qts.getDefault()).Equals("reversible"))
						setDefault(parseFilters(REV_FILTER_STR));
					else
						setDefault(parseFilters(NON_REV_FILTER_STR));
				}
				else
				{
					// All tile-component have been specified, takes the first
					// tile-component value as default.
					setDefault(getTileCompVal(0, 0));
					switch (specValType[0][0])
					{
						
						case SPEC_TILE_DEF: 
							for (int c = nc - 1; c >= 0; c--)
							{
								if (specValType[0][c] == SPEC_TILE_DEF)
									specValType[0][c] = SPEC_DEF;
							}
							tileDef[0] = null;
							break;
						
						case SPEC_COMP_DEF: 
							for (int t = nt - 1; t >= 0; t--)
							{
								if (specValType[t][0] == SPEC_COMP_DEF)
									specValType[t][0] = SPEC_DEF;
							}
							compDef[0] = null;
							break;
						
						case SPEC_TILE_COMP: 
							specValType[0][0] = SPEC_DEF;
							tileCompVal["t0c0"] = null;
							break;
						}
				}
			}
			
			// Check consistency between filter and quantization type
			// specification
			for (int t = nt - 1; t >= 0; t--)
			{
				for (int c = nc - 1; c >= 0; c--)
				{
					// Reversible quantization
					if (((System.String) qts.getTileCompVal(t, c)).Equals("reversible"))
					{
						// If filter is reversible, it is OK
						if (isReversible(t, c))
							continue;
						
						// If no filter has been defined, use reversible filter
						if (!isFilterSpecified)
						{
							setTileCompVal(t, c, parseFilters(REV_FILTER_STR));
						}
						else
						{
							// Non reversible filter specified -> Error
							throw new System.ArgumentException("Filter of " + "tile-component" + " (" + t + "," + c + ") does" + " not allow " + "reversible " + "quantization. " + "Specify '-Qtype " + "expounded' or " + "'-Qtype derived'" + "in " + "the command line.");
						}
					}
					else
					{
						// No reversible quantization
						// No reversible filter -> OK
						if (!isReversible(t, c))
							continue;
						
						// If no filter has been specified, use non-reversible
						// filter
						if (!isFilterSpecified)
						{
							setTileCompVal(t, c, parseFilters(NON_REV_FILTER_STR));
						}
						else
						{
							// Reversible filter specified -> Error
							throw new System.ArgumentException("Filter of " + "tile-component" + " (" + t + "," + c + ") does" + " not allow " + "non-reversible " + "quantization. " + "Specify '-Qtype " + "reversible' in " + "the command line");
						}
					}
				}
			}
		}
コード例 #3
0
ファイル: EntropyCoder.cs プロジェクト: RavenB/gridsearch
		/// <summary> Creates a EntropyCoder object for the appropriate entropy coding
		/// parameters in the parameter list 'pl', and having 'src' as the source
		/// of quantized data.
		/// 
		/// </summary>
		/// <param name="src">The source of data to be entropy coded
		/// 
		/// </param>
		/// <param name="pl">The parameter list (or options).
		/// 
		/// </param>
		/// <param name="cbks">Code-block size specifications
		/// 
		/// </param>
		/// <param name="pss">Precinct partition specifications
		/// 
		/// </param>
		/// <param name="bms">By-pass mode specifications
		/// 
		/// </param>
		/// <param name="mqrs">MQ-reset specifications
		/// 
		/// </param>
		/// <param name="rts">Regular termination specifications
		/// 
		/// </param>
		/// <param name="css">Causal stripes specifications
		/// 
		/// </param>
		/// <param name="sss">Error resolution segment symbol use specifications
		/// 
		/// </param>
		/// <param name="lcs">Length computation specifications
		/// 
		/// </param>
		/// <param name="tts">Termination type specifications
		/// 
		/// </param>
		/// <exception cref="IllegalArgumentException">If an error occurs while parsing
		/// the options in 'pl'
		/// 
		/// </exception>
		public static EntropyCoder createInstance(CBlkQuantDataSrcEnc src, ParameterList pl, CBlkSizeSpec cblks, PrecinctSizeSpec pss, StringSpec bms, StringSpec mqrs, StringSpec rts, StringSpec css, StringSpec sss, StringSpec lcs, StringSpec tts)
		{
			// Check parameters
			pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
			return new StdEntropyCoder(src, cblks, pss, bms, mqrs, rts, css, sss, lcs, tts);
		}
コード例 #4
0
ファイル: EncoderSpecs.cs プロジェクト: KSLcom/Aurora-LibOMV
		/// <summary> Initialize all members with the given number of tiles and components
		/// and the command-line arguments stored in a ParameterList instance
		/// 
		/// </summary>
		/// <param name="nt">Number of tiles
		/// 
		/// </param>
		/// <param name="nc">Number of components
		/// 
		/// </param>
		/// <param name="imgsrc">The image source (used to get the image size)
		/// 
		/// </param>
		/// <param name="pl">The ParameterList instance
		/// 
		/// </param>
		public EncoderSpecs(int nt, int nc, BlkImgDataSrc imgsrc, ParameterList pl)
		{
			nTiles = nt;
			nComp = nc;
			
			// ROI
			rois = new MaxShiftSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
			
			// Quantization
			pl.checkList(Quantizer.OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(Quantizer.ParameterInfo));
			qts = new QuantTypeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
			qsss = new QuantStepSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
			gbs = new GuardBitsSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
			
			// Wavelet transform
			wfs = new AnWTFilterSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, qts, pl);
			dls = new IntegerSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl, "Wlev");
			
			// Component transformation
			cts = new ForwCompTransfSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE, wfs, pl);
			
			// Entropy coder
			System.String[] strLcs = new System.String[]{"near_opt", "lazy_good", "lazy"};
			lcs = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Clen_calc", strLcs, pl);
			System.String[] strTerm = new System.String[]{"near_opt", "easy", "predict", "full"};
			tts = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cterm_type", strTerm, pl);
			System.String[] strBoolean = new System.String[]{"on", "off"};
			sss = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cseg_symbol", strBoolean, pl);
			css = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Ccausal", strBoolean, pl);
			rts = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cterminate", strBoolean, pl);
			mqrs = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "CresetMQ", strBoolean, pl);
			bms = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cbypass", strBoolean, pl);
			cblks = new CBlkSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
			
			// Precinct partition
			pss = new PrecinctSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, imgsrc, dls, pl);
			
			// Codestream
			sops = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE, "Psop", strBoolean, pl);
			ephs = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE, "Peph", strBoolean, pl);
		}
コード例 #5
0
ファイル: HeaderEncoder.cs プロジェクト: cureos/csj2k
        /// <summary> Initializes the header writer with the references to the coding chain.
        /// 
        /// </summary>
        /// <param name="origsrc">The original image data (before any component mixing,
        /// tiling, etc.)
        /// 
        /// </param>
        /// <param name="isorigsig">An array specifying for each component if it was
        /// originally signed or not.
        /// 
        /// </param>
        /// <param name="dwt">The discrete wavelet transform module.
        /// 
        /// </param>
        /// <param name="tiler">The tiler module.
        /// 
        /// </param>
        /// <param name="encSpec">The encoder specifications
        /// 
        /// </param>
        /// <param name="roiSc">The ROI scaler module.
        /// 
        /// </param>
        /// <param name="ralloc">The post compression rate allocator.
        /// 
        /// </param>
        /// <param name="pl">ParameterList instance.
        /// 
        /// </param>
        public HeaderEncoder(ImgData origsrc, bool[] isorigsig, ForwardWT dwt, Tiler tiler, EncoderSpecs encSpec, ROIScaler roiSc, PostCompRateAllocator ralloc, ParameterList pl)
        {
            pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
            if (origsrc.NumComps != isorigsig.Length)
            {
                throw new System.ArgumentException();
            }
            this.origSrc = origsrc;
            this.isOrigSig = isorigsig;
            this.dwt = dwt;
            this.tiler = tiler;
            this.encSpec = encSpec;
            this.roiSc = roiSc;
            this.ralloc = ralloc;

            baos = new System.IO.MemoryStream();
            //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
            hbuf = new CSJ2K.Util.EndianBinaryWriter(baos, true);
            nComp = origsrc.NumComps;
            enJJ2KMarkSeg = pl.getBooleanParameter("Hjj2000_COM");
            otherCOMMarkSeg = pl.getParameter("HCOM");
        }
コード例 #6
0
ファイル: HeaderDecoder.cs プロジェクト: KSLcom/Aurora-LibOMV
		/// <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();
		}
コード例 #7
0
ファイル: HeaderDecoder.cs プロジェクト: KSLcom/Aurora-LibOMV
		/// <summary> Creates and returns the entropy decoder corresponding to the
		/// information read from the codestream header and with the special
		/// additional parameters from the parameter list.
		/// 
		/// </summary>
		/// <param name="src">The bit stream reader agent where to get code-block data
		/// from.
		/// 
		/// </param>
		/// <param name="pl">The parameter list containing parameters applicable to the
		/// entropy decoder (other parameters can also be present).
		/// 
		/// </param>
		/// <returns> The entropy decoder
		/// 
		/// </returns>
		public virtual EntropyDecoder createEntropyDecoder(CodedCBlkDataSrcDec src, ParameterList pl)
		{
			bool doer;
			bool verber;
			int mMax;
			
			// Check parameters
			pl.checkList(EntropyDecoder.OPT_PREFIX, ParameterList.toNameArray(EntropyDecoder.ParameterInfo));
			// Get error detection option
			doer = pl.getBooleanParameter("Cer");
			// Get verbose error detection option
			verber = pl.getBooleanParameter("Cverber");
			
			// Get maximum number of bit planes from m quit condition
			mMax = pl.getIntParameter("m_quit");
			return new StdEntropyDecoder(src, decSpec, doer, verber, mMax);
		}
コード例 #8
0
ファイル: PktEncoder.cs プロジェクト: cureos/csj2k
        /// <summary> Creates a new packet encoder object, using the information from the
        /// 'infoSrc' object. 
        /// 
        /// </summary>
        /// <param name="infoSrc">The source of information to construct the object.
        /// 
        /// </param>
        /// <param name="encSpec">The encoding parameters.
        /// 
        /// </param>
        /// <param name="numPrec">Maximum number of precincts in each tile, component
        /// and resolution level.
        /// 
        /// </param>
        /// <param name="pl">ParameterList instance that holds command line options
        /// 
        /// </param>
        public PktEncoder(CodedCBlkDataSrcEnc infoSrc, EncoderSpecs encSpec, Coord[][][] numPrec, ParameterList pl)
        {
            this.infoSrc = infoSrc;
            this.encSpec = encSpec;

            // Check parameters
            pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));

            // Get number of components and tiles
            int nc = infoSrc.NumComps;
            int nt = infoSrc.getNumTiles();

            // Do initial allocation
            ttIncl = new TagTreeEncoder[nt][][][][];
            for (int i = 0; i < nt; i++)
            {
                ttIncl[i] = new TagTreeEncoder[nc][][][];
            }
            ttMaxBP = new TagTreeEncoder[nt][][][][];
            for (int i2 = 0; i2 < nt; i2++)
            {
                ttMaxBP[i2] = new TagTreeEncoder[nc][][][];
            }
            lblock = new int[nt][][][][];
            for (int i3 = 0; i3 < nt; i3++)
            {
                lblock[i3] = new int[nc][][][];
            }
            prevtIdxs = new int[nt][][][][];
            for (int i4 = 0; i4 < nt; i4++)
            {
                prevtIdxs[i4] = new int[nc][][][];
            }
            ppinfo = new PrecInfo[nt][][][];
            for (int i5 = 0; i5 < nt; i5++)
            {
                ppinfo[i5] = new PrecInfo[nc][][];
            }

            // Finish allocation
            SubbandAn root, sb;
            int maxs, mins;
            int mrl;
            //Coord tmpCoord = null;
            int numcb; // Number of code-blocks
            //System.Collections.ArrayList cblks = null;
            infoSrc.setTile(0, 0);
            for (int t = 0; t < nt; t++)
            {
                // Loop on tiles
                for (int c = 0; c < nc; c++)
                {
                    // Loop on components
                    // Get number of resolution levels
                    root = infoSrc.getAnSubbandTree(t, c);
                    mrl = root.resLvl;

                    lblock[t][c] = new int[mrl + 1][][];
                    ttIncl[t][c] = new TagTreeEncoder[mrl + 1][][];
                    ttMaxBP[t][c] = new TagTreeEncoder[mrl + 1][][];
                    prevtIdxs[t][c] = new int[mrl + 1][][];
                    ppinfo[t][c] = new PrecInfo[mrl + 1][];

                    for (int r = 0; r <= mrl; r++)
                    {
                        // Loop on resolution levels
                        mins = (r == 0)?0:1;
                        maxs = (r == 0)?1:4;

                        int maxPrec = numPrec[t][c][r].x * numPrec[t][c][r].y;

                        ttIncl[t][c][r] = new TagTreeEncoder[maxPrec][];
                        for (int i6 = 0; i6 < maxPrec; i6++)
                        {
                            ttIncl[t][c][r][i6] = new TagTreeEncoder[maxs];
                        }
                        ttMaxBP[t][c][r] = new TagTreeEncoder[maxPrec][];
                        for (int i7 = 0; i7 < maxPrec; i7++)
                        {
                            ttMaxBP[t][c][r][i7] = new TagTreeEncoder[maxs];
                        }
                        prevtIdxs[t][c][r] = new int[maxs][];
                        lblock[t][c][r] = new int[maxs][];

                        // Precincts and code-blocks
                        ppinfo[t][c][r] = new PrecInfo[maxPrec];
                        fillPrecInfo(t, c, r);

                        for (int s = mins; s < maxs; s++)
                        {
                            // Loop on subbands
                            sb = (SubbandAn) root.getSubbandByIdx(r, s);
                            numcb = sb.numCb.x * sb.numCb.y;

                            lblock[t][c][r][s] = new int[numcb];
                            ArrayUtil.intArraySet(lblock[t][c][r][s], INIT_LBLOCK);

                            prevtIdxs[t][c][r][s] = new int[numcb];
                            ArrayUtil.intArraySet(prevtIdxs[t][c][r][s], - 1);
                        }
                    }
                }
                if (t != nt - 1)
                    infoSrc.nextTile();
            }
        }
コード例 #9
0
ファイル: ForwardWT.cs プロジェクト: KSLcom/Aurora-LibOMV
		/// <summary> Creates a ForwardWT object with the specified filters, and with other
		/// options specified in the parameter list 'pl'.
		/// 
		/// </summary>
		/// <param name="src">The source of data to be transformed
		/// 
		/// </param>
		/// <param name="pl">The parameter list (or options).
		/// 
		/// </param>
		/// <param name="kers">The encoder specifications.
		/// 
		/// </param>
		/// <returns> A new ForwardWT object with the specified filters and options
		/// from 'pl'.
		/// 
		/// </returns>
		/// <exception cref="IllegalArgumentException">If mandatory parameters are missing 
		/// or if invalid values are given.
		/// 
		/// </exception>
		public static ForwardWT createInstance(BlkImgDataSrc src, ParameterList pl, EncoderSpecs encSpec)
		{
            int deflev; // defdec removed
			//System.String decompstr;
			//System.String wtstr;
			//System.String pstr;
			//SupportClass.StreamTokenizerSupport stok;
			//SupportClass.Tokenizer strtok;
			//int prefx, prefy; // Partitioning reference point coordinates
			
			// Check parameters
			pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
			
			deflev = ((System.Int32) encSpec.dls.getDefault());
			
			// Code-block partition origin
			System.String str = "";
			if (pl.getParameter("Wcboff") == null)
			{
				throw new System.ApplicationException("You must specify an argument to the '-Wcboff' " + "option. See usage with the '-u' option");
			}
			SupportClass.Tokenizer stk = new SupportClass.Tokenizer(pl.getParameter("Wcboff"));
			if (stk.Count != 2)
			{
				throw new System.ArgumentException("'-Wcboff' option needs two" + " arguments. See usage with " + "the '-u' option.");
			}
			int cb0x = 0;
			str = stk.NextToken();
			try
			{
				cb0x = (System.Int32.Parse(str));
			}
			catch (System.FormatException)
			{
				throw new System.ArgumentException("Bad first parameter for the " + "'-Wcboff' option: " + str);
			}
			if (cb0x < 0 || cb0x > 1)
			{
				throw new System.ArgumentException("Invalid horizontal " + "code-block partition origin.");
			}
			int cb0y = 0;
			str = stk.NextToken();
			try
			{
				cb0y = (System.Int32.Parse(str));
			}
			catch (System.FormatException)
			{
				throw new System.ArgumentException("Bad second parameter for the " + "'-Wcboff' option: " + str);
			}
			if (cb0y < 0 || cb0y > 1)
			{
				throw new System.ArgumentException("Invalid vertical " + "code-block partition origin.");
			}
			if (cb0x != 0 || cb0y != 0)
			{
				FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Code-blocks partition origin is " + "different from (0,0). This is defined in JPEG 2000" + " part 2 and may be not supported by all JPEG 2000 " + "decoders.");
			}
			
			return new ForwWTFull(src, encSpec, cb0x, cb0y);
		}
コード例 #10
0
ファイル: ROIScaler.cs プロジェクト: KSLcom/Aurora-LibOMV
		/// <summary> Creates a ROIScaler object. The Quantizer is the source of data to
		/// scale.
		/// 
		/// <p>The ROI Scaler creates a ROIMaskGenerator depending on what ROI
		/// information is in the ParameterList. If only rectangular ROI are used,
		/// the fast mask generator for rectangular ROI can be used.</p>
		/// 
		/// </summary>
		/// <param name="src">The source of data to scale
		/// 
		/// </param>
		/// <param name="pl">The parameter list (or options).
		/// 
		/// </param>
		/// <param name="encSpec">The encoder specifications for addition of roi specs
		/// 
		/// </param>
		/// <exception cref="IllegalArgumentException">If an error occurs while parsing
		/// the options in 'pl'
		/// 
		/// </exception>
		public static ROIScaler createInstance(Quantizer src, ParameterList pl, EncoderSpecs encSpec)
		{
			System.Collections.ArrayList roiVector = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
			ROIMaskGenerator maskGen = null;
			
			// Check parameters
			pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
			
			// Get parameters and check if there are and ROIs specified 
			System.String roiopt = pl.getParameter("Rroi");
			if (roiopt == null)
			{
				// No ROIs specified! Create ROIScaler with no mask generator
				return new ROIScaler(src, null, false, - 1, false, encSpec);
			}
			
			// Check if the lowest resolution levels should belong to the ROI 
			int sLev = pl.getIntParameter("Rstart_level");
			
			// Check if the ROIs are block-aligned
			bool useBlockAligned = pl.getBooleanParameter("Ralign");
			
			// Check if generic mask generation is specified 
			bool onlyRect = !pl.getBooleanParameter("Rno_rect");
			
			// Parse the ROIs
			parseROIs(roiopt, src.NumComps, roiVector);
			ROI[] roiArray = new ROI[roiVector.Count];
			roiVector.CopyTo(roiArray);
			
			// If onlyRect has been forced, check if there are any non-rectangular
			// ROIs specified.  Currently, only the presence of circular ROIs will
			// make this false
			if (onlyRect)
			{
				for (int i = roiArray.Length - 1; i >= 0; i--)
					if (!roiArray[i].rect)
					{
						onlyRect = false;
						break;
					}
			}
			
			if (onlyRect)
			{
				// It's possible to use the fast ROI mask generation when only
				// rectangular ROIs are specified.
				maskGen = new RectROIMaskGenerator(roiArray, src.NumComps);
			}
			else
			{
				// It's necessary to use the generic mask generation
				maskGen = new ArbROIMaskGenerator(roiArray, src.NumComps, src);
			}
			return new ROIScaler(src, maskGen, true, sLev, useBlockAligned, encSpec);
		}
コード例 #11
0
		/// <summary> Creates a PostCompRateAllocator object for the appropriate rate
		/// allocation parameters in the parameter list 'pl', having 'src' as the
		/// source of entropy coded data, 'rate' as the target bitrate and 'bw' as
		/// the bit stream writer object.
		/// 
		/// </summary>
		/// <param name="src">The source of entropy coded data.
		/// 
		/// </param>
		/// <param name="pl">The parameter lis (or options).
		/// 
		/// </param>
		/// <param name="rate">The target bitrate for the rate allocation
		/// 
		/// </param>
		/// <param name="bw">The bit stream writer object, where the bit stream data will
		/// be written.
		/// 
		/// </param>
		public static PostCompRateAllocator createInstance(CodedCBlkDataSrcEnc src, ParameterList pl, float rate, CodestreamWriter bw, EncoderSpecs encSpec)
		{
			// Check parameters
			pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
			
			// Construct the layer specification from the 'Alayers' option
			LayersInfo lyrs = parseAlayers(pl.getParameter("Alayers"), rate);
			
			int nTiles = encSpec.nTiles;
			int nComp = encSpec.nComp;
			int numLayers = lyrs.TotNumLayers;
			
			// Parse the progressive type
			encSpec.pocs = new ProgressionSpec(nTiles, nComp, numLayers, encSpec.dls, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
			
			return new EBCOTRateAllocator(src, lyrs, bw, encSpec, pl);
		}
コード例 #12
0
		/// <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);
		}