コード例 #1
0
ファイル: PixelsMap.cs プロジェクト: ratsil/bethe.helpers
		public void CopyIn(IntPtr pSource, uint nBytesQty)
		{
			if (1 > nBytesQty)
				throw new Exception("bytes qty must be more than zero");
#if CUDA
			if (bCUDA)
			{
				Command cCmd = new Command(Command.ID.CopyIn, this);
				cCmd.ahParameters.Add(typeof(IntPtr), pSource);
				_nBytesQty = nBytesQty;
				_aqCommands.Enqueue(cCmd);
				cCmd.cMRE.WaitOne();
				if (null != _cException)
					throw _cException;
				if (_nID == 0)
					(new Logger()).WriteError(new Exception("got 0 in id after copy in"));
				return;
			}
#endif
			Logger.Timings cTimings = new Logger.Timings("btl:pixelsmap:copyin:");
			if (null == _aBytes)
				Allocate();
			cTimings.Restart("allocate");
			Marshal.Copy(pSource, _aBytes, 0, (int)nBytesQty);
			cTimings.Stop("copyin > 40ms", "marshal_copy", 40);
		}
コード例 #2
0
ファイル: Video.cs プロジェクト: ratsil/bethe.btl
            public PixelsMap FrameNextVideo()
			{
				Logger.Timings cTimings = new Logger.Timings("btl:video:file");
				try
				{
					_cPixelsMap.Move(stArea.nLeft, stArea.nTop);  // были проблемы в транзишене. т.к. PM многоразовый, то кто-то его мог мувнуть (плейлист) и на место не класть. 
					ffmpeg.net.Frame cFrame = _cFile.FrameNextVideoGet();   //_cFormatVideo, 
					cTimings.Restart("ffmpeg_framenext");  
					if (null != cFrame)
					{
						int nOffset = 0;
						if (720 == _cFormatVideo.nWidth && 576 == _cFormatVideo.nHeight)  // инверси¤ полей нужна только на sd
							nOffset = _cFormatVideo.nWidth * _cFormatVideo.nBitsPerPixel / 8;
						_cPixelsMap.CopyIn(cFrame.pBytes + nOffset, cFrame.nLength - nOffset);  // сдвигаем фрейм на строчку вверх (это если не HD, а PAL)
						cTimings.Restart("copy_in");
						cFrame.Dispose();
						cTimings.Restart("dispose");
						//GC.Collect(1, GCCollectionMode.Forced);  // худший вариант был
						GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized);  // этот лучший был
						//GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);   // гипотеза (“ј  и оказалось!!!!) - т.к. сборка спонтанна¤ высвобождает сразу много мусора и и лочит этим copyin и вышибает пробки у Ѕлэкћэджика
						cTimings.Restart("GCcollect");
						nFrameCurrentVideo++;
					}
					else if (bEOF)
						return null;
					cTimings.Stop("framenext > 20ms","eof_getting", 20);
					return _cPixelsMap;
				}
				catch (Exception ex)
				{
					(new Logger()).WriteError(ex);
				}
                return null;
            }
コード例 #3
0
ファイル: Video.cs プロジェクト: ratsil/bethe.btl
        override public PixelsMap FrameNextVideo()
        {
			Logger.Timings cTimings = new Logger.Timings("btl:video"); 
            PixelsMap cRetVal = _cFile.FrameNextVideo();
			cTimings.Restart("file_nextframe");

            ulong nDuration = this.nDuration;
            nDuration = nDuration < _cFile.nFramesTotal ? nDuration : _cFile.nFramesTotal;
			if ((null == cRetVal && _cFile.bEOF) || (nFrameCurrentVideo >= nDuration && (nFrameCurrentAudio >= nDuration || nFrameCurrentAudio == 0)))
			{
				if (_cFile.bEOF && (nFrameCurrentVideo != nDuration || nFrameCurrentAudio != nDuration))
					(new Logger()).WriteWarning("video has been stopped abnormal [hc:" + GetHashCode() + "] [duration: " + nDuration + "] [current_video: " + _cFile.nFrameCurrentVideo + "] [current_audio: " + _cFile.nFrameCurrentAudio + "]");
				(new Logger()).WriteDebug3("FrameNextVideo(): video stopped [hc:" + GetHashCode() + "]" + "[frames total:" + _cFile.nFramesTotal + "]" + "[nFrameCurrentVideo:" + _cFile.nFrameCurrentVideo + "]" + "[nFrameCurrentAudio:" + _cFile.nFrameCurrentAudio + "][eof: " + _cFile.bEOF + "]");
				Stop();
			}
            (new Logger()).WriteDebug4("video returns a frame [hc:" + GetHashCode() + "]");
			cTimings.Stop("video:framenext > 40ms", "eof_getting and dur_getting", 40);
            return cRetVal;
        }
コード例 #4
0
ファイル: Video.cs プロジェクト: ratsil/bethe.btl
			public void Close()
			{
				if (_bClosed)
				{
					(new Logger()).WriteDebug3("in - already closed " + GetHashCode());
					return;
				}
				_bClosed = true;
				(new Logger()).WriteDebug3("in " + GetHashCode());
				Logger.Timings cTimings = new Logger.Timings("video:file:");
				if (null != _cPixelsMap)
					Baetylus.PixelsMapDispose(_cPixelsMap, true);

				_aAudioMap = null;

				cTimings.Restart("pm disposing");

				new System.Threading.Thread(() =>
				{
					System.Threading.Thread.CurrentThread.IsBackground = true;
					if (null != _cFile)
						_cFile.Dispose();
				}).Start();

				cTimings.Stop("close > 20", "file disposing", 20);

				(new Logger()).WriteDebug4("out");
			}