示例#1
0
        public static Massive DecodeLine(Massive m)
        {
            //Дефолты
            Presets preset = Presets.Medium;
            Tunes tune = Tunes.None;
            Profiles profile = Profiles.Auto;
            Settings.EncodingModes mode = new Settings.EncodingModes();

            //берём за основу последнюю строку
            string line = m.vpasses[m.vpasses.Count - 1].ToString();

            //Определяем пресет, для этого ищем ключ --preset
            string preset_name = Calculate.GetRegexValue(@"\-\-preset\s+(\w+)", line);
            if (!string.IsNullOrEmpty(preset_name))
            {
                try
                {
                    //Определяем preset по его названию или номеру
                    preset = (Presets)Enum.Parse(typeof(Presets), preset_name, true);
                }
                catch { }
            }

            //Ищем --tune
            string tune_name = Calculate.GetRegexValue(@"\-\-tune\s+(\w+)", line);
            if (!string.IsNullOrEmpty(tune_name))
            {
                try
                {
                    //Определяем tune по его названию
                    tune = (Tunes)Enum.Parse(typeof(Tunes), tune_name, true);
                }
                catch { }
            }

            //Ищем --profile (определяем 10-битность)
            string profile_name = Calculate.GetRegexValue(@"\-\-profile\s+(\w+)", line);
            if (!string.IsNullOrEmpty(profile_name))
            {
                try
                {
                    //Определяем profile по его названию
                    profile = (Profiles)Enum.Parse(typeof(Profiles), profile_name, true);
                }
                catch { }
            }

            //Создаём свежий массив параметров x264 (изменяя дефолты с учетом --preset и --tune)
            m.x264options = new x264_arguments(preset, tune, profile);
            m.x264options.profile = profile;
            m.x264options.preset = preset;
            m.x264options.tune = tune;

            int n = 0;
            string[] cli = line.Split(new string[] { " " }, StringSplitOptions.None);
            foreach (string value in cli)
            {
                if (m.vpasses.Count == 1)
                {
                    if (value == "--crf")
                    {
                        mode = Settings.EncodingModes.Quality;
                        m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                    else if (value == "--bitrate" || value == "-B")
                    {
                        mode = Settings.EncodingModes.OnePass;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                    else if (value == "--qp" || value == "-q")
                    {
                        mode = Settings.EncodingModes.Quantizer;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                }
                else if (m.vpasses.Count == 2)
                {
                    if (value == "--crf")
                    {
                        mode = Settings.EncodingModes.TwoPassQuality;
                        m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                    else if (value == "--bitrate" || value == "-B")
                    {
                        mode = Settings.EncodingModes.TwoPass;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                    else if (value == "--size")
                    {
                        mode = Settings.EncodingModes.TwoPassSize;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                }
                else if (m.vpasses.Count == 3)
                {
                    if (value == "--crf")
                    {
                        mode = Settings.EncodingModes.ThreePassQuality;
                        m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                    else if (value == "--bitrate" || value == "-B")
                    {
                        mode = Settings.EncodingModes.ThreePass;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                    else if (value == "--size")
                    {
                        mode = Settings.EncodingModes.ThreePassSize;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                }

                if (value == "--level")
                    m.x264options.level = cli[n + 1];

                else if (value == "--ref" || value == "-r")
                    m.x264options.reference = Convert.ToInt32(cli[n + 1]);

                else if (value == "--aq-strength")
                    m.x264options.aqstrength = cli[n + 1];

                else if (value == "--aq-mode")
                    m.x264options.aqmode = Convert.ToInt32(cli[n + 1]);

                else if (value == "--no-psy")
                    m.x264options.no_psy = true;

                else if (value == "--psy-rd")
                {
                    string[] psyvalues = cli[n + 1].Split(new string[] { ":" }, StringSplitOptions.None);
                    m.x264options.psyrdo = (decimal)Calculate.ConvertStringToDouble(psyvalues[0]);
                    m.x264options.psytrellis = (decimal)Calculate.ConvertStringToDouble(psyvalues[1]);
                }

                else if (value == "--partitions" || value == "--analyse" || value == "-A")
                    m.x264options.analyse = cli[n + 1];

                else if (value == "--deblock" || value == "--filter" || value == "-f")
                {
                    string[] fvalues = cli[n + 1].Split(new string[] { ":" }, StringSplitOptions.None);
                    m.x264options.deblocks = Convert.ToInt32(fvalues[0]);
                    m.x264options.deblockt = Convert.ToInt32(fvalues[1]);
                }

                else if (value == "--subme" || value == "-m")
                    m.x264options.subme = Convert.ToInt32(cli[n + 1]);

                else if (value == "--me")
                    m.x264options.me = cli[n + 1];

                else if (value == "--merange")
                    m.x264options.merange = Convert.ToInt32(cli[n + 1]);

                else if (value == "--no-chroma-me")
                    m.x264options.no_chroma = true;

                else if (value == "--bframes" || value == "-b")
                    m.x264options.bframes = Convert.ToInt32(cli[n + 1]);

                else if (value == "--direct")
                    m.x264options.direct = cli[n + 1];

                else if (value == "--b-adapt")
                    m.x264options.b_adapt = Convert.ToInt32(cli[n + 1]);

                else if (value == "--b-pyramid")
                {
                    if ((cli[n + 1]) == "none" || (cli[n + 1]) == "0")
                        m.x264options.bpyramid = 0;
                    else if ((cli[n + 1]) == "strict" || (cli[n + 1]) == "1")
                        m.x264options.bpyramid = 1;
                    else if ((cli[n + 1]) == "normal" || (cli[n + 1]) == "2")
                        m.x264options.bpyramid = 2;
                }

                else if (value == "--no-weightb")
                    m.x264options.weightb = false;

                else if (value == "--weightp")
                    m.x264options.weightp = Convert.ToInt32(cli[n + 1]);

                else if (value == "--no-8x8dct")
                    m.x264options.adaptivedct = false;

                else if (value == "--trellis" || value == "-t")
                    m.x264options.trellis = Convert.ToInt32(cli[n + 1]);

                else if (value == "--no-mixed-refs")
                    m.x264options.mixedrefs = false;

                else if (value == "--no-cabac")
                    m.x264options.cabac = false;

                else if (value == "--no-fast-pskip")
                    m.x264options.no_fastpskip = true;

                else if (value == "--no-dct-decimate")
                    m.x264options.no_dctdecimate = true;

                else if (value == "--cqm")
                    m.x264options.custommatrix = cli[n + 1];

                else if (value == "--no-deblock" || value == "--nf")
                    m.x264options.deblocking = false;

                else if (value == "--qpmin")
                    m.x264options.min_quant = Convert.ToInt32(cli[n + 1]);

                else if (value == "--qpmax")
                    m.x264options.max_quant = Convert.ToInt32(cli[n + 1]);

                else if (value == "--qpstep")
                    m.x264options.step_quant = Convert.ToInt32(cli[n + 1]);

                else if (value == "--aud")
                    m.x264options.aud = true;

                else if (value == "--pictiming")
                    m.x264options.pictiming = true;

                else if (value == "--threads")
                    m.x264options.threads = cli[n + 1];

                else if (value == "--thread-input")
                    m.x264options.thread_input = true;

                else if (value == "--qcomp")
                    m.x264options.qcomp = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);

                else if (value == "--vbv-maxrate")
                    m.x264options.vbv_maxrate = Convert.ToInt32(cli[n + 1]);

                else if (value == "--vbv-bufsize")
                    m.x264options.vbv_bufsize = Convert.ToInt32(cli[n + 1]);

                else if (value == "--vbv-init")
                    m.x264options.vbv_init = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);

                else if (value == "--chroma-qp-offset")
                    m.x264options.qp_offset = Convert.ToInt32(cli[n + 1]);

                else if (value == "--slow-firstpass")
                    m.x264options.slow_frstpass = true;

                else if (value == "--no-mbtree")
                    m.x264options.no_mbtree = true;

                else if (value == "--rc-lookahead")
                    m.x264options.lookahead = Convert.ToInt32(cli[n + 1]);

                else if (value == "--lookahead-threads")
                    m.x264options.lookahead_threads = cli[n + 1];

                else if (value == "--nal-hrd")
                    m.x264options.nal_hrd = cli[n + 1];

                else if (value == "--min-keyint")
                    m.x264options.gop_min = Convert.ToInt32(cli[n + 1]);

                else if (value == "--keyint")
                {
                    int _value = 0;
                    Int32.TryParse(cli[n + 1], out _value);
                    m.x264options.gop_max = _value;
                }

                else if (value == "--ipratio")
                    m.x264options.ratio_ip = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);

                else if (value == "--pbratio")
                    m.x264options.ratio_pb = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);

                else if (value == "--open-gop")
                    m.x264options.open_gop = true;

                else if (value == "--slices")
                    m.x264options.slices = Convert.ToInt32(cli[n + 1]);

                else if (value == "--pic-struct")
                    m.x264options.pic_struct = true;

                else if (value == "--fake-interlaced")
                    m.x264options.fake_int = true;

                else if (value == "--input-range")
                    m.x264options.range_in = cli[n + 1];

                else if (value == "--range")
                    m.x264options.range_out = cli[n + 1];

                else if (value == "--colorprim")
                {
                    string _value = cli[n + 1].Trim(new char[] { '"' });
                    if (_value == "undef")
                        m.x264options.colorprim = "Undefined";
                    else
                        m.x264options.colorprim = _value;
                }

                else if (value == "--transfer")
                {
                    string _value = cli[n + 1].Trim(new char[] { '"' });
                    if (_value == "undef")
                        m.x264options.transfer = "Undefined";
                    else
                        m.x264options.transfer = _value;
                }

                else if (value == "--colormatrix")
                {
                    string _value = cli[n + 1].Trim(new char[] { '"' });
                    if (_value == "undef")
                        m.x264options.colormatrix = "Undefined";
                    else
                        m.x264options.colormatrix = _value;
                }

                else if (value == "--output-csp")
                    m.x264options.colorspace = cli[n + 1].ToUpper();

                else if (value == "--non-deterministic")
                    m.x264options.non_deterministic = true;

                else if (value == "--bluray-compat")
                    m.x264options.bluray = true;

                else if (value == "--extra:")
                {
                    for (int i = n + 1; i < cli.Length; i++)
                        m.x264options.extra_cli += cli[i] + " ";

                    m.x264options.extra_cli = m.x264options.extra_cli.Trim();
                }

                n++;
            }

            //Сброс на дефолт, если в CLI нет параметров кодирования
            if (mode == 0)
            {
                m.encodingmode = Settings.EncodingModes.Quality;
                m.outvbitrate = 23;
            }
            else
                m.encodingmode = mode;

            return m;
        }
示例#2
0
        public void LoadFromProfile()
        {
            SetMinMaxBitrate();

            combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
            if (combo_mode.SelectedItem == null)
            {
                m.encodingmode = Settings.EncodingModes.Quality;
                combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
                SetMinMaxBitrate();
                SetDefaultBitrates();
            }

            //запоминаем первичные режим кодирования
            oldmode = m.encodingmode;

            if (m.encodingmode == Settings.EncodingModes.OnePass ||
                m.encodingmode == Settings.EncodingModes.TwoPass ||
                m.encodingmode == Settings.EncodingModes.ThreePass)
            {
                text_bitrate.Content = Languages.Translate("Bitrate") + ": (kbps)";
                num_bitrate.Value = (decimal)m.outvbitrate;
            }
            else if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                     m.encodingmode == Settings.EncodingModes.ThreePassSize)
            {
                text_bitrate.Content = Languages.Translate("Size") + ": (MB)";
                num_bitrate.Value = (decimal)m.outvbitrate;
            }
            else
            {
                if (m.encodingmode == Settings.EncodingModes.Quantizer)
                    text_bitrate.Content = Languages.Translate("Quantizer") + ": (Q)";
                else
                    text_bitrate.Content = Languages.Translate("Quality") + ": (CRF)";

                num_bitrate.Value = (decimal)m.outvbitrate;
            }

            //lossless
            check_lossless.IsChecked = IsLossless(m);

            //Встроенный в x264 пресет
            text_preset_name.Content = m.x264options.preset.ToString();
            slider_preset.Value = (int)m.x264options.preset;

            //AVC level
            if (m.x264options.level == "unrestricted") combo_level.SelectedIndex = 0;
            else combo_level.SelectedItem = m.x264options.level;

            //Tune
            combo_tune.SelectedIndex = (int)m.x264options.tune;

            combo_adapt_quant_mode.SelectedIndex = m.x264options.aqmode;
            combo_adapt_quant.SelectedItem = m.x264options.aqstrength;

            num_psyrdo.Value = m.x264options.psyrdo;
            num_psytrellis.Value = m.x264options.psytrellis;
            num_qcomp.Value = m.x264options.qcomp;
            num_vbv_max.Value = m.x264options.vbv_maxrate;
            num_vbv_buf.Value = m.x264options.vbv_bufsize;
            num_vbv_init.Value = m.x264options.vbv_init;

            //прописываем макроблоки
            if (m.x264options.analyse == "none")
            {
                check_p8x8.IsChecked = false;
                check_i8x8.IsChecked = false;
                check_b8x8.IsChecked = false;
                check_i4x4.IsChecked = false;
                check_p4x4.IsChecked = false;
            }
            else if (m.x264options.analyse == "all")
            {
                check_p8x8.IsChecked = true;
                check_i8x8.IsChecked = true;
                check_b8x8.IsChecked = true;
                check_i4x4.IsChecked = true;
                check_p4x4.IsChecked = true;
            }
            else
            {
                check_p8x8.IsChecked = m.x264options.analyse.Contains("p8x8");
                check_i8x8.IsChecked = m.x264options.analyse.Contains("i8x8");
                check_b8x8.IsChecked = m.x264options.analyse.Contains("b8x8");
                check_i4x4.IsChecked = m.x264options.analyse.Contains("i4x4");
                check_p4x4.IsChecked = m.x264options.analyse.Contains("p4x4");
            }

            //adaptive dct
            check_8x8dct.IsChecked = m.x264options.adaptivedct;

            //прогружаем деблокинг
            combo_dstrength.SelectedItem = m.x264options.deblocks;
            combo_dthreshold.SelectedItem = m.x264options.deblockt;
            check_deblocking.IsChecked = m.x264options.deblocking;

            //Прописываем subme
            combo_subme.SelectedIndex = m.x264options.subme;

            //прописываем me алгоритм
            if (m.x264options.me == "dia") combo_me.SelectedIndex = 0;
            else if (m.x264options.me == "hex") combo_me.SelectedIndex = 1;
            else if (m.x264options.me == "umh") combo_me.SelectedIndex = 2;
            else if (m.x264options.me == "esa") combo_me.SelectedIndex = 3;
            else if (m.x264options.me == "tesa") combo_me.SelectedIndex = 4;

            //прописываем me range
            combo_merange.SelectedItem = m.x264options.merange;

            //прописываем chroma me
            check_chroma.IsChecked = m.x264options.no_chroma;

            //B фреймы
            combo_bframes.SelectedItem = m.x264options.bframes;

            //режим B фреймов
            if (m.x264options.direct == "none") combo_bframe_mode.SelectedIndex = 0;
            else if (m.x264options.direct == "spatial") combo_bframe_mode.SelectedIndex = 1;
            else if (m.x264options.direct == "temporal") combo_bframe_mode.SelectedIndex = 2;
            else if (m.x264options.direct == "auto") combo_bframe_mode.SelectedIndex = 3;

            if (!m.x264options.open_gop) combo_open_gop.SelectedIndex = 0;
            else combo_open_gop.SelectedIndex = 1;

            if (m.x264options.nal_hrd == "none") combo_nal_hrd.SelectedIndex = 0;
            else if (m.x264options.nal_hrd == "vbr") combo_nal_hrd.SelectedIndex = 1;
            else if (m.x264options.nal_hrd == "cbr") combo_nal_hrd.SelectedIndex = 2;

            //b-pyramid
            combo_bpyramid_mode.SelectedIndex = m.x264options.bpyramid;

            //weightb
            check_weightedb.IsChecked = m.x264options.weightb;

            //weightp
            combo_weightp_mode.SelectedIndex = m.x264options.weightp;

            //trellis
            combo_trellis.SelectedIndex = m.x264options.trellis;

            //refernce frames
            combo_ref.SelectedItem = m.x264options.reference;

            //mixed reference
            check_mixed_ref.IsChecked = m.x264options.mixedrefs;

            //cabac
            check_cabac.IsChecked = m.x264options.cabac;

            //fast p skip
            check_fast_pskip.IsChecked = m.x264options.no_fastpskip;

            //dct decimate
            check_dct_decimate.IsChecked = m.x264options.no_dctdecimate;

            //min-max quantizer
            num_min_quant.Value = m.x264options.min_quant;
            num_max_quant.Value = m.x264options.max_quant;
            num_step_quant.Value = m.x264options.step_quant;

            num_min_gop.Value = m.x264options.gop_min;
            num_max_gop.Value = m.x264options.gop_max;

            combo_badapt_mode.SelectedIndex = m.x264options.b_adapt;
            num_chroma_qp.Value = m.x264options.qp_offset;
            check_slow_first.IsChecked = m.x264options.slow_frstpass;
            check_nombtree.IsChecked = m.x264options.no_mbtree;
            num_lookahead.Value = m.x264options.lookahead;

            if (m.x264options.lookahead_threads == "auto") combo_lookahead_threads.SelectedIndex = 0;
            else combo_lookahead_threads.SelectedItem = m.x264options.lookahead_threads;

            check_enable_psy.IsChecked = !m.x264options.no_psy;
            check_aud.IsChecked = m.x264options.aud;
            num_ratio_ip.Value = m.x264options.ratio_ip;
            num_ratio_pb.Value = m.x264options.ratio_pb;
            num_slices.Value = m.x264options.slices;
            check_pic_struct.IsChecked = m.x264options.pic_struct;
            check_fake_int.IsChecked = m.x264options.fake_int;

            if (m.x264options.range_in == "auto") combo_range_in.SelectedIndex = 0;
            else if (m.x264options.range_in == "tv") combo_range_in.SelectedIndex = 1;
            else if (m.x264options.range_in == "pc") combo_range_in.SelectedIndex = 2;

            if (m.x264options.range_out == "auto") combo_range_out.SelectedIndex = 0;
            else if (m.x264options.range_out == "tv") combo_range_out.SelectedIndex = 1;
            else if (m.x264options.range_out == "pc") combo_range_out.SelectedIndex = 2;

            combo_colorprim.SelectedItem = m.x264options.colorprim;
            combo_transfer.SelectedItem = m.x264options.transfer;
            combo_colormatrix.SelectedItem = m.x264options.colormatrix;
            combo_colorspace.SelectedItem = m.x264options.colorspace;
            check_non_deterministic.IsChecked = m.x264options.non_deterministic;
            check_bluray.IsChecked = m.x264options.bluray;

            //Кол-во потоков для x264-го
            if (m.x264options.threads == "auto") combo_threads_count.SelectedIndex = 0;
            else if (m.x264options.threads == "1" && m.x264options.thread_input) combo_threads_count.SelectedIndex = 2;
            else combo_threads_count.SelectedItem = m.x264options.threads;

            //Включаем-выключаем элементы.
            //Сначала на основе --preset.
            if (m.x264options.preset == Presets.Ultrafast)
            {
                check_slow_first.IsEnabled = !m.x264options.extra_cli.Contains("--slow-firstpass");
                check_cabac.IsEnabled = false;
                check_deblocking.IsEnabled = false;
                check_mixed_ref.IsEnabled = false;
                check_fast_pskip.IsEnabled = !m.x264options.extra_cli.Contains("--no-fast-pskip");
                check_8x8dct.IsEnabled = false;
                check_nombtree.IsEnabled = false;
                check_weightedb.IsEnabled = false;
            }
            else if (m.x264options.preset == Presets.Superfast)
            {
                check_slow_first.IsEnabled = !m.x264options.extra_cli.Contains("--slow-firstpass");
                check_mixed_ref.IsEnabled = false;
                check_fast_pskip.IsEnabled = !m.x264options.extra_cli.Contains("--no-fast-pskip");
                check_8x8dct.IsEnabled = !m.x264options.extra_cli.Contains("--no-8x8dct");
                check_nombtree.IsEnabled = false;
            }
            else if (m.x264options.preset == Presets.Veryfast || m.x264options.preset == Presets.Faster)
            {
                check_slow_first.IsEnabled = !m.x264options.extra_cli.Contains("--slow-firstpass");
                check_mixed_ref.IsEnabled = false;
                check_fast_pskip.IsEnabled = !m.x264options.extra_cli.Contains("--no-fast-pskip");
                check_8x8dct.IsEnabled = !m.x264options.extra_cli.Contains("--no-8x8dct");
                check_nombtree.IsEnabled = !m.x264options.extra_cli.Contains("--no-mbtree");
            }
            else if (m.x264options.preset == Presets.Placebo)
            {
                check_slow_first.IsEnabled = false;
                check_mixed_ref.IsEnabled = !m.x264options.extra_cli.Contains("--no-mixed-refs");
                check_fast_pskip.IsEnabled = false;
                check_8x8dct.IsEnabled = !m.x264options.extra_cli.Contains("--no-8x8dct");
                check_nombtree.IsEnabled = !m.x264options.extra_cli.Contains("--no-mbtree");
            }
            else
            {
                //Для остальных
                check_slow_first.IsEnabled = !m.x264options.extra_cli.Contains("--slow-firstpass");
                check_mixed_ref.IsEnabled = !m.x264options.extra_cli.Contains("--no-mixed-refs");
                check_fast_pskip.IsEnabled = !m.x264options.extra_cli.Contains("--no-fast-pskip");
                check_8x8dct.IsEnabled = !m.x264options.extra_cli.Contains("--no-8x8dct");
                check_nombtree.IsEnabled = !m.x264options.extra_cli.Contains("--no-mbtree");
            }

            //Tune Grain
            if (m.x264options.tune == Tunes.Grain)
            {
                check_dct_decimate.IsEnabled = false;
            }
            else
                check_dct_decimate.IsEnabled = !m.x264options.extra_cli.Contains("--no-dct-decimate");

            //Tune PSNR и SSIM
            if (m.x264options.tune == Tunes.PSNR || m.x264options.tune == Tunes.SSIM)
            {
                num_psyrdo.IsEnabled = num_psytrellis.IsEnabled = check_enable_psy.IsEnabled = false;
            }
            else
            {
                check_enable_psy.IsEnabled = !m.x264options.extra_cli.Contains("--no-psy");
                num_psyrdo.IsEnabled = num_psytrellis.IsEnabled = (!m.x264options.no_psy && !m.x264options.extra_cli.Contains("--psy-rd "));
            }

            //Tune FastDecode
            if (m.x264options.tune == Tunes.FastDecode)
            {
                check_cabac.IsEnabled = false;
                check_deblocking.IsEnabled = false;
                check_weightedb.IsEnabled = false;
            }
            else
            {
                check_cabac.IsEnabled = ((int)m.x264options.preset > 0) ? !m.x264options.extra_cli.Contains("--no-cabac") : false;
                check_deblocking.IsEnabled = ((int)m.x264options.preset > 0) ? !m.x264options.extra_cli.Contains("--no-deblock") : false;
                check_weightedb.IsEnabled = ((int)m.x264options.preset > 0) ? !m.x264options.extra_cli.Contains("--no-weightb") : false;
            }

            //Теперь на основе содержимого extra_cli
            combo_level.IsEnabled = !m.x264options.extra_cli.Contains("--level ");
            combo_subme.IsEnabled = !m.x264options.extra_cli.Contains("--subme ");
            combo_me.IsEnabled = !m.x264options.extra_cli.Contains("--me ");
            combo_merange.IsEnabled = !m.x264options.extra_cli.Contains("--merange ");
            combo_ref.IsEnabled = !m.x264options.extra_cli.Contains("--ref ");
            check_chroma.IsEnabled = !m.x264options.extra_cli.Contains("--no-chroma-me");
            check_p8x8.IsEnabled = check_p4x4.IsEnabled = check_i8x8.IsEnabled =
                check_b8x8.IsEnabled = check_i4x4.IsEnabled = !m.x264options.extra_cli.Contains("--analyse ");
            combo_bframes.IsEnabled = !m.x264options.extra_cli.Contains("--bframes ");
            combo_bframe_mode.IsEnabled = !m.x264options.extra_cli.Contains("--direct ");
            combo_badapt_mode.IsEnabled = !m.x264options.extra_cli.Contains("--b-adapt ");
            combo_bpyramid_mode.IsEnabled = !m.x264options.extra_cli.Contains("--b-pyramid ");
            combo_weightp_mode.IsEnabled = !m.x264options.extra_cli.Contains("--weightp ");
            num_lookahead.IsEnabled = !m.x264options.extra_cli.Contains("--rc-lookahead ");
            combo_lookahead_threads.IsEnabled = !m.x264options.extra_cli.Contains("--lookahead-threads ");
            combo_trellis.IsEnabled = !m.x264options.extra_cli.Contains("--trellis ");
            combo_adapt_quant_mode.IsEnabled = !m.x264options.extra_cli.Contains("--aq-mode ");
            combo_adapt_quant.IsEnabled = !m.x264options.extra_cli.Contains("--ag-strength ");
            num_vbv_max.IsEnabled = !m.x264options.extra_cli.Contains("--vbv-maxrate ");
            num_vbv_buf.IsEnabled = !m.x264options.extra_cli.Contains("--vbv-bufsize ");
            num_vbv_init.IsEnabled = !m.x264options.extra_cli.Contains("--vbv-init ");
            num_min_gop.IsEnabled = !m.x264options.extra_cli.Contains("--min-keyint ");
            num_max_gop.IsEnabled = !m.x264options.extra_cli.Contains("--keyint ");
            num_min_quant.IsEnabled = !m.x264options.extra_cli.Contains("--qpmin ");
            num_max_quant.IsEnabled = !m.x264options.extra_cli.Contains("--qpmax ");
            num_step_quant.IsEnabled = !m.x264options.extra_cli.Contains("--qpstep ");
            num_qcomp.IsEnabled = !m.x264options.extra_cli.Contains("--qcomp ");
            num_chroma_qp.IsEnabled = !m.x264options.extra_cli.Contains("--chroma-qp-offset ");
            combo_nal_hrd.IsEnabled = !m.x264options.extra_cli.Contains("--nal-hrd ");
            check_aud.IsEnabled = !m.x264options.extra_cli.Contains("--aud");
            num_ratio_ip.IsEnabled = !m.x264options.extra_cli.Contains("--ipratio ");
            num_ratio_pb.IsEnabled = !m.x264options.extra_cli.Contains("--pbratio ");
            combo_open_gop.IsEnabled = !m.x264options.extra_cli.Contains("--open-gop");
            num_slices.IsEnabled = !m.x264options.extra_cli.Contains("--slices ");
            check_pic_struct.IsEnabled = !m.x264options.extra_cli.Contains("--pic-struct");
            check_fake_int.IsEnabled = !m.x264options.extra_cli.Contains("--fake-interlaced");
            combo_range_in.IsEnabled = !m.x264options.extra_cli.Contains("--input-range ");
            combo_range_out.IsEnabled = !m.x264options.extra_cli.Contains("--range ");
            combo_colorprim.IsEnabled = !m.x264options.extra_cli.Contains("--colorprim ");
            combo_transfer.IsEnabled = !m.x264options.extra_cli.Contains("--transfer ");
            combo_colormatrix.IsEnabled = !m.x264options.extra_cli.Contains("--colormatrix ");
            combo_colorspace.IsEnabled = !m.x264options.extra_cli.Contains("--output-csp ");
            check_non_deterministic.IsEnabled = !m.x264options.extra_cli.Contains("--non-deterministic");
            check_bluray.IsEnabled = !m.x264options.extra_cli.Contains("--bluray-compat");

            //И дополнительно на основе --profile
            /*if (m.x264options.profile == Profiles.Baseline)
            {
                check_8x8dct.IsEnabled = false;
                combo_bframes.IsEnabled = false;
                check_cabac.IsEnabled = false;
                combo_weightp_mode.IsEnabled = false;
            }
            else if (m.x264options.profile == Profiles.Main)
            {
                check_8x8dct.IsEnabled = false;
            }*/

            SetAVCProfile();
            SetToolTips();
            UpdateCLI();
        }
示例#3
0
        public static Massive DecodeLine(Massive m)
        {
            //создаём свежий массив параметров ffmpeg
            m.ffmpeg_options = new ffmpeg_arguments();

            Settings.EncodingModes mode = new Settings.EncodingModes();

            //берём пока что за основу последнюю строку
            string line = m.vpasses[m.vpasses.Count - 1].ToString();

            string value = "";
            string[] cli = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int n = 0; n < cli.Length; n++)
            {
                value = cli[n];

                if (value == "-vcodec" || value == "-c:v")
                    m.ffmpeg_options.vcodec = cli[++n];

                else if (value == "-vtag" || value == "-tag:v")
                    m.ffmpeg_options.fourcc = cli[++n];

                else if (value == "-b:v" || value == "-b")
                {
                    m.outvbitrate = Convert.ToInt32(cli[++n]) / 1000;

                    if (m.vpasses.Count == 1) mode = Settings.EncodingModes.OnePass;
                    else if (m.vpasses.Count == 2) mode = Settings.EncodingModes.TwoPass;
                    else if (m.vpasses.Count == 3) mode = Settings.EncodingModes.ThreePass;
                }
                else if (value == "-sizemode")
                {
                    m.outvbitrate = Convert.ToInt32(cli[++n]) / 1000;

                    if (m.vpasses.Count == 1) mode = Settings.EncodingModes.OnePassSize;
                    else if (m.vpasses.Count == 2) mode = Settings.EncodingModes.TwoPassSize;
                    else if (m.vpasses.Count == 3) mode = Settings.EncodingModes.ThreePassSize;
                }
                else if (value == "-q:v" || value == "-qscale:v" || value == "-qscale")
                {
                    m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[++n]);

                    if (m.vpasses.Count == 1) mode = Settings.EncodingModes.Quality;
                    else if (m.vpasses.Count == 2) mode = Settings.EncodingModes.TwoPassQuality;
                    else if (m.vpasses.Count == 3) mode = Settings.EncodingModes.ThreePassQuality;
                }

                else if (value == "-maxrate")
                    m.ffmpeg_options.maxbitrate = Convert.ToInt32(cli[++n]) / 1000;

                else if (value == "-minrate")
                    m.ffmpeg_options.minbitrate = Convert.ToInt32(cli[++n]) / 1000;

                else if (value == "-bufsize")
                    m.ffmpeg_options.buffsize = Convert.ToInt32(cli[++n]) / 1000;

                else if (value == "-bt")
                    m.ffmpeg_options.bittolerance = Convert.ToInt32(cli[++n]) / 1000;

                else if (value == "-trellis")
                    m.ffmpeg_options.trellis = (Convert.ToInt32(cli[++n]) > 0);

                else if (value == "-mbd")
                {
                    string next = cli[++n];
                    if (next == "0") m.ffmpeg_options.mbd = "simple";
                    else if (next == "1") m.ffmpeg_options.mbd = "bits";
                    else if (next == "2") m.ffmpeg_options.mbd = "rd";
                    else m.ffmpeg_options.mbd = next;
                }

                else if (value == "-cmp")
                {
                    int val = 0;
                    string next = cli[++n];
                    if (Int32.TryParse(next, out val))
                    {
                        m.ffmpeg_options.cmp = val;
                    }
                    else
                    {
                        if (next == "sad") m.ffmpeg_options.cmp = 0;
                        else if (next == "sse") m.ffmpeg_options.cmp = 1;
                        else if (next == "satd") m.ffmpeg_options.cmp = 2;
                        else if (next == "dct") m.ffmpeg_options.cmp = 3;
                        else if (next == "psnr") m.ffmpeg_options.cmp = 4;
                        else if (next == "bit") m.ffmpeg_options.cmp = 5;
                        else if (next == "rd") m.ffmpeg_options.cmp = 6;
                        else if (next == "zero") m.ffmpeg_options.cmp = 7;
                        else if (next == "vsad") m.ffmpeg_options.cmp = 8;
                        else if (next == "vsse") m.ffmpeg_options.cmp = 9;
                        else if (next == "nsse") m.ffmpeg_options.cmp = 10;
                    }
                }

                else if (value == "-inter_matrix")
                    m.ffmpeg_options.intermatrix = cli[++n];

                else if (value == "-intra_matrix")
                    m.ffmpeg_options.intramatrix = cli[++n];

                else if (value == "-dia_size")
                    m.ffmpeg_options.dia_size = Convert.ToInt32(cli[++n]);

                else if (value == "-bf")
                    m.ffmpeg_options.bframes = Convert.ToInt32(cli[++n]);

                else if (value == "-brd_scale")
                {
                    string next = cli[++n];
                    if (next == "0") m.ffmpeg_options.bdecision = "Disabled";
                    else m.ffmpeg_options.bdecision = next;
                }

                else if (value == "-bidir_refine")
                {
                    string next = cli[++n];
                    if (next == "0") m.ffmpeg_options.brefine = "Disabled";
                    else m.ffmpeg_options.brefine = next;
                }

                else if (value == "-g")
                    m.ffmpeg_options.gopsize = Convert.ToInt32(cli[++n]);

                else if (value == "-threads")
                {
                    string next = cli[++n];
                    if (next == "auto") m.ffmpeg_options.threads = 0;
                    else m.ffmpeg_options.threads = Convert.ToInt32(next);
                }

                //дешифруем флаги
                else if (value == "-flags")
                {
                    string[] flags = cli[++n].Split(new string[] { "+" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string flag in flags)
                    {
                        if (flag == "qpel")
                            m.ffmpeg_options.qpel = true;

                        else if (flag == "gmc")
                            m.ffmpeg_options.gmc = true;

                        else if (flag == "aic")
                            m.ffmpeg_options.aic = true;

                        else if (flag == "mv0")
                            m.ffmpeg_options.mv0 = true;

                        else if (flag == "mv4")
                            m.ffmpeg_options.mv4 = true;

                        else if (flag == "bitexact")
                            m.ffmpeg_options.bitexact = true;

                        else if (flag == "cgop")
                            m.ffmpeg_options.closedgop = true;
                    }
                }

                else if (value == "-mpv_flags")
                {
                    string[] flags = cli[++n].Split(new string[] { "+" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string flag in flags)
                    {
                        if (flag == "qp_rd")
                            m.ffmpeg_options.qprd = true;

                        else if (flag == "cbp_rd")
                            m.ffmpeg_options.cbp = true;

                        else if (flag == "strict_gop")
                            m.ffmpeg_options.enforce_gopsize = true;
                    }
                }

                else if (value == "-extra:")
                {
                    for (int i = n + 1; i < cli.Length; i++)
                        m.ffmpeg_options.extra_cli += cli[i] + " ";

                    m.ffmpeg_options.extra_cli = m.ffmpeg_options.extra_cli.Trim();
                }
            }

            //Сброс на дефолт, если в CLI нет параметров кодирования
            if (mode == 0)
            {
                m.encodingmode = Settings.EncodingModes.OnePass;
                m.outvbitrate = 200;
            }
            else
                m.encodingmode = mode;

            return m;
        }
示例#4
0
        private void combo_mode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (combo_mode.IsDropDownOpen || combo_mode.IsSelectionBoxHighlighted)
            {
                try
                {
                    //запоминаем старый режим
                    oldmode = m.encodingmode;

                    string x264mode = combo_mode.SelectedItem.ToString();
                    if (x264mode == "1-Pass Bitrate") m.encodingmode = Settings.EncodingModes.OnePass;
                    else if (x264mode == "2-Pass Bitrate") m.encodingmode = Settings.EncodingModes.TwoPass;
                    else if (x264mode == "2-Pass Size") m.encodingmode = Settings.EncodingModes.TwoPassSize;
                    else if (x264mode == "3-Pass Bitrate") m.encodingmode = Settings.EncodingModes.ThreePass;
                    else if (x264mode == "3-Pass Size") m.encodingmode = Settings.EncodingModes.ThreePassSize;
                    else if (x264mode == "Constant Quality") m.encodingmode = Settings.EncodingModes.Quality;
                    else if (x264mode == "Constant Quantizer") m.encodingmode = Settings.EncodingModes.Quantizer;
                    else if (x264mode == "2-Pass Quality") m.encodingmode = Settings.EncodingModes.TwoPassQuality;
                    else if (x264mode == "3-Pass Quality") m.encodingmode = Settings.EncodingModes.ThreePassQuality;

                    SetMinMaxBitrate();

                    //Устанавливаем дефолтный битрейт (при необходимости)
                    if (oldmode == Settings.EncodingModes.OnePass ||
                        oldmode == Settings.EncodingModes.TwoPass ||
                        oldmode == Settings.EncodingModes.ThreePass)
                    {
                        if (m.encodingmode != Settings.EncodingModes.OnePass &&
                            m.encodingmode != Settings.EncodingModes.TwoPass &&
                            m.encodingmode != Settings.EncodingModes.ThreePass)
                            SetDefaultBitrates();
                    }
                    else if (oldmode.ToString().Contains("Size") && !m.encodingmode.ToString().Contains("Size"))
                    {
                        SetDefaultBitrates();
                    }
                    else if (oldmode.ToString().Contains("Quality") && !m.encodingmode.ToString().Contains("Quality"))
                    {
                        SetDefaultBitrates();
                    }
                    else if (oldmode == Settings.EncodingModes.Quantizer)
                    {
                        SetDefaultBitrates();
                    }

                    if (m.encodingmode == Settings.EncodingModes.OnePass ||
                        m.encodingmode == Settings.EncodingModes.Quality ||
                        m.encodingmode == Settings.EncodingModes.Quantizer)
                    {
                        if (m.x264options.bframes > 1)
                        {
                            combo_bframe_mode.SelectedItem = "Spatial";
                            m.x264options.direct = "spatial";
                        }
                        else
                        {
                            combo_bframe_mode.SelectedItem = "Disabled";
                            m.x264options.direct = "none";
                        }
                    }
                    else
                    {
                        if (m.x264options.bframes > 1)
                        {
                            combo_bframe_mode.SelectedItem = "Auto";
                            m.x264options.direct = "auto";
                        }
                        else
                        {
                            combo_bframe_mode.SelectedItem = "Disabled";
                            m.x264options.direct = "none";
                        }
                    }

                    check_lossless.IsChecked = IsLossless(m);

                    SetAVCProfile();
                    root_window.UpdateOutSize();
                    root_window.UpdateManualProfile();
                    UpdateCLI();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#5
0
        public void LoadFromProfile()
        {
            SetMinMaxBitrate();

            combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
            if (combo_mode.SelectedItem == null)
            {
                m.encodingmode = Settings.EncodingModes.OnePass;
                combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
                SetMinMaxBitrate();
                SetDefaultBitrates();
            }

            if (m.encodingmode == Settings.EncodingModes.Quality ||
                m.encodingmode == Settings.EncodingModes.Quantizer ||
                m.encodingmode == Settings.EncodingModes.TwoPassQuality ||
                m.encodingmode == Settings.EncodingModes.ThreePassQuality)
                text_bitrate.Content = Languages.Translate("Quantizer") + ": (Q)";
            else if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                m.encodingmode == Settings.EncodingModes.ThreePassSize)
                text_bitrate.Content = Languages.Translate("Size") + ": (MB)";
            else
                text_bitrate.Content = Languages.Translate("Bitrate") + ": (kbps)";

            //запоминаем первичные режим кодирования
            oldmode = m.encodingmode;

            //защита для гладкой смены кодеков
            if (m.outvbitrate > 90000)
                m.outvbitrate = 90000;
            if (m.encodingmode == Settings.EncodingModes.Quality ||
                m.encodingmode == Settings.EncodingModes.Quantizer ||
                m.encodingmode == Settings.EncodingModes.TwoPassQuality ||
                m.encodingmode == Settings.EncodingModes.ThreePassQuality)
            {
                if (m.outvbitrate > 31)
                    m.outvbitrate = 31;
                if (m.outvbitrate == 0)
                    m.outvbitrate = 1;
            }

            if (m.encodingmode == Settings.EncodingModes.OnePass ||
                m.encodingmode == Settings.EncodingModes.TwoPass ||
                m.encodingmode == Settings.EncodingModes.ThreePass)
                num_bitrate.Value = (decimal)m.outvbitrate;
            else if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                     m.encodingmode == Settings.EncodingModes.ThreePassSize)
                num_bitrate.Value = (decimal)m.outvbitrate;
            else
                num_bitrate.Value = (decimal)m.outvbitrate;

            //combo_me_method.SelectedIndex = m.ffmpeg_options.memethod;
            if (m.ffmpeg_options.dia_size == 0)
                combo_me_method.SelectedItem = "Default Search";
            else if (m.ffmpeg_options.dia_size == -2)
                combo_me_method.SelectedItem = "Sab Diamond Search";
            else if (m.ffmpeg_options.dia_size == -1)
                combo_me_method.SelectedItem = "Funny Diamond Search";
            else if (m.ffmpeg_options.dia_size == 2)
                combo_me_method.SelectedItem = "Small Diamond Search";
            else if (m.ffmpeg_options.dia_size == 257)
                combo_me_method.SelectedItem = "L2s Diamond Search";
            else if (m.ffmpeg_options.dia_size == 513)
                combo_me_method.SelectedItem = "HEX Search";
            else if (m.ffmpeg_options.dia_size == 769)
                combo_me_method.SelectedItem = "UMH Search";
            else if (m.ffmpeg_options.dia_size == 1025)
                combo_me_method.SelectedItem = "Full Search";

            combo_cmp.SelectedIndex = m.ffmpeg_options.cmp;
            check_trellis.IsChecked = m.ffmpeg_options.trellis;
            combo_bframes.SelectedItem = m.ffmpeg_options.bframes;
            check_qprd.IsChecked = m.ffmpeg_options.qprd;
            check_cbp.IsChecked = m.ffmpeg_options.cbp;
            combo_fourcc.SelectedItem = m.ffmpeg_options.fourcc_mpeg2;
            combo_bdecision.SelectedItem = m.ffmpeg_options.bdecision;
            combo_brefine.SelectedItem = m.ffmpeg_options.brefine;
            check_bitexact.IsChecked = m.ffmpeg_options.bitexact;
            check_intra.IsChecked = m.ffmpeg_options.intra;

            num_gopsize.Value = m.ffmpeg_options.gopsize;
            num_minbitrate.Value = m.ffmpeg_options.minbitrate;
            num_maxbitrate.Value = m.ffmpeg_options.maxbitrate;
            num_buffsize.Value = m.ffmpeg_options.buffsize;
            num_bittolerance.Value = m.ffmpeg_options.bittolerance;

            if (m.ffmpeg_options.mbd == "simple")
                combo_mbd.SelectedItem = "Simple";
            if (m.ffmpeg_options.mbd == "bits")
                combo_mbd.SelectedItem = "Fewest bits";
            if (m.ffmpeg_options.mbd == "rd")
                combo_mbd.SelectedItem = "Rate distortion";

            combo_mvectors.SelectedItem = m.ffmpeg_options.mvectors;

            if (m.ffmpeg_options.intramatrix != null || m.ffmpeg_options.intermatrix != null)
            {
                string setmatrix = "H263";
                foreach (string matrix in combo_qmatrix.Items)
                {
                    if (m.ffmpeg_options.intermatrix == PresetLoader.GetInterMatrix(matrix) &&
                        m.ffmpeg_options.intramatrix == PresetLoader.GetIntraMatrix(matrix))
                        setmatrix = matrix;
                }
                combo_qmatrix.SelectedItem = setmatrix;
            }
            else
                combo_qmatrix.SelectedItem = "H263";

            SetToolTips();
            DetectCodecPreset();
        }
示例#6
0
        private void combo_mode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (combo_mode.IsDropDownOpen || combo_mode.IsSelectionBoxHighlighted)
            {
                //запоминаем старый режим
                oldmode = m.encodingmode;

                string XviDmode = combo_mode.SelectedItem.ToString();
                if (XviDmode == "1-Pass Bitrate")
                    m.encodingmode = Settings.EncodingModes.OnePass;

                else if (XviDmode == "2-Pass Bitrate")
                    m.encodingmode = Settings.EncodingModes.TwoPass;

                else if (XviDmode == "2-Pass Size")
                    m.encodingmode = Settings.EncodingModes.TwoPassSize;

                else if (XviDmode == "3-Pass Bitrate")
                    m.encodingmode = Settings.EncodingModes.ThreePass;

                else if (XviDmode == "3-Pass Size")
                    m.encodingmode = Settings.EncodingModes.ThreePassSize;

                else if (XviDmode == "Constant Quality")
                    m.encodingmode = Settings.EncodingModes.Quality;

                else if (XviDmode == "2-Pass Quality")
                    m.encodingmode = Settings.EncodingModes.TwoPassQuality;

                else if (XviDmode == "3-Pass Quality")
                    m.encodingmode = Settings.EncodingModes.ThreePassQuality;

                SetMinMaxBitrate();

                //сброс на квантайзер
                if (oldmode != Settings.EncodingModes.Quality &&
                    oldmode != Settings.EncodingModes.Quantizer &&
                    oldmode != Settings.EncodingModes.TwoPassQuality &&
                    oldmode != Settings.EncodingModes.ThreePassQuality)
                {
                    if (m.encodingmode == Settings.EncodingModes.Quality ||
                        m.encodingmode == Settings.EncodingModes.Quantizer ||
                        m.encodingmode == Settings.EncodingModes.TwoPassQuality ||
                        m.encodingmode == Settings.EncodingModes.ThreePassQuality)
                    {
                        SetDefaultBitrates();
                    }
                }

                //сброс на битрейт
                if (oldmode != Settings.EncodingModes.OnePass &&
                    oldmode != Settings.EncodingModes.TwoPass &&
                    oldmode != Settings.EncodingModes.ThreePass)
                {
                    if (m.encodingmode == Settings.EncodingModes.OnePass ||
                        m.encodingmode == Settings.EncodingModes.TwoPass ||
                        m.encodingmode == Settings.EncodingModes.ThreePass)
                    {
                        SetDefaultBitrates();
                    }
                }

                //сброс на размер
                if (oldmode != Settings.EncodingModes.TwoPassSize &&
                    oldmode != Settings.EncodingModes.ThreePassSize)
                {
                    if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                        m.encodingmode == Settings.EncodingModes.ThreePassSize)
                    {
                        SetDefaultBitrates();
                    }
                }

                root_window.UpdateOutSize();
                root_window.UpdateManualProfile();
                DetectCodecPreset();
            }
        }
示例#7
0
        private void combo_mode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (combo_mode.IsDropDownOpen || combo_mode.IsSelectionBoxHighlighted)
            {
                //запоминаем старый режим
                oldmode = m.encodingmode;

                string XviDmode = combo_mode.SelectedItem.ToString();
                if (XviDmode == "1-Pass Bitrate")
                {
                    m.encodingmode = Settings.EncodingModes.OnePass;
                }

                else if (XviDmode == "2-Pass Bitrate")
                {
                    m.encodingmode = Settings.EncodingModes.TwoPass;
                }

                else if (XviDmode == "1-Pass Size")
                {
                    m.encodingmode = Settings.EncodingModes.OnePassSize;
                }

                else if (XviDmode == "2-Pass Size")
                {
                    m.encodingmode = Settings.EncodingModes.TwoPassSize;
                }

                else if (XviDmode == "3-Pass Bitrate")
                {
                    m.encodingmode = Settings.EncodingModes.ThreePass;
                }

                else if (XviDmode == "3-Pass Size")
                {
                    m.encodingmode = Settings.EncodingModes.ThreePassSize;
                }

                else if (XviDmode == "Constant Quality")
                {
                    m.encodingmode = Settings.EncodingModes.Quality;
                }

                else if (XviDmode == "2-Pass Quality")
                {
                    m.encodingmode = Settings.EncodingModes.TwoPassQuality;
                }

                else if (XviDmode == "3-Pass Quality")
                {
                    m.encodingmode = Settings.EncodingModes.ThreePassQuality;
                }

                SetMinMaxBitrate();

                //сброс на квантайзер
                if (oldmode != Settings.EncodingModes.Quality &&
                    oldmode != Settings.EncodingModes.Quantizer &&
                    oldmode != Settings.EncodingModes.TwoPassQuality &&
                    oldmode != Settings.EncodingModes.ThreePassQuality)
                {
                    if (m.encodingmode == Settings.EncodingModes.Quality ||
                        m.encodingmode == Settings.EncodingModes.Quantizer ||
                        m.encodingmode == Settings.EncodingModes.TwoPassQuality ||
                        m.encodingmode == Settings.EncodingModes.ThreePassQuality)
                    {
                        SetDefaultBitrates();
                    }
                }

                //сброс на битрейт
                if (oldmode != Settings.EncodingModes.OnePass &&
                    oldmode != Settings.EncodingModes.TwoPass &&
                    oldmode != Settings.EncodingModes.ThreePass)
                {
                    if (m.encodingmode == Settings.EncodingModes.OnePass ||
                        m.encodingmode == Settings.EncodingModes.TwoPass ||
                        m.encodingmode == Settings.EncodingModes.ThreePass)
                    {
                        SetDefaultBitrates();
                    }
                }

                //сброс на размер
                if (oldmode != Settings.EncodingModes.TwoPassSize &&
                    oldmode != Settings.EncodingModes.ThreePassSize &&
                    oldmode != Settings.EncodingModes.OnePassSize)
                {
                    if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                        m.encodingmode == Settings.EncodingModes.ThreePassSize ||
                        m.encodingmode == Settings.EncodingModes.OnePassSize)
                    {
                        SetDefaultBitrates();
                    }
                }

                root_window.UpdateOutSize();
                root_window.UpdateManualProfile();
            }
        }
