From 90933dc804de225df47897ddd3a19c5a60ec67e0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 27 May 2013 23:17:34 +0100 Subject: [PATCH] Fix some DCP generation bugs and update some tests. --- src/lib/ffmpeg_decoder.cc | 6 +++--- src/lib/filter_graph.cc | 5 +++-- src/lib/player.cc | 9 +++++--- src/lib/playlist.cc | 2 -- test/dcp_test.cc | 27 ++++++++---------------- test/film_metadata_test.cc | 3 +-- test/metadata.ref | 42 -------------------------------------- test/metadata.xml.ref | 31 ++++++++++++++++++++++++++++ test/pixel_formats_test.cc | 1 + test/test.cc | 2 ++ 10 files changed, 55 insertions(+), 73 deletions(-) delete mode 100644 test/metadata.ref create mode 100644 test/metadata.xml.ref diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 119e82851..a1a6636fb 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -539,7 +539,7 @@ FFmpegDecoder::decode_audio_packet () ); assert (_audio_codec_context->channels == _ffmpeg_content->audio_channels()); - Audio (deinterleave_audio (_frame->data, data_size), source_pts_seconds); + audio (deinterleave_audio (_frame->data, data_size), source_pts_seconds); } copy_packet.data += decode_result; @@ -608,11 +608,11 @@ FFmpegDecoder::decode_video_packet () Time FFmpegDecoder::next () const { - if (_decode_video && _decode_audio) { + if (_decode_video && _decode_audio && _audio_codec_context) { return min (_next_video, _next_audio); } - if (_decode_audio) { + if (_decode_audio && _audio_codec_context) { return _next_audio; } diff --git a/src/lib/filter_graph.cc b/src/lib/filter_graph.cc index 4564033d5..7ec2466c5 100644 --- a/src/lib/filter_graph.cc +++ b/src/lib/filter_graph.cc @@ -40,6 +40,7 @@ extern "C" { using std::stringstream; using std::string; using std::list; +using std::cout; using boost::shared_ptr; using boost::weak_ptr; using libdcp::Size; @@ -86,8 +87,8 @@ FilterGraph::FilterGraph (shared_ptr content, libdcp::Size stringstream a; a << "video_size=" << _size.width << "x" << _size.height << ":" << "pix_fmt=" << _pixel_format << ":" - << "time_base=0/1:" - << "pixel_aspect=0/1"; + << "time_base=1/1:" + << "pixel_aspect=1/1"; int r; diff --git a/src/lib/player.cc b/src/lib/player.cc index 34894ff0e..2926796ef 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -172,8 +172,8 @@ Player::process_audio (weak_ptr weak_content, shared_ptr _next_audio) { /* We can emit some audio from our buffers */ - assert (_film->time_to_audio_frames (time - _next_audio) <= _audio_buffers.frames()); OutputAudioFrame const N = _film->time_to_audio_frames (time - _next_audio); + assert (N <= _audio_buffers.frames()); shared_ptr emit (new AudioBuffers (_audio_buffers.channels(), N)); emit->copy_from (&_audio_buffers, N, 0, 0); Audio (emit, _next_audio); @@ -189,6 +189,7 @@ Player::process_audio (weak_ptr weak_content, shared_ptrframes()); _audio_buffers.accumulate_frames (audio.get(), 0, 0, audio->frames ()); + _audio_buffers.set_frames (_audio_buffers.frames() + audio->frames()); } /** @return true on error */ @@ -324,9 +325,11 @@ Player::setup_pieces () if (diff > 0) { add_black_piece (video_pos, diff); } - video_pos = (*i)->content->end(); - } else { + } + + shared_ptr ac = dynamic_pointer_cast ((*i)->content); + if (ac && ac->audio_channels()) { Time const diff = (*i)->content->start() - audio_pos; if (diff > 0) { add_silent_piece (video_pos, diff); diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index d32ec6ba8..5ee764a8e 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -73,7 +73,6 @@ void Playlist::content_changed (weak_ptr c, int p) { if (p == ContentProperty::LENGTH && _sequence_video && !_sequencing_video) { - cout << "sequencing.\n"; _sequencing_video = true; ContentList cl = _content; @@ -85,7 +84,6 @@ Playlist::content_changed (weak_ptr c, int p) } (*i)->set_start (last); - cout << (*i)->file() << " -> " << last << "\n"; last = (*i)->end (); } diff --git a/test/dcp_test.cc b/test/dcp_test.cc index 5a698684b..795b4dfe3 100644 --- a/test/dcp_test.cc +++ b/test/dcp_test.cc @@ -21,7 +21,14 @@ BOOST_AUTO_TEST_CASE (make_dcp_test) { shared_ptr film = new_test_film ("make_dcp_test"); film->set_name ("test_film2"); - film->add_content (shared_ptr (new FFmpegContent (film, "../../../test/test.mp4"))); + system ("pwd"); + film->examine_and_add_content (shared_ptr (new FFmpegContent (film, "test/test.mp4"))); + + /* Wait for the examine to finish */ + while (JobManager::instance()->work_to_do ()) { + dcpomatic_sleep (1); + } + film->set_container (Container::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test")); film->make_dcp (); @@ -46,21 +53,3 @@ BOOST_AUTO_TEST_CASE (have_dcp_test) boost::filesystem::remove (p); BOOST_CHECK (!f.have_dcp ()); } - -BOOST_AUTO_TEST_CASE (make_dcp_with_range_test) -{ - shared_ptr film = new_test_film ("make_dcp_with_range_test"); - film->set_name ("test_film3"); - film->add_content (shared_ptr (new FFmpegContent (film, "../../../test/test.mp4"))); -// film->examine_content (); - film->set_container (Container::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test")); - film->make_dcp (); - - while (JobManager::instance()->work_to_do() && !JobManager::instance()->errors()) { - dcpomatic_sleep (1); - } - - BOOST_CHECK_EQUAL (JobManager::instance()->errors(), false); -} - diff --git a/test/film_metadata_test.cc b/test/film_metadata_test.cc index 8309de7f1..315461b22 100644 --- a/test/film_metadata_test.cc +++ b/test/film_metadata_test.cc @@ -31,14 +31,13 @@ BOOST_AUTO_TEST_CASE (film_metadata_test) BOOST_CHECK (f->dcp_content_type() == 0); f->set_name ("fred"); -// BOOST_CHECK_THROW (f->add_content ("jim"), OpenFileError); f->set_dcp_content_type (DCPContentType::from_pretty_name ("Short")); f->set_container (Container::from_id ("185")); f->set_ab (true); f->write_metadata (); stringstream s; - s << "diff -u test/metadata.ref " << test_film << "/metadata"; + s << "diff -u test/metadata.xml.ref " << test_film << "/metadata.xml"; BOOST_CHECK_EQUAL (::system (s.str().c_str ()), 0); shared_ptr g (new Film (test_film)); diff --git a/test/metadata.ref b/test/metadata.ref deleted file mode 100644 index b7a031883..000000000 --- a/test/metadata.ref +++ /dev/null @@ -1,42 +0,0 @@ -version 4 -name fred -use_dci_name 1 -content -trust_content_header 1 -dcp_content_type SHR -format 185 -left_crop 1 -right_crop 2 -top_crop 3 -bottom_crop 4 -filter pphb -filter unsharp -scaler bicubic -trim_start 42 -trim_end 99 -trim_type cpl -dcp_ab 1 -use_content_audio 1 -audio_gain 0 -audio_delay 0 -still_duration 10 -with_subtitles 0 -subtitle_offset 0 -subtitle_scale 1 -colour_lut 0 -j2k_bandwidth 200000000 -audio_language -subtitle_language -territory -rating -studio -facility -package_type -dci_date 20130211 -dcp_frame_rate 0 -width 0 -height 0 -length 0 -content_digest -external_audio_stream external 0 0 -source_frame_rate 0 diff --git a/test/metadata.xml.ref b/test/metadata.xml.ref new file mode 100644 index 000000000..be791c741 --- /dev/null +++ b/test/metadata.xml.ref @@ -0,0 +1,31 @@ + + + 4 + fred + 1 + SHR + 185 + bicubic + 1 + 0 + 0 + 1 + 0 + 200000000 + + + + + + + + + + 0 + 20130211 + 6 + + 1 + 1 + + diff --git a/test/pixel_formats_test.cc b/test/pixel_formats_test.cc index 08c9f2d2d..fb2278fdb 100644 --- a/test/pixel_formats_test.cc +++ b/test/pixel_formats_test.cc @@ -62,6 +62,7 @@ BOOST_AUTO_TEST_CASE (pixel_formats_test) f->width = 640; f->height = 480; f->format = static_cast (i->format); + av_frame_get_buffer (f, true); SimpleImage t (f); BOOST_CHECK_EQUAL(t.components(), i->components); BOOST_CHECK_EQUAL(t.lines(0), i->lines[0]); diff --git a/test/test.cc b/test/test.cc index cbbd0443d..7e2715a02 100644 --- a/test/test.cc +++ b/test/test.cc @@ -63,6 +63,8 @@ struct TestConfig Config::instance()->set_servers (vector ()); Config::instance()->set_server_port (61920); Config::instance()->set_default_dci_metadata (DCIMetadata ()); + Config::instance()->set_default_container (0); + Config::instance()->set_default_dcp_content_type (0); } }; -- 2.30.2