From a8364241532c0c4b064c30d6151f1a248a27e467 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 28 Jul 2017 17:04:03 +0100 Subject: [PATCH] Support more detailed horizontal positioning coming from libsub. --- ChangeLog | 2 ++ cscript | 2 +- src/lib/ffmpeg_decoder.cc | 7 ++++++- src/lib/subtitle_decoder.cc | 21 +++++++++++++++++---- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19f656509..a64e2fec6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2017-07-28 Carl Hetherington + * Support a few more SSA style tags. + * Updated de_DE translation from Carsten Kurz. * Version 2.11.15 released. diff --git a/cscript b/cscript index 0a8604fc6..6daf34f14 100644 --- a/cscript +++ b/cscript @@ -296,7 +296,7 @@ def dependencies(target): return (('ffmpeg-cdist', '5fce90f', ffmpeg_options), ('libdcp', '047d8ff'), - ('libsub', 'd3cbf2f'), + ('libsub', 'ec880ed'), ('rtaudio-cdist', None)) def configure_options(target): diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index a09eab68e..af309cdbe 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -647,7 +647,12 @@ FFmpegDecoder::decode_ass_subtitle (string ass, ContentTime from) } sub::RawSubtitle base; - list raw = sub::SSAReader::parse_line (base, bits[9]); + list raw = sub::SSAReader::parse_line ( + base, + bits[9], + _ffmpeg_content->video->size().width, + _ffmpeg_content->video->size().height + ); BOOST_FOREACH (sub::Subtitle const & i, sub::collect > (raw)) { subtitle->emit_text_start (from, i); diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index 4e68e4a79..a3eed6374 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -81,7 +81,7 @@ SubtitleDecoder::emit_text_start (ContentTime from, list s) void SubtitleDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtitle) { - /* See if our next subtitle needs to be placed on screen by us */ + /* See if our next subtitle needs to be vertically placed on screen by us */ bool needs_placement = false; optional bottom_line; BOOST_FOREACH (sub::Line i, subtitle.lines) { @@ -141,7 +141,7 @@ SubtitleDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtit case sub::TOP_OF_SCREEN: v_align = dcp::VALIGN_TOP; break; - case sub::CENTRE_OF_SCREEN: + case sub::VERTICAL_CENTRE_OF_SCREEN: v_align = dcp::VALIGN_CENTER; break; case sub::BOTTOM_OF_SCREEN: @@ -160,6 +160,19 @@ SubtitleDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtit effect = dcp::SHADOW; } + dcp::HAlign h_align; + switch (i.horizontal_position.reference) { + case sub::LEFT_OF_SCREEN: + h_align = dcp::HALIGN_LEFT; + break; + case sub::HORIZONTAL_CENTRE_OF_SCREEN: + h_align = dcp::HALIGN_CENTER; + break; + case sub::RIGHT_OF_SCREEN: + h_align = dcp::HALIGN_RIGHT; + break; + } + out.push_back ( dcp::SubtitleString ( string(TEXT_FONT_ID), @@ -173,8 +186,8 @@ SubtitleDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtit dcp::Time (from.seconds(), 1000), /* XXX: hmm; this is a bit ugly (we don't know the to time yet) */ dcp::Time (), - 0, - dcp::HALIGN_CENTER, + i.horizontal_position.proportional, + h_align, v_position, v_align, dcp::DIRECTION_LTR, -- 2.30.2