public AviSynthClip(IntPtr avs)
 {
     _vi = new AVSDLLVideoInfo();
     this._avs = avs;
     _colorSpace = AviSynthColorspace.RGB32;
     _sampleType = AudioSampleType.INT8;
 }
Exemple #2
0
        public AviSynthClip(string func, string arg, bool bRequireRGB24, bool bRunInThread)
        {
            _vi         = new AVSDLLVideoInfo();
            _avs        = IntPtr.Zero;
            _colorSpace = AviSynthColorspace.Unknown;
            _sampleType = AudioSampleType.Unknown;
            bool   bOpenSuccess    = false;
            string strErrorMessage = string.Empty;

            lock (_locker)
            {
                Random rnd = new Random();
                _random = rnd.Next(1, 1000000);

                if (MainForm.Instance.Settings.ShowDebugInformation)
                {
                    HandleAviSynthWrapperDLL(false, arg);
                }

                System.Windows.Forms.Application.UseWaitCursor = true;
                if (bRunInThread)
                {
                    Thread t = new Thread(new ThreadStart(delegate
                    {
                        bOpenSuccess = OpenAVSScript(func, arg, bRequireRGB24, out strErrorMessage);
                    }));
                    t.Start();
                    while (t.ThreadState == ThreadState.Running)
                    {
                        MeGUI.core.util.Util.Wait(1000);
                    }
                }
                else
                {
                    bOpenSuccess = OpenAVSScript(func, arg, bRequireRGB24, out strErrorMessage);
                }
                System.Windows.Forms.Application.UseWaitCursor = false;
            }

            if (bOpenSuccess == false)
            {
                string err = string.Empty;
                if (_avs != IntPtr.Zero)
                {
                    err = getLastError();
                }
                else
                {
                    err = strErrorMessage;
                }
                Dispose(false);
                throw new AviSynthException(err);
            }
        }
 public AviSynthClip(string func, string arg , AviSynthColorspace forceColorspace, AviSynthScriptEnvironment env)
 {
     _vi = new AVSDLLVideoInfo();
     _avs =  new IntPtr(0);
     _colorSpace = AviSynthColorspace.Unknown;
     _sampleType = AudioSampleType.Unknown;
     if(0!=dimzon_avs_init_2(ref _avs, func, arg, ref _vi, ref _colorSpace, ref _sampleType, forceColorspace.ToString()))
     {
         string err = getLastError();
         cleanup(false);
         throw new AviSynthException(err);
     }
 }
Exemple #4
0
        //Только инициализация
        public AviSynthClip()
        {
            _avs = new IntPtr(0);
            _vi  = new AVSDLLVideoInfo();

            //Просто получаем Handle и выходим
            if (0 != dimzon_avs_init(ref _avs, null, null, ref _vi))
            {
                string err = GetLastError();
                cleanup(false);
                throw new AviSynthException(err);
            }
        }
 public AviSynthClip(string func, string arg, AviSynthColorspace forceColorspace, AviSynthScriptEnvironment env)
 {
     _vi         = new AVSDLLVideoInfo();
     _avs        = new IntPtr(0);
     _colorSpace = AviSynthColorspace.Unknown;
     _sampleType = AudioSampleType.Unknown;
     if (0 != dimzon_avs_init(ref _avs, func, arg, ref _vi, ref _colorSpace, ref _sampleType, forceColorspace.ToString()))
     {
         string err = getLastError();
         cleanup(false);
         throw new AviSynthException(err);
     }
 }
        public AviSynthClip(string func, string arg, AviSynthColorspace forceColorspace, AviSynthScriptEnvironment env)
        {
            _vi         = new AVSDLLVideoInfo();
            _avs        = new IntPtr(0);
            _colorSpace = AviSynthColorspace.Unknown;
            _sampleType = AudioSampleType.Unknown;
            bool bOpenSuccess = false;

            if (MainForm.Instance.Settings.OpenAVSInThreadDuringSession)
            {
                MainForm.Instance.AvsLock++;

                Thread t = new Thread(new ThreadStart(delegate
                {
                    System.Windows.Forms.Application.UseWaitCursor = true;
                    if (0 == dimzon_avs_init_2(ref _avs, func, arg, ref _vi, ref _colorSpace, ref _sampleType, forceColorspace.ToString()))
                    {
                        bOpenSuccess = true;
                    }
                    MainForm.Instance.AvsLock--;
                    if (MainForm.Instance.AvsLock == 0)
                    {
                        System.Windows.Forms.Application.UseWaitCursor = false;
                    }
                }));
                t.Start();

                while (t.ThreadState == ThreadState.Running)
                {
                    System.Windows.Forms.Application.DoEvents();
                    Thread.Sleep(100);
                }
            }
            else
            {
                if (0 == dimzon_avs_init_2(ref _avs, func, arg, ref _vi, ref _colorSpace, ref _sampleType, forceColorspace.ToString()))
                {
                    bOpenSuccess = true;
                }
            }

            if (bOpenSuccess == false)
            {
                string err = getLastError();
                cleanup(false);
                throw new AviSynthException(err);
            }
        }
