Exemplo n.º 1
0
        public static string GetInputLine(string input, string indexFile, bool interlaced, PossibleSources sourceType,
                                          bool colormatrix, bool mpeg2deblock, bool flipVertical, double fps, bool dss2,
                                          NvDeinterlacerType nvDeintType, int nvHorizontalResolution, int nvVerticalResolution, CropValues nvCropValues)
        {
            string inputLine  = "#input";
            string strDLLPath = "";

            switch (sourceType)
            {
            case PossibleSources.avs:
                inputLine = "Import(\"" + input + "\")";
                break;

            case PossibleSources.d2v:
                UpdateCacher.CheckPackage("dgindex");
                if (String.IsNullOrEmpty(indexFile))
                {
                    indexFile = input;
                }
                strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DGIndex.Path), "DGDecode.dll");
                inputLine  = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGDecode_mpeg2source(\"" + indexFile + "\"";
                if (mpeg2deblock)
                {
                    inputLine += ", cpu=4";
                }
                if (colormatrix)
                {
                    inputLine += ", info=3";
                }
                inputLine += ")";
                if (colormatrix)
                {
                    inputLine += string.Format("\r\nLoadPlugin(\"" + Path.Combine(MainForm.Instance.Settings.AvisynthPluginsPath, "ColorMatrix.dll") + "\")\r\nColorMatrix(hints=true{0}, threads=0)", interlaced ? ", interlaced=true" : "");
                }
                break;

            case PossibleSources.dgm:
                UpdateCacher.CheckPackage("dgindexim");
                if (String.IsNullOrEmpty(indexFile))
                {
                    indexFile = input;
                }
                strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DGIndexIM.Path), "dgdecodeim.dll");
                inputLine  = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGSourceIM(\"" + indexFile + "\", silent=true)";
                if (MainForm.Instance.Settings.AviSynthPlus && MainForm.Instance.Settings.Input8Bit)
                {
                    inputLine += "\r\nConvertBits(8)";
                }
                break;

            case PossibleSources.dgi:
                UpdateCacher.CheckPackage("dgindexnv");
                if (String.IsNullOrEmpty(indexFile))
                {
                    indexFile = input;
                }
                strDLLPath = Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.DGIndexNV.Path), "DGDecodeNV.dll");
                inputLine  = "LoadPlugin(\"" + strDLLPath + "\")\r\nDGSource(\"" + indexFile + "\"";
                if (MainForm.Instance.Settings.AutoForceFilm &&
                    MainForm.Instance.Settings.ForceFilmThreshold <= (decimal)dgiFile.GetFilmPercent(indexFile))
                {
                    inputLine += ",fieldop=1";     // fieldop=0 is the default value
                }
                if (nvDeintType != NvDeinterlacerType.nvDeInterlacerNone)
                {
                    inputLine += ScriptServer.GetNvDeInterlacerLine(true, nvDeintType);
                }
                if (nvCropValues != null && nvCropValues.isCropped())
                {
                    GetMod4Cropping(ref nvCropValues);
                    inputLine += ", ct=" + nvCropValues.top + ", cb=" + nvCropValues.bottom + ", cl=" + nvCropValues.left + ", cr=" + nvCropValues.right;
                }
                if (nvHorizontalResolution > 0 && nvVerticalResolution > 0)
                {
                    inputLine += ", rw=" + nvHorizontalResolution + ", rh=" + nvVerticalResolution;
                }
                inputLine += ")";
                if (MainForm.Instance.Settings.AviSynthPlus && MainForm.Instance.Settings.Input8Bit)
                {
                    inputLine += "\r\nConvertBits(8)";
                }
                break;

            case PossibleSources.ffindex:
                inputLine = VideoUtil.getFFMSVideoInputLine(input, indexFile, fps);
                break;

            case PossibleSources.lsmash:
                MediaInfoFile oInfo = null;
                inputLine = VideoUtil.getLSMASHVideoInputLine(input, indexFile, fps, ref oInfo);
                if (oInfo != null)
                {
                    oInfo.Dispose();
                }
                break;

            case PossibleSources.vdr:
            case PossibleSources.avisource:
                inputLine = "AVISource(\"" + input + "\", audio=false)" + VideoUtil.getAssumeFPS(fps, input);
                if (MainForm.Instance.Settings.AviSynthPlus && MainForm.Instance.Settings.Input8Bit)
                {
                    inputLine += "\r\nConvertBits(8)";
                }
                break;

            case PossibleSources.directShow:
                if (dss2)
                {
                    string path = MeGUI.core.util.FileUtil.GetHaaliInstalledPath();
                    if (!File.Exists(Path.Combine(path, "avss.dll")))
                    {
                        UpdateCacher.CheckPackage("haali");
                        path = Path.GetDirectoryName(MainForm.Instance.Settings.Haali.Path);
                    }
                    inputLine = "LoadPlugin(\"" + path + "\\avss.dll" + "\")\r\ndss2(\"" + input + "\"" + ((fps > 0) ? ", fps=" + fps.ToString("F3", new CultureInfo("en-us")) : string.Empty) + ")" + VideoUtil.getAssumeFPS(fps, input);
                }
                else
                {
                    inputLine = String.Empty;
                    if (MainForm.Instance.Settings.PortableAviSynth)
                    {
                        inputLine = "LoadPlugin(\"" + Path.Combine(Path.GetDirectoryName(MainForm.Instance.Settings.AviSynth.Path), @"plugins\directshowsource.dll") + "\")\r\n";
                    }
                    inputLine += "DirectShowSource(\"" + input + "\"" + ((fps > 0) ? ", fps=" + fps.ToString("F3", new CultureInfo("en-us")) : string.Empty) + ", audio=false, convertfps=true)" + VideoUtil.getAssumeFPS(fps, input);
                }
                if (MainForm.Instance.Settings.AviSynthPlus && MainForm.Instance.Settings.Input8Bit)
                {
                    inputLine += "\r\nConvertBits(8)";
                }
                if (flipVertical)
                {
                    inputLine = inputLine + "\r\nFlipVertical()";
                }
                break;
            }
            return(inputLine);
        }