Support binary STL subtitle files.
[dcpomatic.git] / src / lib / text_decoder.cc
index 00d58af869f0135fa45d4d00388f02d734623453..1e13bb3c98322c14bb8d32a0ca1063c9fc0eedca 100644 (file)
@@ -40,10 +40,9 @@ using boost::function;
 TextDecoder::TextDecoder (
        Decoder* parent,
        shared_ptr<const TextContent> c,
-       shared_ptr<Log> log,
        ContentTime first
        )
-       : DecoderPart (parent, log)
+       : DecoderPart (parent)
        , _content (c)
        , _position (first)
 {
@@ -148,9 +147,14 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle)
 
                                v_align = dcp::VALIGN_TOP;
                        } else {
-                               DCPOMATIC_ASSERT (i.vertical_position.proportional);
                                DCPOMATIC_ASSERT (i.vertical_position.reference);
-                               v_position = i.vertical_position.proportional.get();
+                               if (i.vertical_position.proportional) {
+                                       v_position = i.vertical_position.proportional.get();
+                               } else {
+                                       DCPOMATIC_ASSERT (i.vertical_position.line);
+                                       DCPOMATIC_ASSERT (i.vertical_position.lines);
+                                       v_position = float(*i.vertical_position.line) / *i.vertical_position.lines;
+                               }
 
                                if (lowest_proportional) {
                                        /* Adjust line spacing */
@@ -250,6 +254,17 @@ TextDecoder::emit_plain (ContentTimePeriod period, sub::Subtitle const & s)
        emit_stop (period.to);
 }
 
+/*  @param rect Area expressed as a fraction of the video frame that this subtitle
+ *  is for (e.g. a width of 0.5 means the width of the subtitle is half the width
+ *  of the video frame)
+ */
+void
+TextDecoder::emit_bitmap (ContentTimePeriod period, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
+{
+       emit_bitmap_start (period.from, image, rect);
+       emit_stop (period.to);
+}
+
 void
 TextDecoder::seek ()
 {