Exemple #1
0
        public static bool OnFrameBoundary(double time, double frameRate, double epsilon)
        {
            TimeUtility.ValidateFrameRate(frameRate);
            double num  = TimeUtility.ToExactFrames(time, frameRate);
            double num2 = Math.Round(num);

            return(Math.Abs(num - num2) < epsilon);
        }
Exemple #2
0
        public static double RoundToFrame(double time, double frameRate)
        {
            TimeUtility.ValidateFrameRate(frameRate);
            double num  = Math.Max((double)((int)Math.Floor(time * frameRate)) / frameRate, 0.0);
            double num2 = Math.Max((double)((int)Math.Ceiling(time * frameRate)) / frameRate, 0.0);

            return((Math.Abs(time - num) >= Math.Abs(time - num2)) ? num2 : num);
        }
Exemple #3
0
        public static int ToFrames(double time, double frameRate)
        {
            TimeUtility.ValidateFrameRate(frameRate);
            double num = TimeUtility.kTimeEpsilon * time;
            int    result;

            if (time < 0.0)
            {
                result = (int)Math.Ceiling(time * frameRate + num);
            }
            else
            {
                result = (int)Math.Floor(time * frameRate + num);
            }
            return(result);
        }
Exemple #4
0
        public static string TimeAsTimeCode(double timeValue, double frameRate, string format = "F2")
        {
            TimeUtility.ValidateFrameRate(frameRate);
            int    num  = (int)Math.Abs(timeValue);
            int    num2 = num / 3600;
            int    num3 = num % 3600 / 60;
            int    num4 = num % 60;
            string str  = (timeValue >= 0.0) ? string.Empty : "-";
            string str2;

            if (num2 > 0)
            {
                str2 = string.Concat(new string[]
                {
                    num2.ToString(),
                    ":",
                    num3.ToString("D2"),
                    ":",
                    num4.ToString("D2")
                });
            }
            else
            {
                if (num3 > 0)
                {
                    str2 = num3.ToString() + ":" + num4.ToString("D2");
                }
                else
                {
                    str2 = num4.ToString();
                }
            }
            int    totalWidth = (int)Math.Floor(Math.Log10(frameRate) + 1.0);
            string text       = (TimeUtility.ToFrames(timeValue, frameRate) - TimeUtility.ToFrames((double)num, frameRate)).ToString().PadLeft(totalWidth, '0');

            if (!TimeUtility.OnFrameBoundary(timeValue, frameRate))
            {
                string text2 = TimeUtility.ToExactFrames(timeValue, frameRate).ToString(format);
                int    num5  = text2.IndexOf('.');
                if (num5 >= 0)
                {
                    text = text + " [" + text2.Substring(num5) + "]";
                }
            }
            return(str + str2 + ":" + text);
        }
Exemple #5
0
 public static double FromFrames(double frames, double frameRate)
 {
     TimeUtility.ValidateFrameRate(frameRate);
     return(frames / frameRate);
 }
Exemple #6
0
 public static double ToExactFrames(double time, double frameRate)
 {
     TimeUtility.ValidateFrameRate(frameRate);
     return(time * frameRate);
 }