Rename j2k_bandwidth -> video_bit_rate.
authorCarl Hetherington <cth@carlh.net>
Fri, 5 Apr 2024 19:57:03 +0000 (21:57 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 21 Apr 2024 21:18:23 +0000 (23:18 +0200)
28 files changed:
src/lib/config.cc
src/lib/config.h
src/lib/create_cli.cc
src/lib/create_cli.h
src/lib/dcp_video.cc
src/lib/dcp_video.h
src/lib/film.cc
src/lib/film.h
src/lib/film_property.h
src/lib/grok/context.h
src/lib/hints.cc
src/lib/hints.h
src/lib/j2k_encoder.cc
src/lib/make_dcp.cc
src/lib/playlist.cc
src/lib/playlist.h
src/tools/dcpomatic_cli.cc
src/wx/dcp_panel.cc
src/wx/dcp_panel.h
src/wx/full_config_dialog.cc
test/create_cli_test.cc
test/film_metadata_test.cc
test/j2k_bandwidth_test.cc [deleted file]
test/j2k_video_bit_rate_test.cc [new file with mode: 0644]
test/reels_test.cc
test/required_disk_space_test.cc
test/test.cc
test/wscript

index fb7a413de710db00cda5eb004dbe8e884d02dbc7..1400b93098f53a78538b352e3bcc680919422a6f 100644 (file)
@@ -108,7 +108,7 @@ Config::set_defaults ()
        _default_still_length = 10;
        _default_dcp_content_type = DCPContentType::from_isdcf_name ("FTR");
        _default_dcp_audio_channels = 8;
-       _default_j2k_bandwidth = 150000000;
+       _default_video_bit_rate = 150000000;
        _default_audio_delay = 0;
        _default_interop = false;
        _default_metadata.clear ();
@@ -127,7 +127,7 @@ Config::set_defaults ()
        _notification_bcc = "";
        _check_for_updates = false;
        _check_for_test_updates = false;
-       _maximum_j2k_bandwidth = 250000000;
+       _maximum_video_bit_rate = 250000000;
        _log_types = LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR | LogEntry::TYPE_DISK;
        _analyse_ebur128 = true;
        _automatic_audio_analysis = false;
@@ -375,7 +375,11 @@ try
        _dcp_j2k_comment = f.optional_string_child("DCPJ2KComment").get_value_or("");
 
        _default_still_length = f.optional_number_child<int>("DefaultStillLength").get_value_or (10);
-       _default_j2k_bandwidth = f.optional_number_child<int>("DefaultJ2KBandwidth").get_value_or (200000000);
+       if (auto j2k = f.optional_number_child<int>("DefaultJ2KBandwidth")) {
+               _default_video_bit_rate = *j2k;
+       } else {
+               _default_video_bit_rate = f.optional_number_child<int64_t>("DefaultVideoBitRate").get_value_or(200000000);
+       }
        _default_audio_delay = f.optional_number_child<int>("DefaultAudioDelay").get_value_or (0);
        _default_interop = f.optional_bool_child("DefaultInterop").get_value_or (false);
 
@@ -450,7 +454,11 @@ try
        _check_for_updates = f.optional_bool_child("CheckForUpdates").get_value_or (false);
        _check_for_test_updates = f.optional_bool_child("CheckForTestUpdates").get_value_or (false);
 
-       _maximum_j2k_bandwidth = f.optional_number_child<int> ("MaximumJ2KBandwidth").get_value_or (250000000);
+       if (auto j2k = f.optional_number_child<int>("MaximumJ2KBandwidth")) {
+               _maximum_video_bit_rate = *j2k;
+       } else {
+               _maximum_video_bit_rate = f.optional_number_child<int64_t>("MaximumVideoBitRate").get_value_or(250000000);
+       }
        _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);
@@ -807,8 +815,8 @@ 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] DefaultJ2KBandwidth Default bitrate (in bits per second) for JPEG2000 data in new films. */
-       cxml::add_text_child(root, "DefaultJ2KBandwidth", raw_convert<string>(_default_j2k_bandwidth));
+       /* [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] 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. */
@@ -888,8 +896,8 @@ 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] MaximumJ2KBandwidth Maximum J2K bandwidth (in bits per second) that can be specified in the GUI. */
-       cxml::add_text_child(root, "MaximumJ2KBandwidth", raw_convert<string>(_maximum_j2k_bandwidth));
+       /* [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] 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 */
index ec804c9bf58cbdad822028f2da3f7f135b972706..05421c20a7688ddf6b3fc8c4ea7667d16b151931 100644 (file)
@@ -232,8 +232,8 @@ public:
                return _dcp_j2k_comment;
        }
 
