Exemplo n.º 1
0
 override public void Dispose()
 {
     if (_oLock == null)
     {
         return;
     }
     lock (_oLock)
     {
         if (_bDisposed)
         {
             return;
         }
         _bDisposed = true;
     }
     base.Dispose();
     if (null != _cPMDuo)
     {
         (new Logger()).WriteDebug3("disposing pixelmap in animation: [hc=" + this.nID + "][file=" + (null == _cFile ? "null" : _cFile.sName) + "]");
         Baetylus.PixelsMapDispose(_cPMDuo, true);
     }
     _cPMDuo = null;
     nFrameCurrentPhysical = 0;
     nLoopCurrent          = 0;
     _cFile.Dispose();
 }
Exemplo n.º 2
0
        private void DrawText()
        {
            BitmapData cBitmapData = _cImage.LockBits(new Rectangle(0, 0, _cImage.Width, _cImage.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

            lock (_cSyncRoot)
            {
                if (_aDrawCurrent != null)
                {
                    Baetylus._cBinM.BytesBack(_aDrawCurrent, 51);
                }
                _aDrawCurrent = Baetylus._cBinM.BytesGet(cBitmapData.Stride * cBitmapData.Height, 52);
                System.Runtime.InteropServices.Marshal.Copy(cBitmapData.Scan0, _aDrawCurrent.aBytes, 0, cBitmapData.Stride * cBitmapData.Height);
                _aPMGotDrawCurrent.Clear();

                if (null != _cPMDuo && stArea != _cPMDuo.cFirst.stArea)
                {
                    Baetylus.PixelsMapDispose(_cPMDuo, true);
                    _cPMDuo = null;
                }
                if (null == _cPMDuo)
                {
                    _cPMDuo = new PixelsMap.Triple(stMergingMethod, stArea, PixelsMap.Format.ARGB32, true, Baetylus.PixelsMapDispose);
                    _cPMDuo.SetAlphaConstant(_stColor.A);
                    _cPMDuo.Allocate();
                }
                _dtChanged = DateTime.Now;
            }
            _cImage.UnlockBits(cBitmapData);
            _cImage = null;
        }
Exemplo n.º 3
0
        override public void Stop()
        {
            Baetylus.PixelsMapDispose(_cPMDuo, true);
            _cPMDuo = null;

            base.Stop();
        }
Exemplo n.º 4
0
        override public void Prepare()
        {
            lock (_aEffects)
                try
                {
                    if (EffectStatus.Idle != ((IEffect)this).eStatus)
                    {
                        return;
                    }

                    if (stMergingMethod.eDeviceType == MergingDevice.DisCom)
                    {
                        PixelsMap.DisComInit();
                    }

                    foreach (Effect cEffect in _aEffects)
                    {
                        if (EffectStatus.Idle == cEffect.eStatus)
                        {
                            ((IVideo)cEffect).stMergingMethod = this.stMergingMethod;
                            cEffect.Prepare();
                        }
                    }

                    if (null != _cPMDuo && stArea != _cPMDuo.cFirst.stArea)
                    {
                        Baetylus.PixelsMapDispose(_cPMDuo, true);
                        _cPMDuo = null;
                    }
                    if (null == _cPMDuo)
                    {
                        _cPMDuo = new PixelsMap.Triple(this.stMergingMethod, this.stArea, PixelsMap.Format.ARGB32, true, Baetylus.PixelsMapDispose);
                        if (1 > _cPMDuo.cFirst.nLength)
                        {
                            (new Logger()).WriteNotice("1 > __cPixelsMap.nLength. composite.prepare");
                        }
                        _cPMDuo.Allocate();
                    }
                    _cPMDuo.RenewFirstTime();
                    nPixelsMapSyncIndex = byte.MaxValue;
                    base.Prepare();
                }
                catch (Exception ex)
                {
                    (new Logger()).WriteError(ex);
                }
        }
Exemplo n.º 5
0
        override public void Prepare()
        {
            base.Prepare();
            if (0 == nDuration)
            {
                nDuration = 1;
            }


            if (stMergingMethod.eDeviceType == MergingDevice.DisCom)
            {
                PixelsMap.DisComInit();
            }



            if (EffectStatus.Idle == _cEffectSource.eStatus || EffectStatus.Stopped == _cEffectSource.eStatus)
            {
                _cEffectSource.Prepare();
            }
            if (EffectStatus.Idle == _cEffectTarget.eStatus || EffectStatus.Stopped == _cEffectTarget.eStatus)
            {
                _cEffectTarget.Prepare();
            }

            if (_cEffectSource is IVideo && _cEffectTarget is IVideo)
            {
                stArea = SumOfAreas(((IVideo)_cEffectSource).stArea, ((IVideo)_cEffectTarget).stArea);
                if (null != _cPMDuo && stArea != _cPMDuo.cFirst.stArea)
                {
                    Baetylus.PixelsMapDispose(_cPMDuo, true);
                    _cPMDuo = null;
                }
                if (null == _cPMDuo)
                {
                    //_cPixelsMap = new PixelsMap(stMergingMethod, stArea, PixelsMap.Format.ARGB32);
                    _cPMDuo = new PixelsMap.Triple(new MergingMethod(stMergingMethod.eDeviceType, 0), stArea, PixelsMap.Format.ARGB32, true, Baetylus.PixelsMapDispose);  //MergingDevice.DisCom
                    if (1 > _cPMDuo.cFirst.nLength)
                    {
                        (new Logger()).WriteNotice("1 > _cPixelsMap.nLength. transition.prepare");
                    }
                    _cPMDuo.Allocate();
                }
                _cPMDuo.RenewFirstTime();
                nPixelsMapSyncIndex = byte.MaxValue;
            }
        }
Exemplo n.º 6
0
            public void Open(MergingMethod stMergingMethod, ffmpeg.net.File.Input.PlaybackMode ePlaybackMode)
            {
                // TODO  нужно выцеплять размеры кадра из видео.
                _bClosed = false;
                if (null == _cFile)
                {
                    _cFile = new ffmpeg.net.File.Input(_sFile, nFrameStart);
                }
                (new Logger()).WriteDebug("[video_file open " + GetHashCode() + "][ffmpeg_file " + _cFile.GetHashCode() + "]");
                //Area stDeviceArea = Baetylus.Helper.stCurrentBTLArea;
                _cFormatVideo = new ffmpeg.net.Format.Video(stArea.nWidth, stArea.nHeight, ffmpeg.net.PixelFormat.AV_PIX_FMT_BGRA, ffmpeg.net.AVFieldOrder.AV_FIELD_TT);

                short  nTop = stArea.nTop;
                ushort nHei = stArea.nHeight;

                if (stArea.nTop < 0)                 // если верх выше границы, то не будем копировать лишние строки в пиксельсмэп
                {
                    nTop = 0;
                }
                if (nTop < stContainerArea.nHeight && stArea.nHeight + stArea.nTop > stContainerArea.nHeight)                 // если низ ниже, то не будем копировать лишние строки в пиксельсмэп
                {
                    nHei = (ushort)(stContainerArea.nHeight - (ushort)nTop);
                }

                stPixelArea = new Area(stArea.nLeft, nTop, stArea.nWidth, nHei);

                _cPMDuo = new PixelsMap.Triple(stMergingMethod, stPixelArea, PixelsMap.Format.BGRA32, true, Baetylus.PixelsMapDispose);
                ffmpeg.net.AVSampleFormat eAVSampleFormat;
                switch (Preferences.nAudioBitDepth)
                {
                case 32:
                    eAVSampleFormat = ffmpeg.net.AVSampleFormat.AV_SAMPLE_FMT_S32;
                    break;

                case 16:
                default:
                    eAVSampleFormat = ffmpeg.net.AVSampleFormat.AV_SAMPLE_FMT_S16;
                    break;
                }
                int nAudioChannelsQty = Preferences.nAudioChannelsQtyFfmpeg;

                _cFormatAudio = new ffmpeg.net.Format.Audio((int)Preferences.nAudioSamplesRate, nAudioChannelsQty, eAVSampleFormat);
                nFramesTotal  = _cFile.nFramesQty;
                //_cFile.Prepare(nDuration);
                _cFile.Prepare(_cFormatVideo, _cFormatAudio, ePlaybackMode);
            }
Exemplo n.º 7
0
 public override void Dispose()
 {
     lock (_oLock)
     {
         if (_bDisposed)
         {
             return;
         }
         _bDisposed = true;
     }
     base.Dispose();
     lock (_cSyncRoot)
     {
         Baetylus.PixelsMapDispose(_cPMDuo, true);
         //_cPMDuo.Dispose(true);
         _cPMDuo = null;
     }
 }
Exemplo n.º 8
0
        override public void Prepare()
        {
            try
            {
                if (EffectStatus.Idle != ((IEffect)this).eStatus)
                {
                    return;
                }

                _cFile.nAnimationLoopsQty    = nLoopsQty;
                _cFile.nAnimationLoopCurrent = 0;
                _cFile.nAnimationKeepAlive   = bKeepAlive;
                if (Area.stEmpty == stArea || stArea.nWidth == 0 || stArea.nWidth == ushort.MaxValue || stArea.nHeight == 0 || stArea.nHeight == ushort.MaxValue)
                {
                    stArea = new Area(stArea.nLeft, stArea.nTop, (ushort)stFileDimensions.Width, (ushort)stFileDimensions.Height);
                }

                if (nPixelAspectRatio == 0 && (stArea.nWidth != stFileDimensions.Width || stArea.nHeight != stFileDimensions.Height))
                {
                    nPixelAspectRatio = 1;
                }

                if (nPixelAspectRatio > 0) // && 1 != nPixelAspectRatio
                {
                    stArea = AreaResize(stFileDimensions.Width, stFileDimensions.Height, stArea.nWidth, stArea.nHeight, nPixelAspectRatio);
                    _cFile.stDimensionsResized = new Size(stArea.nWidth, stArea.nHeight);
                }
                stArea = stArea.Dock(stBase, cDock);

                if (null == _cPMDuo)
                {
                    _cFile.Open();
                    if (bKeepAlive && bTurnOffQueue || _cFile.nFramesTotal < Preferences.nQueueAnimationLength * 1.5f)   // иначе очень неудобно в воркере работать... да и не зачем тогда очередь разводить раз так мало кадров
                    {
                        _cFile.Cache();
                    }
                    else if (!bTurnOffQueue)
                    {
                        _cFile.DynamicQueueStart();
                    }

                    _cPMDuo = new PixelsMap.Triple(stMergingMethod, new Area(0, 0, stArea.nWidth, stArea.nHeight), PixelsMap.Format.ARGB32, true, Baetylus.PixelsMapDispose);
                    if (1 > _cPMDuo.cFirst.nLength)
                    {
                        (new Logger()).WriteNotice("1 > __cPixelsMap.nLength. animation.prepare");
                    }
                    _cPMDuo.Allocate();
                    (new Logger()).WriteDebug3("new pixelmap for animation: [id=" + _cPMDuo.cFirst.nID + "][hc=" + this.nID + "][file=" + (null == _cFile ? "null" : _cFile.sName) + "]");
                    _cPMDuo.RenewFirstTime();
                }

                nPixelsMapSyncIndex   = byte.MaxValue;
                nFrameCurrentPhysical = 0;   //это если препаре делают после стопа.
                nLoopCurrent          = 0;
                if (nLoopsQty > 0 && nDuration > nLoopsQty * nFramesTotal)
                {
                    nDuration = nLoopsQty * nFramesTotal;
                }

                base.Prepare();
            }
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
                (new Logger()).WriteWarning("[bKeepAlive = " + (null == _cPMDuo.cFirst ? "(__cPixelsMap = null)" : "" + _cPMDuo.cFirst.bKeepAlive) + "][nDuration = " + nDuration + "][file=" + (null == _cFile ? "null" : _cFile.sName) + "]");
                throw;
            }
        }