Ejemplo n.º 1
0
            public PixelsMap FrameNextVideo()
            {
                cTimings.TotalRenew();
                try
                {
                    _cPixelsMap = _cPMDuo.cCurrent;
                    _cPixelsMap.Move(stPixelArea.nLeft, stPixelArea.nTop);                      // были проблемы в транзишене. т.к. PM многоразовый, то кто-то его мог мувнуть (плейлист) и на место не класть.
                    ffmpeg.net.Frame cFrame = _cFile.FrameNextVideoGet();                       //_cFormatVideo,
                    cTimings.Restart("ffmpeg_framenext");
                    if (null != cFrame)
                    {
                        int nOffset    = 0;
                        int nOffsetBot = 0;
                        int nLine      = _cFormatVideo.nWidth * _cFormatVideo.nBitsPerPixel / 8;
                        int nBotDiff   = _cFormatVideo.nHeight - (stContainerArea.nHeight - stArea.nTop);
                        if (720 == _cFormatVideo.nWidth && 576 == _cFormatVideo.nHeight)                          // инверсия полей нужна только на sd
                        {
                            nOffset = nLine;
                        }

                        if (stArea.nTop < 0)
                        {
                            nOffset += (-stArea.nTop) * nLine;
                        }
                        if (nBotDiff > 0)
                        {
                            nOffsetBot = nBotDiff * nLine;
                        }

                        _cPixelsMap.CopyIn(cFrame.pBytes + nOffset, cFrame.nLength - nOffset - nOffsetBot);                          // сдвигаем фрейм на строчку вверх (это если не HD, а PAL)
                        cTimings.Restart("copy_in");
                        cFrame.Dispose();
                        cTimings.Restart("dispose");
                        //GC.Collect(1, GCCollectionMode.Force_d);  // худший вариант был
                        //GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized);  // этот лучший был  ------- уехало в байтилус  -------
                        //GC.Collect(GC.MaxGeneration, GCCollectionMode.Force_d);   // гипотеза (ТАК и оказалось!!!!) - т.к. сборка спонтанная высвобождает сразу много мусора и и лочит этим copyin и вышибает пробки у БлэкМэджика
                        //cTimings.Restart("GCcollect. " + System.Runtime.GCSettings.LatencyMode + ".");
                        nFrameCurrentVideo++;
                    }
                    else if (bEOF)
                    {
                        return(null);
                    }
                    cTimings.Stop("framenext", "eof_getting", 20);
                    ffmpeg.net.File.Input.nBTLCurrentBuffer = Baetylus.nCurrentDeviceBufferCount;
                    return(_cPixelsMap);
                }
                catch (Exception ex)
                {
                    (new Logger()).WriteError(ex);
                    _cFile.Close();
                }
                return(null);
            }
Ejemplo n.º 2
0
        override public PixelsMap FrameNext()
        {
            lock (_cSyncRoot)
            {
                base.FrameNext();
                if (nFrameCurrent >= nDuration)
                {
                    base.Stop();
                }

                _cPixelsMap = _cPMDuo.Switch(nPixelsMapSyncIndex);

                if (null == _cPixelsMap)
                {
                    _cPixelsMap              = new PixelsMap(stMergingMethod, stArea, PixelsMap.Format.ARGB32);
                    _cPixelsMap.bKeepAlive   = false; // на одни раз
                    _cPixelsMap.nIndexTriple = nPixelsMapSyncIndex;
                    _cPixelsMap.Allocate();
                }

                if (null != _cPixelsMap)
                {
                    if (!_aPMGotDrawCurrent.Contains(_cPixelsMap.nID))
                    {
                        _dtChanged = DateTime.Now;
                        _aPMGotDrawCurrent.Add(_cPixelsMap.nID);
                        _cPixelsMap.CopyIn(_aDrawCurrent.aBytes);
                    }
                    if (_cPixelsMap.nAlphaConstant != nCurrentOpacity)
                    {
                        _dtChanged = DateTime.Now;
                        _cPixelsMap.nAlphaConstant = nCurrentOpacity;
                    }
                    if (null != cMask && _cPixelsMap.eAlpha != cMask.eMaskType)
                    {
                        _dtChanged         = DateTime.Now;
                        _cPixelsMap.eAlpha = cMask.eMaskType;
                    }
                    if (_cPixelsMap.stArea.nLeft != stArea.nLeft || _cPixelsMap.stArea.nTop != stArea.nTop)
                    {
                        _dtChanged = DateTime.Now;
                        _cPixelsMap.Move(stArea.nLeft, stArea.nTop);
                    }
                }
                return(_cPixelsMap);
            }
        }
Ejemplo n.º 3
0
            public void VideoFrameNext(PixelsMap cPixelsMap)
            {
                try
                {
                    if (null == _aFiles)
                    {
                        throw new Exception("_aFiles is null in Animation.cs");                         //UNDONE
                    }
                    if (nFrameCurrent < (ulong)_aFiles.Length)
                    {
                        if (null != cPixelsMap)
                        {
                            _cTimings.TotalRenew();
                            if (null == _cCache)
                            {
                                BitmapDataSet(_aFiles[nFrameCurrent]);

                                cPixelsMap.CopyIn(_cBitmapData.Scan0, _cBitmapData.Stride * _cBitmapData.Height);
                                _cBitmap.UnlockBits(_cBitmapData);
                                _cBitmap.Dispose();
                                _cTimings.Restart("copyin1");
                            }
                            else
                            {
                                if (0 <= nQueueLength)
                                {
                                    if (0 == nQueueLength && 0 < (ulong)_aFiles.Length - nFrameCurrent)
                                    {
                                        (new Logger()).WriteWarning("animation queue length is empty - will just return!![" + nQueueLength + "][total=" + nFramesTotal + "][cur=" + nFrameCurrent + "][" + _sFolder + "]");
                                    }
                                    else if (3 > nQueueLength && 3 <= (ulong)_aFiles.Length - nFrameCurrent)
                                    {
                                        (new Logger()).WriteNotice("animation queue length is less than 3! [" + nQueueLength + "][" + _sFolder + "]");
                                    }
                                    else if ((Preferences.nQueueAnimationLength / 2 > nQueueLength) && (Preferences.nQueueAnimationLength / 2) <= _aFiles.Length - (int)nFrameCurrent)
                                    {
                                        (new Logger()).WriteDebug3("animation queue length [" + nQueueLength + "][total=" + nFramesTotal + "][cur=" + nFrameCurrent + "][" + _sFolder + "]");
                                    }
                                }
                                if (0 == nQueueLength || (int)nFrameCurrent >= _cCache.Count)
                                {
                                    bEOF = true;
                                    return;
                                }

                                lock (_oCacheLock)
                                {
                                    cPixelsMap.CopyIn(_cCache[(int)nFrameCurrent].aBytes, false, true);
                                    if (-1 < _nQueueLength)
                                    {
                                        _nQueueLength--;
                                    }
                                }
                                _cTimings.Stop("frnext", "lock and copyin2", 40);
                            }
                        }
                        nFrameCurrent++;
                    }
                    else
                    {
                        bEOF = true;
                    }
                }
                catch (Exception ex)
                {
                    (new Logger()).WriteError("[" + _aFiles[nFrameCurrent] + "][" + _sFolder + "]", ex);
                    bEOF = true;
                }
            }