summaryrefslogtreecommitdiff
path: root/src/stl_util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-01-13 11:31:55 +0000
committerCarl Hetherington <cth@carlh.net>2015-01-13 11:31:55 +0000
commitd15ef17dccf87b633d1971c38032a2049abe3db0 (patch)
tree3bbde3c1959bae6b0ad064972f95bd9406416fbb /src/stl_util.cc
parentacca8cb950de132fbc4be40e7dc7d294c6cb0a38 (diff)
Re-work time.
Diffstat (limited to 'src/stl_util.cc')
-rw-r--r--src/stl_util.cc30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/stl_util.cc b/src/stl_util.cc
index c145a34..2ee0100 100644
--- a/src/stl_util.cc
+++ b/src/stl_util.cc
@@ -26,40 +26,38 @@
using std::string;
using namespace sub;
-bool
-about_equal (float a, float b)
-{
- return fabs (a - b) < 1e-4;
-}
-
string
-sub::stl_frame_rate_to_dfc (float r)
+sub::stl_frame_rate_to_dfc (FrameRate r)
{
/* This is the FAB Subtitler mapping, as used by Annotation Edit */
- if (about_equal (r, 23.976)) {
+ switch (r) {
+ case TWENTY_THREE_DROP:
return "STL24.01";
- } else if (about_equal (r, 24)) {
+ case TWENTY_FOUR:
return "STL23.01";
- } else if (about_equal (r, 25)) {
+ case TWENTY_FIVE:
return "STL25.01";
- } else if (about_equal (r, 30)) {
+ case THIRTY_DROP:
+ /* XXX: not right, but I don't think there is a value for this */
+ return "STL30.01";
+ case THIRTY:
return "STL30.01";
}
return "STL25.01";
}
-float
+FrameRate
sub::stl_dfc_to_frame_rate (string s)
{
if (s == "STL24.01") {
- return 23.976;
+ return TWENTY_THREE_DROP;
} else if (s == "STL23.01") {
- return 24;
+ return TWENTY_FOUR;
} else if (s == "STL25.01") {
- return 25;
+ return TWENTY_FIVE;
} else if (s == "STL30.01") {
- return 30;
+ return THIRTY;
}
throw STLError (String::compose ("Unknown disk format code %1 in binary STL file", s));