summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/content.cc4
-rw-r--r--src/lib/film.h1
-rw-r--r--src/lib/moving_image_content.cc5
-rw-r--r--src/lib/util.cc21
-rw-r--r--src/lib/util.h5
5 files changed, 28 insertions, 8 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 44b52a471..d2a07f795 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -80,7 +80,7 @@ Content::as_xml (xmlpp::Node* node) const
}
void
-Content::examine (shared_ptr<Job>)
+Content::examine (shared_ptr<Job> job)
{
boost::mutex::scoped_lock lm (_mutex);
boost::filesystem::path p = _path;
@@ -90,7 +90,7 @@ Content::examine (shared_ptr<Job>)
if (boost::filesystem::is_regular_file (p)) {
d = md5_digest (p);
} else {
- d = md5_digest_directory (p);
+ d = md5_digest_directory (p, job);
}
lm.lock ();
diff --git a/src/lib/film.h b/src/lib/film.h
index e7f017b02..df26a3ae5 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -41,6 +41,7 @@ class Content;
class Player;
class Playlist;
class AudioContent;
+class Scaler;
/** @class Film
*
diff --git a/src/lib/moving_image_content.cc b/src/lib/moving_image_content.cc
index 63b4b9f24..a72ad6e8e 100644
--- a/src/lib/moving_image_content.cc
+++ b/src/lib/moving_image_content.cc
@@ -23,6 +23,7 @@
#include "config.h"
#include "compose.hpp"
#include "film.h"
+#include "job.h"
#include "i18n.h"
@@ -80,12 +81,16 @@ MovingImageContent::as_xml (xmlpp::Node* node) const
void
MovingImageContent::examine (shared_ptr<Job> job)
{
+ job->descend (0.5);
Content::examine (job);
+ job->ascend ();
shared_ptr<const Film> film = _film.lock ();
assert (film);
+ job->descend (0.5);
shared_ptr<MovingImageExaminer> examiner (new MovingImageExaminer (film, shared_from_this(), job));
+ job->ascend ();
take_from_video_examiner (examiner);
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 26dfa8bf7..4180bbfd7 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -61,6 +61,7 @@ extern "C" {
#include "sound_processor.h"
#include "config.h"
#include "ratio.h"
+#include "job.h"
#ifdef DCPOMATIC_WINDOWS
#include "stack.hpp"
#endif
@@ -407,15 +408,24 @@ md5_digest (boost::filesystem::path file)
return s.str ();
}
+/** @param job Optional job for which to report progress */
string
-md5_digest_directory (boost::filesystem::path directory)
+md5_digest_directory (boost::filesystem::path directory, shared_ptr<Job> job)
{
int const buffer_size = 64 * 1024;
char buffer[buffer_size];
MD5_CTX md5_context;
MD5_Init (&md5_context);
-
+
+ int files = 0;
+ if (job) {
+ for (boost::filesystem::directory_iterator i(directory); i != boost::filesystem::directory_iterator(); ++i) {
+ ++files;
+ }
+ }
+
+ int j = 0;
for (boost::filesystem::directory_iterator i(directory); i != boost::filesystem::directory_iterator(); ++i) {
ifstream f (i->path().string().c_str(), std::ios::binary);
if (!f.good ()) {
@@ -432,6 +442,11 @@ md5_digest_directory (boost::filesystem::path directory)
MD5_Update (&md5_context, buffer, t);
bytes -= t;
}
+
+ if (job) {
+ job->set_progress (float (j) / files);
+ ++j;
+ }
}
unsigned char digest[MD5_DIGEST_LENGTH];
@@ -781,6 +796,6 @@ valid_image_file (boost::filesystem::path f)
{
string ext = f.extension().string();
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
- return (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp");
+ return (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp" || ext == ".tga");
}
diff --git a/src/lib/util.h b/src/lib/util.h
index 121deb532..a83426206 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -51,8 +51,7 @@ extern "C" {
/** The maximum number of audio channels that we can cope with */
#define MAX_AUDIO_CHANNELS 6
-class Scaler;
-class Film;
+class Job;
extern std::string seconds_to_hms (int);
extern std::string seconds_to_approximate_hms (int);
@@ -63,7 +62,7 @@ extern void dcpomatic_setup ();
extern void dcpomatic_setup_gettext_i18n (std::string);
extern std::vector<std::string> split_at_spaces_considering_quotes (std::string);
extern std::string md5_digest (boost::filesystem::path);
-extern std::string md5_digest_directory (boost::filesystem::path);
+extern std::string md5_digest_directory (boost::filesystem::path, boost::shared_ptr<Job>);
extern std::string md5_digest (void const *, int);
extern void ensure_ui_thread ();
extern std::string audio_channel_name (int);