Stop erroneous addition of text subtitles to the lists (when
[dcpomatic.git] / src / lib / player.cc
index 3ae95cf5275d2ea0f5393c6d7d9abc40909e9501..30f36107f231cc05a724df4e380ab147ad69c875 100644 (file)
@@ -27,8 +27,8 @@
 #include "sndfile_decoder.h"
 #include "sndfile_content.h"
 #include "subtitle_content.h"
-#include "subrip_decoder.h"
-#include "subrip_content.h"
+#include "text_subtitle_decoder.h"
+#include "text_subtitle_content.h"
 #include "dcp_content.h"
 #include "job.h"
 #include "image.h"
@@ -174,10 +174,10 @@ Player::setup_pieces ()
                   as simultaneous video content (like we do with audio).
                */
 
-               /* SubRipContent */
-               shared_ptr<const SubRipContent> rc = dynamic_pointer_cast<const SubRipContent> (i);
+               /* TextSubtitleContent */
+               shared_ptr<const TextSubtitleContent> rc = dynamic_pointer_cast<const TextSubtitleContent> (i);
                if (rc) {
-                       decoder.reset (new SubRipDecoder (rc));
+                       decoder.reset (new TextSubtitleDecoder (rc));
                        frc = FrameRateChange (rc->subtitle_video_frame_rate(), _film->video_frame_rate());
                }
 
@@ -219,7 +219,11 @@ Player::playlist_content_changed (weak_ptr<Content> w, int property, bool freque
                property == ContentProperty::TRIM_END ||
                property == ContentProperty::PATH ||
                property == VideoContentProperty::VIDEO_FRAME_TYPE ||
-               property == DCPContentProperty::CAN_BE_PLAYED
+               property == DCPContentProperty::CAN_BE_PLAYED ||
+               property == TextSubtitleContentProperty::TEXT_SUBTITLE_COLOUR ||
+               property == TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE ||
+               property == TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE_COLOUR ||
+               property == FFmpegContentProperty::SUBTITLE_STREAM
                ) {
 
                _have_valid_pieces = false;
@@ -667,8 +671,17 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt,
                                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();
-                               float const average = s.size() * (xs + ys) / 2;
-                               s.set_size (average);
+                               float size = s.size();
+
+                               /* Adjust size to express the common part of the scaling;
+                                  e.g. if xs = ys = 0.5 we scale size by 2.
+                               */
+                               if (xs > 1e-5 && ys > 1e-5) {
+                                       size *= 1 / min (1 / xs, 1 / ys);
+                               }
+                               s.set_size (size);
+
+                               /* Then express aspect ratio changes */
                                if (fabs (1.0 - xs / ys) > dcp::ASPECT_ADJUST_EPSILON) {
                                        s.set_aspect_adjust (xs / ys);
                                }
@@ -783,6 +796,7 @@ Player::get_reel_assets ()
                        }
 
                        if (j->reference_subtitle ()) {
+                               DCPOMATIC_ASSERT (k->main_subtitle ());
                                a.push_back (
                                        ReferencedReelAsset (
                                                k->main_subtitle (),