Allow specification of video bit rate separately for J2K and MPEG2.
[dcpomatic.git] / src / lib / config.cc
index 1400b93098f53a78538b352e3bcc680919422a6f..33b1a865659063042ca06d770b5dfca7d24290a1 100644 (file)
@@ -108,7 +108,8 @@ Config::set_defaults ()
        _default_still_length = 10;
        _default_dcp_content_type = DCPContentType::from_isdcf_name ("FTR");
        _default_dcp_audio_channels = 8;
-       _default_video_bit_rate = 150000000;
+       _default_video_bit_rate[VideoEncoding::JPEG2000] = 150000000;
+       _default_video_bit_rate[VideoEncoding::MPEG2] = 5000000;
        _default_audio_delay = 0;
        _default_interop = false;
        _default_metadata.clear ();
@@ -127,7 +128,8 @@ Config::set_defaults ()
        _notification_bcc = "";
        _check_for_updates = false;
        _check_for_test_updates = false;
-       _maximum_video_bit_rate = 250000000;
+       _maximum_video_bit_rate[VideoEncoding::JPEG2000] = 250000000;
+       _maximum_video_bit_rate[VideoEncoding::MPEG2] = 50000000;
        _log_types = LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR | LogEntry::TYPE_DISK;
        _analyse_ebur128 = true;
        _automatic_audio_analysis = false;
@@ -376,10 +378,11 @@ try
 
        _default_still_length = f.optional_number_child<int>("DefaultStillLength").get_value_or (10);
        if (auto j2k = f.optional_number_child<int>("DefaultJ2KBandwidth")) {
-               _default_video_bit_rate = *j2k;
+               _default_video_bit_rate[VideoEncoding::JPEG2000] = *j2k;
        } else {
-               _default_video_bit_rate = f.optional_number_child<int64_t>("DefaultVideoBitRate").get_value_or(200000000);
+               _default_video_bit_rate[VideoEncoding::JPEG2000] = f.optional_number_child<int64_t>("DefaultJ2KVideoBitRate").get_value_or(200000000);
        }
+       _default_video_bit_rate[VideoEncoding::MPEG2] = f.optional_number_child<int64_t>("DefaultMPEG2VideoBitRate").get_value_or(5000000);
        _default_audio_delay = f.optional_number_child<int>("DefaultAudioDelay").get_value_or (0);
        _default_interop = f.optional_bool_child("DefaultInterop").get_value_or (false);
 
@@ -455,10 +458,11 @@ try
        _check_for_test_updates = f.optional_bool_child("CheckForTestUpdates").get_value_or (false);
 
        if (auto j2k = f.optional_number_child<int>("MaximumJ2KBandwidth")) {
-               _maximum_video_bit_rate = *j2k;
+               _maximum_video_bit_rate[VideoEncoding::JPEG2000] = *j2k;
        } else {
-               _maximum_video_bit_rate = f.optional_number_child<int64_t>("MaximumVideoBitRate").get_value_or(250000000);
+               _maximum_video_bit_rate[VideoEncoding::JPEG2000] = f.optional_number_child<int64_t>("MaximumJ2KVideoBitRate").get_value_or(250000000);
        }
+       _maximum_video_bit_rate[VideoEncoding::MPEG2] = f.optional_number_child<int64_t>("MaximumMPEG2VideoBitRate").get_value_or(50000000);
        _allow_any_dcp_frame_rate = f.optional_bool_child ("AllowAnyDCPFrameRate").get_value_or (false);
        _allow_any_container = f.optional_bool_child ("AllowAnyContainer").get_value_or (false);
        _allow_96khz_audio = f.optional_bool_child("Allow96kHzAudio").get_value_or(false);
@@ -815,8 +819,10 @@ Config::write_config () const
 
        /* [XML] DefaultStillLength Default length (in seconds) for still images in new films. */
        cxml::add_text_child(root, "DefaultStillLength", raw_convert<string>(_default_still_length));
-       /* [XML] DefaultVideoBitRate Default bitrate (in bits per second) for JPEG2000 or MPEG2 data in new films. */
-       cxml::add_text_child(root, "DefaultVideoBitRate", raw_convert<string>(_default_video_bit_rate));
+       /* [XML] DefaultJ2KVideoBitRate Default bitrate (in bits per second) for JPEG2000 data in new films. */
+       cxml::add_text_child(root, "DefaultJ2KVideoBitRate", raw_convert<string>(_default_video_bit_rate[VideoEncoding::JPEG2000]));
+       /* [XML] DefaultMPEG2VideoBitRate Default bitrate (in bits per second) for MPEG2 data in new films. */
+       cxml::add_text_child(root, "DefaultMPEG2VideoBitRate", raw_convert<string>(_default_video_bit_rate[VideoEncoding::MPEG2]));
        /* [XML] DefaultAudioDelay Default delay to apply to audio (positive moves audio later) in milliseconds. */
        cxml::add_text_child(root, "DefaultAudioDelay", raw_convert<string>(_default_audio_delay));
        /* [XML] DefaultInterop 1 to default new films to Interop, 0 for SMPTE. */
@@ -896,8 +902,10 @@ Config::write_config () const
        /* [XML] CheckForUpdates 1 to check dcpomatic.com for new text versions, 0 to check only on request. */
        cxml::add_text_child(root, "CheckForTestUpdates", _check_for_test_updates ? "1" : "0");
 
-       /* [XML] MaximumVideoBitRate Maximum video bit rate (in bits per second) that can be specified in the GUI. */
-       cxml::add_text_child(root, "MaximumVideoBitRate", raw_convert<string>(_maximum_video_bit_rate));
+       /* [XML] MaximumJ2KVideoBitRate Maximum video bit rate (in bits per second) that can be specified in the GUI for JPEG2000 encodes. */
+       cxml::add_text_child(root, "MaximumJ2KVideoBitRate", raw_convert<string>(_maximum_video_bit_rate[VideoEncoding::JPEG2000]));
+       /* [XML] MaximumMPEG2VideoBitRate Maximum video bit rate (in bits per second) that can be specified in the GUI for MPEG2 encodes. */
+       cxml::add_text_child(root, "MaximumMPEG2VideoBitRate", raw_convert<string>(_maximum_video_bit_rate[VideoEncoding::MPEG2]));
        /* [XML] AllowAnyDCPFrameRate 1 to allow users to specify any frame rate when creating DCPs, 0 to limit the GUI to standard rates. */
        cxml::add_text_child(root, "AllowAnyDCPFrameRate", _allow_any_dcp_frame_rate ? "1" : "0");
        /* [XML] AllowAnyContainer 1 to allow users to user any container ratio for their DCP, 0 to limit the GUI to DCI Flat/Scope */