Exemple #7
0
        //, AviSynthScriptEnvironment env)
        //Полноценное открытие: инициализация + Invoke + GetVideoInfo (func обязательно должна возвращать Clip с видео!)
        public AviSynthClip(string func, string arg, AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType)
        {
            _avs = new IntPtr(0);
            _vi = new AVSDLLVideoInfo();
            _vi.mt_import = (SysInfo.AVSIsMT) ? Settings.MTMode_Internal : MTMode.Undefined;

            //Эти два поля работают и на вход, и на выход. Для "dimzon_avs_init" через них можно задать требуемые на выходе PixelType и SampleType.
            //При нуле (Undefined) никаких преобразований не будет. На выходе из "dimzon_avs_init" поля будут содержать то, что получилось в итоге.
            //В "dimzon_avs_invoke" работают только на выход.
            _vi.pixel_type = forceColorSpace;
            _vi.sample_type = forceSampleType;

            //Эти поля содержат инфу об исходных PixelType и SampleType, т.е. до того, как они были изменены в "dimzon_avs_init".
            //В "dimzon_avs_invoke" обновляются только в случае их равенства нулю.
            _vi.pixel_type_orig = AviSynthColorspace.Undefined;
            _vi.sample_type_orig = AudioSampleType.Undefined;

            if (0 != dimzon_avs_init(ref _avs, func, arg, ref _vi))
            {
                string err = GetLastError();
                cleanup(false);
                throw new AviSynthException(err);
            }
        }
Exemple #8
0
        //Полноценное открытие: инициализация + Invoke + GetVideoInfo (func обязательно должна возвращать Clip с видео!)
        public AviSynthClip(string func, string arg, AviSynthColorspace forceColorSpace, AudioSampleType forceSampleType) //, AviSynthScriptEnvironment env)
        {
            _avs          = new IntPtr(0);
            _vi           = new AVSDLLVideoInfo();
            _vi.mt_import = (SysInfo.AVSIsMT) ? Settings.MTMode_Internal : MTMode.Undefined;

            //Эти два поля работают и на вход, и на выход. Для "dimzon_avs_init" через них можно задать требуемые на выходе PixelType и SampleType.
            //При нуле (Undefined) никаких преобразований не будет. На выходе из "dimzon_avs_init" поля будут содержать то, что получилось в итоге.
            //В "dimzon_avs_invoke" работают только на выход.
            _vi.pixel_type  = forceColorSpace;
            _vi.sample_type = forceSampleType;

            //Эти поля содержат инфу об исходных PixelType и SampleType, т.е. до того, как они были изменены в "dimzon_avs_init".
            //В "dimzon_avs_invoke" обновляются только в случае их равенства нулю.
            _vi.pixel_type_orig  = AviSynthColorspace.Undefined;
            _vi.sample_type_orig = AudioSampleType.Undefined;

            if (0 != dimzon_avs_init(ref _avs, func, arg, ref _vi))
            {
                string err = GetLastError();
                cleanup(false);
                throw new AviSynthException(err);
            }
        }
Exemple #9
0
 private static extern int dimzon_avs_init(ref IntPtr avs, string func, string arg, ref AVSDLLVideoInfo vi);
 private static extern int dimzon_avs_init(ref IntPtr avs, string func, string arg, ref AVSDLLVideoInfo vi, ref AviSynthColorspace originalColorspace, ref AudioSampleType originalSampleType, string cs);
Exemple #11
0
 private static extern int dimzon_avs_init(ref IntPtr avs, string func, string arg, ref AVSDLLVideoInfo vi);
