Exemplo n.º 1
0
 public static bool OnFrameBoundary(double time, double frameRate)
 {
     return(TimeUtility.OnFrameBoundary(time, frameRate, Math.Max(time, 1.0) * frameRate * TimeUtility.kTimeEpsilon));
 }
Exemplo n.º 2
0
 public static double ToExactFrames(double time, double frameRate)
 {
     TimeUtility.ValidateFrameRate(frameRate);
     return(time * frameRate);
 }
Exemplo n.º 3
0
 public static double FromFrames(double frames, double frameRate)
 {
     TimeUtility.ValidateFrameRate(frameRate);
     return(frames / frameRate);
 }
Exemplo n.º 4
0
        public static double ParseTimeCode(string timeCode, double frameRate, double defaultValue)
        {
            timeCode = TimeUtility.RemoveChar(timeCode, (char c) => char.IsWhiteSpace(c));
            string[] array = timeCode.Split(new char[]
            {
                ':'
            });
            double result;

            if (array.Length == 0 || array.Length > 4)
            {
                result = defaultValue;
            }
            else
            {
                int    num  = 0;
                int    num2 = 0;
                double num3 = 0.0;
                double num4 = 0.0;
                try
                {
                    string text = array[array.Length - 1];
                    if (Regex.Match(text, "^\\d+\\.\\d+$").Success)
                    {
                        num3 = double.Parse(text);
                        if (array.Length > 3)
                        {
                            return(defaultValue);
                        }
                        if (array.Length > 1)
                        {
                            num2 = int.Parse(array[array.Length - 2]);
                        }
                        if (array.Length > 2)
                        {
                            num = int.Parse(array[array.Length - 3]);
                        }
                    }
                    else
                    {
                        if (Regex.Match(text, "^\\d+\\[\\.\\d+\\]$").Success)
                        {
                            string s = TimeUtility.RemoveChar(text, (char c) => c == '[' || c == ']');
                            num4 = double.Parse(s);
                        }
                        else
                        {
                            if (!Regex.Match(text, "^\\d*$").Success)
                            {
                                return(defaultValue);
                            }
                            num4 = (double)int.Parse(text);
                        }
                        if (array.Length > 1)
                        {
                            num3 = (double)int.Parse(array[array.Length - 2]);
                        }
                        if (array.Length > 2)
                        {
                            num2 = int.Parse(array[array.Length - 3]);
                        }
                        if (array.Length > 3)
                        {
                            num = int.Parse(array[array.Length - 4]);
                        }
                    }
                }
                catch (FormatException)
                {
                    return(defaultValue);
                }
                result = num4 / frameRate + num3 + (double)(num2 * 60) + (double)(num * 3600);
            }
            return(result);
        }