示例#8
0
        public void LoadFromProfile()
        {
            SetMinMaxBitrate();

            combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
            if (combo_mode.SelectedItem == null)
            {
                m.encodingmode          = Settings.EncodingModes.TwoPass;
                combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
                SetMinMaxBitrate();
                SetDefaultBitrates();
            }

            if (m.encodingmode == Settings.EncodingModes.Quality ||
                m.encodingmode == Settings.EncodingModes.Quantizer ||
                m.encodingmode == Settings.EncodingModes.TwoPassQuality ||
                m.encodingmode == Settings.EncodingModes.ThreePassQuality)
            {
                text_bitrate.Content = Languages.Translate("Quantizer") + ": (Q)";
            }
            else if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                     m.encodingmode == Settings.EncodingModes.ThreePassSize ||
                     m.encodingmode == Settings.EncodingModes.OnePassSize)
            {
                text_bitrate.Content = Languages.Translate("Size") + ": (MB)";
            }
            else
            {
                text_bitrate.Content = Languages.Translate("Bitrate") + ": (kbps)";
            }

            //запоминаем первичные режим кодирования
            oldmode = m.encodingmode;

            //защита для гладкой смены кодеков
            if (m.outvbitrate > 90000)
            {
                m.outvbitrate = 90000;
            }
            if (m.encodingmode == Settings.EncodingModes.Quality ||
                m.encodingmode == Settings.EncodingModes.Quantizer ||
                m.encodingmode == Settings.EncodingModes.TwoPassQuality ||
                m.encodingmode == Settings.EncodingModes.ThreePassQuality)
            {
                if (m.outvbitrate > 31)
                {
                    m.outvbitrate = 31;
                }
                if (m.outvbitrate == 0)
                {
                    m.outvbitrate = 1;
                }
            }

            if (m.encodingmode == Settings.EncodingModes.OnePass ||
                m.encodingmode == Settings.EncodingModes.TwoPass ||
                m.encodingmode == Settings.EncodingModes.ThreePass)
            {
                text_bitrate.Content = Languages.Translate("Bitrate") + ": (kbps)";
                num_bitrate.Value    = (decimal)m.outvbitrate;
            }
            else if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                     m.encodingmode == Settings.EncodingModes.ThreePassSize ||
                     m.encodingmode == Settings.EncodingModes.OnePassSize)
            {
                text_bitrate.Content = Languages.Translate("Size") + ": (MB)";
                num_bitrate.Value    = (decimal)m.outvbitrate;
            }
            else
            {
                text_bitrate.Content = Languages.Translate("Quantizer") + ": (Q)";
                num_bitrate.Value    = (decimal)m.outvbitrate;
            }

            check_bitexact.IsChecked = m.ffmpeg_options.bitexact;

            num_gopsize.Value      = m.ffmpeg_options.gopsize;
            num_minbitrate.Value   = m.ffmpeg_options.minbitrate;
            num_maxbitrate.Value   = m.ffmpeg_options.maxbitrate;
            num_buffsize.Value     = m.ffmpeg_options.buffsize;
            num_bittolerance.Value = m.ffmpeg_options.bittolerance;

            SetToolTips();
        }
