summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-06-04 00:17:12 +0100
committerCarl Hetherington <cth@carlh.net>2015-06-04 00:17:12 +0100
commit4f1751a9e43e515be773ee3871150f7beca325f5 (patch)
tree4b8c0c982c647bf5a5e8f82a052e8e48a103f337
parent7affca9f7b210c3137eb084cd393b534051a2647 (diff)
Fix horizontal positioning with .srt / burn-in (#488).
-rw-r--r--cscript2
-rw-r--r--src/lib/player.cc1
-rw-r--r--src/lib/render_subtitles.cc26
-rw-r--r--src/lib/subrip_decoder.cc4
4 files changed, 26 insertions, 7 deletions
diff --git a/cscript b/cscript
index ee9c586ee..92d8a50e5 100644
--- a/cscript
+++ b/cscript
@@ -207,7 +207,7 @@ def make_spec(filename, version, target):
def dependencies(target):
return (('ffmpeg-cdist', '0492ad2'),
- ('libdcp', '47b52fb'),
+ ('libdcp', '81fc376'),
('libsub', 'f66b11f'))
def configure_options(target):
diff --git a/src/lib/player.cc b/src/lib/player.cc
index f53bf68d2..0ddd835ad 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -586,6 +586,7 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting)
list<ContentTextSubtitle> text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting);
BOOST_FOREACH (ContentTextSubtitle& ts, text) {
BOOST_FOREACH (dcp::SubtitleString& s, ts.subs) {
+ s.set_h_position (s.h_position() + subtitle_content->subtitle_x_offset ());
s.set_v_position (s.v_position() + subtitle_content->subtitle_y_offset ());
float const xs = subtitle_content->subtitle_x_scale();
float const ys = subtitle_content->subtitle_y_scale();
diff --git a/src/lib/render_subtitles.cc b/src/lib/render_subtitles.cc
index 8f8958868..0d059eb43 100644
--- a/src/lib/render_subtitles.cc
+++ b/src/lib/render_subtitles.cc
@@ -128,23 +128,39 @@ render_subtitle (dcp::SubtitleString const & subtitle, dcp::Size target)
int layout_height;
layout->get_size (layout_width, layout_height);
+ int x = 0;
+ switch (subtitle.h_align ()) {
+ case dcp::HALIGN_LEFT:
+ /* h_position is distance between left of frame and left of subtitle */
+ x = subtitle.h_position() * target.width;
+ break;
+ case dcp::HALIGN_CENTER:
+ /* h_position is distance between centre of frame and centre of subtitle */
+ x = (0.5 + subtitle.h_position()) * target.width - layout_width / (PANGO_SCALE * 2);
+ break;
+ case dcp::HALIGN_RIGHT:
+ /* h_position is distance between right of frame and right of subtitle */
+ x = (1.0 - subtitle.h_position()) * target.width - layout_width / PANGO_SCALE;
+ break;
+ }
+
int y = 0;
switch (subtitle.v_align ()) {
- case dcp::TOP:
+ case dcp::VALIGN_TOP:
/* v_position is distance between top of frame and top of subtitle */
y = subtitle.v_position() * target.height;
break;
- case dcp::CENTER:
+ case dcp::VALIGN_CENTER:
/* v_position is distance between centre of frame and centre of subtitle */
- y = 0.5 + subtitle.v_position() * target.height - (layout_height / (PANGO_SCALE * 2));
+ y = (0.5 + subtitle.v_position()) * target.height - layout_height / (PANGO_SCALE * 2);
break;
- case dcp::BOTTOM:
+ case dcp::VALIGN_BOTTOM:
/* v_position is distance between bottom of frame and bottom of subtitle */
y = (1.0 - subtitle.v_position()) * target.height - layout_height / PANGO_SCALE;
break;
}
- return PositionImage (image, Position<int> ((image->size().width - layout_width * xscale / PANGO_SCALE) / 2, y));
+ return PositionImage (image, Position<int> (x, y));
}
list<PositionImage>
diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc
index dae2e4ab7..5c6d331df 100644
--- a/src/lib/subrip_decoder.cc
+++ b/src/lib/subrip_decoder.cc
@@ -68,8 +68,10 @@ SubRipDecoder::pass (PassReason)
1.0,
dcp::Time (_subtitles[_next].from.all_as_seconds()),
dcp::Time (_subtitles[_next].to.all_as_seconds()),
+ 0,
+ dcp::HALIGN_CENTER,
i->vertical_position.line.get() * (1.5 / 22) + 0.8,
- dcp::TOP,
+ dcp::VALIGN_TOP,
j->text,
dcp::NONE,
dcp::Colour (255, 255, 255),