Apply subtitle scale (ish) to text subs; should help with #413.
[dcpomatic.git] / src / lib / player.cc
index f83c9563b29ce80cab262ad02c22c913219cf835..db99cd2ad81626bbe10180bc3e28ea9ea878cf43 100644 (file)
@@ -17,8 +17,6 @@
 
 */
 
-#include <stdint.h>
-#include <algorithm>
 #include "player.h"
 #include "film.h"
 #include "ffmpeg_decoder.h"
@@ -48,6 +46,9 @@
 #include "dcp_decoder.h"
 #include "dcp_subtitle_content.h"
 #include "dcp_subtitle_decoder.h"
+#include <boost/foreach.hpp>
+#include <stdint.h>
+#include <algorithm>
 
 #define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
 
@@ -300,6 +301,7 @@ Player::black_player_video_frame (DCPTime time) const
                        shared_ptr<const ImageProxy> (new RawImageProxy (_black_image, _film->log ())),
                        time,
                        Crop (),
+                       optional<float> (),
                        _video_container_size,
                        _video_container_size,
                        Scaler::from_id ("bicubic"),
@@ -356,6 +358,7 @@ Player::get_video (DCPTime time, bool accurate)
                                                i->image,
                                                content_video_to_dcp (piece, i->frame),
                                                content->crop (),
+                                               content->fade (i->frame),
                                                image_size,
                                                _video_container_size,
                                                _film->scaler(),
@@ -570,8 +573,12 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting)
                }
 
                list<ContentTextSubtitle> text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting);
-               for (list<ContentTextSubtitle>::const_iterator i = text.begin(); i != text.end(); ++i) {
-                       copy (i->subs.begin(), i->subs.end(), back_inserter (ps.text));
+               BOOST_FOREACH (ContentTextSubtitle& ts, text) {
+                       BOOST_FOREACH (dcp::SubtitleString& s, ts.subs) {
+                               s.set_v_position (s.v_position() + subtitle_content->subtitle_y_offset ());
+                               s.set_size (s.size() * max (subtitle_content->subtitle_x_scale(), subtitle_content->subtitle_y_scale()));
+                               ps.text.push_back (s);
+                       }
                }
        }