From: Carl Hetherington Date: Sat, 24 Jan 2015 17:41:00 +0000 (+0000) Subject: Hand-apply bbfb370d7de28ec1e8f307865cc6253bb5d4366e from master; quicker digest calcu... X-Git-Tag: v2.0.48~271 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=59e769023c392c332331567a1aea94660002c463 Hand-apply bbfb370d7de28ec1e8f307865cc6253bb5d4366e from master; quicker digest calculation. --- diff --git a/TO_PORT b/TO_PORT index eb4531ef6..414fcd759 100644 --- a/TO_PORT +++ b/TO_PORT @@ -1,4 +1,2 @@ -3cee9121d9cda951e3fb15a53a792b682a27a01b -e48f13a1fc46fb469417d602acfe4b3fa57d5aa2 a0b2c57943ddc55ff2b5b04aba829427a66f41e6 87521fff39a85b532f462a667bd2fb00adeb1185 diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 61357c60f..9909e3a08 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -181,7 +181,7 @@ AudioContent::audio_analysis_path () const } boost::filesystem::path p = film->audio_analysis_dir (); - p /= digest().get_value_or ("X") + "_" + audio_mapping().digest(); + p /= digest() + "_" + audio_mapping().digest(); return p; } diff --git a/src/lib/content.cc b/src/lib/content.cc index a8d058cc1..550a8cd05 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -88,7 +88,7 @@ Content::Content (shared_ptr f, cxml::ConstNodePtr node) for (list::const_iterator i = path_children.begin(); i != path_children.end(); ++i) { _paths.push_back ((*i)->content ()); } - _digest = node->optional_string_child ("Digest"); + _digest = node->optional_string_child ("Digest").get_value_or ("X"); _position = DCPTime (node->number_child ("Position")); _trim_start = DCPTime (node->number_child ("TrimStart")); _trim_end = DCPTime (node->number_child ("TrimEnd")); @@ -124,21 +124,15 @@ Content::as_xml (xmlpp::Node* node) const for (vector::const_iterator i = _paths.begin(); i != _paths.end(); ++i) { node->add_child("Path")->add_child_text (i->string ()); } - if (_digest) { - node->add_child("Digest")->add_child_text (_digest.get ()); - } + node->add_child("Digest")->add_child_text (_digest); node->add_child("Position")->add_child_text (raw_convert (_position.get ())); node->add_child("TrimStart")->add_child_text (raw_convert (_trim_start.get ())); node->add_child("TrimEnd")->add_child_text (raw_convert (_trim_end.get ())); } void -Content::examine (shared_ptr job, bool calculate_digest) +Content::examine (shared_ptr job) { - if (!calculate_digest) { - return; - } - if (job) { job->sub (_("Computing digest")); } @@ -146,8 +140,12 @@ Content::examine (shared_ptr job, bool calculate_digest) boost::mutex::scoped_lock lm (_mutex); vector p = _paths; lm.unlock (); - - string const d = md5_digest (p, job); + + /* Some content files are very big, so we use a poor's + digest here: a MD5 of the first and last 1e6 bytes with the + size of the first file tacked on the end as a string. + */ + string const d = md5_digest_head_tail (p, 1000000) + dcp::raw_convert (boost::filesystem::file_size (p.front ())); lm.lock (); _digest = d; @@ -220,7 +218,7 @@ Content::clone () const string Content::technical_summary () const { - return String::compose ("%1 %2 %3", path_summary(), digest().get_value_or("X"), position().seconds()); + return String::compose ("%1 %2 %3", path_summary(), digest(), position().seconds()); } DCPTime @@ -237,7 +235,7 @@ Content::identifier () const { SafeStringStream s; - s << Content::digest().get_value_or("X") + s << Content::digest() << "_" << position().get() << "_" << trim_start().get() << "_" << trim_end().get(); diff --git a/src/lib/content.h b/src/lib/content.h index a3e6da988..c6cede5fa 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -66,9 +66,8 @@ public: /** Examine the content to establish digest, frame rates and any other * useful metadata. * @param job Job to use to report progress, or 0. - * @param calculate_digest True to calculate a digest for the content's file(s). */ - virtual void examine (boost::shared_ptr job, bool calculate_digest); + virtual void examine (boost::shared_ptr job); /** @return Quick one-line summary of the content, as will be presented in the * film editor. @@ -107,8 +106,11 @@ public: bool paths_valid () const; - /** @return MD5 digest of the content's file(s) */ - boost::optional digest () const { + /** @return Digest of the content's file(s). Note: this is + * not a complete MD5-or-whatever hash, but a sort of poor + * man' version (see comments in ::examine). + */ + std::string digest () const { boost::mutex::scoped_lock lm (_mutex); return _digest; } @@ -167,7 +169,7 @@ protected: std::vector _paths; private: - boost::optional _digest; + std::string _digest; DCPTime _position; DCPTime _trim_start; DCPTime _trim_end; diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 2bf14dcff..d1a658001 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -77,12 +77,12 @@ DCPContent::read_directory (boost::filesystem::path p) } void -DCPContent::examine (shared_ptr job, bool calculate_digest) +DCPContent::examine (shared_ptr job) { bool const could_be_played = can_be_played (); job->set_progress_unknown (); - Content::examine (job, calculate_digest); + Content::examine (job); shared_ptr examiner (new DCPExaminer (shared_from_this ())); take_from_video_examiner (examiner); diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 82f5a8089..aa53d76a9 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -52,7 +52,7 @@ public: DCPTime full_length () const; - void examine (boost::shared_ptr, bool calculate_digest); + void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *) const; diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index 45c4be9b2..9f2ff61c5 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -47,9 +47,9 @@ DCPSubtitleContent::DCPSubtitleContent (shared_ptr film, cxml::Const } void -DCPSubtitleContent::examine (shared_ptr job, bool calculate_digest) +DCPSubtitleContent::examine (shared_ptr job) { - Content::examine (job, calculate_digest); + Content::examine (job); shared_ptr sc = load (path (0)); diff --git a/src/lib/dcp_subtitle_content.h b/src/lib/dcp_subtitle_content.h index 4b5f1fa05..05af71690 100644 --- a/src/lib/dcp_subtitle_content.h +++ b/src/lib/dcp_subtitle_content.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ public: DCPSubtitleContent (boost::shared_ptr, cxml::ConstNodePtr, int); /* Content */ - void examine (boost::shared_ptr, bool calculate_digest); + void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *) const; diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc index ee887271f..2b8f118f8 100644 --- a/src/lib/examine_content_job.cc +++ b/src/lib/examine_content_job.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,10 +29,9 @@ using std::string; using std::cout; using boost::shared_ptr; -ExamineContentJob::ExamineContentJob (shared_ptr f, shared_ptr c, bool calculate_digest) +ExamineContentJob::ExamineContentJob (shared_ptr f, shared_ptr c) : Job (f) , _content (c) - , _calculate_digest (calculate_digest) { } @@ -50,7 +49,7 @@ ExamineContentJob::name () const void ExamineContentJob::run () { - _content->examine (shared_from_this (), _calculate_digest); + _content->examine (shared_from_this ()); set_progress (1); set_state (FINISHED_OK); } diff --git a/src/lib/examine_content_job.h b/src/lib/examine_content_job.h index e59dba0b8..016a56371 100644 --- a/src/lib/examine_content_job.h +++ b/src/lib/examine_content_job.h @@ -26,7 +26,7 @@ class Log; class ExamineContentJob : public Job { public: - ExamineContentJob (boost::shared_ptr, boost::shared_ptr, bool calculate_digest); + ExamineContentJob (boost::shared_ptr, boost::shared_ptr); ~ExamineContentJob (); std::string name () const; @@ -34,6 +34,5 @@ public: private: boost::shared_ptr _content; - bool _calculate_digest; }; diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index d5fd592d6..9e9473935 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -163,11 +163,11 @@ FFmpegContent::as_xml (xmlpp::Node* node) const } void -FFmpegContent::examine (shared_ptr job, bool calculate_digest) +FFmpegContent::examine (shared_ptr job) { job->set_progress_unknown (); - Content::examine (job, calculate_digest); + Content::examine (job); shared_ptr examiner (new FFmpegExaminer (shared_from_this (), job)); take_from_video_examiner (examiner); @@ -367,7 +367,7 @@ FFmpegContent::audio_analysis_path () const */ boost::filesystem::path p = film->audio_analysis_dir (); - string name = digest().get_value_or ("X"); + string name = digest(); if (audio_stream ()) { name += "_" + audio_stream()->identifier (); } diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index 2831c2acf..76ba43567 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -56,7 +56,7 @@ public: return boost::dynamic_pointer_cast (Content::shared_from_this ()); } - void examine (boost::shared_ptr, bool calculate_digest); + void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *) const; diff --git a/src/lib/film.cc b/src/lib/film.cc index 82add67c5..ecc98d7dc 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -952,20 +952,20 @@ Film::content () const } void -Film::examine_content (shared_ptr c, bool calculate_digest) +Film::examine_content (shared_ptr c) { - shared_ptr j (new ExamineContentJob (shared_from_this(), c, calculate_digest)); + shared_ptr j (new ExamineContentJob (shared_from_this(), c)); JobManager::instance()->add (j); } void -Film::examine_and_add_content (shared_ptr c, bool calculate_digest) +Film::examine_and_add_content (shared_ptr c) { if (dynamic_pointer_cast (c)) { run_ffprobe (c->path(0), file ("ffprobe.log"), _log); } - shared_ptr j (new ExamineContentJob (shared_from_this(), c, calculate_digest)); + shared_ptr j (new ExamineContentJob (shared_from_this(), c)); j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr (j), boost::weak_ptr (c))); JobManager::instance()->add (j); } diff --git a/src/lib/film.h b/src/lib/film.h index 43f7bae78..2de065159 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -252,8 +252,8 @@ public: void set_directory (boost::filesystem::path); void set_name (std::string); void set_use_isdcf_name (bool); - void examine_content (boost::shared_ptr, bool calculate_digest); - void examine_and_add_content (boost::shared_ptr, bool calculate_digest); + void examine_content (boost::shared_ptr); + void examine_and_add_content (boost::shared_ptr); void add_content (boost::shared_ptr); void remove_content (boost::shared_ptr); void move_content_earlier (boost::shared_ptr); diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index b8d2a6921..1dbd7871b 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -100,9 +100,9 @@ ImageContent::as_xml (xmlpp::Node* node) const } void -ImageContent::examine (shared_ptr job, bool calculate_digest) +ImageContent::examine (shared_ptr job) { - Content::examine (job, calculate_digest); + Content::examine (job); shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); diff --git a/src/lib/image_content.h b/src/lib/image_content.h index 8c50fd8a8..38aa77bf5 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -37,7 +37,7 @@ public: return boost::dynamic_pointer_cast (Content::shared_from_this ()); }; - void examine (boost::shared_ptr, bool calculate_digest); + void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *) const; diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index e0b7cc10c..e757c77c5 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -82,10 +82,10 @@ SndfileContent::valid_file (boost::filesystem::path f) } void -SndfileContent::examine (shared_ptr job, bool calculate_digest) +SndfileContent::examine (shared_ptr job) { job->set_progress_unknown (); - Content::examine (job, calculate_digest); + Content::examine (job); shared_ptr dec (new SndfileDecoder (shared_from_this())); take_from_audio_examiner (dec); } diff --git a/src/lib/sndfile_content.h b/src/lib/sndfile_content.h index 1fff01f60..1bac51167 100644 --- a/src/lib/sndfile_content.h +++ b/src/lib/sndfile_content.h @@ -41,7 +41,7 @@ public: DCPTime full_length () const; - void examine (boost::shared_ptr, bool calculate_digest); + void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; std::string information () const; diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc index 819bca321..fc0637bfd 100644 --- a/src/lib/subrip_content.cc +++ b/src/lib/subrip_content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -50,9 +50,9 @@ SubRipContent::SubRipContent (shared_ptr film, cxml::ConstNodePtr no } void -SubRipContent::examine (boost::shared_ptr job, bool calculate_digest) +SubRipContent::examine (boost::shared_ptr job) { - Content::examine (job, calculate_digest); + Content::examine (job); SubRip s (shared_from_this ()); shared_ptr film = _film.lock (); diff --git a/src/lib/subrip_content.h b/src/lib/subrip_content.h index 4321ecb6a..e63526179 100644 --- a/src/lib/subrip_content.h +++ b/src/lib/subrip_content.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ public: } /* Content */ - void examine (boost::shared_ptr, bool calculate_digest); + void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *) const; diff --git a/src/lib/util.cc b/src/lib/util.cc index c0e32b778..0a6f381db 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -417,45 +417,53 @@ dcpomatic_setup_gettext_i18n (string lang) #endif } -/** @param job Optional job for which to report progress */ +/** Compute a digest of the first and last `size' bytes of a set of files. */ string -md5_digest (vector files, shared_ptr job) +md5_digest_head_tail (vector files, boost::uintmax_t size) { - boost::uintmax_t const buffer_size = 64 * 1024; - char buffer[buffer_size]; - + boost::scoped_array buffer (new char[size]); MD5Digester digester; - vector sizes; - for (size_t i = 0; i < files.size(); ++i) { - sizes.push_back (boost::filesystem::file_size (files[i])); - } - - for (size_t i = 0; i < files.size(); ++i) { + /* Head */ + boost::uintmax_t to_do = size; + char* p = buffer.get (); + int i = 0; + while (i < int64_t (files.size()) && to_do > 0) { FILE* f = fopen_boost (files[i], "rb"); if (!f) { throw OpenFileError (files[i].string()); } - boost::uintmax_t const bytes = boost::filesystem::file_size (files[i]); - boost::uintmax_t remaining = bytes; - - while (remaining > 0) { - int const t = min (remaining, buffer_size); - int const r = fread (buffer, 1, t, f); - if (r != t) { - throw ReadFileError (files[i], errno); - } - digester.add (buffer, t); - remaining -= t; - - if (job) { - job->set_progress ((float (i) + 1 - float(remaining) / bytes) / files.size ()); - } + boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i])); + fread (p, 1, this_time, f); + p += this_time; + to_do -= this_time; + fclose (f); + + ++i; + } + digester.add (buffer.get(), size - to_do); + + /* Tail */ + to_do = size; + p = buffer.get (); + i = files.size() - 1; + while (i >= 0 && to_do > 0) { + FILE* f = fopen_boost (files[i], "rb"); + if (!f) { + throw OpenFileError (files[i].string()); } + boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i])); + fseek (f, -this_time, SEEK_END); + fread (p, 1, this_time, f); + p += this_time; + to_do -= this_time; fclose (f); - } + + --i; + } + digester.add (buffer.get(), size - to_do); return digester.get (); } diff --git a/src/lib/util.h b/src/lib/util.h index b06c8a58b..ee2865e76 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -61,7 +61,7 @@ extern std::string dependency_version_summary (); extern double seconds (struct timeval); extern void dcpomatic_setup (); extern void dcpomatic_setup_gettext_i18n (std::string); -extern std::string md5_digest (std::vector, boost::shared_ptr); +extern std::string md5_digest_head_tail (std::vector, boost::uintmax_t size); extern void ensure_ui_thread (); extern std::string audio_channel_name (int); extern bool valid_image_file (boost::filesystem::path); diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 614073947..e929f185d 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -810,7 +810,7 @@ class App : public wxApp if (!_film_to_create.empty ()) { _frame->new_film (_film_to_create); if (!_content_to_add.empty ()) { - _frame->film()->examine_and_add_content (content_factory (_frame->film(), _content_to_add), true); + _frame->film()->examine_and_add_content (content_factory (_frame->film(), _content_to_add)); } } @@ -903,7 +903,7 @@ class App : public wxApp dialog->Destroy (); } else if (uc->state() == UpdateChecker::FAILED) { if (!UpdateChecker::instance()->last_emit_was_first ()) { - error_dialog (_frame, _("The DCP-o-matic download server could not be contaced.")); + error_dialog (_frame, _("The DCP-o-matic download server could not be contacted.")); } } else { if (!UpdateChecker::instance()->last_emit_was_first ()) { diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc index 6e8f16888..304f4f697 100644 --- a/src/tools/dcpomatic_create.cc +++ b/src/tools/dcpomatic_create.cc @@ -178,7 +178,7 @@ main (int argc, char* argv[]) if (vc) { vc->set_scale (VideoContentScale (content_ratio)); } - film->examine_and_add_content (c, true); + film->examine_and_add_content (c); } JobManager* jm = JobManager::instance (); diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 15a234184..3bdaf2591 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -207,7 +207,7 @@ ContentMenu::find_missing () return; } - shared_ptr j (new ExamineContentJob (film, content, true)); + shared_ptr j (new ExamineContentJob (film, content)); j->Finished.connect ( bind ( @@ -231,7 +231,7 @@ ContentMenu::re_examine () } for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - film->examine_content (*i, true); + film->examine_content (*i); } } @@ -269,7 +269,7 @@ ContentMenu::kdm () dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ())))); shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - film->examine_content (dcp, true); + film->examine_content (dcp); } d->Destroy (); diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 4d73a608d..8bcf46f5c 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -248,7 +248,7 @@ ContentPanel::add_file_clicked () /* XXX: check for lots of files here and do something */ for (unsigned int i = 0; i < paths.GetCount(); ++i) { - _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])), true); + _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i]))); } d->Destroy (); @@ -281,7 +281,7 @@ ContentPanel::add_folder_clicked () if (is_dcp) { try { shared_ptr content (new DCPContent (_film, path)); - _film->examine_and_add_content (content, true); + _film->examine_and_add_content (content); } catch (...) { error_dialog (_panel, _("Could not find a DCP in that folder.")); } @@ -290,7 +290,6 @@ ContentPanel::add_folder_clicked () ImageSequenceDialog* e = new ImageSequenceDialog (_panel); r = e->ShowModal (); float const frame_rate = e->frame_rate (); - bool const digest = e->digest (); e->Destroy (); if (r != wxID_OK) { @@ -302,7 +301,7 @@ ContentPanel::add_folder_clicked () try { shared_ptr content (new ImageContent (_film, path)); content->set_video_frame_rate (frame_rate); - _film->examine_and_add_content (content, digest); + _film->examine_and_add_content (content); } catch (...) { error_dialog (_panel, _("Could not find any images in that folder")); return; @@ -491,6 +490,6 @@ ContentPanel::files_dropped (wxDropFilesEvent& event) wxString* paths = event.GetFiles (); for (int i = 0; i < event.GetNumberOfFiles(); i++) { - _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])), true); + _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i]))); } } diff --git a/src/wx/image_sequence_dialog.cc b/src/wx/image_sequence_dialog.cc index f4491bda3..02602267c 100644 --- a/src/wx/image_sequence_dialog.cc +++ b/src/wx/image_sequence_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,11 +28,6 @@ ImageSequenceDialog::ImageSequenceDialog (wxWindow* parent) { add (_("Frame rate"), true); _frame_rate = add (new wxTextCtrl (this, wxID_ANY, N_("24"))); - _digest = new wxCheckBox (this, wxID_ANY, _("Calculate digests")); - _digest->SetValue (true); - _digest->SetToolTip (_("By default DCP-o-matic will calculate digests (hashes) of your image files so that it knows if they change. Turning this off will speed up import but you must not alter the image files after import or strange things may happen.")); - add (_digest); - layout (); } @@ -47,9 +42,3 @@ ImageSequenceDialog::frame_rate () const return 0; } - -bool -ImageSequenceDialog::digest () const -{ - return _digest->GetValue (); -} diff --git a/src/wx/image_sequence_dialog.h b/src/wx/image_sequence_dialog.h index d3658b7b8..536ae6680 100644 --- a/src/wx/image_sequence_dialog.h +++ b/src/wx/image_sequence_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,9 +26,7 @@ public: ImageSequenceDialog (wxWindow* parent); float frame_rate () const; - bool digest () const; private: wxTextCtrl* _frame_rate; - wxCheckBox* _digest; }; diff --git a/test/4k_test.cc b/test/4k_test.cc index 63c5f5435..de4e5218b 100644 --- a/test/4k_test.cc +++ b/test/4k_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE (fourk_test) film->set_resolution (RESOLUTION_4K); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); film->set_container (Ratio::from_id ("185")); - film->examine_and_add_content (c, true); + film->examine_and_add_content (c); wait_for_jobs (); film->make_dcp (); diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc index 2da38f455..279944919 100644 --- a/test/audio_analysis_test.cc +++ b/test/audio_analysis_test.cc @@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE (audio_analysis_test) boost::filesystem::path p = private_data / "betty_L.wav"; shared_ptr c (new SndfileContent (film, p)); - film->examine_and_add_content (c, true); + film->examine_and_add_content (c); wait_for_jobs (); c->analyse_audio (boost::bind (&finished)); diff --git a/test/audio_delay_test.cc b/test/audio_delay_test.cc index 0127cc644..68e14ff3c 100644 --- a/test/audio_delay_test.cc +++ b/test/audio_delay_test.cc @@ -51,7 +51,7 @@ void test_audio_delay (int delay_in_ms) shared_ptr content (new SndfileContent (film, "test/data/staircase.wav")); content->set_audio_delay (delay_in_ms); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); film->make_dcp (); diff --git a/test/black_fill_test.cc b/test/black_fill_test.cc index 99e0870b1..5981552d1 100644 --- a/test/black_fill_test.cc +++ b/test/black_fill_test.cc @@ -40,8 +40,8 @@ BOOST_AUTO_TEST_CASE (black_fill_test) shared_ptr contentA (new ImageContent (film, "test/data/simple_testcard_640x480.png")); shared_ptr contentB (new ImageContent (film, "test/data/simple_testcard_640x480.png")); - film->examine_and_add_content (contentA, true); - film->examine_and_add_content (contentB, true); + film->examine_and_add_content (contentA); + film->examine_and_add_content (contentB); wait_for_jobs (); contentA->set_scale (VideoContentScale (Ratio::from_id ("185"))); diff --git a/test/dcp_subtitle_test.cc b/test/dcp_subtitle_test.cc index 08e8a5cc0..314b214f2 100644 --- a/test/dcp_subtitle_test.cc +++ b/test/dcp_subtitle_test.cc @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test) film->set_name ("frobozz"); film->set_burn_subtitles (false); shared_ptr content (new DCPSubtitleContent (film, "test/data/dcp_sub.xml")); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (2)); diff --git a/test/ffmpeg_audio_test.cc b/test/ffmpeg_audio_test.cc index 5117cf412..444b0869b 100644 --- a/test/ffmpeg_audio_test.cc +++ b/test/ffmpeg_audio_test.cc @@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test) shared_ptr film = new_test_film ("ffmpeg_audio_test"); film->set_name ("ffmpeg_audio_test"); shared_ptr c (new FFmpegContent (film, "test/data/staircase.mov")); - film->examine_and_add_content (c, true); + film->examine_and_add_content (c); wait_for_jobs (); diff --git a/test/ffmpeg_dcp_test.cc b/test/ffmpeg_dcp_test.cc index 8b441db98..559277e51 100644 --- a/test/ffmpeg_dcp_test.cc +++ b/test/ffmpeg_dcp_test.cc @@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_dcp_test) shared_ptr film = new_test_film ("ffmpeg_dcp_test"); film->set_name ("test_film2"); shared_ptr c (new FFmpegContent (film, "test/data/test.mp4")); - film->examine_and_add_content (c, true); + film->examine_and_add_content (c); wait_for_jobs (); diff --git a/test/ffmpeg_decoder_seek_test.cc b/test/ffmpeg_decoder_seek_test.cc index 3274fd8a9..f3504ffc5 100644 --- a/test/ffmpeg_decoder_seek_test.cc +++ b/test/ffmpeg_decoder_seek_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -60,7 +60,7 @@ test (boost::filesystem::path file, vector frames) shared_ptr film = new_test_film ("ffmpeg_decoder_seek_test_" + file.string()); shared_ptr content (new FFmpegContent (film, path)); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); shared_ptr log (new NullLog); FFmpegDecoder decoder (content, log); diff --git a/test/ffmpeg_decoder_sequential_test.cc b/test/ffmpeg_decoder_sequential_test.cc index cf1fb8189..c5f43173e 100644 --- a/test/ffmpeg_decoder_sequential_test.cc +++ b/test/ffmpeg_decoder_sequential_test.cc @@ -47,7 +47,7 @@ test (boost::filesystem::path file, float fps, int gaps) shared_ptr film = new_test_film ("ffmpeg_decoder_seek_test_" + file.string()); shared_ptr content (new FFmpegContent (film, path)); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); shared_ptr log (new NullLog); FFmpegDecoder decoder (content, log); diff --git a/test/frame_rate_test.cc b/test/frame_rate_test.cc index 0ed5a64a7..e8ebcea3b 100644 --- a/test/frame_rate_test.cc +++ b/test/frame_rate_test.cc @@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE (audio_sampling_rate_test) shared_ptr film = new_test_film ("audio_sampling_rate_test"); /* Get any piece of content, it doesn't matter what */ shared_ptr content (new FFmpegContent (film, "test/data/test.mp4")); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); std::list afr; diff --git a/test/import_dcp_test.cc b/test/import_dcp_test.cc index b2420b1fe..80cd9c3df 100644 --- a/test/import_dcp_test.cc +++ b/test/import_dcp_test.cc @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE (import_dcp_test) A->set_name ("frobozz"); shared_ptr c (new FFmpegContent (A, "test/data/test.mp4")); - A->examine_and_add_content (c, true); + A->examine_and_add_content (c); A->set_encrypted (true); wait_for_jobs (); @@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE (import_dcp_test) shared_ptr d (new DCPContent (B, "build/test/import_dcp_test/" + A->dcp_name())); d->add_kdm (kdm); - B->examine_and_add_content (d, true); + B->examine_and_add_content (d); wait_for_jobs (); B->make_dcp (); diff --git a/test/isdcf_name_test.cc b/test/isdcf_name_test.cc index b0b83de44..c2ea833bd 100644 --- a/test/isdcf_name_test.cc +++ b/test/isdcf_name_test.cc @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) /* Test interior aspect ratio: shouldn't be shown with trailers */ shared_ptr content (new ImageContent (film, "test/data/simple_testcard_640x480.png")); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); content->set_scale (VideoContentScale (Ratio::from_id ("133"))); film->set_container (Ratio::from_id ("185")); diff --git a/test/play_test.cc b/test/play_test.cc index f7aa52d6f..bbf70781a 100644 --- a/test/play_test.cc +++ b/test/play_test.cc @@ -87,13 +87,13 @@ BOOST_AUTO_TEST_CASE (play_test) film->set_name ("play_test"); shared_ptr A (new FFmpegContent (film, "test/data/red_24.mp4")); - film->examine_and_add_content (A, true); + film->examine_and_add_content (A); wait_for_jobs (); BOOST_CHECK_EQUAL (A->video_length_after_3d_combine(), 16); shared_ptr B (new FFmpegContent (film, "test/data/red_30.mp4")); - film->examine_and_add_content (B, true); + film->examine_and_add_content (B); wait_for_jobs (); BOOST_CHECK_EQUAL (B->video_length_after_3d_combine(), 16); diff --git a/test/player_test.cc b/test/player_test.cc index d7a55b57a..b6f864f82 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -44,9 +44,9 @@ BOOST_AUTO_TEST_CASE (player_overlaps_test) shared_ptr B (new FFmpegContent (film, "test/data/test.mp4")); shared_ptr C (new FFmpegContent (film, "test/data/test.mp4")); - film->examine_and_add_content (A, true); - film->examine_and_add_content (B, true); - film->examine_and_add_content (C, true); + film->examine_and_add_content (A); + film->examine_and_add_content (B); + film->examine_and_add_content (C); wait_for_jobs (); BOOST_CHECK_EQUAL (A->full_length(), DCPTime (288000)); @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE (player_silence_padding_test) film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - film->examine_and_add_content (c, true); + film->examine_and_add_content (c); wait_for_jobs (); shared_ptr player = film->make_player (); diff --git a/test/recover_test.cc b/test/recover_test.cc index d442b6a4d..a0886fbf4 100644 --- a/test/recover_test.cc +++ b/test/recover_test.cc @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE (recover_test) shared_ptr content (new ImageContent (film, "test/data/3d_test")); content->set_video_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); film->make_dcp (); diff --git a/test/repeat_frame_test.cc b/test/repeat_frame_test.cc index d312ae7ed..1d19d269e 100644 --- a/test/repeat_frame_test.cc +++ b/test/repeat_frame_test.cc @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE (repeat_frame_test) film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test")); shared_ptr c (new FFmpegContent (film, "test/data/red_24.mp4")); - film->examine_and_add_content (c, true); + film->examine_and_add_content (c); wait_for_jobs (); diff --git a/test/scaling_test.cc b/test/scaling_test.cc index d642271c2..441af6bf3 100644 --- a/test/scaling_test.cc +++ b/test/scaling_test.cc @@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE (scaling_test) film->set_name ("scaling_test"); shared_ptr imc (new ImageContent (film, "test/data/simple_testcard_640x480.png")); - film->examine_and_add_content (imc, true); + film->examine_and_add_content (imc); wait_for_jobs (); diff --git a/test/seek_zero_test.cc b/test/seek_zero_test.cc index 7abe7fa26..2a1a06136 100644 --- a/test/seek_zero_test.cc +++ b/test/seek_zero_test.cc @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE (seek_zero_test) film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test")); shared_ptr content (new FFmpegContent (film, "test/data/count300bd48.m2ts")); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); content->set_scale (VideoContentScale (Ratio::from_id ("185"))); diff --git a/test/silence_padding_test.cc b/test/silence_padding_test.cc index 25f2d80c9..d876a0228 100644 --- a/test/silence_padding_test.cc +++ b/test/silence_padding_test.cc @@ -48,7 +48,7 @@ test_silence_padding (int channels) film->set_name (film_name); shared_ptr content (new SndfileContent (film, "test/data/staircase.wav")); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); film->set_audio_channels (channels); diff --git a/test/skip_frame_test.cc b/test/skip_frame_test.cc index 3e4f895c5..dac7b5a25 100644 --- a/test/skip_frame_test.cc +++ b/test/skip_frame_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE (skip_frame_test) film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test")); shared_ptr c (new FFmpegContent (film, "test/data/count300bd48.m2ts")); - film->examine_and_add_content (c, true); + film->examine_and_add_content (c); wait_for_jobs (); diff --git a/test/threed_test.cc b/test/threed_test.cc index 0553d4c0f..f51a77109 100644 --- a/test/threed_test.cc +++ b/test/threed_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE (threed_test) film->set_name ("test_film2"); shared_ptr c (new FFmpegContent (film, "test/data/test.mp4")); c->set_video_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT); - film->examine_and_add_content (c, true); + film->examine_and_add_content (c); wait_for_jobs (); diff --git a/test/upmixer_a_test.cc b/test/upmixer_a_test.cc index bdca521a2..9bcbf3a69 100644 --- a/test/upmixer_a_test.cc +++ b/test/upmixer_a_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE (upmixer_a_test) film->set_name ("frobozz"); shared_ptr content (new SndfileContent (film, "test/data/white.wav")); content->set_audio_processor (AudioProcessor::from_id ("stereo-5.1-upmix-a")); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); diff --git a/test/util_test.cc b/test/util_test.cc index 43b7b9b1d..2a66cb855 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -33,12 +33,21 @@ BOOST_AUTO_TEST_CASE (md5_digest_test) { vector p; p.push_back ("test/data/md5.test"); - string const t = md5_digest (p, shared_ptr ()); - BOOST_CHECK_EQUAL (t, "15058685ba99decdc4398c7634796eb0"); + BOOST_CHECK_EQUAL (md5_digest_head_tail (p, 1024), "57497ef84a0487f2bb0939a1f5703912"); + p.push_back ("test/data/md5.test2"); + BOOST_CHECK_EQUAL (md5_digest_head_tail (p, 1024), "5a3a89857b931755ae728a518224a05c"); + + p.clear (); + p.push_back ("test/data/md5.test3"); + p.push_back ("test/data/md5.test"); + p.push_back ("test/data/md5.test2"); + p.push_back ("test/data/md5.test4"); + BOOST_CHECK_EQUAL (md5_digest_head_tail (p, 1024), "52ccf111e4e72b58bb7b2aaa6bd45ea5"); + p.clear (); p.push_back ("foobar"); - BOOST_CHECK_THROW (md5_digest (p, shared_ptr ()), std::runtime_error); + BOOST_CHECK_THROW (md5_digest_head_tail (p, 1024), OpenFileError); } /* Straightforward test of DCPTime::round_up */ diff --git a/test/xml_subtitle_test.cc b/test/xml_subtitle_test.cc index f6452c788..7c3ca3efe 100644 --- a/test/xml_subtitle_test.cc +++ b/test/xml_subtitle_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE (xml_subtitle_test) film->set_burn_subtitles (false); shared_ptr content (new SubRipContent (film, "test/data/subrip2.srt")); content->set_use_subtitles (true); - film->examine_and_add_content (content, true); + film->examine_and_add_content (content); wait_for_jobs (); film->make_dcp (); wait_for_jobs ();