Tweak ISO6937 mapping to put $ sign on 0xa4 (164) (from master).
[libsub.git] / src / subtitle.cc
index 26c4fd921470862e8aff6b701d2847a92b482bf8..663c16185da051659c2f62597b5eceed59c969bd 100644 (file)
 */
 
 #include "subtitle.h"
-#include "convert_time.h"
 
-using std::list;
 using namespace sub;
 
-bool
-sub::operator< (Subtitle const & a, Subtitle const & b)
+Subtitle::Subtitle (RawSubtitle s)
+       : from (s.from)
+       , to (s.to)
+       , fade_up (s.fade_up)
+       , fade_down (s.fade_down)
 {
-       if (a.from.frame && b.from.frame) {
-               return a.from.frame.get() < b.from.frame.get();
-       }
+       lines.push_back (Line (s));
+}
 
-       if (a.from.metric && b.from.metric) {
-               return a.from.metric.get() < b.from.metric.get();
-       }
+bool
+Subtitle::same_metadata (RawSubtitle s) const
+{
+       return from == s.from && to == s.to && fade_up == s.fade_up && fade_down == s.fade_down;
+}
 
-       assert (false);
+Line::Line (RawSubtitle s)
+       : vertical_position (s.vertical_position)
+{
+       blocks.push_back (Block (s));
 }
 
-void
-sub::convert_font_sizes (list<Subtitle>& subs, int screen_height_in_points)
+bool
+Line::same_metadata (RawSubtitle s) 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;
-               }
-       }
+       return vertical_position == s.vertical_position;
 }
 
-void
-sub::convert_times (list<Subtitle>& subs, float frames_per_second)
+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)
 {
-       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);
-               }
-       }
 }