示例#9
0
        public void LoadFromProfile()
        {
            SetMinMaxBitrate();

            combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
            if (combo_mode.SelectedItem == null)
            {
                m.encodingmode = Settings.EncodingModes.TwoPass;
                combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
                SetMinMaxBitrate();
                SetDefaultBitrates();
            }

            //запоминаем первичные режим кодирования
            oldmode = m.encodingmode;

            //защита для гладкой смены кодеков
            if (m.outvbitrate > 10000)
                m.outvbitrate = 10000;
            if (m.encodingmode == Settings.EncodingModes.Quality ||
                m.encodingmode == Settings.EncodingModes.Quantizer ||
                m.encodingmode == Settings.EncodingModes.TwoPassQuality ||
                m.encodingmode == Settings.EncodingModes.ThreePassQuality)
            {
                if (m.outvbitrate > 31)
                    m.outvbitrate = 31;
                if (m.outvbitrate == 0)
                    m.outvbitrate = 1;
            }

            if (m.encodingmode == Settings.EncodingModes.OnePass ||
                m.encodingmode == Settings.EncodingModes.TwoPass ||
                m.encodingmode == Settings.EncodingModes.ThreePass)
            {
                text_bitrate.Content = Languages.Translate("Bitrate") + ": (kbps)";
                num_bitrate.Value = (decimal)m.outvbitrate;
            }
            else if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                m.encodingmode == Settings.EncodingModes.ThreePassSize)
            {
                text_bitrate.Content = Languages.Translate("Size") + ": (MB)";
                num_bitrate.Value = (decimal)m.outvbitrate;
            }
            else
            {
                if (m.encodingmode == Settings.EncodingModes.Quantizer)
                    text_bitrate.Content = Languages.Translate("Quantizer") + ": (Q)";
                else
                    text_bitrate.Content = Languages.Translate("Quality") + ": (Q)";

                num_bitrate.Value = (decimal)m.outvbitrate;
            }

            if (m.XviD_options.bframes == 0)
            {
                check_bvhq.IsEnabled = false;
                check_bvhq.IsChecked = false;
                m.XviD_options.bvhq = false;
            }
            else
                check_bvhq.IsEnabled = true;

            combo_quality.SelectedIndex = m.XviD_options.quality;
            combo_vhqmode.SelectedIndex = m.XviD_options.vhqmode;
            combo_metric.SelectedIndex = m.XviD_options.metric;
            check_chroma.IsChecked = m.XviD_options.chromame;
            combo_qmatrix.SelectedItem = m.XviD_options.qmatrix;
            check_trellis.IsChecked = m.XviD_options.trellis;
            check_fullpass.IsChecked = m.XviD_options.full_first_pass;
            check_grayscale.IsChecked = m.XviD_options.gray;
            check_cartoon.IsChecked = m.XviD_options.cartoon;
            check_chroma_opt.IsChecked = m.XviD_options.chroma_opt;
            check_packedmode.IsChecked = m.XviD_options.packedmode;
            check_gmc.IsChecked = m.XviD_options.gmc;
            check_qpel.IsChecked = m.XviD_options.qpel;
            check_bvhq.IsChecked = m.XviD_options.bvhq;
            check_closedgop.IsChecked = m.XviD_options.closedgop;
            combo_bframes.SelectedItem = m.XviD_options.bframes;
            num_bquant_ratio.Value = m.XviD_options.b_ratio;
            num_bquant_offset.Value = m.XviD_options.b_offset;
            num_keyint.Value = m.XviD_options.keyint;
            combo_masking.SelectedIndex = m.XviD_options.masking;
            combo_fourcc.SelectedItem = m.XviD_options.fourcc;
            combo_imin.SelectedItem = m.XviD_options.imin;
            combo_imax.SelectedItem = m.XviD_options.imax;
            combo_pmin.SelectedItem = m.XviD_options.pmin;
            combo_pmax.SelectedItem = m.XviD_options.pmax;
            combo_bmin.SelectedItem = m.XviD_options.bmin;
            combo_bmax.SelectedItem = m.XviD_options.bmax;
            check_xvid_new.IsChecked = Settings.UseXviD_130;
            combo_threads.SelectedIndex = Settings.XviD_Threads;
            num_kboost.Value = m.XviD_options.kboost;
            num_chigh.Value = m.XviD_options.chigh;
            num_clow.Value = m.XviD_options.clow;
            num_ostrength.Value = m.XviD_options.ostrength;
            num_oimprove.Value = m.XviD_options.oimprove;
            num_odegrade.Value = m.XviD_options.odegrade;
            num_reaction.Value = m.XviD_options.reaction;
            num_averaging.Value = m.XviD_options.averaging;
            num_smoother.Value = m.XviD_options.smoother;
            num_vbvmax.Value = m.XviD_options.vbvmax;
            num_vbvsize.Value = m.XviD_options.vbvsize;
            num_vbvpeak.Value = m.XviD_options.vbvpeak;
            num_firstpass_q.Value = m.XviD_options.firstpass_q;

            SetToolTips();
            DetectCodecPreset();
        }
