summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-12-03 10:12:35 +0000
committerCarl Hetherington <cth@carlh.net>2014-12-03 10:12:35 +0000
commitc008066160d85b9ec9e5485375d7baaa5d27bda2 (patch)
treecf2876d69549119bf22761c5f6eccb568242b647 /src/lib
parent996fa2194581bf95113b9778849654893c414889 (diff)
Hand-apply 6a3cd511559433554ab40ed72ff94b7d8dc2c5bd from master;
Basics of an image sequence dialog that asks about frame rate and digest calculation.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/content.cc9
-rw-r--r--src/lib/content.h3
-rw-r--r--src/lib/dcp_content.cc4
-rw-r--r--src/lib/dcp_content.h2
-rw-r--r--src/lib/dcp_examiner.h4
-rw-r--r--src/lib/dcp_subtitle_content.cc4
-rw-r--r--src/lib/dcp_subtitle_content.h2
-rw-r--r--src/lib/examine_content_job.cc5
-rw-r--r--src/lib/examine_content_job.h3
-rw-r--r--src/lib/ffmpeg_content.cc4
-rw-r--r--src/lib/ffmpeg_content.h2
-rw-r--r--src/lib/ffmpeg_examiner.cc2
-rw-r--r--src/lib/ffmpeg_examiner.h2
-rw-r--r--src/lib/film.cc8
-rw-r--r--src/lib/film.h4
-rw-r--r--src/lib/image_content.cc5
-rw-r--r--src/lib/image_content.h2
-rw-r--r--src/lib/image_examiner.cc15
-rw-r--r--src/lib/image_examiner.h4
-rw-r--r--src/lib/sndfile_content.cc4
-rw-r--r--src/lib/sndfile_content.h2
-rw-r--r--src/lib/subrip_content.cc4
-rw-r--r--src/lib/subrip_content.h2
-rw-r--r--src/lib/video_content.cc6
-rw-r--r--src/lib/video_examiner.h2
25 files changed, 57 insertions, 47 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 21e49a2c9..6e0218323 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -32,6 +32,7 @@
#include "exceptions.h"
#include "film.h"
#include "safe_stringstream.h"
+#include "job.h"
#include "i18n.h"
@@ -131,8 +132,14 @@ Content::as_xml (xmlpp::Node* node) const
}
void
-Content::examine (shared_ptr<Job> job)
+Content::examine (shared_ptr<Job> job, bool calculate_digest)
{
+ if (!calculate_digest) {
+ return;
+ }
+
+ job->sub (_("Computing digest"));
+
boost::mutex::scoped_lock lm (_mutex);
vector<boost::filesystem::path> p = _paths;
lm.unlock ();
diff --git a/src/lib/content.h b/src/lib/content.h
index f7e97feac..0b72ada9c 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -67,8 +67,9 @@ 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> job);
+ virtual void examine (boost::shared_ptr<Job> job, bool calculate_digest);
/** @return Quick one-line summary of the content, as will be presented in the
* film editor.
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index a5b5f37e1..28b7ac862 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> job)
+DCPContent::examine (shared_ptr<Job> job, bool calculate_digest)
{
bool const could_be_played = can_be_played ();
job->set_progress_unknown ();
- Content::examine (job);
+ Content::examine (job, calculate_digest);
shared_ptr<DCPExaminer> 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 da78e6d72..d6fe8c820 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<Job>);
+ void examine (boost::shared_ptr<Job>, bool calculate_digest);
std::string summary () const;
std::string technical_summary () const;
void as_xml (xmlpp::Node *) const;
diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h
index 03d43d0f6..ef780dc3e 100644
--- a/src/lib/dcp_examiner.h
+++ b/src/lib/dcp_examiner.h
@@ -27,8 +27,8 @@ class DCPExaminer : public VideoExaminer, public AudioExaminer
public:
DCPExaminer (boost::shared_ptr<const DCPContent>);
- float video_frame_rate () const {
- return _video_frame_rate.get_value_or (24);
+ boost::optional<float> video_frame_rate () const {
+ return _video_frame_rate;
}
dcp::Size video_size () const {
diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc
index 83b0d200c..1935a874f 100644
--- a/src/lib/dcp_subtitle_content.cc
+++ b/src/lib/dcp_subtitle_content.cc
@@ -44,9 +44,9 @@ DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, cxml::Const
}
void
-DCPSubtitleContent::examine (shared_ptr<Job> job)
+DCPSubtitleContent::examine (shared_ptr<Job> job, bool calculate_digest)
{
- Content::examine (job);
+ Content::examine (job, calculate_digest);
dcp::SubtitleContent sc (path (0), false);
_length = DCPTime::from_seconds (sc.latest_subtitle_out().to_seconds ());
}
diff --git a/src/lib/dcp_subtitle_content.h b/src/lib/dcp_subtitle_content.h
index 5794b5951..551dafd15 100644
--- a/src/lib/dcp_subtitle_content.h
+++ b/src/lib/dcp_subtitle_content.h
@@ -26,7 +26,7 @@ public:
DCPSubtitleContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
/* Content */
- void examine (boost::shared_ptr<Job>);
+ void examine (boost::shared_ptr<Job>, bool calculate_digest);
std::string summary () const;
std::string technical_summary () const;
std::string information () const;
diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc
index cbf180ffc..ee887271f 100644
--- a/src/lib/examine_content_job.cc
+++ b/src/lib/examine_content_job.cc
@@ -29,9 +29,10 @@ using std::string;
using std::cout;
using boost::shared_ptr;
-ExamineContentJob::ExamineContentJob (shared_ptr<const Film> f, shared_ptr<Content> c)
+ExamineContentJob::ExamineContentJob (shared_ptr<const Film> f, shared_ptr<Content> c, bool calculate_digest)
: Job (f)
, _content (c)
+ , _calculate_digest (calculate_digest)
{
}
@@ -49,7 +50,7 @@ ExamineContentJob::name () const
void
ExamineContentJob::run ()
{
- _content->examine (shared_from_this ());
+ _content->examine (shared_from_this (), _calculate_digest);
set_progress (1);
set_state (FINISHED_OK);
}
diff --git a/src/lib/examine_content_job.h b/src/lib/examine_content_job.h
index b6903b86b..f0d9eae93 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<const Film>, boost::shared_ptr<Content>);
+ ExamineContentJob (boost::shared_ptr<const Film>, boost::shared_ptr<Content>, bool calculate_digest);
~ExamineContentJob ();
std::string name () const;
@@ -34,5 +34,6 @@ public:
private:
boost::shared_ptr<Content> _content;
+ bool _calculate_digest;
};
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index bb4e02230..a186db48e 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> job)
+FFmpegContent::examine (shared_ptr<Job> job, bool calculate_digest)
{
job->set_progress_unknown ();
- Content::examine (job);
+ Content::examine (job, calculate_digest);
shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this ()));
take_from_video_examiner (examiner);
diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h
index da8152c0d..fca3bf8be 100644
--- a/src/lib/ffmpeg_content.h
+++ b/src/lib/ffmpeg_content.h
@@ -56,7 +56,7 @@ public:
return boost::dynamic_pointer_cast<FFmpegContent> (Content::shared_from_this ());
}
- void examine (boost::shared_ptr<Job>);
+ void examine (boost::shared_ptr<Job>, bool calculate_digest);
std::string summary () const;
std::string technical_summary () const;
std::string information () const;
diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc
index 5ca05dd55..1d01981f6 100644
--- a/src/lib/ffmpeg_examiner.cc
+++ b/src/lib/ffmpeg_examiner.cc
@@ -156,7 +156,7 @@ FFmpegExaminer::frame_time (AVStream* s) const
return t;
}
-float
+optional<float>
FFmpegExaminer::video_frame_rate () const
{
/* This use of r_frame_rate is debateable; there's a few different
diff --git a/src/lib/ffmpeg_examiner.h b/src/lib/ffmpeg_examiner.h
index 59c3299b2..4378e241b 100644
--- a/src/lib/ffmpeg_examiner.h
+++ b/src/lib/ffmpeg_examiner.h
@@ -29,7 +29,7 @@ class FFmpegExaminer : public FFmpeg, public VideoExaminer
public:
FFmpegExaminer (boost::shared_ptr<const FFmpegContent>);
- float video_frame_rate () const;
+ boost::optional<float> video_frame_rate () const;
dcp::Size video_size () const;
ContentTime video_length () const;
boost::optional<float> sample_aspect_ratio () const;
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 8144759b6..22dc0ca90 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -948,20 +948,20 @@ Film::content () const
}
void
-Film::examine_content (shared_ptr<Content> c)
+Film::examine_content (shared_ptr<Content> c, bool calculate_digest)
{
- shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c));
+ shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c, calculate_digest));
JobManager::instance()->add (j);
}
void
-Film::examine_and_add_content (shared_ptr<Content> c)
+Film::examine_and_add_content (shared_ptr<Content> c, bool calculate_digest)
{
if (dynamic_pointer_cast<FFmpegContent> (c)) {
run_ffprobe (c->path(0), file ("ffprobe.log"), _log);
}
- shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c));
+ shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c, calculate_digest));
j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr<Job> (j), boost::weak_ptr<Content> (c)));
JobManager::instance()->add (j);
}
diff --git a/src/lib/film.h b/src/lib/film.h
index 8a0823094..1906de91b 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -250,8 +250,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<Content>);
- void examine_and_add_content (boost::shared_ptr<Content>);
+ void examine_content (boost::shared_ptr<Content>, bool calculate_digest);
+ void examine_and_add_content (boost::shared_ptr<Content>, bool calculate_digest);
void add_content (boost::shared_ptr<Content>);
void remove_content (boost::shared_ptr<Content>);
void move_content_earlier (boost::shared_ptr<Content>);
diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc
index 84b0b75c9..132b26144 100644
--- a/src/lib/image_content.cc
+++ b/src/lib/image_content.cc
@@ -100,10 +100,9 @@ ImageContent::as_xml (xmlpp::Node* node) const
}
void
-ImageContent::examine (shared_ptr<Job> job)
+ImageContent::examine (shared_ptr<Job> job, bool calculate_digest)
{
- job->sub (_("Computing digest"));
- Content::examine (job);
+ Content::examine (job, calculate_digest);
shared_ptr<const Film> film = _film.lock ();
assert (film);
diff --git a/src/lib/image_content.h b/src/lib/image_content.h
index a1b1437c8..6b70d5789 100644
--- a/src/lib/image_content.h
+++ b/src/lib/image_content.h
@@ -37,7 +37,7 @@ public:
return boost::dynamic_pointer_cast<ImageContent> (Content::shared_from_this ());
};
- void examine (boost::shared_ptr<Job>);
+ void examine (boost::shared_ptr<Job>, bool calculate_digest);
std::string summary () const;
std::string technical_summary () const;
void as_xml (xmlpp::Node *) const;
diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc
index ef9c13c5a..d6c7d0502 100644
--- a/src/lib/image_examiner.cc
+++ b/src/lib/image_examiner.cc
@@ -34,6 +34,7 @@ using std::cout;
using std::list;
using std::sort;
using boost::shared_ptr;
+using boost::optional;
ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const ImageContent> content, shared_ptr<Job>)
: _film (film)
@@ -63,7 +64,9 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
if (content->still ()) {
_video_length = ContentTime::from_seconds (Config::instance()->default_still_length());
} else {
- _video_length = ContentTime::from_frames (_image_content->number_of_paths (), video_frame_rate ());
+ _video_length = ContentTime::from_frames (
+ _image_content->number_of_paths (), video_frame_rate().get_value_or (0)
+ );
}
}
@@ -73,13 +76,9 @@ ImageExaminer::video_size () const
return _video_size.get ();
}
-float
+optional<float>
ImageExaminer::video_frame_rate () const
{
- boost::shared_ptr<const Film> f = _film.lock ();
- if (!f) {
- return 24;
- }
-
- return f->video_frame_rate ();
+ /* Don't know */
+ return optional<float> ();
}
diff --git a/src/lib/image_examiner.h b/src/lib/image_examiner.h
index 6ae0422cb..1917a23f3 100644
--- a/src/lib/image_examiner.h
+++ b/src/lib/image_examiner.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
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 @@ class ImageExaminer : public VideoExaminer
public:
ImageExaminer (boost::shared_ptr<const Film>, boost::shared_ptr<const ImageContent>, boost::shared_ptr<Job>);
- float video_frame_rate () const;
+ boost::optional<float> video_frame_rate () const;
dcp::Size video_size () const;
ContentTime video_length () const {
return _video_length;
diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc
index 1a1797665..cdc9734bf 100644
--- a/src/lib/sndfile_content.cc
+++ b/src/lib/sndfile_content.cc
@@ -101,10 +101,10 @@ SndfileContent::valid_file (boost::filesystem::path f)
}
void
-SndfileContent::examine (shared_ptr<Job> job)
+SndfileContent::examine (shared_ptr<Job> job, bool calculate_digest)
{
job->set_progress_unknown ();
- Content::examine (job);
+ Content::examine (job, calculate_digest);
shared_ptr<AudioExaminer> 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 75c723518..cb255fd74 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<Job>);
+ void examine (boost::shared_ptr<Job>, bool calculate_digest);
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 14cb50b86..7a336f88a 100644
--- a/src/lib/subrip_content.cc
+++ b/src/lib/subrip_content.cc
@@ -47,9 +47,9 @@ SubRipContent::SubRipContent (shared_ptr<const Film> film, cxml::ConstNodePtr no
}
void
-SubRipContent::examine (boost::shared_ptr<Job> job)
+SubRipContent::examine (boost::shared_ptr<Job> job, bool calculate_digest)
{
- Content::examine (job);
+ Content::examine (job, calculate_digest);
SubRip s (shared_from_this ());
shared_ptr<const Film> film = _film.lock ();
diff --git a/src/lib/subrip_content.h b/src/lib/subrip_content.h
index d2dcdee00..243032691 100644
--- a/src/lib/subrip_content.h
+++ b/src/lib/subrip_content.h
@@ -30,7 +30,7 @@ public:
}
/* Content */
- void examine (boost::shared_ptr<Job>);
+ void examine (boost::shared_ptr<Job>, bool calculate_digest);
std::string summary () const;
std::string technical_summary () const;
std::string information () const;
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index 8e07174e3..ca0c687a7 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -221,14 +221,16 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> d)
{
/* These examiner calls could call other content methods which take a lock on the mutex */
dcp::Size const vs = d->video_size ();
- float const vfr = d->video_frame_rate ();
+ optional<float> const vfr = d->video_frame_rate ();
ContentTime vl = d->video_length ();
optional<float> const ar = d->sample_aspect_ratio ();
{
boost::mutex::scoped_lock lm (_mutex);
_video_size = vs;
- _video_frame_rate = vfr;
+ if (vfr) {
+ _video_frame_rate = vfr.get ();
+ }
_video_length = vl;
_sample_aspect_ratio = ar;
diff --git a/src/lib/video_examiner.h b/src/lib/video_examiner.h
index de7966507..55b27ac94 100644
--- a/src/lib/video_examiner.h
+++ b/src/lib/video_examiner.h
@@ -32,7 +32,7 @@ class VideoExaminer
{
public:
virtual ~VideoExaminer () {}
- virtual float video_frame_rate () const = 0;
+ virtual boost::optional<float> video_frame_rate () const = 0;
virtual dcp::Size video_size () const = 0;
virtual ContentTime video_length () const = 0;
virtual boost::optional<float> sample_aspect_ratio () const {