vtc/
consts.rs

1use lazy_static::lazy_static;
2use num::rational::Ratio;
3use num::Rational64;
4use regex::Regex;
5
6/// The number of seconds in a minute as a Rational64.
7pub(super) const SECONDS_PER_MINUTE: Rational64 = Rational64::new_raw(60, 1);
8/// The number of seconds in an hour as a Rational64.
9pub(super) const SECONDS_PER_HOUR: Rational64 = Rational64::new_raw(60 * 60, 1);
10
11/// The number of performations in a foot of 35mm film.
12pub(super) const PERFS_PER_FOOT_35: i64 = 64;
13
14/// The number of performations in six inches of 16mm film.
15/// 16mm film counts in an XX+YY form, as 35mm, but YY rolls over every 20 frames,
16/// and there are 40 frames in a 16mm foot.
17pub(super) const PERFS_PER_6INCHES_16: i64 = 20;
18
19/// The number of ticks Adobe Premiere Pro breaks a second ratio.
20pub(super) const PREMIERE_TICKS_PER_SECOND: Ratio<i128> = Ratio::<i128>::new_raw(254016000000, 1);
21
22/// The number of seconds in a minute as an i64.
23pub(super) const SECONDS_PER_MINUTE_I64: i64 = 60;
24/// The number of seconds in an hour as an i64.
25pub(super) const SECONDS_PER_HOUR_I64: i64 = SECONDS_PER_MINUTE_I64 * 60;
26
27lazy_static! {
28    /// TIMECODE_REGEX is a regex for parsing timecode values.
29    pub(super) static ref TIMECODE_REGEX: Regex = regex::Regex::new(
30        r"^(?P<negative>-)?((?P<section1>[0-9]+)[:|;])?((?P<section2>[0-9]+)[:|;])?((?P<section3>[0-9]+)[:|;])?(?P<frames>[0-9]+)$"
31    ).unwrap();
32}
33
34lazy_static! {
35    /// TIMECODE_REGEX is a regex for parsing timecode values.
36    pub(super) static ref FEET_AND_FRAMES_REGEX: Regex = regex::Regex::new(
37        r"^(?P<negative>-)?(?P<feet>[0-9]+)\+(?P<frames>[0-9]+)(\.(?P<perf>[0-9]))?$",
38    ).unwrap();
39}
40
41lazy_static! {
42    /// RUNTIME_REGEX is a regex for parsing runtime values.
43    pub(super) static ref RUNTIME_REGEX: Regex = regex::Regex::new(
44        r"^(?P<negative>-)?((?P<section1>[0-9]+)[:|;])?((?P<section2>[0-9]+)[:|;])?(?P<seconds>[0-9]+(\.[0-9]+)?)$",
45    ).unwrap();
46}