summaryrefslogtreecommitdiff
path: root/src/subtitle.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-05-25 21:25:33 +0100
committerCarl Hetherington <cth@carlh.net>2014-05-25 21:25:33 +0100
commit8181d97d7f9ef0d44af748a5bd5666cf575955fe (patch)
treed27502e2c9e1acf554796d94987620804d5a25c9 /src/subtitle.cc
parentb5dc08b66bc7e2340dd5a8a0156036a65a49f269 (diff)
Change API for alternate representations of time / font size etc. Fix Arial recognition.
Diffstat (limited to 'src/subtitle.cc')
-rw-r--r--src/subtitle.cc79
1 files changed, 52 insertions, 27 deletions
diff --git a/src/subtitle.cc b/src/subtitle.cc
index 105bf31..6d3360f 100644
--- a/src/subtitle.cc
+++ b/src/subtitle.cc
@@ -37,37 +37,62 @@ sub::operator< (Subtitle const & a, Subtitle const & b)
assert (false);
}
-void
-sub::convert_font_sizes (list<Subtitle>& subs, int screen_height_in_points)
+FrameTime
+Subtitle::from_frame (float frames_per_second) const
{
- 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;
- }
+ if (from.frame) {
+ return from.frame.get ();
}
+
+ return metric_to_frame (from.metric.get(), frames_per_second);
+}
+
+FrameTime
+Subtitle::to_frame (float frames_per_second) const
+{
+ if (to.frame) {
+ return to.frame.get ();
+ }
+
+ return metric_to_frame (to.metric.get(), frames_per_second);
+}
+
+MetricTime
+Subtitle::from_metric (float frames_per_second) const
+{
+ if (from.metric) {
+ return from.metric.get ();
+ }
+
+ return frame_to_metric (from.frame.get(), frames_per_second);
}
-/** Take a list of Subtitles and convert their times either from metric to frame, or vice-versa,
- * depending on what the Subtitles currently have.
- * @param sub Subtitles.
- * @param frames_per_second Video frames-per-second value to use in the conversion.
- */
-void
-sub::convert_times (list<Subtitle>& subs, float frames_per_second)
+MetricTime
+Subtitle::to_metric (float frames_per_second) const
{
- 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);
- }
+ if (to.metric) {
+ return to.metric.get ();
}
+
+ return frame_to_metric (to.frame.get(), frames_per_second);
+}
+
+float
+Subtitle::font_size_proportional (int screen_height_in_points) const
+{
+ if (font_size.proportional) {
+ return font_size.proportional.get ();
+ }
+
+ return float (font_size.points.get ()) / screen_height_in_points;
+}
+
+int
+Subtitle::font_size_points (int screen_height_in_points) const
+{
+ if (font_size.points) {
+ return font_size.points.get ();
+ }
+
+ return font_size.proportional.get() * screen_height_in_points;
}