Fix subtitle scaling when writing PNG subs.
[dcpomatic.git] / src / lib / player.cc
index cf9bc2e63dd61a43c4e64a28d398917e8c4594a3..12c03e3066ad4c47ed311ee454f2c482c0eabe5e 100644 (file)
@@ -237,6 +237,8 @@ Player::playlist_content_change (ChangeType type, int property, bool frequent)
        } else if (type == CHANGE_TYPE_DONE) {
                /* A change in our content has gone through.  Re-build our pieces. */
                setup_pieces ();
+       } else if (type == CHANGE_TYPE_CANCELLED) {
+               _suspended = false;
        }
 
        Change (type, property, frequent);
@@ -914,7 +916,10 @@ Player::bitmap_text_start (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, C
        subtitle.sub.rectangle.height *= text->y_scale ();
 
        PlayerText ps;
-       ps.bitmap.push_back (subtitle.sub);
+       shared_ptr<Image> image = subtitle.sub.image;
+       /* We will scale the subtitle up to fit _video_container_size */
+       dcp::Size scaled_size (subtitle.sub.rectangle.width * _video_container_size.width, subtitle.sub.rectangle.height * _video_container_size.height);
+       ps.bitmap.push_back (BitmapText(image->scale(scaled_size, dcp::YUV_TO_RGB_REC601, image->pixel_format(), true, _fast), subtitle.sub.rectangle));
        DCPTime from (content_time_to_dcp (piece, subtitle.from()));
 
        _active_texts[text->type()].add_from (wc, ps, from);
@@ -991,7 +996,7 @@ Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, Conte
 
        bool const always = (text->type() == TEXT_OPEN_SUBTITLE && _always_burn_open_subtitles);
        if (text->use() && !always && !text->burn()) {
-               Text (from.first, text->type(), DCPTimePeriod (from.second, dcp_to));
+               Text (from.first, text->type(), text->dcp_track().get_value_or(DCPTextTrack()), DCPTimePeriod (from.second, dcp_to));
        }
 }