#include "ab_transcode_job.h"
#include "transcode_job.h"
#include "scp_dcp_job.h"
-#include "copy_from_dvd_job.h"
#include "make_dcp_job.h"
#include "log.h"
#include "options.h"
using std::ofstream;
using std::setfill;
using std::min;
+using std::make_pair;
using boost::shared_ptr;
using boost::lexical_cast;
using boost::to_upper_copy;
o->out_size = format()->dcp_size ();
o->padding = format()->dcp_padding (shared_from_this ());
o->ratio = format()->ratio_as_float (shared_from_this ());
+ if (dcp_length ()) {
+ o->video_decode_range = make_pair (dcp_trim_start(), dcp_trim_start() + dcp_length().get());
+ o->audio_decode_range = make_pair (
+ video_frames_to_audio_frames (o->video_decode_range.get().first, audio_sample_rate(), frames_per_second()),
+ video_frames_to_audio_frames (o->video_decode_range.get().second, audio_sample_rate(), frames_per_second())
+ );
+
+ }
o->decode_subtitles = with_subtitles ();
+ o->decode_video_skip = dcp_frame_rate (frames_per_second()).skip;
shared_ptr<Job> r;
return;
}
- set_thumbs (vector<int> ());
+ set_thumbs (vector<SourceFrame> ());
boost::filesystem::remove_all (dir ("thumbs"));
/* This call will recreate the directory */
JobManager::instance()->add (j);
}
-void
-Film::copy_from_dvd ()
-{
- shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
- JobManager::instance()->add (j);
-}
-
/** Count the number of frames that have been encoded for this film.
* @return frame count.
*/
/* Cached stuff; this is information about our content; we could
look it up each time, but that's slow.
*/
- for (vector<int>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
+ for (vector<SourceFrame>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
f << "thumb " << *i << "\n";
}
f << "width " << _size.width << "\n";
return thumb_file_for_frame (thumb_frame (n));
}
-/** @param n A frame index within the Film.
+/** @param n A frame index within the Film's source.
* @return The path to the thumb's image file for this frame;
* we assume that it exists.
*/
string
-Film::thumb_file_for_frame (int n) const
+Film::thumb_file_for_frame (SourceFrame n) const
{
return thumb_base_for_frame(n) + ".png";
}
-/** Must not be called with the _state_mutex locked */
+/** @param n Thumb index.
+ * Must not be called with the _state_mutex locked.
+ */
string
Film::thumb_base (int n) const
{
}
string
-Film::thumb_base_for_frame (int n) const
+Film::thumb_base_for_frame (SourceFrame n) const
{
stringstream s;
s.width (8);
}
/** @param n A thumb index.
- * @return The frame within the Film that it is for.
+ * @return The frame within the Film's source that it is for.
*
* Must not be called with the _state_mutex locked.
*/
-int
+SourceFrame
Film::thumb_frame (int n) const
{
boost::mutex::scoped_lock lm (_state_mutex);
/* Resample to a DCI-approved sample rate */
double t = dcp_audio_sample_rate (audio_sample_rate());
+ DCPFrameRate dfr = dcp_frame_rate (frames_per_second ());
+
/* Compensate for the fact that video will be rounded to the
nearest integer number of frames per second.
*/
- if (rint (frames_per_second()) != frames_per_second()) {
- t *= _frames_per_second / rint (frames_per_second());
+ if (dfr.run_fast) {
+ t *= _frames_per_second * dfr.skip / dfr.frames_per_second;
}
return rint (t);
}
-boost::optional<int>
+boost::optional<SourceFrame>
Film::dcp_length () const
{
if (!length()) {
- return boost::optional<int> ();
+ return boost::optional<SourceFrame> ();
}
return length().get() - dcp_trim_start() - dcp_trim_end();
d << "_";
}
- switch (_audio_streams[_audio_stream].channels()) {
- case 1:
- d << "10_";
- break;
- case 2:
- d << "20_";
- break;
- case 6:
- d << "51_";
- break;
- case 8:
- d << "71_";
- break;
+ if (_audio_stream != -1) {
+ switch (_audio_streams[_audio_stream].channels()) {
+ case 1:
+ d << "10_";
+ break;
+ case 2:
+ d << "20_";
+ break;
+ case 6:
+ d << "51_";
+ break;
+ case 8:
+ d << "71_";
+ break;
+ }
}
d << "2K_";
shared_ptr<Options> o (new Options ("", "", ""));
o->out_size = Size (1024, 1024);
- shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0, 0);
+ shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0);
set_size (d->native_size ());
set_frames_per_second (d->frames_per_second ());
}
void
-Film::set_thumbs (vector<int> t)
+Film::set_thumbs (vector<SourceFrame> t)
{
{
boost::mutex::scoped_lock lm (_state_mutex);
}
void
-Film::set_length (int l)
+Film::set_length (SourceFrame l)
{
{
boost::mutex::scoped_lock lm (_state_mutex);
{
_dci_date = boost::gregorian::day_clock::local_day ();
}
+