示例#10
0
        public static Massive DecodeLine(Massive m)
        {
            //создаём свежий массив параметров ffmpeg
            m.ffmpeg_options = new ffmpeg_arguments();

            //для начала определяем колличество проходов
            Settings.EncodingModes mode = Settings.EncodingModes.OnePass;
            if (m.vpasses.Count == 3)
            {
                mode = Settings.EncodingModes.ThreePass;
            }
            else if (m.vpasses.Count == 2)
            {
                mode = Settings.EncodingModes.TwoPass;
            }

            //берём пока что за основу последнюю строку
            string line = m.vpasses[m.vpasses.Count - 1].ToString();

            string[] separator = new string[] { " " };
            string[] cli       = line.Split(separator, StringSplitOptions.None);
            int      n         = 0;

            foreach (string value in cli)
            {
                if (value == "-b")
                {
                    m.outvbitrate = Convert.ToInt32(cli[n + 1]) / 1000;
                }

                if (value == "-sizemode")
                {
                    m.outvbitrate = Convert.ToInt32(cli[n + 1]) / 1000;
                    if (m.vpasses.Count == 3)
                    {
                        mode = Settings.EncodingModes.ThreePassSize;
                    }
                    else if (m.vpasses.Count == 2)
                    {
                        mode = Settings.EncodingModes.TwoPassSize;
                    }
                    else if (m.vpasses.Count == 1)
                    {
                        mode = Settings.EncodingModes.OnePassSize;
                    }
                }

                if (m.vpasses.Count == 1)
                {
                    if (value == "-qscale")
                    {
                        mode          = Settings.EncodingModes.Quality;
                        m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                }

                if (m.vpasses.Count == 2)
                {
                    if (value == "-qscale")
                    {
                        mode          = Settings.EncodingModes.TwoPassQuality;
                        m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                }

                if (m.vpasses.Count == 3)
                {
                    if (value == "-qscale")
                    {
                        mode          = Settings.EncodingModes.ThreePassQuality;
                        m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[n + 1]);
                    }
                }

                if (value == "-maxrate")
                {
                    m.ffmpeg_options.maxbitrate = Convert.ToInt32(cli[n + 1]) / 1000;
                }

                if (value == "-minrate")
                {
                    m.ffmpeg_options.minbitrate = Convert.ToInt32(cli[n + 1]) / 1000;
                }

                if (value == "-bt")
                {
                    m.ffmpeg_options.bittolerance = Convert.ToInt32(cli[n + 1]) / 1000;
                }

                if (value == "-bufsize")
                {
                    m.ffmpeg_options.buffsize = Convert.ToInt32(cli[n + 1]) / 1000;
                }

                //дешифруем флаги
                if (value == "-flags")
                {
                    string   flags_string = cli[n + 1];
                    string[] separator2   = new string[] { "+" };
                    string[] flags        = flags_string.Split(separator2, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string flag in flags)
                    {
                        if (flag == "bitexact")
                        {
                            m.ffmpeg_options.bitexact = true;
                        }
                    }
                }

                if (value == "-g")
                {
                    m.ffmpeg_options.gopsize = Convert.ToInt32(cli[n + 1]);
                }

                n++;
            }

            //прописываем вычисленное колличество проходов
            m.encodingmode = mode;

            return(m);
        }
示例#11
0
        private void combo_mode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if ((combo_mode.IsDropDownOpen || combo_mode.IsSelectionBoxHighlighted) && combo_mode.SelectedItem != null)
            {
                //запоминаем старый режим
                oldmode = m.encodingmode;

                string XviDmode = combo_mode.SelectedItem.ToString();
                if (XviDmode == "1-Pass Bitrate")
                    m.encodingmode = Settings.EncodingModes.OnePass;

                else if (XviDmode == "2-Pass Bitrate")
                    m.encodingmode = Settings.EncodingModes.TwoPass;

                else if (XviDmode == "2-Pass Size")
                    m.encodingmode = Settings.EncodingModes.TwoPassSize;

                else if (XviDmode == "3-Pass Bitrate")
                    m.encodingmode = Settings.EncodingModes.ThreePass;

                else if (XviDmode == "3-Pass Size")
                    m.encodingmode = Settings.EncodingModes.ThreePassSize;

                else if (XviDmode == "Constant Quality")
                    m.encodingmode = Settings.EncodingModes.Quality;

                else if (XviDmode == "2-Pass Quality")
                    m.encodingmode = Settings.EncodingModes.TwoPassQuality;

                else if (XviDmode == "3-Pass Quality")
                    m.encodingmode = Settings.EncodingModes.ThreePassQuality;

                SetMinMaxBitrate();

                //Устанавливаем дефолтный битрейт (при необходимости)
                if (oldmode == Settings.EncodingModes.OnePass ||
                    oldmode == Settings.EncodingModes.TwoPass ||
                    oldmode == Settings.EncodingModes.ThreePass)
                {
                    if (m.encodingmode != Settings.EncodingModes.OnePass &&
                        m.encodingmode != Settings.EncodingModes.TwoPass &&
                        m.encodingmode != Settings.EncodingModes.ThreePass)
                        SetDefaultBitrates();
                }
                else if (oldmode.ToString().Contains("Size") && !m.encodingmode.ToString().Contains("Size"))
                {
                    SetDefaultBitrates();
                }
                else if (oldmode.ToString().Contains("Quality") && !m.encodingmode.ToString().Contains("Quality"))
                {
                    SetDefaultBitrates();
                }
                else if (oldmode == Settings.EncodingModes.Quantizer)
                {
                    SetDefaultBitrates();
                }

                if (m.encodingmode == Settings.EncodingModes.TwoPass ||
                    m.encodingmode == Settings.EncodingModes.ThreePass ||
                    m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                    m.encodingmode == Settings.EncodingModes.ThreePassSize ||
                    m.encodingmode == Settings.EncodingModes.TwoPassQuality ||
                    m.encodingmode == Settings.EncodingModes.ThreePassQuality)
                {
                    //отключаем пакет бит стрим так как он не работает в многопроходном режиме
                    m.XviD_options.packedmode = false;
                    check_packedmode.IsChecked = false;
                }

                root_window.UpdateOutSize();
                root_window.UpdateManualProfile();
                DetectCodecPreset();
            }
        }
