Ejemplo n.º 1
0
			private void  InitBlock(ThreadPool enclosingInstance)
			{
				this.enclosingInstance = enclosingInstance;
			}
Ejemplo n.º 2
0
			/// <summary> Creates a ThreadPoolThread object, setting its name according to
			/// the given 'idx', daemon type and the priority to the one of the
			/// pool.
			/// 
			/// </summary>
			/// <param name="idx">The index of this thread in the pool
			/// 
			/// </param>
			/// <param name="name">The name of the thread
			/// 
			/// </param>
			public ThreadPoolThread(ThreadPool enclosingInstance, int idx, System.String name):base(name)
			{
				InitBlock(enclosingInstance);
				IsBackground = true;
				//UPGRADE_TODO: The differences in the type  of parameters for method 'java.lang.Thread.setPriority'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
				Priority = (System.Threading.ThreadPriority) Enclosing_Instance.poolPriority;
			}
Ejemplo n.º 3
0
		/// <summary> Instantiates a new entropy coder engine, with the specified source of
		/// data, nominal block width and height.
		/// 
		/// <p>If the 'OPT_PRED_TERM' option is given then the MQ termination must
		/// be 'TERM_PRED_ER' or an exception is thrown.</p>
		/// 
		/// </summary>
		/// <param name="src">The source of data
		/// 
		/// </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>
		/// <seealso cref="MQCoder">
		/// 
		/// </seealso>
		public StdEntropyCoder(CBlkQuantDataSrcEnc src, CBlkSizeSpec cblks, PrecinctSizeSpec pss, StringSpec bms, StringSpec mqrs, StringSpec rts, StringSpec css, StringSpec sss, StringSpec lcs, StringSpec tts):base(src)
		{
			this.cblks = cblks;
			this.pss = pss;
			this.bms = bms;
			this.mqrs = mqrs;
			this.rts = rts;
			this.css = css;
			this.sss = sss;
			this.lcs = lcs;
			this.tts = tts;
			int maxCBlkWidth, maxCBlkHeight;
			int i; // Counter
			int nt; // The number of threads
			int tsl; // Size for thread structures
			
			// Get the biggest width/height for the code-blocks
			maxCBlkWidth = cblks.MaxCBlkWidth;
			maxCBlkHeight = cblks.MaxCBlkHeight;
			
            nt = Environment.ProcessorCount;
            /*
			// Get the number of threads to use, or default to one
			try
			{
				//UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
				nt = System.Int32.Parse(System_Renamed.getProperty(THREADS_PROP_NAME, DEF_THREADS_NUM));
				if (nt < 0)
					throw new System.FormatException();
			}
			catch (System.FormatException e)
			{
				throw new System.ArgumentException("Invalid number of threads " + "for " + "entropy coding in property " + THREADS_PROP_NAME);
			}
			*/

			// If we do timing create necessary structures
#if DO_TIMING
			time = new long[src.NumComps];
			// If we are timing make sure that 'finalize' gets called.
			//UPGRADE_ISSUE: Method 'java.lang.System.runFinalizersOnExit' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
			// CONVERSION PROBLEM?
            //System_Renamed.runFinalizersOnExit(true);
#endif			
			// If using multithreaded implementation get necessasry objects
			if (nt > 0)
			{
				FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, "Using multithreaded entropy coder " + "with " + nt + " compressor threads.");
				tsl = nt;
				tPool = new ThreadPool(nt, (System.Int32) SupportClass.ThreadClass.Current().Priority + THREADS_PRIORITY_INC, "StdEntropyCoder");
				idleComps = new System.Collections.ArrayList();
				completedComps = new System.Collections.ArrayList[src.NumComps];
				nBusyComps = new int[src.NumComps];
				finishedTileComponent = new bool[src.NumComps];
				for (i = src.NumComps - 1; i >= 0; i--)
				{
					completedComps[i] = new System.Collections.ArrayList();
				}
				for (i = 0; i < nt; i++)
				{
					idleComps.Add(new StdEntropyCoder.Compressor(this, i));
				}
			}
			else
			{
				tsl = 1;
				tPool = null;
				idleComps = null;
				completedComps = null;
				nBusyComps = null;
				finishedTileComponent = null;
			}
			
			// Allocate data structures
			outT = new ByteOutputBuffer[tsl];
			mqT = new MQCoder[tsl];
			boutT = new BitToByteOutput[tsl];
			stateT = new int[tsl][];
			for (int i2 = 0; i2 < tsl; i2++)
			{
				stateT[i2] = new int[(maxCBlkWidth + 2) * ((maxCBlkHeight + 1) / 2 + 2)];
			}
			symbufT = new int[tsl][];
			for (int i3 = 0; i3 < tsl; i3++)
			{
				symbufT[i3] = new int[maxCBlkWidth * (CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT * 2 + 2)];
			}
			ctxtbufT = new int[tsl][];
			for (int i4 = 0; i4 < tsl; i4++)
			{
				ctxtbufT[i4] = new int[maxCBlkWidth * (CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT * 2 + 2)];
			}
			distbufT = new double[tsl][];
			for (int i5 = 0; i5 < tsl; i5++)
			{
				distbufT[i5] = new double[32 * CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES];
			}
			ratebufT = new int[tsl][];
			for (int i6 = 0; i6 < tsl; i6++)
			{
				ratebufT[i6] = new int[32 * CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES];
			}
			istermbufT = new bool[tsl][];
			for (int i7 = 0; i7 < tsl; i7++)
			{
				istermbufT[i7] = new bool[32 * CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES];
			}
			srcblkT = new CBlkWTData[tsl];
			for (i = 0; i < tsl; i++)
			{
				outT[i] = new ByteOutputBuffer();
				mqT[i] = new MQCoder(outT[i], NUM_CTXTS, MQ_INIT);
			}
			precinctPartition = new bool[src.NumComps][];
			for (int i8 = 0; i8 < src.NumComps; i8++)
			{
				precinctPartition[i8] = new bool[src.getNumTiles()];
			}
			
			// Create the subband description for each component and each tile
			//Subband sb = null;
			Coord numTiles = null;
			int nc = NumComps;
			numTiles = src.getNumTiles(numTiles);
			initTileComp(getNumTiles(), nc);
			
			for (int c = 0; c < nc; c++)
			{
				for (int tY = 0; tY < numTiles.y; tY++)
				{
					for (int tX = 0; tX < numTiles.x; tX++)
					{
						precinctPartition[c][tIdx] = false;
					}
				}
			}
		}