summaryrefslogtreecommitdiff
path: root/src/subtitle.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-05-29 11:57:08 +0100
committerCarl Hetherington <cth@carlh.net>2014-05-29 11:57:08 +0100
commitaebf2cb7812c8f593b85182611b587e6014aefc6 (patch)
treec954ebc0cf39263b6c051e159f48e177cafae310 /src/subtitle.cc
parent8b1958988ca234f51ec99385d81b95c1f0f092af (diff)
Re-work Subtitle class; remove STL text writer.
Diffstat (limited to 'src/subtitle.cc')
-rw-r--r--src/subtitle.cc76
1 files changed, 30 insertions, 46 deletions
diff --git a/src/subtitle.cc b/src/subtitle.cc
index 6d3360f..5eb5784 100644
--- a/src/subtitle.cc
+++ b/src/subtitle.cc
@@ -18,81 +18,65 @@
*/
#include "subtitle.h"
-#include "convert_time.h"
-using std::list;
using namespace sub;
bool
sub::operator< (Subtitle const & a, Subtitle const & b)
{
- if (a.from.frame && b.from.frame) {
- return a.from.frame.get() < b.from.frame.get();
+ if (a.from.frame() && b.from.frame()) {
+ return a.from.frame().get() < b.from.frame().get();
}
- if (a.from.metric && b.from.metric) {
- return a.from.metric.get() < b.from.metric.get();
+ if (a.from.metric() && b.from.metric()) {
+ return a.from.metric().get() < b.from.metric().get();
}
assert (false);
}
-FrameTime
-Subtitle::from_frame (float frames_per_second) const
-{
- 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
+float
+Block::FontSize::proportional (int screen_height_in_points) const
{
- if (to.frame) {
- return to.frame.get ();
+ if (_proportional) {
+ return _proportional.get ();
}
- return metric_to_frame (to.metric.get(), frames_per_second);
+ return float (_points.get ()) / screen_height_in_points;
}
-MetricTime
-Subtitle::from_metric (float frames_per_second) const
+int
+Block::FontSize::points (int screen_height_in_points) const
{
- if (from.metric) {
- return from.metric.get ();
+ if (_points) {
+ return _points.get ();
}
- return frame_to_metric (from.frame.get(), frames_per_second);
+ return _proportional.get() * screen_height_in_points;
}
-MetricTime
-Subtitle::to_metric (float frames_per_second) const
+bool
+Subtitle::same_metadata (Subtitle const & other) const
{
- if (to.metric) {
- return to.metric.get ();
- }
-
- return frame_to_metric (to.frame.get(), frames_per_second);
+ return (
+ vertical_position == other.vertical_position &&
+ from == other.from &&
+ to == other.to &&
+ fade_up == other.fade_up &&
+ fade_down == other.fade_down
+ );
}
-float
-Subtitle::font_size_proportional (int screen_height_in_points) const
+bool
+Subtitle::VerticalPosition::operator== (Subtitle::VerticalPosition const & other) const
{
- if (font_size.proportional) {
- return font_size.proportional.get ();
+ if (proportional && reference && other.proportional && other.reference) {
+ return proportional.get() == other.proportional.get() && reference.get() == other.reference.get();
+ } else if (line && other.line) {
+ return line.get() == other.line.get();
}
- return float (font_size.points.get ()) / screen_height_in_points;
+ return false;
}
-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;
-}