示例#12
0
        public void LoadFromProfile()
        {
            SetMinMaxBitrate();

            combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
            if (combo_mode.SelectedItem == null)
            {
                m.encodingmode = Settings.EncodingModes.Quality;
                combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
                SetMinMaxBitrate();
                SetDefaultBitrates();
            }

            //запоминаем первичные режим кодирования
            oldmode = m.encodingmode;

            if (m.encodingmode == Settings.EncodingModes.OnePass ||
                m.encodingmode == Settings.EncodingModes.TwoPass ||
                m.encodingmode == Settings.EncodingModes.ThreePass)
            {
                text_bitrate.Content = Languages.Translate("Bitrate") + ": (kbps)";
                num_bitrate.Value = (decimal)m.outvbitrate;
            }
            else if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                     m.encodingmode == Settings.EncodingModes.ThreePassSize)
            {
                text_bitrate.Content = Languages.Translate("Size") + ": (MB)";
                num_bitrate.Value = (decimal)m.outvbitrate;
            }
            else
            {
                if (m.encodingmode == Settings.EncodingModes.Quantizer)
                    text_bitrate.Content = Languages.Translate("Quantizer") + ": (Q)";
                else
                    text_bitrate.Content = Languages.Translate("Quality") + ": (CRF)";

                num_bitrate.Value = (decimal)m.outvbitrate;
            }

            combo_hevc_profile.SelectedIndex = (int)m.x265options.profile;

            //HEVC level
            if (m.x265options.level == "unrestricted") combo_level.SelectedIndex = 0;
            else combo_level.SelectedItem = m.x265options.level;

            //Встроенный в x265 пресет
            text_preset_name.Content = m.x265options.preset.ToString();
            slider_preset.Value = (int)m.x265options.preset;

            //Tune
            combo_tune.SelectedIndex = (int)m.x265options.tune;

            check_lossless.IsChecked = m.x265options.lossless;
            check_slow_first.IsChecked = m.x265options.slow_firstpass;

            num_qcomp.Value = m.x265options.qcomp;
            num_ratio_ip.Value = m.x265options.ratio_ip;
            num_ratio_pb.Value = m.x265options.ratio_pb;
            num_chroma_qpb.Value = m.x265options.chroma_offset_cb;
            num_chroma_qpr.Value = m.x265options.chroma_offset_cr;
            num_vbv_max.Value = m.x265options.vbv_maxrate;
            num_vbv_buf.Value = m.x265options.vbv_bufsize;
            num_vbv_init.Value = m.x265options.vbv_init;
            combo_adapt_quant_mode.SelectedIndex = m.x265options.aqmode;
            combo_adapt_quant.SelectedItem = m.x265options.aqstrength;
            check_cutree.IsChecked = m.x265options.cutree;

            num_psyrd.Value = m.x265options.psyrd;
            num_psyrdoq.Value = m.x265options.psyrdoq;

            //прогружаем деблокинг
            combo_dstrength.SelectedItem = m.x265options.deblockTC;
            combo_dthreshold.SelectedItem = m.x265options.deblockBeta;
            check_deblocking.IsChecked = m.x265options.deblocking;

            check_sao.IsChecked = m.x265options.sao;

            //Прописываем subme
            combo_subme.SelectedIndex = m.x265options.subme;

            //прописываем me алгоритм
            if (m.x265options.me == "dia" || m.x265options.me == "0") combo_me.SelectedIndex = 0;
            else if (m.x265options.me == "hex" || m.x265options.me == "1") combo_me.SelectedIndex = 1;
            else if (m.x265options.me == "umh" || m.x265options.me == "2") combo_me.SelectedIndex = 2;
            else if (m.x265options.me == "star" || m.x265options.me == "3") combo_me.SelectedIndex = 3;
            else if (m.x265options.me == "full" || m.x265options.me == "4") combo_me.SelectedIndex = 4;

            //прописываем me range
            combo_merange.SelectedItem = m.x265options.merange;

            combo_max_merge.SelectedIndex = m.x265options.max_merge - 1;
            combo_rd.SelectedIndex = m.x265options.rd;
            combo_ctu.SelectedItem = m.x265options.ctu;
            combo_max_tu.SelectedItem = m.x265options.max_tu;
            check_cu_lossless.IsChecked = m.x265options.cu_lossless;
            check_early_skip.IsChecked = m.x265options.early_skip;
            check_rect.IsChecked = m.x265options.rect;
            check_amp.IsChecked = m.x265options.amp;
            check_constr_intra.IsChecked = m.x265options.constr_intra;
            check_b_intra.IsChecked = m.x265options.b_intra;

            //B фреймы
            combo_bframes.SelectedIndex = m.x265options.bframes;

            combo_bpyramid_mode.SelectedIndex = (m.x265options.bpyramid) ? 1 : 0;

            if (!m.x265options.open_gop) combo_open_gop.SelectedIndex = 0;
            else combo_open_gop.SelectedIndex = 1;

            //weightp
            check_weightedp.IsChecked = m.x265options.weightp;

            //weightb
            check_weightedb.IsChecked = m.x265options.weightb;

            //refernce frames
            combo_ref.SelectedItem = m.x265options.reference;

            num_min_gop.Value = m.x265options.gop_min;
            num_max_gop.Value = m.x265options.gop_max;

            combo_badapt_mode.SelectedIndex = m.x265options.b_adapt;

            num_lookahead.Value = m.x265options.lookahead;

            if (m.x265options.range_out == "auto") combo_range_out.SelectedIndex = 0;
            else if (m.x265options.range_out == "limited") combo_range_out.SelectedIndex = 1;
            else if (m.x265options.range_out == "full") combo_range_out.SelectedIndex = 2;

            combo_colorprim.SelectedItem = m.x265options.colorprim;
            combo_transfer.SelectedItem = m.x265options.transfer;
            combo_colormatrix.SelectedItem = m.x265options.colormatrix;
            combo_hash.SelectedIndex = m.x265options.hash;

            check_info.IsChecked = m.x265options.info;
            check_aud.IsChecked = m.x265options.aud;
            check_hrd.IsChecked = m.x265options.hrd;
            check_headers.IsChecked = m.x265options.headers_repeat;
            check_temp_layers.IsChecked = m.x265options.temp_layers;

            check_wpp.IsChecked = m.x265options.wpp;
            check_pmode.IsChecked = m.x265options.pmode;
            check_pme.IsChecked = m.x265options.pme;

            //Кол-во потоков для x265-го
            combo_threads_count.SelectedIndex = m.x265options.threads;
            combo_threads_frames.SelectedIndex = m.x265options.threads_frames;

            //Включаем-выключаем элементы на основе содержимого extra_cli
            combo_hevc_profile.IsEnabled = !m.x265options.extra_cli.Contains("--profile ");
            combo_level.IsEnabled = !m.x265options.extra_cli.Contains("--level-idc ") && !m.x265options.extra_cli.Contains("--level ");
            check_high_tier.IsEnabled = !m.x265options.extra_cli.Contains("--high-tier") && !m.x265options.extra_cli.Contains("--no-high-tier");
            combo_tune.IsEnabled = !m.x265options.extra_cli.Contains("--tune ");
            check_lossless.IsEnabled = !m.x265options.extra_cli.Contains("--lossless") && !m.x265options.extra_cli.Contains("--no-lossless");
            check_slow_first.IsEnabled = !m.x265options.extra_cli.Contains("--slow-firstpass") && !m.x265options.extra_cli.Contains("--no-slow-firstpass");

            combo_subme.IsEnabled = !m.x265options.extra_cli.Contains("--subme ");
            combo_me.IsEnabled = !m.x265options.extra_cli.Contains("--me ");
            combo_merange.IsEnabled = !m.x265options.extra_cli.Contains("--merange ");
            combo_max_merge.IsEnabled = !m.x265options.extra_cli.Contains("--max-merge ");
            combo_rd.IsEnabled = !m.x265options.extra_cli.Contains("--rd ");
            combo_ctu.IsEnabled = !m.x265options.extra_cli.Contains("--ctu ");
            combo_max_tu.IsEnabled = !m.x265options.extra_cli.Contains("--max-tu-size ");
            check_weightedp.IsEnabled = !m.x265options.extra_cli.Contains("--weightp") && !m.x265options.extra_cli.Contains("--no-weightp");
            check_weightedb.IsEnabled = !m.x265options.extra_cli.Contains("--weightb") && !m.x265options.extra_cli.Contains("--no-weightb");
            check_cu_lossless.IsEnabled = !m.x265options.extra_cli.Contains("--cu-lossless") && !m.x265options.extra_cli.Contains("--no-cu-lossless");
            check_early_skip.IsEnabled = !m.x265options.extra_cli.Contains("--early-skip") && !m.x265options.extra_cli.Contains("--no-early-skip");
            check_rect.IsEnabled = !m.x265options.extra_cli.Contains("--rect") && !m.x265options.extra_cli.Contains("--no-rect");
            check_amp.IsEnabled = !m.x265options.extra_cli.Contains("--amp") && !m.x265options.extra_cli.Contains("--no-amp");
            check_constr_intra.IsEnabled = !m.x265options.extra_cli.Contains("--constrained-intra") && !m.x265options.extra_cli.Contains("--no-constrained-intra");
            check_b_intra.IsEnabled = !m.x265options.extra_cli.Contains("--b-intra") && !m.x265options.extra_cli.Contains("--no-b-intra");

            combo_bframes.IsEnabled = !m.x265options.extra_cli.Contains("--bframes ");
            combo_badapt_mode.IsEnabled = !m.x265options.extra_cli.Contains("--b-adapt ") && !m.x265options.extra_cli.Contains("--no-b-adapt");
            combo_bpyramid_mode.IsEnabled = !m.x265options.extra_cli.Contains("--b-pyramid") && !m.x265options.extra_cli.Contains("--no-b-pyramid");
            combo_ref.IsEnabled = !m.x265options.extra_cli.Contains("--ref ");
            combo_open_gop.IsEnabled = !m.x265options.extra_cli.Contains("--open-gop") && !m.x265options.extra_cli.Contains("--no-open-gop");
            num_min_gop.IsEnabled = !m.x265options.extra_cli.Contains("--min-keyint ");
            num_max_gop.IsEnabled = !m.x265options.extra_cli.Contains("--keyint ");
            num_lookahead.IsEnabled = !m.x265options.extra_cli.Contains("--rc-lookahead ");
            check_deblocking.IsEnabled = !m.x265options.extra_cli.Contains("--deblock ") && !m.x265options.extra_cli.Contains("--no-deblock");
            check_sao.IsEnabled = !m.x265options.extra_cli.Contains("--sao") && !m.x265options.extra_cli.Contains("--no-sao");

            num_qcomp.IsEnabled = !m.x265options.extra_cli.Contains("--qcomp ");
            num_ratio_ip.IsEnabled = !m.x265options.extra_cli.Contains("--ipratio ");
            num_ratio_pb.IsEnabled = !m.x265options.extra_cli.Contains("--pbratio ");
            num_chroma_qpb.IsEnabled = !m.x265options.extra_cli.Contains("--cbqpoffs ");
            num_chroma_qpr.IsEnabled = !m.x265options.extra_cli.Contains("--crqpoffs ");
            num_vbv_max.IsEnabled = !m.x265options.extra_cli.Contains("--vbv-maxrate ");
            num_vbv_buf.IsEnabled = !m.x265options.extra_cli.Contains("--vbv-bufsize ");
            num_vbv_init.IsEnabled = !m.x265options.extra_cli.Contains("--vbv-init ");
            combo_adapt_quant_mode.IsEnabled = !m.x265options.extra_cli.Contains("--aq-mode ");
            combo_adapt_quant.IsEnabled = !m.x265options.extra_cli.Contains("--aq-strength ");
            check_cutree.IsEnabled = !m.x265options.extra_cli.Contains("--cutree") && !m.x265options.extra_cli.Contains("--no-cutree");

            num_psyrd.IsEnabled = !m.x265options.extra_cli.Contains("--psy-rd ") && !m.x265options.extra_cli.Contains("--no-psy-rd");
            num_psyrdoq.IsEnabled = !m.x265options.extra_cli.Contains("--psy-rdoq ") && !m.x265options.extra_cli.Contains("--no-psy-rdoq");
            combo_range_out.IsEnabled = !m.x265options.extra_cli.Contains("--range ");
            combo_colorprim.IsEnabled = !m.x265options.extra_cli.Contains("--colorprim ");
            combo_transfer.IsEnabled = !m.x265options.extra_cli.Contains("--transfer ");
            combo_colormatrix.IsEnabled = !m.x265options.extra_cli.Contains("--colormatrix ");

            combo_hash.IsEnabled = !m.x265options.extra_cli.Contains("--hash ");
            check_info.IsEnabled = !m.x265options.extra_cli.Contains("--info") && !m.x265options.extra_cli.Contains("--no-info");
            check_aud.IsEnabled = !m.x265options.extra_cli.Contains("--aud") && !m.x265options.extra_cli.Contains("--no-aud");
            check_hrd.IsEnabled = !m.x265options.extra_cli.Contains("--hrd") && !m.x265options.extra_cli.Contains("--no-hrd");
            check_headers.IsEnabled = !m.x265options.extra_cli.Contains("--repeat-headers") && !m.x265options.extra_cli.Contains("--no-repeat-headers");
            check_temp_layers.IsEnabled = !m.x265options.extra_cli.Contains("--temporal-layers") && !m.x265options.extra_cli.Contains("--no-temporal-layers");
            check_wpp.IsEnabled = !m.x265options.extra_cli.Contains("--wpp") && !m.x265options.extra_cli.Contains("--no-wpp");
            check_pmode.IsEnabled = !m.x265options.extra_cli.Contains("--pmode") && !m.x265options.extra_cli.Contains("--no-pmode");
            check_pme.IsEnabled = !m.x265options.extra_cli.Contains("--pme") && !m.x265options.extra_cli.Contains("--no-pme");
            combo_threads_count.IsEnabled = !m.x265options.extra_cli.Contains("--threads ");
            combo_threads_frames.IsEnabled = !m.x265options.extra_cli.Contains("--frame-threads ");

            SetToolTips();
            UpdateCLI();
        }
