typeid() doesn't seem to downcast, so just check types in the take_settings_from...
[dcpomatic.git] / src / lib / ffmpeg_content.cc
index 0e782c9dbd5124100f2001590afdc69f5f29fb52..06ed5a8014f81db7b29b3efe1bf73c1017a789b1 100644 (file)
@@ -243,7 +243,6 @@ FFmpegContent::examine (shared_ptr<Job> job)
        if (examiner->has_video ()) {
                video.reset (new VideoContent (this));
                video->take_from_examiner (examiner);
-               set_default_colour_conversion ();
        }
 
        boost::filesystem::path first_path = path (0);
@@ -281,6 +280,10 @@ FFmpegContent::examine (shared_ptr<Job> job)
 
        }
 
+       if (examiner->has_video ()) {
+               set_default_colour_conversion ();
+       }
+
        signal_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
        signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
 }
@@ -394,7 +397,7 @@ FFmpegContent::identifier () const
                s += "_" + video->identifier();
        }
 
-       if (subtitle) {
+       if (subtitle && subtitle->use() && subtitle->burn()) {
                s += "_" + subtitle->identifier();
        }
 
@@ -411,28 +414,6 @@ FFmpegContent::identifier () const
        return s;
 }
 
-list<ContentTimePeriod>
-FFmpegContent::image_subtitles_during (ContentTimePeriod period, bool starting) const
-{
-       shared_ptr<FFmpegSubtitleStream> stream = subtitle_stream ();
-       if (!stream) {
-               return list<ContentTimePeriod> ();
-       }
-
-       return stream->image_subtitles_during (period, starting);
-}
-
-list<ContentTimePeriod>
-FFmpegContent::text_subtitles_during (ContentTimePeriod period, bool starting) const
-{
-       shared_ptr<FFmpegSubtitleStream> stream = subtitle_stream ();
-       if (!stream) {
-               return list<ContentTimePeriod> ();
-       }
-
-       return stream->text_subtitles_during (period, starting);
-}
-
 void
 FFmpegContent::set_default_colour_conversion ()
 {
@@ -442,10 +423,29 @@ FFmpegContent::set_default_colour_conversion ()
 
        boost::mutex::scoped_lock lm (_mutex);
 
-       if (s.width < 1080) {
-               video->set_colour_conversion (PresetColourConversion::from_id ("rec601").conversion);
-       } else {
+       switch (_colorspace) {
+       case AVCOL_SPC_RGB:
+               video->set_colour_conversion (PresetColourConversion::from_id ("srgb").conversion);
+               break;
+       case AVCOL_SPC_BT709:
                video->set_colour_conversion (PresetColourConversion::from_id ("rec709").conversion);
+               break;
+       case AVCOL_SPC_BT470BG:
+       case AVCOL_SPC_SMPTE170M:
+       case AVCOL_SPC_SMPTE240M:
+               video->set_colour_conversion (PresetColourConversion::from_id ("rec601").conversion);
+               break;
+       case AVCOL_SPC_BT2020_CL:
+       case AVCOL_SPC_BT2020_NCL:
+               video->set_colour_conversion (PresetColourConversion::from_id ("rec2020").conversion);
+               break;
+       default:
+               if (s.width < 1080) {
+                       video->set_colour_conversion (PresetColourConversion::from_id ("rec601").conversion);
+               } else {
+                       video->set_colour_conversion (PresetColourConversion::from_id ("rec709").conversion);
+               }
+               break;
        }
 }
 
@@ -604,10 +604,13 @@ FFmpegContent::ffmpeg_audio_streams () const
 }
 
 void
-FFmpegContent::use_template (shared_ptr<const Content> c)
+FFmpegContent::take_settings_from (shared_ptr<const Content> c)
 {
-       Content::use_template (c);
-
        shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (c);
+       if (!fc) {
+               return;
+               }
+
+       Content::take_settings_from (c);
        _filters = fc->_filters;
 }