Get initial colour conversion from FFmpeg header, if it's understood (#993).
authorCarl Hetherington <cth@carlh.net>
Sat, 13 May 2017 11:36:39 +0000 (12:36 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 13 May 2017 11:36:39 +0000 (12:36 +0100)
ChangeLog
src/lib/ffmpeg_content.cc

index e7e9684543ccbff40c61c48b339c9c2925472e32..b95bb611f1bf26b07d16df01fabfa1e89726e26e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-13  Carl Hetherington  <cth@carlh.net>
+
+       * Start off video content using the colour conversion
+       from their header, if present (#993).
+
 2017-05-12  Carl Hetherington  <cth@carlh.net>
 
        * Add option for default scale-to (#664).
index 44e1b2afb22363499a8b5d9c0b772ade907c1931..3cd9d66e2e1c5d034e3510c5475af2b508ba8e17 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);
 }
@@ -420,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;
        }
 }