示例#13
0
        public static Massive DecodeLine(Massive m)
        {
            //Дефолты
            Presets preset = Presets.Medium;
            Tunes tune = Tunes.None;
            Profiles profile = Profiles.Auto;
            Settings.EncodingModes mode = new Settings.EncodingModes();

            //берём за основу последнюю строку
            string line = m.vpasses[m.vpasses.Count - 1].ToString();

            //Определяем пресет, для этого ищем ключ --preset
            string preset_name = Calculate.GetRegexValue(@"\-\-preset\s+(\w+)", line);
            if (!string.IsNullOrEmpty(preset_name))
            {
                try
                {
                    //Определяем preset по его названию или номеру
                    preset = (Presets)Enum.Parse(typeof(Presets), preset_name, true);
                }
                catch { }
            }

            //Ищем --tune
            string tune_name = Calculate.GetRegexValue(@"\-\-tune\s+(\w+)", line);
            if (!string.IsNullOrEmpty(tune_name))
            {
                try
                {
                    //Определяем tune по его названию
                    tune = (Tunes)Enum.Parse(typeof(Tunes), tune_name, true);
                }
                catch { }
            }

            //Ищем --profile (определяем 10-битность)
            string profile_name = Calculate.GetRegexValue(@"\-\-profile\s+(\w+-?\w*)", line);
            if (!string.IsNullOrEmpty(profile_name))
            {
                //Определяем profile по его названию
                if (profile_name.Equals("main", StringComparison.InvariantCultureIgnoreCase)) profile = Profiles.Main;
                else if (profile_name.Equals("main444-8", StringComparison.InvariantCultureIgnoreCase)) profile = Profiles.Main444;
                else if (profile_name.Equals("main10", StringComparison.InvariantCultureIgnoreCase)) profile = Profiles.Main_10;
                else if (profile_name.Equals("main422-10", StringComparison.InvariantCultureIgnoreCase)) profile = Profiles.Main422_10;
                else if (profile_name.Equals("main444-10", StringComparison.InvariantCultureIgnoreCase)) profile = Profiles.Main444_10;
            }

            //Создаём свежий массив параметров x265 (изменяя дефолты с учетом --preset и --tune)
            m.x265options = new x265_arguments(preset, tune, profile);
            m.x265options.profile = profile;
            m.x265options.preset = preset;
            m.x265options.tune = tune;

            string value = "";
            string[] cli = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int n = 0; n < cli.Length; n++)
            {
                value = cli[n];

                if (m.vpasses.Count == 1)
                {
                    if (value == "--crf")
                    {
                        mode = Settings.EncodingModes.Quality;
                        m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[++n]);
                    }
                    else if (value == "--bitrate")
                    {
                        mode = Settings.EncodingModes.OnePass;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[++n]);
                    }
                    else if (value == "--qp" || value == "-q")
                    {
                        mode = Settings.EncodingModes.Quantizer;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[++n]);
                    }
                }
                else if (m.vpasses.Count == 2)
                {
                    if (value == "--crf")
                    {
                        mode = Settings.EncodingModes.TwoPassQuality;
                        m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[++n]);
                    }
                    else if (value == "--bitrate")
                    {
                        mode = Settings.EncodingModes.TwoPass;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[++n]);
                    }
                    else if (value == "--size")
                    {
                        mode = Settings.EncodingModes.TwoPassSize;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[++n]);
                    }
                }
                else if (m.vpasses.Count == 3)
                {
                    if (value == "--crf")
                    {
                        mode = Settings.EncodingModes.ThreePassQuality;
                        m.outvbitrate = (decimal)Calculate.ConvertStringToDouble(cli[++n]);
                    }
                    else if (value == "--bitrate")
                    {
                        mode = Settings.EncodingModes.ThreePass;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[++n]);
                    }
                    else if (value == "--size")
                    {
                        mode = Settings.EncodingModes.ThreePassSize;
                        m.outvbitrate = (int)Calculate.ConvertStringToDouble(cli[++n]);
                    }
                }

                if (value == "--level-idc" || value == "--level")
                    m.x265options.level = cli[++n];

                else if (value == "--high-tier")
                    m.x265options.high_tier = true;
                else if (value == "--no-high-tier")
                    m.x265options.high_tier = false;

                else if (value == "--lossless")
                    m.x265options.lossless = true;
                else if (value == "--no-lossless")
                    m.x265options.lossless = false;

                else if (value == "--slow-firstpass")
                    m.x265options.slow_firstpass = true;
                else if (value == "--no-slow-firstpass")
                    m.x265options.slow_firstpass = false;

                else if (value == "--ref")
                    m.x265options.reference = Convert.ToInt32(cli[++n]);

                else if (value == "--aq-mode")
                    m.x265options.aqmode = Convert.ToInt32(cli[++n]);

                else if (value == "--aq-strength")
                    m.x265options.aqstrength = cli[++n];

                else if (value == "--cutree")
                    m.x265options.cutree = true;
                else if (value == "--no-cutree")
                    m.x265options.cutree = false;

                else if (value == "--psy-rd")
                    m.x265options.psyrd = (decimal)Calculate.ConvertStringToDouble(cli[++n]);
                else if (value == "--no-psy-rd")
                    m.x265options.psyrd = 0;

                else if (value == "--psy-rdoq")
                    m.x265options.psyrdoq = (decimal)Calculate.ConvertStringToDouble(cli[++n]);
                else if (value == "--no-psy-rdoq")
                    m.x265options.psyrdoq = 0;

                else if (value == "--deblock")
                {
                    m.x265options.deblocking = true;
                    if (n + 1 < cli.Length && (cli[n + 1].Contains(":") || cli[n + 1].Contains(",")))
                    {
                        string[] dvalues = cli[n].Split(new string[] { ":" }, StringSplitOptions.None);
                        if (dvalues.Length < 2) dvalues = cli[++n].Split(new string[] { "," }, StringSplitOptions.None);
                        if (dvalues.Length > 1)
                        {
                            m.x265options.deblockTC = Convert.ToInt32(dvalues[0]);
                            m.x265options.deblockBeta = Convert.ToInt32(dvalues[1]);
                        }
                    }
                }
                else if (value == "--no-deblock")
                {
                    m.x265options.deblocking = false;
                }

                else if (value == "--sao")
                    m.x265options.sao = true;
                else if (value == "--no-sao")
                    m.x265options.sao = false;

                else if (value == "--subme" || value == "-m")
                    m.x265options.subme = Convert.ToInt32(cli[++n]);

                else if (value == "--me")
                    m.x265options.me = cli[++n];

                else if (value == "--merange")
                    m.x265options.merange = Convert.ToInt32(cli[++n]);

                else if (value == "--max-merge")
                    m.x265options.max_merge = Convert.ToInt32(cli[++n]);

                else if (value == "--rd")
                    m.x265options.rd = Convert.ToInt32(cli[++n]);

                else if (value == "--ctu" || value == "-s")
                    m.x265options.ctu = Convert.ToInt32(cli[++n]);

                else if (value == "--max-tu-size")
                    m.x265options.max_tu = Convert.ToInt32(cli[++n]);

                else if (value == "--cu-lossless")
                    m.x265options.cu_lossless = true;
                else if (value == "--no-cu-lossless")
                    m.x265options.cu_lossless = false;

                else if (value == "--early-skip")
                    m.x265options.early_skip = true;
                else if (value == "--no-early-skip")
                    m.x265options.early_skip = false;

                else if (value == "--rect")
                    m.x265options.rect = true;
                else if (value == "--no-rect")
                    m.x265options.rect = false;

                else if (value == "--amp")
                    m.x265options.amp = true;
                else if (value == "--no-amp")
                    m.x265options.amp = false;

                else if (value == "--constrained-intra")
                    m.x265options.constr_intra = true;
                else if (value == "--no-constrained-intra")
                    m.x265options.constr_intra = false;

                else if (value == "--b-intra")
                    m.x265options.b_intra = true;
                else if (value == "--no-b-intra")
                    m.x265options.b_intra = false;

                else if (value == "--bframes" || value == "-b")
                    m.x265options.bframes = Convert.ToInt32(cli[++n]);

                else if (value == "--b-adapt")
                    m.x265options.b_adapt = Convert.ToInt32(cli[++n]);
                else if (value == "--no-b-adapt")
                    m.x265options.b_adapt = 0;

                else if (value == "--b-pyramid")
                    m.x265options.bpyramid = true;
                else if (value == "--no-b-pyramid")
                    m.x265options.bpyramid = false;

                else if (value == "--weightb")
                    m.x265options.weightb = true;
                else if (value == "--no-weightb")
                    m.x265options.weightb = false;

                else if (value == "--weightp" || value == "-w")
                    m.x265options.weightp = true;
                else if (value == "--no-weightp")
                    m.x265options.weightp = false;

                else if (value == "--threads")
                    m.x265options.threads = Convert.ToInt32(cli[++n]);

                else if (value == "--frame-threads" || value == "-F")
                    m.x265options.threads_frames = Convert.ToInt32(cli[++n]);

                else if (value == "--qcomp")
                    m.x265options.qcomp = (decimal)Calculate.ConvertStringToDouble(cli[++n]);

                else if (value == "--ipratio")
                    m.x265options.ratio_ip = (decimal)Calculate.ConvertStringToDouble(cli[++n]);

                else if (value == "--pbratio")
                    m.x265options.ratio_pb = (decimal)Calculate.ConvertStringToDouble(cli[++n]);

                else if (value == "--cbqpoffs")
                    m.x265options.chroma_offset_cb = Convert.ToInt32(cli[++n]);

                else if (value == "--crqpoffs")
                    m.x265options.chroma_offset_cr = Convert.ToInt32(cli[++n]);

                else if (value == "--vbv-maxrate")
                    m.x265options.vbv_maxrate = Convert.ToInt32(cli[++n]);

                else if (value == "--vbv-bufsize")
                    m.x265options.vbv_bufsize = Convert.ToInt32(cli[++n]);

                else if (value == "--vbv-init")
                    m.x265options.vbv_init = (decimal)Calculate.ConvertStringToDouble(cli[++n]);

                else if (value == "--rc-lookahead")
                    m.x265options.lookahead = Convert.ToInt32(cli[++n]);

                else if (value == "--min-keyint" || value == "-i")
                    m.x265options.gop_min = Convert.ToInt32(cli[++n]);

                else if (value == "--keyint" || value == "-I")
                    m.x265options.gop_max = Convert.ToInt32(cli[++n]);

                else if (value == "--open-gop")
                    m.x265options.open_gop = true;
                else if (value == "--no-open-gop")
                    m.x265options.open_gop = false;

                else if (value == "--range")
                    m.x265options.range_out = cli[++n];

                else if (value == "--colorprim")
                {
                    string _value = cli[++n].Trim(new char[] { '"' });
                    if (_value == "undef")
                        m.x265options.colorprim = "Undefined";
                    else
                        m.x265options.colorprim = _value;
                }

                else if (value == "--transfer")
                {
                    string _value = cli[++n].Trim(new char[] { '"' });
                    if (_value == "undef")
                        m.x265options.transfer = "Undefined";
                    else
                        m.x265options.transfer = _value;
                }

                else if (value == "--colormatrix")
                {
                    string _value = cli[++n].Trim(new char[] { '"' });
                    if (_value == "undef")
                        m.x265options.colormatrix = "Undefined";
                    else
                        m.x265options.colormatrix = _value;
                }

                else if (value == "--hash")
                    m.x265options.hash = Convert.ToInt32(cli[++n]);

                else if (value == "--info")
                    m.x265options.info = true;
                else if (value == "--no-info")
                    m.x265options.info = false;

                else if (value == "--aud")
                    m.x265options.aud = true;
                else if (value == "--no-aud")
                    m.x265options.aud = false;

                else if (value == "--hrd")
                    m.x265options.hrd = true;
                else if (value == "--no-hrd")
                    m.x265options.hrd = false;

                else if (value == "--repeat-headers")
                    m.x265options.headers_repeat = true;
                else if (value == "--no-repeat-headers")
                    m.x265options.headers_repeat = false;

                else if (value == "--temporal-layers")
                    m.x265options.temp_layers = true;
                else if (value == "--no-temporal-layers")
                    m.x265options.temp_layers = false;

                else if (value == "--wpp")
                    m.x265options.wpp = true;
                else if (value == "--no-wpp")
                    m.x265options.wpp = false;

                else if (value == "--pmode")
                    m.x265options.pmode = true;
                else if (value == "--no-pmode")
                    m.x265options.pmode = false;

                else if (value == "--pme")
                    m.x265options.pme = true;
                else if (value == "--no-pme")
                    m.x265options.pme = false;

                else if (value == "--extra:")
                {
                    for (int i = n + 1; i < cli.Length; i++)
                        m.x265options.extra_cli += cli[i] + " ";

                    m.x265options.extra_cli = m.x265options.extra_cli.Trim();
                }
            }

            //Сброс на дефолт, если в CLI нет параметров кодирования
            if (mode == 0)
            {
                m.encodingmode = Settings.EncodingModes.Quality;
                m.outvbitrate = 28;
            }
            else
                m.encodingmode = mode;

            return m;
        }
