*/
#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.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
+Subtitle::Subtitle (RawSubtitle s)
+ : from (s.from)
+ , to (s.to)
+ , fade_up (s.fade_up)
+ , fade_down (s.fade_down)
{
- if (to.frame) {
- return to.frame.get ();
- }
-
- return metric_to_frame (to.metric.get(), frames_per_second);
+ lines.push_back (Line (s));
}
-MetricTime
-Subtitle::from_metric (float frames_per_second) const
+bool
+Subtitle::same_metadata (RawSubtitle s) const
{
- if (from.metric) {
- return from.metric.get ();
- }
-
- return frame_to_metric (from.frame.get(), frames_per_second);
+ return from == s.from && to == s.to && fade_up == s.fade_up && fade_down == s.fade_down;
}
-MetricTime
-Subtitle::to_metric (float frames_per_second) const
+Line::Line (RawSubtitle s)
+ : vertical_position (s.vertical_position)
{
- if (to.metric) {
- return to.metric.get ();
- }
-
- return frame_to_metric (to.frame.get(), frames_per_second);
+ blocks.push_back (Block (s));
}
-float
-Subtitle::font_size_proportional (int screen_height_in_points) const
+bool
+Line::same_metadata (RawSubtitle s) const
{
- if (font_size.proportional) {
- return font_size.proportional.get ();
- }
-
- return float (font_size.points.get ()) / screen_height_in_points;
+ return vertical_position == s.vertical_position;
}
-int
-Subtitle::font_size_points (int screen_height_in_points) const
+Block::Block (RawSubtitle s)
+ : text (s.text)
+ , font (s.font)
+ , font_size (s.font_size)
+ , effect (s.effect)
+ , effect_colour (s.effect_colour)
+ , colour (s.colour)
+ , bold (s.bold)
+ , italic (s.italic)
+ , underline (s.underline)
{
- if (font_size.points) {
- return font_size.points.get ();
- }
- return font_size.proportional.get() * screen_height_in_points;
}