CCAP doc tweaks.
[dcpomatic.git] / src / lib / subtitle_decoder.cc
index 714c784b1c0de49b871b2dbccfc37ac6ee0472e0..32cae6accc0e40318ad495944bcb3ce2aedd6beb 100644 (file)
@@ -61,6 +61,7 @@ void
 SubtitleDecoder::emit_image_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
 {
        ImageStart (ContentImageSubtitle (from, image, rect));
+       _position = from;
 }
 
 void
@@ -75,16 +76,22 @@ SubtitleDecoder::emit_text_start (ContentTime from, list<dcp::SubtitleString> s)
                boost::algorithm::replace_all (t, ">", "&gt;");
                i.set_text (t);
 
-               /* Force our configured appearance */
-               i.set_colour (content()->colour());
-               i.set_effect_colour (content()->effect_colour());
-               if (content()->outline()) {
-                       i.set_effect (dcp::BORDER);
-               } else if (content()->shadow()) {
-                       i.set_effect (dcp::SHADOW);
+               /* Set any forced appearance */
+               if (content()->colour()) {
+                       i.set_colour (*content()->colour());
+               }
+               if (content()->effect_colour()) {
+                       i.set_effect_colour (*content()->effect_colour());
+               }
+               if (content()->effect()) {
+                       i.set_effect (*content()->effect());
+               }
+               if (content()->fade_in()) {
+                       i.set_fade_up_time (dcp::Time(content()->fade_in()->seconds(), 1000));
+               }
+               if (content()->fade_out()) {
+                       i.set_fade_down_time (dcp::Time(content()->fade_out()->seconds(), 1000));
                }
-               i.set_fade_up_time (dcp::Time(content()->fade_in().seconds(), 1000));
-               i.set_fade_down_time (dcp::Time(content()->fade_out().seconds(), 1000));
        }
 
        TextStart (ContentTextSubtitle (from, s));
@@ -207,8 +214,14 @@ SubtitleDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtit
                                        j.text,
                                        dcp::NONE,
                                        j.effect_colour.get_value_or(sub::Colour(0, 0, 0)).dcp(),
-                                       dcp::Time (subtitle.fade_up.get_value_or(sub::Time()).all_as_seconds(), 1000),
-                                       dcp::Time (subtitle.fade_down.get_value_or(sub::Time()).all_as_seconds(), 1000)
+                                       /* Hack: we should use subtitle.fade_up and subtitle.fade_down here
+                                          but the times of these often don't have a frame rate associated
+                                          with them so the sub::Time won't convert them to milliseconds without
+                                          throwing an exception.  Since only DCP subs fill those in (and we don't
+                                          use libsub for DCP subs) we can cheat by just putting 0 in here.
+                                       */
+                                       dcp::Time (),
+                                       dcp::Time ()
                                        )
                                );
                }