X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ftext_decoder.cc;h=1e13bb3c98322c14bb8d32a0ca1063c9fc0eedca;hb=873531444a857760023d84c8530b109518f5fbd2;hp=56a7e1e1598a4853f80903b6e5aa69f54d87351d;hpb=d7ac100c0eb1b5efdcfbec59be870fd869252840;p=dcpomatic.git diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index 56a7e1e15..1e13bb3c9 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -40,10 +40,9 @@ using boost::function; TextDecoder::TextDecoder ( Decoder* parent, shared_ptr c, - shared_ptr log, ContentTime first ) - : DecoderPart (parent, log) + : DecoderPart (parent) , _content (c) , _position (first) { @@ -58,14 +57,14 @@ TextDecoder::TextDecoder ( * of the video frame) */ void -TextDecoder::emit_image_start (ContentTime from, shared_ptr image, dcpomatic::Rect rect) +TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr image, dcpomatic::Rect rect) { - ImageStart (ContentImageSubtitle (from, image, rect)); + BitmapStart (ContentBitmapText (from, image, rect)); _position = from; } void -TextDecoder::emit_text_start (ContentTime from, list s) +TextDecoder::emit_plain_start (ContentTime from, list s) { BOOST_FOREACH (dcp::SubtitleString& i, s) { /* We must escape < and > in strings, otherwise they might confuse our subtitle @@ -94,12 +93,12 @@ TextDecoder::emit_text_start (ContentTime from, list s) } } - TextStart (ContentTextSubtitle (from, s)); + PlainStart (ContentStringText (from, s)); _position = from; } void -TextDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtitle) +TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle) { /* See if our next subtitle needs to be vertically placed on screen by us */ bool needs_placement = false; @@ -148,9 +147,14 @@ TextDecoder::emit_text_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 */ @@ -191,7 +195,7 @@ TextDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtitle) /* The idea here (rightly or wrongly) is that we set the appearance based on the values in the libsub objects, and these are overridden with values from the - content by the other emit_text_start() above. + content by the other emit_plain_start() above. */ out.push_back ( @@ -227,7 +231,7 @@ TextDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtitle) } } - emit_text_start (from, out); + emit_plain_start (from, out); } void @@ -237,16 +241,27 @@ TextDecoder::emit_stop (ContentTime to) } void -TextDecoder::emit_text (ContentTimePeriod period, list s) +TextDecoder::emit_plain (ContentTimePeriod period, list s) { - emit_text_start (period.from, s); + emit_plain_start (period.from, s); emit_stop (period.to); } void -TextDecoder::emit_text (ContentTimePeriod period, sub::Subtitle const & s) +TextDecoder::emit_plain (ContentTimePeriod period, sub::Subtitle const & s) +{ + emit_plain_start (period.from, 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, dcpomatic::Rect rect) { - emit_text_start (period.from, s); + emit_bitmap_start (period.from, image, rect); emit_stop (period.to); }