-       int default_j2k_bandwidth () const {
-               return _default_j2k_bandwidth;
+       int64_t default_video_bit_rate() const {
+               return _default_video_bit_rate;
        }
 
        int default_audio_delay () const {
@@ -348,8 +348,8 @@ public:
                return _check_for_test_updates;
        }
 
-       int maximum_j2k_bandwidth () const {
-               return _maximum_j2k_bandwidth;
+       int64_t maximum_video_bit_rate() const {
+               return _maximum_video_bit_rate;
        }
 
        int log_types () const {
@@ -810,8 +810,8 @@ public:
                maybe_set (_dcp_j2k_comment, c);
        }
 
-       void set_default_j2k_bandwidth (int b) {
-               maybe_set (_default_j2k_bandwidth, b);
+       void set_default_video_bit_rate(int64_t b) {
+               maybe_set(_default_video_bit_rate, b);
        }
 
        void set_default_audio_delay (int d) {
@@ -933,8 +933,8 @@ public:
                maybe_set (_check_for_test_updates, c);
        }
 
-       void set_maximum_j2k_bandwidth (int b) {
-               maybe_set (_maximum_j2k_bandwidth, b);
+       void set_maximum_video_bit_rate(int64_t b) {
+               maybe_set(_maximum_video_bit_rate, b);
        }
 
        void set_log_types (int t) {
@@ -1380,7 +1380,7 @@ private:
        std::string _dcp_product_name;
        std::string _dcp_product_version;
        std::string _dcp_j2k_comment;
-       int _default_j2k_bandwidth;
+       int64_t _default_video_bit_rate;
        int _default_audio_delay;
        bool _default_interop;
        boost::optional<dcp::LanguageTag> _default_audio_language;
@@ -1417,8 +1417,8 @@ private:
        /** true to check for updates on startup */
        bool _check_for_updates;
        bool _check_for_test_updates;
-       /** maximum allowed J2K bandwidth in bits per second */
-       int _maximum_j2k_bandwidth;
+       /** maximum allowed video bit rate in bits per second */
+       int64_t _maximum_video_bit_rate;
        int _log_types;
        bool _analyse_ebur128;
        bool _automatic_audio_analysis;
index cf903e376097fd684091f446f261ba883acfbc54..b33537974bae5adea41081fa7777439b7ee50b75 100644 (file)
@@ -133,7 +133,7 @@ CreateCLI::CreateCLI (int argc, char* argv[])
        optional<string> standard_string;
        int dcp_frame_rate_int = 0;
        string template_name_string;
-       int j2k_bandwidth_int = 0;
+       int64_t video_bit_rate_int = 0;
        auto next_frame_type = VideoFrameType::TWO_D;
        optional<dcp::Channel> channel;
        optional<float> gain;
@@ -206,7 +206,7 @@ CreateCLI::CreateCLI (int argc, char* argv[])
                argument_option(i, argc, argv, "",   "--standard",         &claimed, &error, &standard_string, string_to_string);
                argument_option(i, argc, argv, "",   "--config",           &claimed, &error, &config_dir, string_to_path);
                argument_option(i, argc, argv, "-o", "--output",           &claimed, &error, &output_dir, string_to_path);
-               argument_option(i, argc, argv, "",   "--j2k-bandwidth",    &claimed, &error, &j2k_bandwidth_int);
+               argument_option(i, argc, argv, "",   "--video-bit-rate",   &claimed, &error, &video_bit_rate_int);
 
                std::function<optional<dcp::Channel> (string)> convert_channel = [](string channel) -> optional<dcp::Channel>{
                        if (channel == "L") {
@@ -272,8 +272,8 @@ CreateCLI::CreateCLI (int argc, char* argv[])
                dcp_frame_rate = dcp_frame_rate_int;
        }
 
-       if (j2k_bandwidth_int) {
-               _j2k_bandwidth = j2k_bandwidth_int * 1000000;
+       if (video_bit_rate_int) {
+               _video_bit_rate = video_bit_rate_int * 1000000;
        }
 
        if (dcp_content_type_string) {
@@ -320,8 +320,8 @@ CreateCLI::CreateCLI (int argc, char* argv[])
                _name = content[0].path.filename().string();
        }
 
-       if (_j2k_bandwidth && (*_j2k_bandwidth < 10000000 || *_j2k_bandwidth > Config::instance()->maximum_j2k_bandwidth())) {
-               error = String::compose("%1: j2k-bandwidth must be between 10 and %2 Mbit/s", argv[0], (Config::instance()->maximum_j2k_bandwidth() / 1000000));
+       if (_video_bit_rate && (*_video_bit_rate < 10000000 || *_video_bit_rate > Config::instance()->maximum_video_bit_rate())) {
+               error = String::compose("%1: video-bit-rate must be between 10 and %2 Mbit/s", argv[0], (Config::instance()->maximum_video_bit_rate() / 1000000));
                return;
        }
 }
@@ -372,8 +372,8 @@ CreateCLI::make_film() const
        if (_fourk) {
                film->set_resolution(Resolution::FOUR_K);
        }
-       if (_j2k_bandwidth) {
-               film->set_j2k_bandwidth(*_j2k_bandwidth);
+       if (_video_bit_rate) {
+               film->set_video_bit_rate(*_video_bit_rate);
        }
 
        int channels = 6;
index 782aaf97478d10e01063c0373229657af1fd0583..850cddea9d86d197dffa2574d3ef9320899ccf78 100644 (file)
@@ -72,7 +72,7 @@ private:
        bool _no_use_isdcf_name = false;
        bool _twok = false;
        bool _fourk = false;
-       boost::optional<int> _j2k_bandwidth;
+       boost::optional<int64_t> _video_bit_rate;
 
        static std::string _help;
 };
index 6580ac448bc9d80c0c7e83983e1bd5e88fa5fc3d..ec88888ddb573c7b221277e0cc10e50eb1a8a8f0 100644 (file)
@@ -74,15 +74,15 @@ using namespace boost::placeholders;
 /** Construct a DCP video frame.
  *  @param frame Input frame.
  *  @param index Index of the frame within the DCP.
- *  @param bw J2K bandwidth to use (see Config::j2k_bandwidth ())
+ *  @param bit_rate Video bit rate to use.
  */
 DCPVideo::DCPVideo (
-       shared_ptr<const PlayerVideo> frame, int index, int dcp_fps, int bw, Resolution r
+       shared_ptr<const PlayerVideo> frame, int index, int dcp_fps, int64_t bit_rate, Resolution r
        )
        : _frame (frame)
        , _index (index)
        , _frames_per_second (dcp_fps)
-       , _j2k_bandwidth (bw)
+       , _video_bit_rate(bit_rate)
        , _resolution (r)
 {
 
@@ -93,7 +93,7 @@ DCPVideo::DCPVideo (shared_ptr<const PlayerVideo> frame, shared_ptr<const cxml::
 {
        _index = node->number_child<int> ("Index");
        _frames_per_second = node->number_child<int> ("FramesPerSecond");
-       _j2k_bandwidth = node->number_child<int> ("J2KBandwidth");
+       _video_bit_rate = node->number_child<int64_t>("VideoBitRate");
        _resolution = Resolution (node->optional_number_child<int>("Resolution").get_value_or(static_cast<int>(Resolution::TWO_K)));
 }
 
@@ -160,7 +160,7 @@ DCPVideo::encode_locally () const
        while (true) {
                enc = dcp::compress_j2k (
                        xyz,
-                       _j2k_bandwidth,
+                       _video_bit_rate,
                        _frames_per_second,
                        _frame->eyes() == Eyes::LEFT || _frame->eyes() == Eyes::RIGHT,
                        _resolution == Resolution::FOUR_K,
@@ -280,7 +280,7 @@ DCPVideo::add_metadata (xmlpp::Element* el) const
 {
        cxml::add_text_child(el, "Index", raw_convert<string>(_index));
        cxml::add_text_child(el, "FramesPerSecond", raw_convert<string>(_frames_per_second));
-       cxml::add_text_child(el, "J2KBandwidth", raw_convert<string>(_j2k_bandwidth));
+       cxml::add_text_child(el, "VideoBitRate", raw_convert<string>(_video_bit_rate));
        cxml::add_text_child(el, "Resolution", raw_convert<string>(int(_resolution)));
        _frame->add_metadata (el);
 }
@@ -298,7 +298,7 @@ bool
 DCPVideo::same (shared_ptr<const DCPVideo> other) const
 {
        if (_frames_per_second != other->_frames_per_second ||
-           _j2k_bandwidth != other->_j2k_bandwidth ||
+           _video_bit_rate != other->_video_bit_rate ||
            _resolution != other->_resolution) {
                return false;
        }
index d07c8322b56a456de6ddd1417eca3bdcd3e960ee..92c155f0c1d915399abfded39ea6c1158b3e5ceb 100644 (file)
@@ -49,7 +49,7 @@ class PlayerVideo;
 class DCPVideo
 {
 public:
-       DCPVideo (std::shared_ptr<const PlayerVideo>, int index, int dcp_fps, int bandwidth, Resolution r);
+       DCPVideo(std::shared_ptr<const PlayerVideo>, int index, int dcp_fps, int64_t bit_rate, Resolution r);
        DCPVideo (std::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr);
 
        DCPVideo (DCPVideo const&) = default;
@@ -78,7 +78,7 @@ private:
        std::shared_ptr<const PlayerVideo> _frame;
        int _index;                      ///< frame index within the DCP's intrinsic duration
        int _frames_per_second;          ///< Frames per second that we will use for the DCP
-       int _j2k_bandwidth;              ///< J2K bandwidth to use
+       int64_t _video_bit_rate;         ///< Video bit rate to use
        Resolution _resolution;          ///< Resolution (2K or 4K)
 };
 
index fd703a72a348380f6ae6ea32e7d03224ce28dd68..3de536a6d95fcec2aeb70a8afcbdd522820b53d0 100644 (file)
@@ -163,7 +163,7 @@ Film::Film (optional<boost::filesystem::path> dir)
        , _resolution (Resolution::TWO_K)
        , _encrypted (false)
        , _context_id (dcp::make_uuid ())
-       , _j2k_bandwidth (Config::instance()->default_j2k_bandwidth ())
+       , _video_bit_rate(Config::instance()->default_video_bit_rate())
        , _video_frame_rate (24)
        , _audio_channels (Config::instance()->default_dcp_audio_channels ())
        , _three_d (false)
@@ -240,7 +240,7 @@ Film::video_identifier () const
                + "_" + resolution_to_string (_resolution)
                + "_" + _playlist->video_identifier()
                + "_" + raw_convert<string>(_video_frame_rate)
-               + "_" + raw_convert<string>(j2k_bandwidth());
+               + "_" + raw_convert<string>(video_bit_rate());
 
        if (encrypted ()) {
                /* This is insecure but hey, the key is in plaintext in metadata.xml */
@@ -397,7 +397,7 @@ Film::metadata (bool with_content_paths) const
        }
 
        cxml::add_text_child(root, "Resolution", resolution_to_string(_resolution));
-       cxml::add_text_child(root, "J2KBandwidth", raw_convert<string>(_j2k_bandwidth));
+       cxml::add_text_child(root, "VideoBitRate", raw_convert<string>(_video_bit_rate));
        cxml::add_text_child(root, "VideoFrameRate", raw_convert<string>(_video_frame_rate));
        cxml::add_text_child(root, "AudioFrameRate", raw_convert<string>(_audio_frame_rate));
        cxml::add_text_child(root, "ISDCFDate", boost::gregorian::to_iso_string(_isdcf_date));
@@ -569,7 +569,11 @@ Film::read_metadata (optional<boost::filesystem::path> path)
        }
 
        _resolution = string_to_resolution (f.string_child ("Resolution"));
-       _j2k_bandwidth = f.number_child<int> ("J2KBandwidth");
+       if (auto j2k = f.optional_number_child<int>("J2KBandwidth")) {
+               _video_bit_rate = *j2k;
+       } else {
+               _video_bit_rate = f.number_child<int64_t>("VideoBitRate");
+       }
        _video_frame_rate = f.number_child<int> ("VideoFrameRate");
        _audio_frame_rate = f.optional_number_child<int>("AudioFrameRate").get_value_or(48000);
        _encrypted = f.bool_child ("Encrypted");
@@ -1169,10 +1173,10 @@ Film::set_resolution (Resolution r, bool explicit_user)
 
 
 void
-Film::set_j2k_bandwidth (int b)
+Film::set_video_bit_rate(int64_t bit_rate)
 {
-       FilmChangeSignaller ch(this, FilmProperty::J2K_BANDWIDTH);
-       _j2k_bandwidth = b;
+       FilmChangeSignaller ch(this, FilmProperty::VIDEO_BIT_RATE);
+       _video_bit_rate = bit_rate;
 }
 
 /** @param f New frame rate.
@@ -1765,7 +1769,7 @@ Film::make_kdm(boost::filesystem::path cpl_file, dcp::LocalTime from, dcp::Local
 uint64_t
 Film::required_disk_space () const
 {
-       return _playlist->required_disk_space (shared_from_this(), j2k_bandwidth(), audio_channels(), audio_frame_rate());
+       return _playlist->required_disk_space (shared_from_this(), video_bit_rate(), audio_channels(), audio_frame_rate());
 }
 
 /** This method checks the disk that the Film is on and tries to decide whether or not
@@ -1897,7 +1901,7 @@ Film::reels () const
                /* Integer-divide reel length by the size of one frame to give the number of frames per reel,
                 * making sure we don't go less than 1s long.
                 */
-               Frame const reel_in_frames = max(_reel_length / ((j2k_bandwidth() / video_frame_rate()) / 8), static_cast<Frame>(video_frame_rate()));
+               Frame const reel_in_frames = max(_reel_length / ((video_bit_rate() / video_frame_rate()) / 8), static_cast<Frame>(video_frame_rate()));
                while (current < len) {
                        DCPTime end = min (len, current + DCPTime::from_frames (reel_in_frames, video_frame_rate ()));
                        periods.emplace_back(current, end);
@@ -1941,7 +1945,7 @@ Film::use_template (string name)
        _dcp_content_type = _template_film->_dcp_content_type;
        _container = _template_film->_container;
        _resolution = _template_film->_resolution;
-       _j2k_bandwidth = _template_film->_j2k_bandwidth;
+       _video_bit_rate = _template_film->_video_bit_rate;
        _video_frame_rate = _template_film->_video_frame_rate;
        _encrypted = _template_film->_encrypted;
        _audio_channels = _template_film->_audio_channels;
index 0a0c5a4e1dcadd716af7197d3335eeb185ca0821..392f1dc5e39fd2faf41eb5e7457e60bad68c42d5 100644 (file)
@@ -250,8 +250,8 @@ public:
                return _key;
        }
 
-       int j2k_bandwidth () const {
-               return _j2k_bandwidth;
+       int video_bit_rate() const {
+               return _video_bit_rate;
        }
 
        /** @return The frame rate of the DCP */
@@ -401,7 +401,7 @@ public:
        void set_container (Ratio const *, bool user_explicit = true);
        void set_resolution (Resolution, bool user_explicit = true);
        void set_encrypted (bool);
-       void set_j2k_bandwidth (int);
+       void set_video_bit_rate(int64_t);
        void set_video_frame_rate (int rate, bool user_explicit = false);
        void set_audio_channels (int);
        void set_three_d (bool);
@@ -515,8 +515,8 @@ private:
         *  re-start picture MXF encodes.
         */
        std::string _context_id;
-       /** bandwidth for J2K files in bits per second */
-       int _j2k_bandwidth;
+       /** bit rate for encoding video using J2K or MPEG2 in bits per second */
+       int64_t _video_bit_rate;
        /** Frames per second to run our DCP at */
        int _video_frame_rate;
        /** The date that we should use in a ISDCF name */
index 0841caa5ca19ea56ab1b3778e36c6cd18b687db3..b755a4887418f4e684a1cca3b22a8556cdfb3e15 100644 (file)
@@ -39,7 +39,7 @@ enum class FilmProperty {
        CONTAINER,
        RESOLUTION,
        ENCRYPTED,
-       J2K_BANDWIDTH,
+       VIDEO_BIT_RATE,
        VIDEO_FRAME_RATE,
        AUDIO_FRAME_RATE,
        AUDIO_CHANNELS,
index 521faae8d7c74543bf28d4cf9c28f6c0788e7c04..fc9b74a579628c1db21d69405917c92379dacea9 100644 (file)
@@ -226,7 +226,7 @@ public:
                                        device,
                                        _dcpomatic_context->film->resolution() == Resolution::FOUR_K,
                                        _dcpomatic_context->film->video_frame_rate(),
-                                       _dcpomatic_context->film->j2k_bandwidth(),
+                                       _dcpomatic_context->film->video_bit_rate(),
                                        grok.licence_server,
                                        grok.licence_port,
                                        grok.licence)) {
index 7a6a2a4bfce32fb5a3ad22939b0cfec1ed1446e5..fc59fa703a6252e9c08d2483cfd13afa2117f8b8 100644 (file)
@@ -173,10 +173,10 @@ Hints::check_unusual_container ()
 
 
 void
-Hints::check_high_j2k_bandwidth ()
+Hints::check_high_video_bit_rate()
 {
-       if (film()->j2k_bandwidth() >= 245000000) {
-               hint (_("A few projectors have problems playing back very high bit-rate DCPs.  It is a good idea to drop the JPEG2000 bandwidth down to about 200Mbit/s; this is unlikely to have any visible effect on the image."));
+       if (film()->video_bit_rate() >= 245000000) {
+               hint (_("A few projectors have problems playing back very high bit-rate DCPs.  It is a good idea to drop the video bit rate down to about 200Mbit/s; this is unlikely to have any visible effect on the image."));
        }
 }
 
@@ -468,7 +468,7 @@ try
        check_upmixers ();
        check_incorrect_container ();
        check_unusual_container ();
-       check_high_j2k_bandwidth ();
+       check_high_video_bit_rate();
        check_frame_rate ();
        check_4k_3d ();
        check_speed_up ();
index e7a6646ef64a7f69269d2cc1a607cfd150ddfcb5..a46678af8a357ff918f5dbfbbfa77b46dfa64ddf 100644 (file)
@@ -74,7 +74,7 @@ private:
        void check_upmixers ();
        void check_incorrect_container ();
        void check_unusual_container ();
-       void check_high_j2k_bandwidth ();
+       void check_high_video_bit_rate();
        void check_frame_rate ();
        void check_4k_3d ();
        void check_speed_up ();
index 6154dfb6262638adfb0de763b678f5d979672235..d5c7b3eed635a63334ebe5c806e10782baefa25d 100644 (file)
@@ -310,7 +310,7 @@ J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time)
                                pv,
                                position,
                                _film->video_frame_rate(),
-                               _film->j2k_bandwidth(),
+                               _film->video_bit_rate(),
                                _film->resolution()
                                );
                _queue.push_back (dcpv);
index 41c5e8ec55402b51d0613ee7d77f775c1a1ea65f..e4707721c374b9fadd5d67f7abc005c00c0e801c 100644 (file)
@@ -91,7 +91,7 @@ make_dcp (shared_ptr<Film> film, TranscodeJob::ChangedBehaviour behaviour)
                LOG_GENERAL ("Content: %1", content->technical_summary());
        }
        LOG_GENERAL ("DCP video rate %1 fps", film->video_frame_rate());
-       LOG_GENERAL ("J2K bandwidth %1", film->j2k_bandwidth());
+       LOG_GENERAL("Video bit rate %1", film->video_bit_rate());
 
        auto tj = make_shared<DCPTranscodeJob>(film, behaviour);
        tj->set_encoder(make_shared<DCPFilmEncoder>(film, tj));
index 7f83e94740bc4b6dc3b4837090aab81bb1e4f692..d2af000e5567088a5b6c6bfa4234895f8692a8e7 100644 (file)
@@ -645,16 +645,16 @@ Playlist::move_later (shared_ptr<const Film> film, shared_ptr<Content> c)
 
 
 int64_t
-Playlist::required_disk_space (shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const
+Playlist::required_disk_space(shared_ptr<const Film> film, int64_t video_bit_rate, int audio_channels, int audio_frame_rate) const
 {
-       int64_t video = uint64_t(j2k_bandwidth / 8) * length(film).seconds();
+       int64_t video = uint64_t(video_bit_rate / 8) * length(film).seconds();
        int64_t audio = uint64_t(audio_channels) * audio_frame_rate * 3 * length(film).seconds();
 
        for (auto i: content()) {
                auto d = dynamic_pointer_cast<DCPContent> (i);
                if (d) {
                        if (d->reference_video()) {
-                               video -= uint64_t (j2k_bandwidth / 8) * d->length_after_trim(film).seconds();
+                               video -= uint64_t(video_bit_rate / 8) * d->length_after_trim(film).seconds();
                        }
                        if (d->reference_audio()) {
                                audio -= uint64_t(audio_channels) * audio_frame_rate * 3 * d->length_after_trim(film).seconds();
index 7b9bd19fac914ed644e2251a29ccadf7f6e37539..3868c0b51ae1f82e86f17fe16a130e8d318ef2e5 100644 (file)
@@ -65,7 +65,7 @@ public:
 
        dcpomatic::DCPTime length (std::shared_ptr<const Film> film) const;
        boost::optional<dcpomatic::DCPTime> start () const;
-       int64_t required_disk_space (std::shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const;
+       int64_t required_disk_space(std::shared_ptr<const Film> film, int64_t video_bit_rate, int audio_channels, int audio_frame_rate) const;
 
        int best_video_frame_rate () const;
        dcpomatic::DCPTime video_end (std::shared_ptr<const Film> film) const;
index 9eec498f975d72d2dad73552cd2987c3d8fa71f4..b593489089edef9abab3a6f9df5cf41e67bd6c5a 100644 (file)
@@ -94,7 +94,7 @@ print_dump (shared_ptr<Film> film)
 {
        cout << film->dcp_name (true) << "\n"
             << film->container()->container_nickname() << " at " << ((film->resolution() == Resolution::TWO_K) ? "2K" : "4K") << "\n"
-            << (film->j2k_bandwidth() / 1000000) << "Mbit/s" << "\n"
+            << (film->video_bit_rate() / 1000000) << "Mbit/s" << "\n"
             << "Duration " << (film->length().timecode(film->video_frame_rate())) << "\n"
             << "Output " << film->video_frame_rate() << "fps " << (film->three_d() ? "3D" : "2D") << " " << (film->audio_frame_rate() / 1000) << "kHz\n"
             << (film->interop() ? "Inter-Op" : "SMPTE") << " " << (film->encrypted() ? "encrypted" : "unencrypted") << "\n";
index 781c95de7af6936abf9c12646d53be4597ec53d4..c2f32fbb9572191c069b0540b491b96ad60eada1 100644 (file)
@@ -253,13 +253,13 @@ DCPPanel::name_changed ()
 
 
 void
-DCPPanel::j2k_bandwidth_changed ()
+DCPPanel::video_bit_rate_changed()
 {
        if (!_film) {
                return;
        }
 
-       _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
+       _film->set_video_bit_rate(_video_bit_rate->GetValue() * 1000000);
 }
 
 
@@ -385,8 +385,8 @@ DCPPanel::film_changed(FilmProperty p)
                setup_container ();
                setup_dcp_name ();
                break;
-       case FilmProperty::J2K_BANDWIDTH:
-               checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
+       case FilmProperty::VIDEO_BIT_RATE:
+               checked_set(_video_bit_rate, _film->video_bit_rate() / 1000000);
                break;
        case FilmProperty::USE_ISDCF_NAME:
        {
@@ -605,7 +605,7 @@ DCPPanel::set_film (shared_ptr<Film> film)
        film_changed(FilmProperty::CONTAINER);
        film_changed(FilmProperty::RESOLUTION);
        film_changed(FilmProperty::ENCRYPTED);
-       film_changed(FilmProperty::J2K_BANDWIDTH);
+       film_changed(FilmProperty::VIDEO_BIT_RATE);
        film_changed(FilmProperty::VIDEO_FRAME_RATE);
        film_changed(FilmProperty::AUDIO_CHANNELS);
        film_changed(FilmProperty::SEQUENCE);
@@ -649,7 +649,7 @@ DCPPanel::setup_sensitivity ()
        _frame_rate_spin->Enable        (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->contains_atmos_content());
        _audio_channels->Enable         (_generally_sensitive && _film && !_film->references_dcp_audio());
        _audio_processor->Enable        (_generally_sensitive && _film && !_film->references_dcp_audio());
-       _j2k_bandwidth->Enable          (_generally_sensitive && _film && !_film->references_dcp_video());
+       _video_bit_rate->Enable         (_generally_sensitive && _film && !_film->references_dcp_video());
        _container->Enable              (_generally_sensitive && _film && !_film->references_dcp_video());
        _best_frame_rate->Enable (
                _generally_sensitive &&
@@ -732,7 +732,7 @@ DCPPanel::reencode_j2k_changed ()
 void
 DCPPanel::config_changed (Config::Property p)
 {
-       _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
+       _video_bit_rate->SetRange(1, Config::instance()->maximum_video_bit_rate() / 1000000);
        setup_frame_rate_widget ();
 
        if (p == Config::SHOW_EXPERIMENTAL_AUDIO_PROCESSORS) {
@@ -791,8 +791,8 @@ DCPPanel::make_video_panel ()
 
        _three_d = new CheckBox (panel, _("3D"));
 
-       _j2k_bandwidth_label = create_label (panel, _("JPEG2000 bandwidth\nfor newly-encoded data"), true);
-       _j2k_bandwidth = new SpinCtrl (panel, DCPOMATIC_SPIN_CTRL_WIDTH);
+       _video_bit_rate_label = create_label(panel, _("Video bit rate\nfor newly-encoded data"), true);
+       _video_bit_rate = new SpinCtrl(panel, DCPOMATIC_SPIN_CTRL_WIDTH);
        _mbits_label = create_label (panel, _("Mbit/s"), false);
 
        _reencode_j2k = new CheckBox (panel, _("Re-encode JPEG2000 data from input"));
@@ -801,9 +801,9 @@ DCPPanel::make_video_panel ()
        _frame_rate_choice->Bind (wxEVT_CHOICE,   boost::bind(&DCPPanel::frame_rate_choice_changed, this));
        _frame_rate_spin->Bind   (wxEVT_SPINCTRL, boost::bind(&DCPPanel::frame_rate_spin_changed, this));
        _best_frame_rate->Bind   (wxEVT_BUTTON,   boost::bind(&DCPPanel::best_frame_rate_clicked, this));
-       _j2k_bandwidth->Bind     (wxEVT_SPINCTRL, boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
+       _video_bit_rate->Bind    (wxEVT_SPINCTRL, boost::bind(&DCPPanel::video_bit_rate_changed, this));
        /* Also listen to wxEVT_TEXT so that typing numbers directly in is always noticed */
-       _j2k_bandwidth->Bind     (wxEVT_TEXT,     boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
+       _video_bit_rate->Bind    (wxEVT_TEXT,     boost::bind(&DCPPanel::video_bit_rate_changed, this));
        _resolution->Bind        (wxEVT_CHOICE,   boost::bind(&DCPPanel::resolution_changed, this));
        _three_d->bind(&DCPPanel::three_d_changed, this);
        _reencode_j2k->bind(&DCPPanel::reencode_j2k_changed, this);
@@ -816,7 +816,7 @@ DCPPanel::make_video_panel ()
                _frame_rate_choice->add(boost::lexical_cast<string>(i));
        }
 
-       _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
+       _video_bit_rate->SetRange(1, Config::instance()->maximum_video_bit_rate() / 1000000);
        _frame_rate_spin->SetRange (1, 480);
 
        _resolution->add(_("2K"));
@@ -860,9 +860,9 @@ DCPPanel::add_video_panel_to_grid ()
        _video_grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
        ++r;
 
-       add_label_to_sizer (_video_grid, _j2k_bandwidth_label, true, wxGBPosition (r, 0));
+       add_label_to_sizer(_video_grid, _video_bit_rate_label, true, wxGBPosition (r, 0));
        auto s = new wxBoxSizer (wxHORIZONTAL);
-       s->Add (_j2k_bandwidth, 0, wxALIGN_CENTER_VERTICAL);
+       s->Add(_video_bit_rate, 0, wxALIGN_CENTER_VERTICAL);
        add_label_to_sizer (s, _mbits_label, false, 0, wxLEFT | wxALIGN_CENTER_VERTICAL);
        _video_grid->Add (s, wxGBPosition(r, 1), wxDefaultSpan);
        ++r;
index 6c97a41c31c5bea31783616e163e0c6532a1ed75..c686a9c557317dd07f213c1e4925d46057e69557 100644 (file)
@@ -71,7 +71,7 @@ private:
        void copy_isdcf_name_button_clicked ();
        void container_changed ();
        void dcp_content_type_changed ();
-       void j2k_bandwidth_changed ();
+       void video_bit_rate_changed();
        void frame_rate_choice_changed ();
        void frame_rate_spin_changed ();
        void best_frame_rate_clicked ();
@@ -129,9 +129,9 @@ private:
        Choice* _container;
        wxStaticText* _container_size;
        wxButton* _copy_isdcf_name_button;
-       wxStaticText* _j2k_bandwidth_label;
+       wxStaticText* _video_bit_rate_label;
        wxStaticText* _mbits_label;
-       wxSpinCtrl* _j2k_bandwidth;
+       wxSpinCtrl* _video_bit_rate;
        wxStaticText* _dcp_content_type_label;
        Choice* _dcp_content_type;
        wxStaticText* _frame_rate_label;
index 193392f29d05cff6041be898aefb1d2f55e5b067..c3c194fbccd9246d161f52b0f33c9e2717a82f35 100644 (file)
@@ -322,8 +322,8 @@ private:
                {
                        add_label_to_sizer (table, _panel, _("Default JPEG2000 bandwidth"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
                        auto s = new wxBoxSizer (wxHORIZONTAL);
-                       _j2k_bandwidth = new wxSpinCtrl (_panel);
-                       s->Add (_j2k_bandwidth);
+                       _video_bit_rate = new wxSpinCtrl(_panel);
+                       s->Add(_video_bit_rate);
                        add_label_to_sizer (s, _panel, _("Mbit/s"), false, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
                        table->Add (s, 1);
                }
@@ -410,8 +410,8 @@ private:
                _dcp_content_type->Bind (wxEVT_CHOICE, boost::bind (&DefaultsPage::dcp_content_type_changed, this));
                _dcp_audio_channels->Bind (wxEVT_CHOICE, boost::bind (&DefaultsPage::dcp_audio_channels_changed, this));
 
-               _j2k_bandwidth->SetRange (50, 250);
-               _j2k_bandwidth->Bind (wxEVT_SPINCTRL, boost::bind (&DefaultsPage::j2k_bandwidth_changed, this));
+               _video_bit_rate->SetRange(50, 250);
+               _video_bit_rate->Bind(wxEVT_SPINCTRL, boost::bind(&DefaultsPage::video_bit_rate_changed, this));
 
                _audio_delay->SetRange (-1000, 1000);
                _audio_delay->Bind (wxEVT_SPINCTRL, boost::bind (&DefaultsPage::audio_delay_changed, this));
@@ -451,8 +451,8 @@ private:
                _kdm_directory->SetPath (std_to_wx (config->default_kdm_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()));
                _kdm_type->set (config->default_kdm_type());
                checked_set (_use_isdcf_name_by_default, config->use_isdcf_name_by_default());
-               checked_set (_j2k_bandwidth, config->default_j2k_bandwidth() / 1000000);
-               _j2k_bandwidth->SetRange (50, config->maximum_j2k_bandwidth() / 1000000);
+               checked_set(_video_bit_rate, config->default_video_bit_rate() / 1000000);
+               _video_bit_rate->SetRange(50, config->maximum_video_bit_rate() / 1000000);
                checked_set (_dcp_audio_channels, locale_convert<string> (config->default_dcp_audio_channels()));
                checked_set (_audio_delay, config->default_audio_delay ());
                checked_set (_standard, config->default_interop() ? 1 : 0);
@@ -527,9 +527,9 @@ private:
                config->set_default_kdm_duration (RoughDuration(duration, unit));
        }
 
-       void j2k_bandwidth_changed ()
+       void video_bit_rate_changed()
        {
-               Config::instance()->set_default_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
+               Config::instance()->set_default_video_bit_rate(_video_bit_rate->GetValue() * 1000000);
        }
 
        void audio_delay_changed ()
@@ -634,7 +634,7 @@ private:
                }
        }
 
-       wxSpinCtrl* _j2k_bandwidth;
+       wxSpinCtrl* _video_bit_rate;
        wxSpinCtrl* _audio_delay;
        wxSpinCtrl* _still_length;
 #ifdef DCPOMATIC_USE_OWN_PICKER
@@ -1543,8 +1543,8 @@ private:
                {
                        add_label_to_sizer(table, _panel, _("Maximum JPEG2000 bandwidth"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
                        auto s = new wxBoxSizer(wxHORIZONTAL);
-                       _maximum_j2k_bandwidth = new wxSpinCtrl(_panel);
-                       s->Add(_maximum_j2k_bandwidth, 1);
+                       _maximum_video_bit_rate = new wxSpinCtrl(_panel);
+                       s->Add(_maximum_video_bit_rate, 1);
                        add_label_to_sizer(s, _panel, _("Mbit/s"), false, 0, wxLEFT | wxALIGN_CENTRE_VERTICAL);
                        table->Add(s, 1);
                }
@@ -1579,8 +1579,8 @@ private:
                        table->Add(s, 1);
                }
 
-               _maximum_j2k_bandwidth->SetRange(1, 1000);
-               _maximum_j2k_bandwidth->Bind(wxEVT_SPINCTRL, boost::bind(&NonStandardPage::maximum_j2k_bandwidth_changed, this));
+               _maximum_video_bit_rate->SetRange(1, 1000);
+               _maximum_video_bit_rate->Bind(wxEVT_SPINCTRL, boost::bind(&NonStandardPage::maximum_video_bit_rate_changed, this));
                _allow_any_dcp_frame_rate->bind(&NonStandardPage::allow_any_dcp_frame_rate_changed, this);
                _allow_any_container->bind(&NonStandardPage::allow_any_container_changed, this);
                _allow_96khz_audio->bind(&NonStandardPage::allow_96khz_audio_changed, this);
@@ -1594,7 +1594,7 @@ private:
        {
                auto config = Config::instance();
 
-               checked_set(_maximum_j2k_bandwidth, config->maximum_j2k_bandwidth() / 1000000);
+               checked_set(_maximum_video_bit_rate, config->maximum_video_bit_rate() / 1000000);
                checked_set(_allow_any_dcp_frame_rate, config->allow_any_dcp_frame_rate());
                checked_set(_allow_any_container, config->allow_any_container());
                checked_set(_allow_96khz_audio, config->allow_96khz_audio());
@@ -1603,9 +1603,9 @@ private:
                checked_set(_isdcf_name_part_length, config->isdcf_name_part_length());
        }
 
-       void maximum_j2k_bandwidth_changed()
+       void maximum_video_bit_rate_changed()
        {
-               Config::instance()->set_maximum_j2k_bandwidth(_maximum_j2k_bandwidth->GetValue() * 1000000);
+               Config::instance()->set_maximum_video_bit_rate(_maximum_video_bit_rate->GetValue() * 1000000);
        }
 
        void allow_any_dcp_frame_rate_changed()
@@ -1638,7 +1638,7 @@ private:
                Config::instance()->set_isdcf_name_part_length(_isdcf_name_part_length->GetValue());
        }
 
-       wxSpinCtrl* _maximum_j2k_bandwidth = nullptr;
+       wxSpinCtrl* _maximum_video_bit_rate = nullptr;
        CheckBox* _allow_any_dcp_frame_rate = nullptr;
        CheckBox* _allow_any_container = nullptr;
        CheckBox* _allow_96khz_audio = nullptr;
index aae5fb6de051d81b83719ba8275918d80c47cde5..09f1a453855ed3b0dd69867a5b8dbb06c3579359 100644 (file)
@@ -179,11 +179,11 @@ BOOST_AUTO_TEST_CASE (create_cli_test)
        BOOST_CHECK_EQUAL(cc._fourk, true);
        BOOST_CHECK (!cc.error);
 
-       cc = run ("dcpomatic2_create --j2k-bandwidth 120 foo.mp4");
+       cc = run ("dcpomatic2_create --video-bit-rate 120 foo.mp4");
        BOOST_REQUIRE_EQUAL (cc.content.size(), 1U);
        BOOST_CHECK_EQUAL (cc.content[0].path, "foo.mp4");
-       BOOST_REQUIRE(cc._j2k_bandwidth);
-       BOOST_CHECK_EQUAL(*cc._j2k_bandwidth, 120000000);
+       BOOST_REQUIRE(cc._video_bit_rate);
+       BOOST_CHECK_EQUAL(*cc._video_bit_rate, 120000000);
        BOOST_CHECK (!cc.error);
 
        cc = run ("dcpomatic2_create --channel L fred.wav --channel R jim.wav sheila.wav");
index 2bd60dc81071e0b2180d66060c0f0cab40b8be45..2f1346d1da5a6c032298d5531ebe06182169312b 100644 (file)
@@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE (film_metadata_test)
        film->set_name ("fred");
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("SHR"));
        film->set_container (Ratio::from_id ("185"));
-       film->set_j2k_bandwidth (200000000);
+       film->set_video_bit_rate(200000000);
        film->set_interop (false);
        film->set_chain (string(""));
        film->set_distributor (string(""));
diff --git a/test/j2k_bandwidth_test.cc b/test/j2k_bandwidth_test.cc
deleted file mode 100644 (file)
index f9e47c4..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-    Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-/** @file  test/bandwidth_test.cc
- *  @brief Test whether we output whatever J2K bandwidth is requested.
- *  @ingroup feature
- */
-
-
-#include "test.h"
-#include "lib/dcp_content_type.h"
-#include "lib/film.h"
-#include "lib/image_content.h"
-#include "lib/video_content.h"
-#include <dcp/raw_convert.h>
-#include <boost/test/unit_test.hpp>
-
-
-using std::make_shared;
-using std::string;
-
-
-static void
-check (int target_bits_per_second)
-{
-       int const duration = 10;
-
-       string const name = "bandwidth_test_" + dcp::raw_convert<string> (target_bits_per_second);
-       auto film = new_test_film (name);
-       film->set_name (name);
-       film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
-       film->set_j2k_bandwidth (target_bits_per_second);
-       auto content = make_shared<ImageContent>(TestPaths::private_data() / "prophet_frame.tiff");
-       film->examine_and_add_content (content);
-       BOOST_REQUIRE (!wait_for_jobs());
-       content->video->set_length (24 * duration);
-       make_and_verify_dcp (
-               film,
-               {
-                       dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE,
-                       dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE,
-                       dcp::VerificationNote::Code::NEARLY_INVALID_PICTURE_FRAME_SIZE_IN_BYTES,
-                       dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_SIZE_IN_BYTES,
-                       dcp::VerificationNote::Code::INVALID_JPEG2000_TILE_PART_SIZE,
-               },
-               target_bits_per_second <= 250000000,
-               target_bits_per_second <= 250000000
-               );
-
-       boost::filesystem::directory_iterator i (boost::filesystem::path("build") / "test" / name / "video");
-       boost::filesystem::path test = *i++;
-       BOOST_REQUIRE (i == boost::filesystem::directory_iterator());
-
-       double actual_bits_per_second = boost::filesystem::file_size(test) * 8.0 / duration;
-
-       /* Check that we're within 85% to 115% of target on average */
-       BOOST_CHECK ((actual_bits_per_second / target_bits_per_second) > 0.85);
-       BOOST_CHECK ((actual_bits_per_second / target_bits_per_second) < 1.15);
-}
-
-
-BOOST_AUTO_TEST_CASE (bandwidth_test)
-{
-       check (50000000);
-       check (100000000);
-       check (150000000);
-       check (200000000);
-       check (250000000);
-       check (300000000);
-       check (350000000);
-       check (400000000);
-       check (450000000);
-       check (500000000);
-}
diff --git a/test/j2k_video_bit_rate_test.cc b/test/j2k_video_bit_rate_test.cc
new file mode 100644 (file)
index 0000000..67579a3
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+    Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+/** @file  test/bandwidth_test.cc
+ *  @brief Test whether we output whatever J2K bandwidth is requested.
+ *  @ingroup feature
+ */
+
+
+#include "test.h"
+#include "lib/dcp_content_type.h"
+#include "lib/film.h"
+#include "lib/image_content.h"
+#include "lib/video_content.h"
+#include <dcp/raw_convert.h>
+#include <boost/test/unit_test.hpp>
+
+
+using std::make_shared;
+using std::string;
+
+
+static void
+check (int target_bits_per_second)
+{
+       int const duration = 10;
+
+       string const name = "bandwidth_test_" + dcp::raw_convert<string> (target_bits_per_second);
+       auto film = new_test_film (name);
+       film->set_name (name);
+       film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
+       film->set_video_bit_rate(target_bits_per_second);
+       auto content = make_shared<ImageContent>(TestPaths::private_data() / "prophet_frame.tiff");
+       film->examine_and_add_content (content);
+       BOOST_REQUIRE (!wait_for_jobs());
+       content->video->set_length (24 * duration);
+       make_and_verify_dcp (
+               film,
+               {
+                       dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE,
+                       dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE,
+                       dcp::VerificationNote::Code::NEARLY_INVALID_PICTURE_FRAME_SIZE_IN_BYTES,
+                       dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_SIZE_IN_BYTES,
+                       dcp::VerificationNote::Code::INVALID_JPEG2000_TILE_PART_SIZE,
+               },
+               target_bits_per_second <= 250000000,
+               target_bits_per_second <= 250000000
+               );
+
+       boost::filesystem::directory_iterator i (boost::filesystem::path("build") / "test" / name / "video");
+       boost::filesystem::path test = *i++;
+       BOOST_REQUIRE (i == boost::filesystem::directory_iterator());
+
+       double actual_bits_per_second = boost::filesystem::file_size(test) * 8.0 / duration;
+
+       /* Check that we're within 85% to 115% of target on average */
+       BOOST_CHECK ((actual_bits_per_second / target_bits_per_second) > 0.85);
+       BOOST_CHECK ((actual_bits_per_second / target_bits_per_second) < 1.15);
+}
+
+
+BOOST_AUTO_TEST_CASE (bandwidth_test)
+{
+       check (50000000);
+       check (100000000);
+       check (150000000);
+       check (200000000);
+       check (250000000);
+       check (300000000);
+       check (350000000);
+       check (400000000);
+       check (450000000);
+       check (500000000);
+}
index df4bbbbe6dc1a44e699c98229a78b33455231d51..5fcddfe781378ade48ce2ad86be6d5f4efeee13f 100644 (file)
@@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE (reels_test1)
        BOOST_CHECK_EQUAL (r.back().from.get(), 288000);
        BOOST_CHECK_EQUAL (r.back().to.get(), 288000 * 2);
 
-       film->set_j2k_bandwidth (100000000);
+       film->set_video_bit_rate(100000000);
        film->set_reel_type (ReelType::BY_LENGTH);
        /* This is just over 2.5s at 100Mbit/s; should correspond to 60 frames */
        film->set_reel_length (31253154);
@@ -310,7 +310,7 @@ BOOST_AUTO_TEST_CASE (reels_test6)
        auto A = make_shared<FFmpegContent>("test/data/test2.mp4");
        auto film = new_test_film2 ("reels_test6", {A});
 
-       film->set_j2k_bandwidth (100000000);
+       film->set_video_bit_rate(100000000);
        film->set_reel_type (ReelType::BY_LENGTH);
        /* This is just over 2.5s at 100Mbit/s; should correspond to 60 frames */
        film->set_reel_length (31253154);
index b704ccef2d13557fa923bbadbb288a0853d3c626..bd969bdb27a56d75a3c2f47558f39a55e4c67ab5 100644 (file)
@@ -45,7 +45,7 @@ void check_within_n (int64_t a, int64_t b, int64_t n)
 BOOST_AUTO_TEST_CASE (required_disk_space_test)
 {
        auto film = new_test_film ("required_disk_space_test");
-       film->set_j2k_bandwidth (100000000);
+       film->set_video_bit_rate(100000000);
        film->set_audio_channels(8);
        film->set_reel_type (ReelType::BY_VIDEO_CONTENT);
        auto content_a = content_factory("test/data/flat_blue.png")[0];
index 64a48b7147111cb2ea3ff0a8aefe1bc1ef6aeca1..1d5eb9083e92267db462b7de1cc777d9b2ab2253 100644 (file)
@@ -122,7 +122,7 @@ setup_test_config ()
        Config::instance()->set_server_port_base (61921);
        Config::instance()->set_default_dcp_content_type (static_cast<DCPContentType*> (0));
        Config::instance()->set_default_audio_delay (0);
-       Config::instance()->set_default_j2k_bandwidth (100000000);
+       Config::instance()->set_default_video_bit_rate(100000000);
        Config::instance()->set_default_interop (false);
        Config::instance()->set_default_still_length (10);
        Config::instance()->set_default_dcp_audio_channels(8);
index eb89013383a539832661088cdb1c4665e37f79a7..3acca09e895be2feaedf3a3e824c0dab254475b0 100644 (file)
@@ -111,9 +111,9 @@ def build(bld):
                  import_dcp_test.cc
                  interrupt_encoder_test.cc
                  isdcf_name_test.cc
-                 j2k_bandwidth_test.cc
                  j2k_encode_threading_test.cc
                  job_manager_test.cc
+                 j2k_video_bit_rate_test.cc
                  kdm_cli_test.cc
                  kdm_naming_test.cc
                  kdm_util_test.cc