summaryrefslogtreecommitdiff
path: root/src/subtitle.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-02-05 16:35:34 +0000
committerCarl Hetherington <cth@carlh.net>2014-02-05 16:35:34 +0000
commit6c5e5435d105685a537561ca0e6a223d34af85e1 (patch)
treeb2415a607f5fdaadc4a37edb7e7a68a5ef0bc7cc /src/subtitle.cc
parent095dcf9a0fb075ca84537beff2fe6a41c837e8da (diff)
Support for conversions of things that have multiple representations.
Diffstat (limited to 'src/subtitle.cc')
-rw-r--r--src/subtitle.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/subtitle.cc b/src/subtitle.cc
index d637ed9..26c4fd9 100644
--- a/src/subtitle.cc
+++ b/src/subtitle.cc
@@ -18,7 +18,9 @@
*/
#include "subtitle.h"
+#include "convert_time.h"
+using std::list;
using namespace sub;
bool
@@ -34,3 +36,33 @@ sub::operator< (Subtitle const & a, Subtitle const & b)
assert (false);
}
+
+void
+sub::convert_font_sizes (list<Subtitle>& subs, int screen_height_in_points)
+{
+ for (list<Subtitle>::iterator i = subs.begin(); i != subs.end(); ++i) {
+ if (i->font_size.proportional) {
+ i->font_size.points = i->font_size.proportional.get() * screen_height_in_points;
+ } else {
+ i->font_size.proportional = float (i->font_size.points.get()) / screen_height_in_points;
+ }
+ }
+}
+
+void
+sub::convert_times (list<Subtitle>& subs, float frames_per_second)
+{
+ for (list<Subtitle>::iterator i = subs.begin(); i != subs.end(); ++i) {
+ if (i->from.frame) {
+ i->from.metric = frame_to_metric (i->from.frame.get(), frames_per_second);
+ } else {
+ i->from.frame = metric_to_frame (i->from.metric.get(), frames_per_second);
+ }
+
+ if (i->to.frame) {
+ i->to.metric = frame_to_metric (i->to.frame.get(), frames_per_second);
+ } else {
+ i->to.frame = metric_to_frame (i->to.metric.get(), frames_per_second);
+ }
+ }
+}