示例#14
0
        private void combo_mode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if ((combo_mode.IsDropDownOpen || combo_mode.IsSelectionBoxHighlighted) && combo_mode.SelectedItem != null)
            {
                try
                {
                    //запоминаем старый режим
                    oldmode = m.encodingmode;

                    string x265mode = combo_mode.SelectedItem.ToString();
                    if (x265mode == "1-Pass Bitrate") m.encodingmode = Settings.EncodingModes.OnePass;
                    else if (x265mode == "2-Pass Bitrate") m.encodingmode = Settings.EncodingModes.TwoPass;
                    else if (x265mode == "2-Pass Size") m.encodingmode = Settings.EncodingModes.TwoPassSize;
                    else if (x265mode == "3-Pass Bitrate") m.encodingmode = Settings.EncodingModes.ThreePass;
                    else if (x265mode == "3-Pass Size") m.encodingmode = Settings.EncodingModes.ThreePassSize;
                    else if (x265mode == "Constant Quality") m.encodingmode = Settings.EncodingModes.Quality;
                    else if (x265mode == "Constant Quantizer") m.encodingmode = Settings.EncodingModes.Quantizer;
                    else if (x265mode == "2-Pass Quality") m.encodingmode = Settings.EncodingModes.TwoPassQuality;
                    else if (x265mode == "3-Pass Quality") m.encodingmode = Settings.EncodingModes.ThreePassQuality;

                    SetMinMaxBitrate();

                    //Устанавливаем дефолтный битрейт (при необходимости)
                    if (oldmode == Settings.EncodingModes.OnePass ||
                        oldmode == Settings.EncodingModes.TwoPass ||
                        oldmode == Settings.EncodingModes.ThreePass)
                    {
                        if (m.encodingmode != Settings.EncodingModes.OnePass &&
                            m.encodingmode != Settings.EncodingModes.TwoPass &&
                            m.encodingmode != Settings.EncodingModes.ThreePass)
                            SetDefaultBitrates();
                    }
                    else if (oldmode.ToString().Contains("Size") && !m.encodingmode.ToString().Contains("Size"))
                    {
                        SetDefaultBitrates();
                    }
                    else if (oldmode.ToString().Contains("Quality") && !m.encodingmode.ToString().Contains("Quality"))
                    {
                        SetDefaultBitrates();
                    }
                    else if (oldmode == Settings.EncodingModes.Quantizer)
                    {
                        SetDefaultBitrates();
                    }

                    root_window.UpdateOutSize();
                    root_window.UpdateManualProfile();
                    UpdateCLI();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#15
0
        public void LoadFromProfile()
        {
            SetMinMaxBitrate();

            combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
            if (combo_mode.SelectedItem == null)
            {
                m.encodingmode = Settings.EncodingModes.Quality;
                combo_mode.SelectedItem = Calculate.EncodingModeEnumToString(m.encodingmode);
                SetMinMaxBitrate();
                SetDefaultBitrates();
            }

            //запоминаем первичные режим кодирования
            oldmode = m.encodingmode;

            if (m.encodingmode == Settings.EncodingModes.OnePass ||
                m.encodingmode == Settings.EncodingModes.TwoPass ||
                m.encodingmode == Settings.EncodingModes.ThreePass)
            {
                text_bitrate.Content = Languages.Translate("Bitrate") + ": (kbps)";
                num_bitrate.Value = (decimal)m.outvbitrate;
            }
            else if (m.encodingmode == Settings.EncodingModes.TwoPassSize ||
                     m.encodingmode == Settings.EncodingModes.ThreePassSize)
            {
                text_bitrate.Content = Languages.Translate("Size") + ": (MB)";
                num_bitrate.Value = (decimal)m.outvbitrate;
            }
            else
            {
                if (m.encodingmode == Settings.EncodingModes.Quantizer)
                    text_bitrate.Content = Languages.Translate("Quantizer") + ": (Q)";
                else
                    text_bitrate.Content = Languages.Translate("Quality") + ": (CRF)";

                num_bitrate.Value = (decimal)m.outvbitrate;
            }

            //Встроенный в x262 пресет
            text_preset_name.Content = m.x262options.preset.ToString();
            slider_preset.Value = (int)m.x262options.preset;

            //Level
            if (m.x262options.level == "low") combo_level.SelectedIndex = 1;
            else if (m.x262options.level == "main") combo_level.SelectedIndex = 2;
            else if (m.x262options.level == "high") combo_level.SelectedIndex = 3;
            else if (m.x262options.level == "high-1440") combo_level.SelectedIndex = 4;
            else if (m.x262options.level == "highp") combo_level.SelectedIndex = 5;
            else combo_level.SelectedIndex = 0;

            //Tune
            combo_tune.SelectedIndex = (int)m.x262options.tune;

            combo_adapt_quant_mode.SelectedIndex = m.x262options.aqmode;
            combo_adapt_quant.SelectedItem = m.x262options.aqstrength;

            num_psyrdo.Value = m.x262options.psyrdo;
            num_qcomp.Value = m.x262options.qcomp;
            num_vbv_max.Value = m.x262options.vbv_maxrate;
            num_vbv_buf.Value = m.x262options.vbv_bufsize;
            num_vbv_init.Value = m.x262options.vbv_init;

            //Прописываем subme
            combo_subme.SelectedIndex = m.x262options.subme;

            //прописываем me алгоритм
            if (m.x262options.me == "dia") combo_me.SelectedIndex = 0;
            else if (m.x262options.me == "hex") combo_me.SelectedIndex = 1;
            else if (m.x262options.me == "umh") combo_me.SelectedIndex = 2;
            else if (m.x262options.me == "esa") combo_me.SelectedIndex = 3;
            else if (m.x262options.me == "tesa") combo_me.SelectedIndex = 4;

            //прописываем me range
            combo_merange.SelectedItem = m.x262options.merange;

            //прописываем chroma me
            check_chroma.IsChecked = m.x262options.no_chroma;

            //B фреймы
            combo_bframes.SelectedItem = m.x262options.bframes;

            combo_dc_precision.SelectedItem = m.x262options.dc;

            if (!m.x262options.open_gop) combo_open_gop.SelectedIndex = 0;
            else combo_open_gop.SelectedIndex = 1;

            //altscan
            check_altscan.IsChecked = m.x262options.altscan;

            //fast p skip
            check_fast_pskip.IsChecked = m.x262options.no_fastpskip;

            //linear quantization
            check_linear_q.IsChecked = m.x262options.linear_q;

            //min-max quantizer
            num_min_quant.Value = m.x262options.min_quant;
            num_max_quant.Value = m.x262options.max_quant;
            num_step_quant.Value = m.x262options.step_quant;

            num_min_gop.Value = m.x262options.gop_min;
            num_max_gop.Value = m.x262options.gop_max;

            combo_badapt_mode.SelectedIndex = m.x262options.b_adapt;
            num_chroma_qp.Value = m.x262options.qp_offset;
            check_slow_first.IsChecked = m.x262options.slow_frstpass;
            check_nombtree.IsChecked = m.x262options.no_mbtree;
            num_lookahead.Value = m.x262options.lookahead;

            if (m.x262options.lookahead_threads == "auto") combo_lookahead_threads.SelectedIndex = 0;
            else combo_lookahead_threads.SelectedItem = m.x262options.lookahead_threads;

            check_enable_psy.IsChecked = !m.x262options.no_psy;
            num_ratio_ip.Value = m.x262options.ratio_ip;
            num_ratio_pb.Value = m.x262options.ratio_pb;
            num_slices.Value = m.x262options.slices;
            check_fake_int.IsChecked = m.x262options.fake_int;

            if (m.x262options.range_in == "auto") combo_range_in.SelectedIndex = 0;
            else if (m.x262options.range_in == "tv") combo_range_in.SelectedIndex = 1;
            else if (m.x262options.range_in == "pc") combo_range_in.SelectedIndex = 2;

            if (m.x262options.range_out == "auto") combo_range_out.SelectedIndex = 0;
            else if (m.x262options.range_out == "tv") combo_range_out.SelectedIndex = 1;
            else if (m.x262options.range_out == "pc") combo_range_out.SelectedIndex = 2;

            combo_colorprim.SelectedItem = m.x262options.colorprim;
            combo_transfer.SelectedItem = m.x262options.transfer;
            combo_colormatrix.SelectedItem = m.x262options.colormatrix;
            combo_colorspace.SelectedItem = m.x262options.colorspace;
            check_non_deterministic.IsChecked = m.x262options.non_deterministic;
            check_bluray.IsChecked = m.x262options.bluray;

            //Кол-во потоков для x262-го
            if (m.x262options.threads == "auto") combo_threads_count.SelectedIndex = 0;
            else if (m.x262options.threads == "1" && m.x262options.thread_input) combo_threads_count.SelectedIndex = 2;
            else combo_threads_count.SelectedItem = m.x262options.threads;

            //Включаем-выключаем элементы.
            //Сначала на основе --preset.
            if (m.x262options.preset == Presets.Ultrafast)
            {
                check_slow_first.IsEnabled = !m.x262options.extra_cli.Contains("--slow-firstpass");
                check_fast_pskip.IsEnabled = !m.x262options.extra_cli.Contains("--no-fast-pskip");
                check_nombtree.IsEnabled = false;
            }
            else if (m.x262options.preset == Presets.Superfast)
            {
                check_slow_first.IsEnabled = !m.x262options.extra_cli.Contains("--slow-firstpass");
                check_fast_pskip.IsEnabled = !m.x262options.extra_cli.Contains("--no-fast-pskip");
                check_nombtree.IsEnabled = false;
            }
            else if (m.x262options.preset == Presets.Veryfast || m.x262options.preset == Presets.Faster)
            {
                check_slow_first.IsEnabled = !m.x262options.extra_cli.Contains("--slow-firstpass");
                check_fast_pskip.IsEnabled = !m.x262options.extra_cli.Contains("--no-fast-pskip");
                check_nombtree.IsEnabled = !m.x262options.extra_cli.Contains("--no-mbtree");
            }
            else if (m.x262options.preset == Presets.Placebo)
            {
                check_slow_first.IsEnabled = false;
                check_fast_pskip.IsEnabled = false;
                check_nombtree.IsEnabled = !m.x262options.extra_cli.Contains("--no-mbtree");
            }
            else
            {
                //Для остальных
                check_slow_first.IsEnabled = !m.x262options.extra_cli.Contains("--slow-firstpass");
                check_fast_pskip.IsEnabled = !m.x262options.extra_cli.Contains("--no-fast-pskip");
                check_nombtree.IsEnabled = !m.x262options.extra_cli.Contains("--no-mbtree");
            }

            //Tune Grain
            /*if (m.x262options.tune == Tunes.Grain)
            {
            }
            else
            {
            }*/

            //Tune PSNR и SSIM
            if (m.x262options.tune == Tunes.PSNR || m.x262options.tune == Tunes.SSIM)
            {
                num_psyrdo.IsEnabled = check_enable_psy.IsEnabled = false;
            }
            else
            {
                check_enable_psy.IsEnabled = !m.x262options.extra_cli.Contains("--no-psy");
                num_psyrdo.IsEnabled = (!m.x262options.no_psy && !m.x262options.extra_cli.Contains("--psy-rd "));
            }

            //Tune FastDecode
            /*if (m.x262options.tune == Tunes.FastDecode)
            {
            }
            else
            {
            }*/

            //Теперь на основе содержимого extra_cli
            combo_level.IsEnabled = !m.x262options.extra_cli.Contains("--level ");
            combo_subme.IsEnabled = !m.x262options.extra_cli.Contains("--subme ");
            combo_me.IsEnabled = !m.x262options.extra_cli.Contains("--me ");
            combo_merange.IsEnabled = !m.x262options.extra_cli.Contains("--merange ");
            check_chroma.IsEnabled = !m.x262options.extra_cli.Contains("--no-chroma-me");
            combo_bframes.IsEnabled = !m.x262options.extra_cli.Contains("--bframes ");
            combo_dc_precision.IsEnabled = !m.x262options.extra_cli.Contains("--dc ");
            combo_badapt_mode.IsEnabled = !m.x262options.extra_cli.Contains("--b-adapt ");
            check_altscan.IsEnabled = !m.x262options.extra_cli.Contains("--altscan");
            num_lookahead.IsEnabled = !m.x262options.extra_cli.Contains("--rc-lookahead ");
            combo_lookahead_threads.IsEnabled = !m.x262options.extra_cli.Contains("--lookahead-threads ");
            combo_adapt_quant_mode.IsEnabled = !m.x262options.extra_cli.Contains("--aq-mode ");
            combo_adapt_quant.IsEnabled = !m.x262options.extra_cli.Contains("--ag-strength ");
            num_vbv_max.IsEnabled = !m.x262options.extra_cli.Contains("--vbv-maxrate ");
            num_vbv_buf.IsEnabled = !m.x262options.extra_cli.Contains("--vbv-bufsize ");
            num_vbv_init.IsEnabled = !m.x262options.extra_cli.Contains("--vbv-init ");
            num_min_gop.IsEnabled = !m.x262options.extra_cli.Contains("--min-keyint ");
            num_max_gop.IsEnabled = !m.x262options.extra_cli.Contains("--keyint ");
            num_min_quant.IsEnabled = !m.x262options.extra_cli.Contains("--qpmin ");
            num_max_quant.IsEnabled = !m.x262options.extra_cli.Contains("--qpmax ");
            num_step_quant.IsEnabled = !m.x262options.extra_cli.Contains("--qpstep ");
            num_qcomp.IsEnabled = !m.x262options.extra_cli.Contains("--qcomp ");
            num_chroma_qp.IsEnabled = !m.x262options.extra_cli.Contains("--chroma-qp-offset ");
            num_ratio_ip.IsEnabled = !m.x262options.extra_cli.Contains("--ipratio ");
            num_ratio_pb.IsEnabled = !m.x262options.extra_cli.Contains("--pbratio ");
            combo_open_gop.IsEnabled = !m.x262options.extra_cli.Contains("--open-gop");
            num_slices.IsEnabled = !m.x262options.extra_cli.Contains("--slices ");
            check_fake_int.IsEnabled = !m.x262options.extra_cli.Contains("--fake-interlaced");
            combo_range_in.IsEnabled = !m.x262options.extra_cli.Contains("--input-range ");
            combo_range_out.IsEnabled = !m.x262options.extra_cli.Contains("--range ");
            combo_colorprim.IsEnabled = !m.x262options.extra_cli.Contains("--colorprim ");
            combo_transfer.IsEnabled = !m.x262options.extra_cli.Contains("--transfer ");
            combo_colormatrix.IsEnabled = !m.x262options.extra_cli.Contains("--colormatrix ");
            combo_colorspace.IsEnabled = !m.x262options.extra_cli.Contains("--output-csp ");
            check_non_deterministic.IsEnabled = !m.x262options.extra_cli.Contains("--non-deterministic");
            check_bluray.IsEnabled = !m.x262options.extra_cli.Contains("--bluray-compat");

            SetMPEG2Profile();
            SetToolTips();
            UpdateCLI();
        }