Exemple #12
0
        /// <summary>
        /// Detects if the AviSynth version can be used
        /// </summary>
        /// <returns>0 if everything is fine, 3 if the version is outdated or a different value for other errors</param>
        public static int CheckAvisynthInstallation(out string strVersion, out bool bIsAVS26, out bool bIsAVSPlus, out bool bIsMT, out string strAviSynthDLL, ref core.util.LogItem oLog)
        {
            strVersion     = "";
            bIsAVS26       = false;
            bIsAVSPlus     = false;
            bIsMT          = false;
            strAviSynthDLL = string.Empty;

            IntPtr             _avs        = new IntPtr(0);
            AVSDLLVideoInfo    _vi         = new AVSDLLVideoInfo();
            AviSynthColorspace _colorSpace = AviSynthColorspace.Unknown;
            AudioSampleType    _sampleType = AudioSampleType.Unknown;

            int iStartResult = -1;

            try
            {
                iStartResult = dimzon_avs_init_2(ref _avs, "Eval", "Version()", ref _vi, ref _colorSpace, ref _sampleType, AviSynthColorspace.RGB24.ToString());

                foreach (System.Diagnostics.ProcessModule module in System.Diagnostics.Process.GetCurrentProcess().Modules)
                {
                    if (module.FileName.ToLowerInvariant().EndsWith("avisynth.dll"))
                    {
                        strAviSynthDLL = module.FileName.ToLowerInvariant();
                    }
                }

                if (iStartResult == 0)
                {
                    int iWrapperVersion = GetAvisynthWrapperInterfaceVersion();
                    try
                    {
                        const int     errlen = 1024;
                        StringBuilder sb     = new StringBuilder(errlen);
                        sb.Length  = dimzon_avs_getstrfunction(_avs, "VersionString", sb, errlen);
                        strVersion = sb.ToString();

                        bool bResult = false;
                        int  iResult = dimzon_avs_functionexists(_avs, "AutoloadPlugins", ref bResult);
                        bIsAVSPlus = false;
                        if (iResult == 0)
                        {
                            bIsAVSPlus = bResult;
                        }

                        if (iWrapperVersion < 5)
                        {
                            bResult  = false;
                            iResult  = dimzon_avs_functionexists(_avs, "ConvertToYV16", ref bResult);
                            bIsAVS26 = false;
                            if (iResult == 0)
                            {
                                bIsAVS26 = bResult;
                            }
                        }
                        else
                        {
                            bIsAVS26 = true;
                        }

                        string strMTFunction = "Prefetch";
                        if (!bIsAVSPlus)
                        {
                            strMTFunction = "SetMTMode";
                        }
                        bResult = false;
                        iResult = dimzon_avs_functionexists(_avs, strMTFunction, ref bResult);
                        bIsMT   = false;
                        if (iResult == 0)
                        {
                            bIsMT = bResult;
                        }
                    }
                    catch (Exception ex)
                    {
                        oLog.LogValue("Error", ex.Message, core.util.ImageType.Error, false);
                    }
                }

                int iCloseResult = dimzon_avs_destroy(ref _avs);
                if (_avs != IntPtr.Zero)
                {
                    CloseHandle(_avs);
                }
                _avs = IntPtr.Zero;
            }
            catch (Exception ex)
            {
                oLog.LogValue("Error", ex.Message, core.util.ImageType.Error, false);
            }

            return(iStartResult);
        }
Exemple #13
0
 private static extern int dimzon_avs_init_2(ref IntPtr avs, string func, string arg, ref AVSDLLVideoInfo vi, ref AviSynthColorspace originalColorspace, ref AudioSampleType originalSampleType, string cs);
Exemple #14
0
        //Только инициализация
        public AviSynthClip()
        {
            _avs = new IntPtr(0);
            _vi = new AVSDLLVideoInfo();

            //Просто получаем Handle и выходим
            if (0 != dimzon_avs_init(ref _avs, null, null, ref _vi))
            {
                string err = GetLastError();
                cleanup(false);
                throw new AviSynthException(err);
            }
        }
Exemple #15
0
 private static extern int dimzon_avs_invoke(IntPtr avs, string func, string[] args, int len, ref AVSDLLVideoInfo vi, ref float func_out);
Exemple #16
0
 private static extern int avs_invoke(IntPtr avs, int clp, string func, string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, bool clip, ref AVSDLLVideoInfo vi);
Exemple #17
0
 private static extern int dimzon_avs_invoke(IntPtr avs, string func, string[] args, int len, ref AVSDLLVideoInfo vi, ref float func_out);