diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-10 10:02:20 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-10 10:02:20 +0100 |
| commit | cb33319a820b17a05cfb2ef78ba1799f4d0c54b9 (patch) | |
| tree | 7529501950b16db912a527d269ed83e39a37f7d6 /src | |
| parent | 3781be4da4601176d7bb954f9cc65621d75e7344 (diff) | |
| parent | a097506d4867fec47406283caa5b262a21791585 (diff) | |
Merge branch 'master' of /home/carl/git/dvdomatic
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/ab_transcoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/check_hashes_job.cc | 4 | ||||
| -rw-r--r-- | src/lib/decoder.cc | 17 | ||||
| -rw-r--r-- | src/lib/decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/decoder_factory.cc | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 38 | ||||
| -rw-r--r-- | src/lib/film.cc | 15 | ||||
| -rw-r--r-- | src/lib/film_state.cc | 28 | ||||
| -rw-r--r-- | src/lib/film_state.h | 2 | ||||
| -rw-r--r-- | src/lib/format.cc | 124 | ||||
| -rw-r--r-- | src/lib/format.h | 71 | ||||
| -rw-r--r-- | src/lib/image.cc | 2 | ||||
| -rw-r--r-- | src/lib/j2k_still_encoder.cc | 4 | ||||
| -rw-r--r-- | src/lib/j2k_still_encoder.h | 4 | ||||
| -rw-r--r-- | src/lib/j2k_wav_encoder.cc | 12 | ||||
| -rw-r--r-- | src/lib/job_manager.cc | 14 | ||||
| -rw-r--r-- | src/lib/job_manager.h | 1 | ||||
| -rw-r--r-- | src/lib/options.h | 5 | ||||
| -rw-r--r-- | src/lib/transcode_job.cc | 2 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 49 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 5 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 2 |
22 files changed, 247 insertions, 158 deletions
diff --git a/src/lib/ab_transcoder.cc b/src/lib/ab_transcoder.cc index 95492a9d8..1c20ae477 100644 --- a/src/lib/ab_transcoder.cc +++ b/src/lib/ab_transcoder.cc @@ -112,7 +112,7 @@ ABTranscoder::go () bool const b = _db->pass (); if (_job) { - _job->set_progress (float (_last_frame) / _da->decoding_frames ()); + _job->set_progress (float (_last_frame) / _fs_a->dcp_length()); } if (a && b) { diff --git a/src/lib/check_hashes_job.cc b/src/lib/check_hashes_job.cc index cf269564a..f60a2d40d 100644 --- a/src/lib/check_hashes_job.cc +++ b/src/lib/check_hashes_job.cc @@ -48,8 +48,10 @@ void CheckHashesJob::run () { _bad = 0; + + int const N = _fs->dcp_length (); - for (int i = 0; i < _fs->length; ++i) { + for (int i = 0; i < N; ++i) { string const j2k_file = _opt->frame_out_path (i, false); string const hash_file = j2k_file + ".md5"; diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 8aa5f77c6..324d1a296 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -112,7 +112,7 @@ Decoder::process_end () */ int64_t const audio_short_by_frames = - ((int64_t) decoding_frames() * _fs->target_sample_rate() / _fs->frames_per_second) + ((int64_t) _fs->dcp_length() * _fs->target_sample_rate() / _fs->frames_per_second) - _audio_frames_processed; if (audio_short_by_frames >= 0) { @@ -147,24 +147,13 @@ Decoder::go () while (pass () == false) { if (_job && !_ignore_length) { - _job->set_progress (float (_video_frame) / decoding_frames ()); + _job->set_progress (float (_video_frame) / _fs->dcp_length()); } } process_end (); } -/** @return Number of frames that we will be decoding */ -int -Decoder::decoding_frames () const -{ - if (_opt->num_frames > 0) { - return _opt->num_frames; - } - - return _fs->length; -} - /** Run one pass. This may or may not generate any actual video / audio data; * some decoders may require several passes to generate a single frame. * @return true if we have finished processing all data; otherwise false. @@ -177,7 +166,7 @@ Decoder::pass () _have_setup_video_filters = true; } - if (_opt->num_frames != 0 && _video_frame >= _opt->num_frames) { + if (_video_frame >= _fs->dcp_length()) { return true; } diff --git a/src/lib/decoder.h b/src/lib/decoder.h index 19ef25ede..04ff512eb 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -77,8 +77,6 @@ public: return _video_frame; } - int decoding_frames () const; - /** Emitted when a video frame is ready. * First parameter is the frame. * Second parameter is its index within the content. diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc index 6826724af..c03912094 100644 --- a/src/lib/decoder_factory.cc +++ b/src/lib/decoder_factory.cc @@ -42,7 +42,7 @@ decoder_factory ( if (fs->content_type() == STILL) { /* Always ignore length of decodes of stills, since the decoder finishes very quickly - and its the encoder that takes the time. + and it's the encoder that takes the time. */ return shared_ptr<Decoder> (new ImageMagickDecoder (fs, o, j, l, minimal, true)); } diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 3471ffaab..767299ea6 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -161,11 +161,37 @@ FFmpegDecoder::do_pass () { int r = av_read_frame (_format_context, &_packet); if (r < 0) { + if (r != AVERROR_EOF) { + throw DecodeError ("error on av_read_frame"); + } + + /* Get any remaining frames */ + + _packet.data = 0; + _packet.size = 0; + + int frame_finished; + + while (avcodec_decode_video2 (_video_codec_context, _frame, &frame_finished, &_packet) >= 0 && frame_finished) { + process_video (_frame); + } + + if (_audio_stream >= 0 && _opt->decode_audio) { + while (avcodec_decode_audio4 (_audio_codec_context, _frame, &frame_finished, &_packet) >= 0 && frame_finished) { + int const data_size = av_samples_get_buffer_size ( + 0, _audio_codec_context->channels, _frame->nb_samples, audio_sample_format (), 1 + ); + + assert (_audio_codec_context->channels == _fs->audio_channels); + process_audio (_frame->data[0], data_size); + } + } + return true; } - if (_packet.stream_index == _video_stream && _opt->decode_video) { - + if (_packet.stream_index == _video_stream) { + int frame_finished; if (avcodec_decode_video2 (_video_codec_context, _frame, &frame_finished, &_packet) >= 0 && frame_finished) { process_video (_frame); @@ -199,7 +225,13 @@ FFmpegDecoder::length_in_frames () const float FFmpegDecoder::frames_per_second () const { - return av_q2d (_format_context->streams[_video_stream]->avg_frame_rate); + AVStream* s = _format_context->streams[_video_stream]; + + if (s->avg_frame_rate.num && s->avg_frame_rate.den) { + return av_q2d (s->avg_frame_rate); + } + + return av_q2d (s->r_frame_rate); } int diff --git a/src/lib/film.cc b/src/lib/film.cc index 2db03f6a6..e2b3d4bc3 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -85,8 +85,12 @@ Film::Film (string d, bool must_exist) _state.directory = result.string (); - if (must_exist && !filesystem::exists (_state.directory)) { - throw OpenFileError (_state.directory); + if (!filesystem::exists (_state.directory)) { + if (must_exist) { + throw OpenFileError (_state.directory); + } else { + filesystem::create_directory (_state.directory); + } } read_metadata (); @@ -513,25 +517,22 @@ Film::make_dcp (bool transcode, int freq) o->out_size = format()->dcp_size (); if (dcp_frames() == 0) { /* Decode the whole film, no blacking */ - o->num_frames = 0; o->black_after = 0; } else { switch (dcp_trim_action()) { case CUT: /* Decode only part of the film, no blacking */ - o->num_frames = dcp_frames (); o->black_after = 0; break; case BLACK_OUT: /* Decode the whole film, but black some frames out */ - o->num_frames = 0; o->black_after = dcp_frames (); } } o->decode_video_frequency = freq; - o->padding = format()->dcp_padding (); - o->ratio = format()->ratio_as_float (); + o->padding = format()->dcp_padding (this); + o->ratio = format()->ratio_as_float (this); if (transcode) { if (_state.dcp_ab) { diff --git a/src/lib/film_state.cc b/src/lib/film_state.cc index d7d9a1462..3d58a4fec 100644 --- a/src/lib/film_state.cc +++ b/src/lib/film_state.cc @@ -283,19 +283,27 @@ FilmState::bytes_per_sample () const int FilmState::target_sample_rate () const { + /* Resample to a DCI-approved sample rate */ double t = dcp_audio_sample_rate (audio_sample_rate); + + /* 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) { - if (fabs (frames_per_second - 23.976) < 1e-6 || (fabs (frames_per_second - 29.97) < 1e-6)) { - /* 24fps or 30fps drop-frame ie {24,30} * 1000 / 1001 frames per second; - hence we need to resample the audio to dcp_audio_sample_rate * 1000 / 1001 - so that when we play it back at dcp_audio_sample_rate it is sped up - by the same amount that the video is - */ - t *= double(1000) / 1001; - } else { - throw EncodeError ("unknown fractional frame rate"); - } + t *= frames_per_second / rint (frames_per_second); } return rint (t); } + +int +FilmState::dcp_length () const +{ + if (dcp_frames) { + return dcp_frames; + } + + return length; +} + + diff --git a/src/lib/film_state.h b/src/lib/film_state.h index 8dc0ce11b..16a1b0508 100644 --- a/src/lib/film_state.h +++ b/src/lib/film_state.h @@ -87,6 +87,8 @@ public: Size cropped_size (Size) const; + int dcp_length () const; + /** Complete path to directory containing the film metadata; must not be relative. */ diff --git a/src/lib/format.cc b/src/lib/format.cc index e689aa05d..aaf5211f9 100644 --- a/src/lib/format.cc +++ b/src/lib/format.cc @@ -28,28 +28,15 @@ #include <iomanip> #include <iostream> #include "format.h" +#include "film.h" using namespace std; vector<Format const *> Format::_formats; -/** @param r Ratio multiplied by 100 (e.g. 185) - * @param dcp Size (in pixels) of the images that we should put in a DCP. - * @param id ID (e.g. 185) - * @param n Nick name (e.g. Flat) - */ -Format::Format (int r, Size dcp, string id, string n) - : _ratio (r) - , _dcp_size (dcp) - , _id (id) - , _nickname (n) -{ - -} - /** @return A name to be presented to the user */ string -Format::name () const +FixedFormat::name () const { stringstream s; if (!_nickname.empty ()) { @@ -76,34 +63,18 @@ Format::as_metadata () const void Format::setup_formats () { - _formats.push_back (new Format (119, Size (1285, 1080), "119", "1.19")); - _formats.push_back (new Format (133, Size (1436, 1080), "133", "1.33")); - _formats.push_back (new Format (138, Size (1485, 1080), "138", "1.375")); - _formats.push_back (new Format (133, Size (1998, 1080), "133-in-flat", "4:3 within Flat")); - _formats.push_back (new Format (137, Size (1480, 1080), "137", "Academy")); - _formats.push_back (new Format (166, Size (1793, 1080), "166", "1.66")); - _formats.push_back (new Format (166, Size (1998, 1080), "166-in-flat", "1.66 within Flat")); - _formats.push_back (new Format (178, Size (1998, 1080), "178-in-flat", "16:9 within Flat")); - _formats.push_back (new Format (185, Size (1998, 1080), "185", "Flat")); - _formats.push_back (new Format (239, Size (2048, 858), "239", "Scope")); -} - -/** @param r Ratio multiplied by 100. - * @return Matching Format, or 0. - */ -Format const * -Format::from_ratio (int r) -{ - vector<Format const *>::iterator i = _formats.begin (); - while (i != _formats.end() && (*i)->ratio_as_integer() != r) { - ++i; - } - - if (i == _formats.end ()) { - return 0; - } - - return *i; + _formats.push_back (new FixedFormat (119, Size (1285, 1080), "119", "1.19")); + _formats.push_back (new FixedFormat (133, Size (1436, 1080), "133", "1.33")); + _formats.push_back (new FixedFormat (138, Size (1485, 1080), "138", "1.375")); + _formats.push_back (new FixedFormat (133, Size (1998, 1080), "133-in-flat", "4:3 within Flat")); + _formats.push_back (new FixedFormat (137, Size (1480, 1080), "137", "Academy")); + _formats.push_back (new FixedFormat (166, Size (1793, 1080), "166", "1.66")); + _formats.push_back (new FixedFormat (166, Size (1998, 1080), "166-in-flat", "1.66 within Flat")); + _formats.push_back (new FixedFormat (178, Size (1998, 1080), "178-in-flat", "16:9 within Flat")); + _formats.push_back (new FixedFormat (185, Size (1998, 1080), "185", "Flat")); + _formats.push_back (new FixedFormat (239, Size (2048, 858), "239", "Scope")); + _formats.push_back (new VariableFormat (Size (1998, 1080), "var-185", "Flat")); + _formats.push_back (new VariableFormat (Size (2048, 858), "var-239", "Scope")); } /** @param n Nickname. @@ -152,45 +123,29 @@ Format::from_metadata (string m) return from_id (m); } -/** @param f A Format. - * @return Index of f within our static list, or -1. - */ -int -Format::as_index (Format const * f) +/** @return All available formats */ +vector<Format const *> +Format::all () { - vector<Format*>::size_type i = 0; - while (i < _formats.size() && _formats[i] != f) { - ++i; - } - - if (i == _formats.size ()) { - return -1; - } - - return i; + return _formats; } -/** @param i An index returned from as_index(). - * @return Corresponding Format. +/** @param r Ratio multiplied by 100 (e.g. 185) + * @param dcp Size (in pixels) of the images that we should put in a DCP. + * @param id ID (e.g. 185) + * @param n Nick name (e.g. Flat) */ -Format const * -Format::from_index (int i) +FixedFormat::FixedFormat (int r, Size dcp, string id, string n) + : Format (dcp, id, n) + , _ratio (r) { - assert (i >= 0 && i < int(_formats.size ())); - return _formats[i]; -} -/** @return All available formats */ -vector<Format const *> -Format::all () -{ - return _formats; } int -Format::dcp_padding () const +Format::dcp_padding (Film const * f) const { - int p = rint ((_dcp_size.width - (_dcp_size.height * _ratio / 100.0)) / 2.0); + int p = rint ((_dcp_size.width - (_dcp_size.height * ratio_as_integer(f) / 100.0)) / 2.0); /* This comes out -ve for Scope; bodge it */ if (p < 0) { @@ -199,3 +154,28 @@ Format::dcp_padding () const return p; } + +VariableFormat::VariableFormat (Size dcp, string id, string n) + : Format (dcp, id, n) +{ + +} + +int +VariableFormat::ratio_as_integer (Film const * f) const +{ + return rint (ratio_as_float (f) * 100); +} + +float +VariableFormat::ratio_as_float (Film const * f) const +{ + return float (f->size().width) / f->size().height; +} + +/** @return A name to be presented to the user */ +string +VariableFormat::name () const +{ + return _nickname; +} diff --git a/src/lib/format.h b/src/lib/format.h index 4b727b2e3..fd6cdbece 100644 --- a/src/lib/format.h +++ b/src/lib/format.h @@ -18,7 +18,7 @@ */ /** @file src/format.h - * @brief Class to describe a format (aspect ratio) that a Film should + * @brief Classes to describe a format (aspect ratio) that a Film should * be shown in. */ @@ -26,26 +26,26 @@ #include <vector> #include "util.h" -/** @class Format - * @brief Class to describe a format (aspect ratio) that a Film should - * be shown in. - */ +class Film; + class Format { public: - Format (int, Size, std::string, std::string); + Format (Size dcp, std::string id, std::string n) + : _dcp_size (dcp) + , _id (id) + , _nickname (n) + {} /** @return the aspect ratio multiplied by 100 * (e.g. 239 for Cinemascope 2.39:1) */ - int ratio_as_integer () const { - return _ratio; - } + virtual int ratio_as_integer (Film const * f) const = 0; /** @return the ratio as a floating point number */ - float ratio_as_float () const { - return _ratio / 100.0; - } + virtual float ratio_as_float (Film const * f) const = 0; + + int dcp_padding (Film const * f) const; /** @return size in pixels of the images that we should * put in a DCP for this ratio. This size will not correspond @@ -60,7 +60,7 @@ public: } /** @return Full name to present to the user */ - std::string name () const; + virtual std::string name () const = 0; /** @return Nickname (e.g. Flat, Scope) */ std::string nickname () const { @@ -69,21 +69,13 @@ public: std::string as_metadata () const; - int dcp_padding () const; - - static Format const * from_ratio (int); static Format const * from_nickname (std::string n); static Format const * from_metadata (std::string m); - static Format const * from_index (int i); static Format const * from_id (std::string i); - static int as_index (Format const * f); static std::vector<Format const *> all (); static void setup_formats (); - -private: - /** Ratio expressed as the actual ratio multiplied by 100 */ - int _ratio; +protected: /** Size in pixels of the images that we should * put in a DCP for this ratio. This size will not correspond * to the ratio when we are doing things like 16:9 in a Flat frame. @@ -94,8 +86,43 @@ private: /** nickname (e.g. Flat, Scope) */ std::string _nickname; +private: /** all available formats */ static std::vector<Format const *> _formats; }; +/** @class FixedFormat + * @brief Class to describe a format whose ratio is fixed regardless + * of source size. + */ +class FixedFormat : public Format +{ +public: + FixedFormat (int, Size, std::string, std::string); + + int ratio_as_integer (Film const *) const { + return _ratio; + } + + float ratio_as_float (Film const *) const { + return _ratio / 100.0; + } + + std::string name () const; +private: + + /** Ratio expressed as the actual ratio multiplied by 100 */ + int _ratio; +}; + +class VariableFormat : public Format +{ +public: + VariableFormat (Size, std::string, std::string); + + int ratio_as_integer (Film const * f) const; + float ratio_as_float (Film const * f) const; + + std::string name () const; +}; diff --git a/src/lib/image.cc b/src/lib/image.cc index 620e71aa7..2df7636af 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -94,7 +94,7 @@ Image::scale_and_convert_to_rgb (Size out_size, int padding, Scaler const * scal content_size.width -= (padding * 2); shared_ptr<RGBFrameImage> rgb (new RGBFrameImage (content_size)); - + struct SwsContext* scale_context = sws_getContext ( size().width, size().height, pixel_format(), content_size.width, content_size.height, PIX_FMT_RGB24, diff --git a/src/lib/j2k_still_encoder.cc b/src/lib/j2k_still_encoder.cc index 8f3339a0a..d218d08fe 100644 --- a/src/lib/j2k_still_encoder.cc +++ b/src/lib/j2k_still_encoder.cc @@ -17,8 +17,8 @@ */ -/** @file src/j2k_wav_encoder.cc - * @brief An encoder which writes JPEG2000 and WAV files. +/** @file src/j2k_still_encoder.cc + * @brief An encoder which writes JPEG2000 files for a single still source image. */ #include <sstream> diff --git a/src/lib/j2k_still_encoder.h b/src/lib/j2k_still_encoder.h index 755c68877..7a03e1195 100644 --- a/src/lib/j2k_still_encoder.h +++ b/src/lib/j2k_still_encoder.h @@ -17,8 +17,8 @@ */ -/** @file src/j2k_wav_encoder.h - * @brief An encoder which writes JPEG2000 and WAV files. +/** @file src/j2k_still_encoder.h + * @brief An encoder which writes JPEG2000 files for a single still source image. */ #include <list> diff --git a/src/lib/j2k_wav_encoder.cc b/src/lib/j2k_wav_encoder.cc index 2f892948d..a1f70a08a 100644 --- a/src/lib/j2k_wav_encoder.cc +++ b/src/lib/j2k_wav_encoder.cc @@ -149,7 +149,7 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server) while (1) { - TIMING ("encoder thread %1 sleeps", pthread_self ()); + TIMING ("encoder thread %1 sleeps", boost::this_thread::get_id()); boost::mutex::scoped_lock lock (_worker_mutex); while (_queue.empty () && !_process_end) { _worker_condition.wait (lock); @@ -159,9 +159,9 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server) return; } - TIMING ("encoder thread %1 wakes with queue of %2", pthread_self(), _queue.size()); + TIMING ("encoder thread %1 wakes with queue of %2", boost::this_thread::get_id(), _queue.size()); boost::shared_ptr<DCPVideoFrame> vf = _queue.front (); - _log->log (String::compose ("Encoder thread %1 pops frame %2 from queue", pthread_self(), vf->frame())); + _log->log (String::compose ("Encoder thread %1 pops frame %2 from queue", boost::this_thread::get_id(), vf->frame())); _queue.pop_front (); lock.unlock (); @@ -193,9 +193,9 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server) } else { try { - TIMING ("encoder thread %1 begins local encode of %2", pthread_self(), vf->frame()); + TIMING ("encoder thread %1 begins local encode of %2", boost::this_thread::get_id(), vf->frame()); encoded = vf->encode_locally (); - TIMING ("encoder thread %1 finishes local encode of %2", pthread_self(), vf->frame()); + TIMING ("encoder thread %1 finishes local encode of %2", boost::this_thread::get_id(), vf->frame()); } catch (std::exception& e) { _log->log (String::compose ("Local encode failed (%1)", e.what ())); } @@ -206,7 +206,7 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server) frame_done (vf->frame ()); } else { lock.lock (); - _log->log (String::compose ("Encoder thread %1 pushes frame %2 back onto queue after failure", pthread_self(), vf->frame())); + _log->log (String::compose ("Encoder thread %1 pushes frame %2 back onto queue after failure", boost::this_thread::get_id(), vf->frame())); _queue.push_front (vf); lock.unlock (); } diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index a166b5924..76fcc6c5d 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -73,6 +73,20 @@ JobManager::work_to_do () const return i != _jobs.end (); } +bool +JobManager::errors () const +{ + boost::mutex::scoped_lock lm (_mutex); + for (list<shared_ptr<Job> >::const_iterator i = _jobs.begin(); i != _jobs.end(); ++i) { + if ((*i)->finished_in_error ()) { + return true; + } + } + + return false; +} + + void JobManager::scheduler () { diff --git a/src/lib/job_manager.h b/src/lib/job_manager.h index d1d33cfc2..8b79fd67d 100644 --- a/src/lib/job_manager.h +++ b/src/lib/job_manager.h @@ -41,6 +41,7 @@ public: void add_after (boost::shared_ptr<Job> after, boost::shared_ptr<Job> j); std::list<boost::shared_ptr<Job> > get () const; bool work_to_do () const; + bool errors () const; static JobManager* instance (); diff --git a/src/lib/options.h b/src/lib/options.h index b283e330d..39068c24f 100644 --- a/src/lib/options.h +++ b/src/lib/options.h @@ -39,8 +39,7 @@ public: Options (std::string f, std::string e, std::string m) : padding (0) , apply_crop (true) - , num_frames (0) - , decode_video (true) + , black_after (0) , decode_video_frequency (0) , decode_audio (true) , _frame_out_path (f) @@ -93,9 +92,7 @@ public: float ratio; ///< ratio of the wanted output image (not considering padding) int padding; ///< number of pixels of padding (in terms of the output size) each side of the image bool apply_crop; ///< true to apply cropping - int num_frames; ///< number of video frames to run for, or 0 for all int black_after; ///< first frame for which to output a black frame, rather than the actual video content, or 0 for none - bool decode_video; ///< true to decode video, otherwise false int decode_video_frequency; ///< skip frames so that this many are decoded in all (or 0) (for generating thumbnails) bool decode_audio; ///< true to decode audio, otherwise false diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index e79be09fe..e1ba82359 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -107,5 +107,5 @@ TranscodeJob::remaining_time () const return 0; } - return ((_fs->length - _encoder->last_frame()) / fps); + return ((_fs->dcp_length() - _encoder->last_frame()) / fps); } diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 9171daa5c..3b26a5537 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -182,11 +182,6 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent) _audio_delay->SetRange (-1000, 1000); _still_duration->SetRange (0, 60 * 60); - vector<Format const *> fmt = Format::all (); - for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) { - _format->Append (std_to_wx ((*i)->name ())); - } - vector<DCPContentType const *> const ct = DCPContentType::all (); for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) { _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ())); @@ -221,6 +216,7 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent) _change_dcp_range_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::change_dcp_range_clicked), 0, this); setup_visibility (); + setup_formats (); } /** Called when the left crop widget has been changed */ @@ -295,6 +291,7 @@ FilmEditor::content_changed (wxCommandEvent &) _ignore_changes = Film::NONE; setup_visibility (); + setup_formats (); } /** Called when the DCP A/B switch has been toggled */ @@ -342,10 +339,19 @@ FilmEditor::film_changed (Film::Property p) case Film::CONTENT: _content->SetPath (std_to_wx (_film->content ())); setup_visibility (); + setup_formats (); break; case Film::FORMAT: - _format->SetSelection (Format::as_index (_film->format ())); + { + int n = 0; + vector<Format const *>::iterator i = _formats.begin (); + while (i != _formats.end() && *i != _film->format ()) { + ++i; + ++n; + } + _format->SetSelection (n); break; + } case Film::CROP: _left_crop->SetValue (_film->crop().left); _right_crop->SetValue (_film->crop().right); @@ -445,7 +451,8 @@ FilmEditor::format_changed (wxCommandEvent &) _ignore_changes = Film::FORMAT; int const n = _format->GetSelection (); if (n >= 0) { - _film->set_format (Format::from_index (n)); + assert (n < int (_formats.size())); + _film->set_format (_formats[n]); } _ignore_changes = Film::NONE; } @@ -667,3 +674,31 @@ FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &) d->Destroy (); } + +void +FilmEditor::setup_formats () +{ + ContentType c = VIDEO; + + if (_film) { + c = _film->content_type (); + } + + _formats.clear (); + + vector<Format const *> fmt = Format::all (); + for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) { + if (c == VIDEO && dynamic_cast<FixedFormat const *> (*i)) { + _formats.push_back (*i); + } else if (c == STILL && dynamic_cast<VariableFormat const *> (*i)) { + _formats.push_back (*i); + } + } + + _format->Clear (); + for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) { + _format->Append (std_to_wx ((*i)->name ())); + } + + _sizer->Layout (); +} diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index ac9a5fb31..c599cd285 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -68,7 +68,8 @@ private: void change_dcp_range_clicked (wxCommandEvent &); void set_things_sensitive (bool); - + void setup_formats (); + wxControl* video_control (wxControl *); wxControl* still_control (wxControl *); @@ -125,5 +126,7 @@ private: std::list<wxControl*> _video_controls; std::list<wxControl*> _still_controls; + std::vector<Format const *> _formats; + wxSizer* _sizer; }; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index e647a5886..3c7d76bce 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -131,7 +131,7 @@ private: int vw, vh; GetSize (&vw, &vh); - float const target = _film->format() ? _film->format()->ratio_as_float () : 1.78; + float const target = _film->format() ? _film->format()->ratio_as_float (_film) : 1.78; _cropped_image = _image->GetSubImage ( wxRect ( |
