コード例 #1
0
        private void PlayScript(string script)
        {
            try
            {
                reader = new AviSynthReader();
                reader.ParseScript(script);
                int total = reader.FrameCount;

                for (int i = 0; i < total && !IsAborted; i++)
                {
                    reader.ReadFrameDummy(i);
                    worker.ReportProgress(((i + 1) * 100) / total);
                }
            }
            catch (Exception ex)
            {
                if (!IsAborted && num_closes == 0)
                {
                    IsErrors   = true;
                    ErrorText  = "SourceDetector (PlayScript): " + ex.Message;
                    StackTrace = ex.StackTrace;
                    Script     = script;
                }
            }
            finally
            {
                CloseReader(true);
            }
        }
コード例 #2
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                reader = new AviSynthReader();
                reader.ParseScript(script);
                total = reader.FrameCount;
                start = DateTime.Now;

                for (int i = 0; i < total && !IsAborted; i++)
                {
                    reader.ReadFrameDummy(i);
                    worker.ReportProgress(i + 1, DateTime.Now);
                }
            }
            catch (Exception ex)
            {
                if (!IsAborted && num_closes == 0)
                {
                    e.Result = ex;
                }
            }
            finally
            {
                CloseReader(true);
            }
        }
コード例 #3
0
ファイル: ScriptRunner.xaml.cs プロジェクト: MaksHDR/xvid4psp
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                reader = new AviSynthReader();
                reader.ParseScript(script);
                total = reader.FrameCount;
                start = DateTime.Now;

                for (int i = 0; i < total && !IsAborted; i++)
                {
                    reader.ReadFrameDummy(i);
                    worker.ReportProgress(i + 1, DateTime.Now);
                }
            }
            catch (Exception ex)
            {
                if (!IsAborted && num_closes == 0)
                {
                    e.Result = ex;
                }
            }
            finally
            {
                CloseReader(true);
            }
        }
コード例 #4
0
        private void PlayScript(string script)
        {
            try
            {
                reader = new AviSynthReader();
                reader.ParseScript(script);
                int total = reader.FrameCount;

                for (int i = 0; i < total && !IsAborted; i++)
                {
                    reader.ReadFrameDummy(i);
                    worker.ReportProgress(((i + 1) * 100) / total);
                }
            }
            catch (Exception ex)
            {
                if (!IsAborted && num_closes == 0)
                {
                    IsErrors = true;
                    ErrorText = "SourceDetector (PlayScript): " + ex.Message;
                    StackTrace = ex.StackTrace;
                    Script = script;
                }
            }
            finally
            {
                CloseReader(true);
            }
        }
コード例 #5
0
ファイル: Autocrop.xaml.cs プロジェクト: DaVinciUA/xvid4psp
        private void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            try
            {
                //Готовим скрипт
                script = AviSynthScripting.GetInfoScript(m, AviSynthScripting.ScriptMode.Autocrop);
                script = AviSynthScripting.TuneAutoCropScript(script, frame);

                //Открываем скрипт
                reader = new AviSynthReader();
                reader.ParseScript(script);

                int width  = m.inresw;
                int height = m.inresh;
                int frames = reader.FrameCount;

                ArrayList ll = new ArrayList();
                ArrayList tt = new ArrayList();
                ArrayList rr = new ArrayList();
                ArrayList bb = new ArrayList();

                //Проигрываем все кадры и считываем значения кропа
                for (int i = 0; i < frames && !worker.CancellationPending; i++)
                {
                    reader.ReadFrameDummy(i);
                    worker.ReportProgress(((i + 1) * 100) / frames);

                    //Фильтрация возможных(?) недопустимых значений
                    ll.Add(Math.Min(Math.Max(reader.GetVarInteger("crop_left", 0), 0), width));
                    tt.Add(Math.Min(Math.Max(reader.GetVarInteger("crop_top", 0), 0), height));
                    rr.Add(Math.Min(Math.Max(reader.GetVarInteger("crop_right", 0), 0), width));
                    bb.Add(Math.Min(Math.Max(reader.GetVarInteger("crop_bottom", 0), 0), height));
                }

                //Анализ полученного
                if (!worker.CancellationPending)
                {
                    if (ll.Count > 0)
                    {
                        bool new_mode = Settings.AutocropMostCommon;

                        //Ищем наиболее часто встречающиеся значения ("усредняем") или берём минимальные значения
                        m.cropl = m.cropl_copy = (ll.Count > 4 && new_mode) ? FindMostCommon(ll) : FindMinimum(ll);  //Слева
                        m.cropt = m.cropt_copy = (tt.Count > 4 && new_mode) ? FindMostCommon(tt) : FindMinimum(tt);  //Сверху
                        m.cropr = m.cropr_copy = (rr.Count > 4 && new_mode) ? FindMostCommon(rr) : FindMinimum(rr);  //Справа
                        m.cropb = m.cropb_copy = (bb.Count > 4 && new_mode) ? FindMostCommon(bb) : FindMinimum(bb);  //Снизу
                    }
                    else
                    {
                        m.cropl = m.cropl_copy = 0;  //Слева
                        m.cropt = m.cropt_copy = 0;  //Сверху
                        m.cropr = m.cropr_copy = 0;  //Справа
                        m.cropb = m.cropb_copy = 0;  //Снизу
                    }
                }
            }
            catch (Exception ex)
            {
                if (worker != null && !worker.CancellationPending && m != null && num_closes == 0)
                {
                    //Ошибка
                    ex.HelpLink = script;
                    e.Result    = ex;
                }
            }
            finally
            {
                CloseReader(true);
            }
        }