From: Carl Hetherington Date: Tue, 11 Feb 2014 12:04:27 +0000 (+0000) Subject: Merge master. X-Git-Tag: v2.0.48~918 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=8aeb741ccbe2edb528e98a431bf55459a6836a9b Merge master. --- 8aeb741ccbe2edb528e98a431bf55459a6836a9b diff --cc src/lib/player.cc index 3e6a1598d,59db923be..48c75078e --- a/src/lib/player.cc +++ b/src/lib/player.cc @@@ -450,43 -455,31 +450,47 @@@ Player::setup_pieces ( for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { + if (!(*i)->paths_valid ()) { + continue; + } ++ + shared_ptr decoder; + optional frc; + + /* Work out a FrameRateChange for the best overlap video for this content, in case we need it below */ + DCPTime best_overlap_t = 0; + shared_ptr best_overlap; + for (ContentList::iterator j = content.begin(); j != content.end(); ++j) { + shared_ptr vc = dynamic_pointer_cast (*j); + if (!vc) { + continue; + } + + DCPTime const overlap = max (vc->position(), (*i)->position()) - min (vc->end(), (*i)->end()); + if (overlap > best_overlap_t) { + best_overlap = vc; + best_overlap_t = overlap; + } + } - shared_ptr piece (new Piece (*i)); - - /* XXX: into content? */ + optional best_overlap_frc; + if (best_overlap) { + best_overlap_frc = FrameRateChange (best_overlap->video_frame_rate(), _film->video_frame_rate ()); + } else { + /* No video overlap; e.g. if the DCP is just audio */ + best_overlap_frc = FrameRateChange (_film->video_frame_rate(), _film->video_frame_rate ()); + } + /* FFmpeg */ shared_ptr fc = dynamic_pointer_cast (*i); if (fc) { - shared_ptr fd (new FFmpegDecoder (_film, fc, _video, _audio)); - - fd->Video.connect (bind (&Player::process_video, this, weak_ptr (piece), _1, _2, _3, _4, 0)); - fd->Audio.connect (bind (&Player::process_audio, this, weak_ptr (piece), _1, _2)); - fd->Subtitle.connect (bind (&Player::process_subtitle, this, weak_ptr (piece), _1, _2, _3, _4)); - - fd->seek (fc->time_to_content_video_frames (fc->trim_start ()), true); - piece->decoder = fd; + decoder.reset (new FFmpegDecoder (_film, fc, _video, _audio)); + frc = FrameRateChange (fc->video_frame_rate(), _film->video_frame_rate()); } - + + /* ImageContent */ shared_ptr ic = dynamic_pointer_cast (*i); if (ic) { - bool reusing = false; - /* See if we can re-use an old ImageDecoder */ for (list >::const_iterator j = old_pieces.begin(); j != old_pieces.end(); ++j) { shared_ptr imd = dynamic_pointer_cast ((*j)->decoder); diff --cc src/lib/transcode_job.cc index 289259369,5c195ee1b..46fc97fb3 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@@ -111,6 -114,6 +114,6 @@@ TranscodeJob::remaining_time () cons } /* Compute approximate proposed length here, as it's only here that we need it */ - VideoFrame const left = _film->time_to_video_frames (_film->length ()) - _transcoder->video_frames_out(); - OutputVideoFrame const left = _film->time_to_video_frames (_film->length ()) - t->video_frames_out(); ++ VideoFrame const left = _film->time_to_video_frames (_film->length ()) - t->video_frames_out(); return left / fps; } diff --cc src/lib/util.cc index ef203c2bd,b2f8c4470..418d7b3e0 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@@ -308,9 -337,10 +338,11 @@@ dcpomatic_setup ( boost::filesystem::path lib = app_contents (); lib /= "lib"; setenv ("LTDL_LIBRARY_PATH", lib.c_str (), 1); - #endif + #endif + + set_terminate (terminate); + Pango::init (); libdcp::init (); Ratio::setup_ratios (); @@@ -920,9 -949,13 +952,19 @@@ fit_ratio_within (float ratio, libdcp:: return libdcp::Size (full_frame.width, rint (full_frame.width / ratio)); } +DCPTime +time_round_up (DCPTime t, DCPTime nearest) +{ + DCPTime const a = t + nearest - 1; + return a - (a % nearest); +} ++ + void * + wrapped_av_malloc (size_t s) + { + void* p = av_malloc (s); + if (!p) { + throw bad_alloc (); + } + return p; + } - diff --cc src/wx/film_viewer.cc index a4a293918,e24583d6c..deee65a5f --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@@ -127,9 -127,15 +128,16 @@@ FilmViewer::set_film (shared_ptr return; } - _player = f->make_player (); + try { + _player = f->make_player (); + } catch (bad_alloc) { + error_dialog (this, _("There is not enough free memory to do that.")); + _film.reset (); + return; + } + _player->disable_audio (); + _player->set_approximate_size (); _player->Video.connect (boost::bind (&FilmViewer::process_video, this, _1, _2, _5)); _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1)); diff --cc src/wx/timeline.cc index 2119e7813,4e306c499..ac26c77a9 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@@ -471,10 -471,10 +471,10 @@@ DCPTimeline::tracks () cons } void -Timeline::setup_pixels_per_time_unit () +DCPTimeline::setup_pixels_per_time_unit () { shared_ptr film = _film.lock (); - if (!film) { + if (!film || film->length() == 0) { return; } diff --cc test/resampler_test.cc index 5bee3603b,9247159a7..3be251b3a --- a/test/resampler_test.cc +++ b/test/resampler_test.cc @@@ -33,10 -33,8 +33,9 @@@ resampler_test_one (int from, int to int total_out = 0; /* 3 hours */ - int64_t const N = from * 60 * 60 * 3; - + int64_t const N = int64_t (from) * 60 * 60 * 3; - ++ + /* XXX: no longer checks anything */ - for (int64_t i = 0; i < N; i += 1000) { shared_ptr a (new AudioBuffers (1, 1000)); a->make_silent (); diff --cc test/wscript index 24daa7762,676f47104..ec8dfd42c --- a/test/wscript +++ b/test/wscript @@@ -10,9 -10,9 +10,9 @@@ def configure(conf) """, msg = 'Checking for boost unit testing library', lib = 'boost_unit_test_framework%s' % boost_test_suffix, uselib_store = 'BOOST_TEST') def build(bld): - obj = bld(features = 'cxx cxxprogram') + obj = bld(features='cxx cxxprogram') obj.name = 'unit-tests' - obj.uselib = 'BOOST_TEST DCP OPENJPEG AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC CXML' + obj.uselib = 'BOOST_TEST BOOST_THREAD DCP OPENJPEG AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC CXML' obj.use = 'libdcpomatic' obj.source = """ 4k_test.cc diff --cc wscript index 6c97047fc,50d89f434..86cddf7f2 --- a/wscript +++ b/wscript @@@ -202,13 -272,30 +272,32 @@@ def configure(conf) libpath='/usr/local/lib', lib=['boost_locale%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], uselib_store='BOOST_LOCALE') + dynamic_quickmail(conf) + dynamic_boost(conf, boost_lib_suffix, boost_thread) + dynamic_ffmpeg(conf) + dynamic_openjpeg(conf) + dynamic_dcp(conf) + dynamic_ssh(conf) - conf.check_cxx(fragment=""" - #include \n - int main() { boost::signals2::signal x; }\n - """, - msg='Checking for boost signals2 library', - uselib_store='BOOST_SIGNALS2') + # Not packaging; just a straight build + if not conf.env.TARGET_WINDOWS and not conf.env.TARGET_DEBIAN and not conf.env.TARGET_CENTOS: + conf.check_cfg(package='libcxml', atleast_version='0.08', args='--cflags --libs', uselib_store='CXML', mandatory=True) + conf.check_cfg(package='libxml++-2.6', args='--cflags --libs', uselib_store='XML++', mandatory=True) + conf.check_cfg(package='libcurl', args='--cflags --libs', uselib_store='CURL', mandatory=True) + dynamic_quickmail(conf) + dynamic_boost(conf, boost_lib_suffix, boost_thread) + dynamic_ffmpeg(conf) + dynamic_dcp(conf) + dynamic_openjpeg(conf) + dynamic_ssh(conf) + + # Dependencies which are always dynamically linked + conf.check_cfg(package='sndfile', args='--cflags --libs', uselib_store='SNDFILE', mandatory=True) + conf.check_cfg(package='glib-2.0', args='--cflags --libs', uselib_store='GLIB', mandatory=True) + conf.check_cfg(package= '', path=conf.options.magickpp_config, args='--cppflags --cxxflags --libs', uselib_store='MAGICK', mandatory=True) + conf.check_cfg(package='libzip', args='--cflags --libs', uselib_store='ZIP', mandatory=True) ++ conf.check_cfg(package='pangomm-1.4', args='--cflags --libs', uselib_store='PANGOMM', mandatory=True) ++ conf.check_cfg(package='cairomm-1.0', args='--cflags --libs', uselib_store='CAIROMM', mandatory=True) conf.check_cc(fragment=""" #include