diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-07-13 01:40:26 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-07-13 01:40:26 +0200 |
| commit | e5fd940695802fc383044d5c29ff3653e8fe6d65 (patch) | |
| tree | 02b2364ea7a8111b3e98c05bcde68e5af3165743 | |
| parent | 8e60c0c1ad5dc30306bd410b8e540a1981136962 (diff) | |
White space: auto_crop_dialog.{cc,h}, export_video_file_dialog.{cc,h}, time_calculation_test.cc
| -rw-r--r-- | src/wx/auto_crop_dialog.cc | 42 | ||||
| -rw-r--r-- | src/wx/auto_crop_dialog.h | 6 | ||||
| -rw-r--r-- | src/wx/export_video_file_dialog.cc | 104 | ||||
| -rw-r--r-- | src/wx/export_video_file_dialog.h | 26 | ||||
| -rw-r--r-- | test/time_calculation_test.cc | 810 |
5 files changed, 494 insertions, 494 deletions
diff --git a/src/wx/auto_crop_dialog.cc b/src/wx/auto_crop_dialog.cc index 7e1f73653..15beecad8 100644 --- a/src/wx/auto_crop_dialog.cc +++ b/src/wx/auto_crop_dialog.cc @@ -25,18 +25,18 @@ #include "lib/config.h" -AutoCropDialog::AutoCropDialog (wxWindow* parent, Crop crop) - : TableDialog (parent, _("Auto crop"), 2, 1, true) +AutoCropDialog::AutoCropDialog(wxWindow* parent, Crop crop) + : TableDialog(parent, _("Auto crop"), 2, 1, true) { - add (_("Left"), true); + add(_("Left"), true); _left = add(new SpinCtrl(this, DCPOMATIC_SPIN_CTRL_WIDTH)); - add (_("Right"), true); + add(_("Right"), true); _right = add(new SpinCtrl(this, DCPOMATIC_SPIN_CTRL_WIDTH)); - add (_("Top"), true); + add(_("Top"), true); _top = add(new SpinCtrl(this, DCPOMATIC_SPIN_CTRL_WIDTH)); - add (_("Bottom"), true); + add(_("Bottom"), true); _bottom = add(new SpinCtrl(this, DCPOMATIC_SPIN_CTRL_WIDTH)); - add (_("Threshold"), true); + add(_("Threshold"), true); _threshold = add(new SpinCtrl(this, DCPOMATIC_SPIN_CTRL_WIDTH)); _left->SetRange(0, 4096); @@ -44,32 +44,32 @@ AutoCropDialog::AutoCropDialog (wxWindow* parent, Crop crop) _top->SetRange(0, 4096); _bottom->SetRange(0, 4096); - set (crop); - _threshold->SetValue (std::round(Config::instance()->auto_crop_threshold() * 100)); + set(crop); + _threshold->SetValue(std::round(Config::instance()->auto_crop_threshold() * 100)); - layout (); + layout(); - _left->Bind (wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); }); - _right->Bind (wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); }); - _top->Bind (wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); }); - _bottom->Bind (wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); }); - _threshold->Bind (wxEVT_SPINCTRL, [](wxSpinEvent& ev) { Config::instance()->set_auto_crop_threshold(ev.GetPosition() / 100.0); }); + _left->Bind(wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); }); + _right->Bind(wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); }); + _top->Bind(wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); }); + _bottom->Bind(wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); }); + _threshold->Bind(wxEVT_SPINCTRL, [](wxSpinEvent& ev) { Config::instance()->set_auto_crop_threshold(ev.GetPosition() / 100.0); }); } Crop -AutoCropDialog::get () const +AutoCropDialog::get() const { return Crop(_left->GetValue(), _right->GetValue(), _top->GetValue(), _bottom->GetValue()); } void -AutoCropDialog::set (Crop crop) +AutoCropDialog::set(Crop crop) { - _left->SetValue (crop.left); - _right->SetValue (crop.right); - _top->SetValue (crop.top); - _bottom->SetValue (crop.bottom); + _left->SetValue(crop.left); + _right->SetValue(crop.right); + _top->SetValue(crop.top); + _bottom->SetValue(crop.bottom); } diff --git a/src/wx/auto_crop_dialog.h b/src/wx/auto_crop_dialog.h index 4ccd681ed..383f95a5a 100644 --- a/src/wx/auto_crop_dialog.h +++ b/src/wx/auto_crop_dialog.h @@ -34,10 +34,10 @@ class SpinCtrl; class AutoCropDialog : public TableDialog { public: - AutoCropDialog (wxWindow* parent, Crop crop); + AutoCropDialog(wxWindow* parent, Crop crop); - Crop get () const; - void set (Crop crop); + Crop get() const; + void set(Crop crop); boost::signals2::signal<void (Crop)> Changed; diff --git a/src/wx/export_video_file_dialog.cc b/src/wx/export_video_file_dialog.cc index 226381bef..414be30bd 100644 --- a/src/wx/export_video_file_dialog.cc +++ b/src/wx/export_video_file_dialog.cc @@ -67,45 +67,45 @@ ExportFormat formats[] = { ExportFormat::H264_AAC, }; -ExportVideoFileDialog::ExportVideoFileDialog (wxWindow* parent, string name) - : TableDialog (parent, _("Export video file"), 2, 1, true) - , _initial_name (name) +ExportVideoFileDialog::ExportVideoFileDialog(wxWindow* parent, string name) + : TableDialog(parent, _("Export video file"), 2, 1, true) + , _initial_name(name) { auto& config = Config::instance()->export_config(); - add (_("Format"), true); - _format = new wxChoice (this, wxID_ANY); - add (_format); - add_spacer (); - _mixdown = new CheckBox (this, _("Mix audio down to stereo")); - add (_mixdown, false); - add_spacer (); - _split_reels = new CheckBox (this, _("Write reels into separate files")); - add (_split_reels, false); - add_spacer (); - _split_streams = new CheckBox (this, _("Write each audio channel to its own stream")); - add (_split_streams, false); - _x264_crf_label[0] = add (_("Quality"), true); - _x264_crf = new wxSlider (this, wxID_ANY, config.x264_crf(), 0, 51, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS); - add (_x264_crf, false); - add_spacer (); - _x264_crf_label[1] = add (_("0 is best, 51 is worst"), false); + add(_("Format"), true); + _format = new wxChoice(this, wxID_ANY); + add(_format); + add_spacer(); + _mixdown = new CheckBox(this, _("Mix audio down to stereo")); + add(_mixdown, false); + add_spacer(); + _split_reels = new CheckBox(this, _("Write reels into separate files")); + add(_split_reels, false); + add_spacer(); + _split_streams = new CheckBox(this, _("Write each audio channel to its own stream")); + add(_split_streams, false); + _x264_crf_label[0] = add(_("Quality"), true); + _x264_crf = new wxSlider(this, wxID_ANY, config.x264_crf(), 0, 51, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS); + add(_x264_crf, false); + add_spacer(); + _x264_crf_label[1] = add(_("0 is best, 51 is worst"), false); wxFont font = _x264_crf_label[1]->GetFont(); font.SetStyle(wxFONTSTYLE_ITALIC); font.SetPointSize(font.GetPointSize() - 1); _x264_crf_label[1]->SetFont(font); - add (_("Output file"), true); + add(_("Output file"), true); /* Don't warn overwrite here, because on Linux (at least) if we specify a filename like foo the wxFileDialog will check that foo exists, but we will add an extension so we actually need to check if foo.mov (or similar) exists. I can't find a way to make wxWidgets do this, so disable its check and the caller will have to do it themselves. */ _file = new FilePickerCtrl(this, _("Select output file"), format_filters[0], false, false, "ExportVideoPath", _initial_name); - add (_file); + add(_file); for (int i = 0; i < FORMATS; ++i) { - _format->Append (format_names[i]); + _format->Append(format_names[i]); } for (int i = 0; i < FORMATS; ++i) { if (config.format() == formats[i]) { @@ -117,24 +117,24 @@ ExportVideoFileDialog::ExportVideoFileDialog (wxWindow* parent, string name) _split_reels->SetValue(config.split_reels()); _split_streams->SetValue(config.split_streams()); - _x264_crf->Enable (false); + _x264_crf->Enable(false); for (int i = 0; i < 2; ++i) { - _x264_crf_label[i]->Enable (false); + _x264_crf_label[i]->Enable(false); } _mixdown->bind(&ExportVideoFileDialog::mixdown_changed, this); _split_reels->bind(&ExportVideoFileDialog::split_reels_changed, this); _split_streams->bind(&ExportVideoFileDialog::split_streams_changed, this); - _x264_crf->Bind (wxEVT_SLIDER, bind(&ExportVideoFileDialog::x264_crf_changed, this)); - _format->Bind (wxEVT_CHOICE, bind (&ExportVideoFileDialog::format_changed, this)); - _file->Bind (wxEVT_FILEPICKER_CHANGED, bind (&ExportVideoFileDialog::file_changed, this)); + _x264_crf->Bind(wxEVT_SLIDER, bind(&ExportVideoFileDialog::x264_crf_changed, this)); + _format->Bind(wxEVT_CHOICE, bind(&ExportVideoFileDialog::format_changed, this)); + _file->Bind(wxEVT_FILEPICKER_CHANGED, bind(&ExportVideoFileDialog::file_changed, this)); - format_changed (); + format_changed(); - layout (); + layout(); - auto ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this)); - ok->Enable (false); + auto ok = dynamic_cast<wxButton *>(FindWindowById(wxID_OK, this)); + ok->Enable(false); } @@ -167,12 +167,12 @@ ExportVideoFileDialog::x264_crf_changed() void -ExportVideoFileDialog::format_changed () +ExportVideoFileDialog::format_changed() { auto const selection = _format->GetSelection(); - DCPOMATIC_ASSERT (selection >= 0 && selection < FORMATS); + DCPOMATIC_ASSERT(selection >= 0 && selection < FORMATS); _file->set_wildcard(format_filters[selection]); - _x264_crf->Enable (formats[selection] == ExportFormat::H264_AAC); + _x264_crf->Enable(formats[selection] == ExportFormat::H264_AAC); for (int i = 0; i < 2; ++i) { _x264_crf_label[i]->Enable(formats[selection] == ExportFormat::H264_AAC); } @@ -181,50 +181,50 @@ ExportVideoFileDialog::format_changed () } boost::filesystem::path -ExportVideoFileDialog::path () const +ExportVideoFileDialog::path() const { auto path = _file->path(); DCPOMATIC_ASSERT(path); wxFileName fn(std_to_wx(path->string())); - fn.SetExt (format_extensions[_format->GetSelection()]); - return wx_to_std (fn.GetFullPath()); + fn.SetExt(format_extensions[_format->GetSelection()]); + return wx_to_std(fn.GetFullPath()); } ExportFormat -ExportVideoFileDialog::format () const +ExportVideoFileDialog::format() const { - DCPOMATIC_ASSERT (_format->GetSelection() >= 0 && _format->GetSelection() < FORMATS); + DCPOMATIC_ASSERT(_format->GetSelection() >= 0 && _format->GetSelection() < FORMATS); return formats[_format->GetSelection()]; } bool -ExportVideoFileDialog::mixdown_to_stereo () const +ExportVideoFileDialog::mixdown_to_stereo() const { - return _mixdown->GetValue (); + return _mixdown->GetValue(); } bool -ExportVideoFileDialog::split_reels () const +ExportVideoFileDialog::split_reels() const { - return _split_reels->GetValue (); + return _split_reels->GetValue(); } bool -ExportVideoFileDialog::split_streams () const +ExportVideoFileDialog::split_streams() const { - return _split_streams->GetValue (); + return _split_streams->GetValue(); } int -ExportVideoFileDialog::x264_crf () const +ExportVideoFileDialog::x264_crf() const { - return _x264_crf->GetValue (); + return _x264_crf->GetValue(); } void -ExportVideoFileDialog::file_changed () +ExportVideoFileDialog::file_changed() { - auto ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this)); - DCPOMATIC_ASSERT (ok); - ok->Enable (path().is_absolute()); + auto ok = dynamic_cast<wxButton *>(FindWindowById(wxID_OK, this)); + DCPOMATIC_ASSERT(ok); + ok->Enable(path().is_absolute()); } diff --git a/src/wx/export_video_file_dialog.h b/src/wx/export_video_file_dialog.h index 4e626be6b..822fa4b99 100644 --- a/src/wx/export_video_file_dialog.h +++ b/src/wx/export_video_file_dialog.h @@ -34,22 +34,22 @@ class FilePickerCtrl; class ExportVideoFileDialog : public TableDialog { public: - ExportVideoFileDialog (wxWindow* parent, std::string name); + ExportVideoFileDialog(wxWindow* parent, std::string name); - boost::filesystem::path path () const; - ExportFormat format () const; - bool mixdown_to_stereo () const; - bool split_reels () const; - bool split_streams () const; - int x264_crf () const; + boost::filesystem::path path() const; + ExportFormat format() const; + bool mixdown_to_stereo() const; + bool split_reels() const; + bool split_streams() const; + int x264_crf() const; private: - void format_changed (); - void mixdown_changed (); - void split_reels_changed (); - void split_streams_changed (); - void x264_crf_changed (); - void file_changed (); + void format_changed(); + void mixdown_changed(); + void split_reels_changed(); + void split_streams_changed(); + void x264_crf_changed(); + void file_changed(); std::string _initial_name; wxChoice* _format; diff --git a/test/time_calculation_test.cc b/test/time_calculation_test.cc index 386e50e25..7d23b80e0 100644 --- a/test/time_calculation_test.cc +++ b/test/time_calculation_test.cc @@ -130,159 +130,159 @@ static string const xml = "<Content>" "</Content>"; -BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test) +BOOST_AUTO_TEST_CASE(ffmpeg_time_calculation_test) { auto film = new_test_film("ffmpeg_time_calculation_test"); auto doc = make_shared<cxml::Document>(); - doc->read_string (xml); + doc->read_string(xml); list<string> notes; auto content = std::make_shared<FFmpegContent>(doc, boost::none, 38, notes); /* 25fps content, 25fps DCP */ - film->set_video_frame_rate (25); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(content->video->length() / 25.0).get()); + film->set_video_frame_rate(25); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(content->video->length() / 25.0).get()); /* 25fps content, 24fps DCP; length should be increased */ - film->set_video_frame_rate (24); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(content->video->length() / 24.0).get()); + film->set_video_frame_rate(24); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(content->video->length() / 24.0).get()); /* 25fps content, 30fps DCP; length should be decreased */ - film->set_video_frame_rate (30); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(content->video->length() / 30.0).get()); + film->set_video_frame_rate(30); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(content->video->length() / 30.0).get()); /* 25fps content, 50fps DCP; length should be the same */ - film->set_video_frame_rate (50); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(content->video->length() / 25.0).get()); + film->set_video_frame_rate(50); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(content->video->length() / 25.0).get()); /* 25fps content, 60fps DCP; length should be decreased */ - film->set_video_frame_rate (60); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(content->video->length() * (50.0 / 60) / 25.0).get()); + film->set_video_frame_rate(60); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(content->video->length() * (50.0 / 60) / 25.0).get()); /* Make the content audio-only */ - content->video.reset (); + content->video.reset(); /* 24fps content, 24fps DCP */ - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); content->set_video_frame_rate(film, 24); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(1).get()); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(1).get()); /* 25fps content, 25fps DCP */ - film->set_video_frame_rate (25); + film->set_video_frame_rate(25); content->set_video_frame_rate(film, 25); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(1).get()); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(1).get()); /* 25fps content, 24fps DCP; length should be increased */ - film->set_video_frame_rate (24); - BOOST_CHECK_SMALL (labs (content->full_length(film).get() - DCPTime::from_seconds(25.0 / 24).get()), 2L); + film->set_video_frame_rate(24); + BOOST_CHECK_SMALL(labs(content->full_length(film).get() - DCPTime::from_seconds(25.0 / 24).get()), 2L); /* 25fps content, 30fps DCP; length should be decreased */ - film->set_video_frame_rate (30); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(25.0 / 30).get()); + film->set_video_frame_rate(30); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(25.0 / 30).get()); /* 25fps content, 50fps DCP; length should be the same */ - film->set_video_frame_rate (50); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(1).get()); + film->set_video_frame_rate(50); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(1).get()); /* 25fps content, 60fps DCP; length should be decreased */ - film->set_video_frame_rate (60); - BOOST_CHECK_EQUAL (content->full_length(film).get(), DCPTime::from_seconds(50.0 / 60).get()); + film->set_video_frame_rate(60); + BOOST_CHECK_EQUAL(content->full_length(film).get(), DCPTime::from_seconds(50.0 / 60).get()); } /** Test Player::dcp_to_content_video */ -BOOST_AUTO_TEST_CASE (player_time_calculation_test1) +BOOST_AUTO_TEST_CASE(player_time_calculation_test1) { auto film = new_test_film("player_time_calculation_test1"); auto doc = make_shared<cxml::Document>(); - doc->read_string (xml); + doc->read_string(xml); list<string> notes; auto content = std::make_shared<FFmpegContent>(doc, boost::none, 38, notes); - film->set_sequence (false); - film->add_content (content); + film->set_sequence(false); + film->add_content(content); auto player = make_shared<Player>(film, Image::Alignment::COMPACT, false); /* Position 0, no trim, content rate = DCP rate */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); auto piece = player->_pieces.front(); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.5)), 12); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.0)), 72); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.5)), 12); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.0)), 72); /* Position 3s, no trim, content rate = DCP rate */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.50)), 36); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 162); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.00)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(4.50)), 36); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(9.75)), 162); /* Position 3s, 1.5s trim, content rate = DCP rate */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 36); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.50)), 72); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 198); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.00)), 36); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(4.50)), 72); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(9.75)), 198); /* Position 0, no trim, content rate 24, DCP rate 25. Now, for example, a DCPTime position of 3s means 3s at 25fps. Since we run the video fast (at 25fps) in this case, this means 75 frames of content video will be used. */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (25); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.6)), 15); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.0)), 75); + film->set_video_frame_rate(25); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.6)), 15); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.0)), 75); /* Position 3s, no trim, content rate 24, DCP rate 25 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (25); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.60)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.60)), 40); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 168); + film->set_video_frame_rate(25); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.60)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.00)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(4.60)), 40); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(9.75)), 168); /* Position 3s, 1.6s trim, content rate 24, DCP rate 25. Here the trim is in ContentTime, so it's 1.6s at 24fps. Note that trims are rounded to the nearest video frame, so some of these results are not quite what you'd perhaps expect. */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.6)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (25); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.60)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 38); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.60)), 78); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 206); + film->set_video_frame_rate(25); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.60)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.00)), 38); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(4.60)), 78); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(9.75)), 206); /* Position 0, no trim, content rate 24, DCP rate 48 Now, for example, a DCPTime position of 3s means 3s at 48fps. Since we run the video @@ -290,196 +290,196 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) be used to make 3 * 48 frames of DCP video. The results should be the same as the content rate = DCP rate case. */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (48); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.5)), 12); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.0)), 72); + film->set_video_frame_rate(48); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.5)), 12); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.0)), 72); /* Position 3s, no trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (48); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.50)), 36); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 162); + film->set_video_frame_rate(48); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.00)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(4.50)), 36); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(9.75)), 162); /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (48); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 36); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.50)), 72); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 198); + film->set_video_frame_rate(48); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.00)), 36); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(4.50)), 72); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(9.75)), 198); /* Position 0, no trim, content rate 48, DCP rate 24 Now, for example, a DCPTime position of 3s means 3s at 24fps. Since we run the video with skipped frames in this case, 3 * 48 frames of content video will be used to make 3 * 24 frames of DCP video. */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 48); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.5)), 24); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.0)), 144); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.5)), 24); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.0)), 144); /* Position 3s, no trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 48); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.50)), 72); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 324); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.00)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(4.50)), 72); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(9.75)), 324); /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 48); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 72); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.50)), 144); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 396); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(3.00)), 72); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(4.50)), 144); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime::from_seconds(9.75)), 396); /* Position 0s, no trim, content rate 29.9978733, DCP rate 30 */ - content->set_position (film, DCPTime::from_seconds(0)); - content->set_trim_start(film, ContentTime::from_seconds (0)); + content->set_position(film, DCPTime::from_seconds(0)); + content->set_trim_start(film, ContentTime::from_seconds(0)); content->set_video_frame_rate(film, 29.9978733); - film->set_video_frame_rate (30); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (3200)), 1); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (6400)), 2); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (9600)), 3); - BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (12800)), 4); + film->set_video_frame_rate(30); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime(3200)), 1); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime(6400)), 2); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime(9600)), 3); + BOOST_CHECK_EQUAL(player->dcp_to_content_video(piece, DCPTime(12800)), 4); } /** Test Player::content_video_to_dcp */ -BOOST_AUTO_TEST_CASE (player_time_calculation_test2) +BOOST_AUTO_TEST_CASE(player_time_calculation_test2) { auto film = new_test_film("player_time_calculation_test2"); auto doc = make_shared<cxml::Document>(); - doc->read_string (xml); + doc->read_string(xml); list<string> notes; auto content = std::make_shared<FFmpegContent>(doc, boost::none, 38, notes); - film->set_sequence (false); - film->add_content (content); + film->set_sequence(false); + film->add_content(content); auto player = make_shared<Player>(film, Image::Alignment::COMPACT, false); /* Position 0, no trim, content rate = DCP rate */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - auto piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0).get(), 0); - BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 12).get(), DCPTime::from_seconds(0.5).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72).get(), DCPTime::from_seconds(3.0).get()); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + auto piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), 0); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 12).get(), DCPTime::from_seconds(0.5).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(3.0).get()); /* Position 3s, no trim, content rate = DCP rate */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(4.50).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 162).get(), DCPTime::from_seconds(9.75).get()); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(4.50).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 162).get(), DCPTime::from_seconds(9.75).get()); /* Position 3s, 1.5s trim, content rate = DCP rate */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.50).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(3.00).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(4.50).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 198).get(), DCPTime::from_seconds(9.75).get()); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.50).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(3.00).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(4.50).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 198).get(), DCPTime::from_seconds(9.75).get()); /* Position 0, no trim, content rate 24, DCP rate 25. Now, for example, a DCPTime position of 3s means 3s at 25fps. Since we run the video fast (at 25fps) in this case, this means 75 frames of content video will be used. */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (25); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), 0); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 15).get(), DCPTime::from_seconds(0.6).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 75).get(), DCPTime::from_seconds(3.0).get()); + film->set_video_frame_rate(25); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), 0); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 15).get(), DCPTime::from_seconds(0.6).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 75).get(), DCPTime::from_seconds(3.0).get()); /* Position 3s, no trim, content rate 24, DCP rate 25 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (25); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 40).get(), DCPTime::from_seconds(4.60).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 169).get(), DCPTime::from_seconds(9.76).get()); + film->set_video_frame_rate(25); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 40).get(), DCPTime::from_seconds(4.60).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 169).get(), DCPTime::from_seconds(9.76).get()); /* Position 3s, 1.6s trim, content rate 24, DCP rate 25, so the 1.6s trim is at 24fps */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.6)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (25); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), 142080); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 40).get(), 295680); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 80).get(), 449280); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 209).get(), 944640); + film->set_video_frame_rate(25); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), 142080); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 40).get(), 295680); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 80).get(), 449280); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 209).get(), 944640); /* Position 0, no trim, content rate 24, DCP rate 48 Now, for example, a DCPTime position of 3s means 3s at 48fps. Since we run the video @@ -487,332 +487,332 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2) be used to make 3 * 48 frames of DCP video. The results should be the same as the content rate = DCP rate case. */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (48); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), 0); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 12).get(), DCPTime::from_seconds(0.5).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(3.0).get()); + film->set_video_frame_rate(48); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), 0); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 12).get(), DCPTime::from_seconds(0.5).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(3.0).get()); /* Position 3s, no trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (48); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(4.50).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 162).get(), DCPTime::from_seconds(9.75).get()); + film->set_video_frame_rate(48); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(4.50).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 162).get(), DCPTime::from_seconds(9.75).get()); /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (48); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.50).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(3.00).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(4.50).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 198).get(), DCPTime::from_seconds(9.75).get()); + film->set_video_frame_rate(48); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.50).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(3.00).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(4.50).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 198).get(), DCPTime::from_seconds(9.75).get()); /* Position 0, no trim, content rate 48, DCP rate 24 Now, for example, a DCPTime position of 3s means 3s at 24fps. Since we run the video with skipped frames in this case, 3 * 48 frames of content video will be used to make 3 * 24 frames of DCP video. */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 48); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), 0); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 24).get(), DCPTime::from_seconds(0.5).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 144).get(), DCPTime::from_seconds(3.0).get()); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), 0); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 24).get(), DCPTime::from_seconds(0.5).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 144).get(), DCPTime::from_seconds(3.0).get()); /* Position 3s, no trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 48); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(4.50).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 324).get(), DCPTime::from_seconds(9.75).get()); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(4.50).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 324).get(), DCPTime::from_seconds(9.75).get()); /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 48); - film->set_video_frame_rate (24); - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.50).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(3.00).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 144).get(), DCPTime::from_seconds(4.50).get()); - BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 396).get(), DCPTime::from_seconds(9.75).get()); + film->set_video_frame_rate(24); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.50).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(3.00).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 144).get(), DCPTime::from_seconds(4.50).get()); + BOOST_CHECK_EQUAL(player->content_video_to_dcp(piece, 396).get(), DCPTime::from_seconds(9.75).get()); } /** Test Player::dcp_to_content_audio */ -BOOST_AUTO_TEST_CASE (player_time_calculation_test3) +BOOST_AUTO_TEST_CASE(player_time_calculation_test3) { auto film = new_test_film("player_time_calculation_test3"); auto doc = make_shared<cxml::Document>(); - doc->read_string (xml); + doc->read_string(xml); list<string> notes; auto content = std::make_shared<FFmpegContent>(doc, boost::none, 38, notes); auto stream = content->audio->streams().front(); - film->set_sequence (false); - film->add_content (content); + film->set_sequence(false); + film->add_content(content); auto player = make_shared<Player>(film, Image::Alignment::COMPACT, false); /* Position 0, no trim, video/audio content rate = video/audio DCP rate */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - auto piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.5)), 24000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.0)), 144000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + auto piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.5)), 24000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.0)), 144000); /* Position 3s, no trim, video/audio content rate = video/audio DCP rate */ - content->set_position (film, DCPTime::from_seconds (3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 72000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 324000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.50)), 72000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 324000); /* Position 3s, 1.5s trim, video/audio content rate = video/audio DCP rate */ - content->set_position (film, DCPTime::from_seconds (3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 72000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 72000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.50)), 144000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 396000); /* Position 0, no trim, content video rate 24, DCP video rate 25, both audio rates still 48k */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (25); + film->set_video_frame_rate(25); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.6)), 28800); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.0)), 144000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.6)), 28800); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.0)), 144000); /* Position 3s, no trim, content video rate 24, DCP rate 25, both audio rates still 48k. */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (25); + film->set_video_frame_rate(25); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.60)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.60)), 76800); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 324000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.60)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.60)), 76800); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 324000); /* Position 3s, 1.6s trim, content rate 24, DCP rate 25, both audio rates still 48k. 1s of content is 46080 samples after resampling. */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.6)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (25); + film->set_video_frame_rate(25); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.60)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 72960); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.60)), 149760); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396960); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.60)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 72960); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.60)), 149760); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 396960); /* Position 0, no trim, content rate 24, DCP rate 48, both audio rates still 48k. Now, for example, a DCPTime position of 3s means 3s at 48fps. Since we run the video with repeated frames in this case, audio samples will map straight through. The results should be the same as the content rate = DCP rate case. */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (48); + film->set_video_frame_rate(48); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.5)), 24000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.0)), 144000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.5)), 24000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.0)), 144000); /* Position 3s, no trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 72000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 324000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.50)), 72000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 324000); /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 72000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 72000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.50)), 144000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 396000); /* Position 0, no trim, content rate 48, DCP rate 24 Now, for example, a DCPTime position of 3s means 3s at 24fps. Since we run the video with skipped frames in this case, audio samples should map straight through. */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (48); + film->set_video_frame_rate(48); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.5)), 24000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.0)), 144000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.5)), 24000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.0)), 144000); /* Position 3s, no trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 72000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 324000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.50)), 72000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 324000); /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 72000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 72000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.50)), 144000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 396000); /* Position 0, no trim, video content rate = video DCP rate, content audio rate = 44.1k */ - content->set_position (film, DCPTime()); + content->set_position(film, DCPTime()); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 44100; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.5)), 24000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.0)), 144000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.5)), 24000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.0)), 144000); /* Position 3s, no trim, video content rate = video DCP rate, content audio rate = 44.1k */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime()); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 44100; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 72000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 324000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.50)), 72000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 324000); /* Position 3s, 1.5s trim, video content rate = video DCP rate, content audio rate = 44.1k */ - content->set_position (film, DCPTime::from_seconds(3)); + content->set_position(film, DCPTime::from_seconds(3)); content->set_trim_start(film, ContentTime::from_seconds(1.5)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 44100; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 72000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(0.50)), 0); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(3.00)), 72000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(4.50)), 144000); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime::from_seconds(9.75)), 396000); /* Check with a large start trim */ - content->set_position (film, DCPTime::from_seconds(0)); + content->set_position(film, DCPTime::from_seconds(0)); content->set_trim_start(film, ContentTime::from_seconds(54143)); content->set_video_frame_rate(film, 24); - film->set_video_frame_rate (24); + film->set_video_frame_rate(24); stream->_frame_rate = 48000; - player->setup_pieces (); - BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - piece = player->_pieces.front (); - BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 54143LL * 48000); + player->setup_pieces(); + BOOST_REQUIRE_EQUAL(player->_pieces.size(), 1U); + piece = player->_pieces.front(); + BOOST_CHECK_EQUAL(player->dcp_to_resampled_audio(piece, DCPTime()), 54143LL * 48000); } |
