diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/decoder.cc | 27 | ||||
| -rw-r--r-- | src/lib/decoder.h | 4 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/film.cc | 79 | ||||
| -rw-r--r-- | src/lib/film.h | 26 | ||||
| -rw-r--r-- | src/lib/imagemagick_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/imagemagick_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/options.h | 2 | ||||
| -rw-r--r-- | src/lib/tiff_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/tiff_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/trim_action.h | 28 |
12 files changed, 43 insertions, 135 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 3feaf43e9..a8da1ae67 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -140,27 +140,13 @@ Decoder::go () while (pass () == false) { if (_job && _film->dcp_length()) { - _job->set_progress (float (_video_frame_index) / _film->dcp_length().get()); + _job->set_progress (float ((_video_frame_index - _film->dcp_trim_start())) / _film->dcp_length().get()); } } process_end (); } -/** 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. - */ -bool -Decoder::pass () -{ - if (!_ignore_length && _video_frame_index >= _film->dcp_length()) { - return true; - } - - return do_pass (); -} - /** Called by subclasses to tell the world that some audio data is ready * @param data Audio data, in Film::audio_sample_format. * @param size Number of bytes of data. @@ -263,6 +249,8 @@ Decoder::emit_audio (uint8_t* data, int size) void Decoder::process_video (AVFrame* frame) { + assert (_ignore_length || _film->length()); + if (_minimal) { ++_video_frame_index; return; @@ -275,6 +263,11 @@ Decoder::process_video (AVFrame* frame) return; } + if (_film->dcp_trim_start() > _video_frame_index || (_film->length().get() - _film->dcp_trim_end()) < _video_frame_index) { + ++_video_frame_index; + return; + } + shared_ptr<FilterGraph> graph; list<shared_ptr<FilterGraph> >::iterator i = _filter_graphs.begin(); @@ -293,10 +286,6 @@ Decoder::process_video (AVFrame* frame) list<shared_ptr<Image> > images = graph->process (frame); for (list<shared_ptr<Image> >::iterator i = images.begin(); i != images.end(); ++i) { - if (_opt->black_after > 0 && _video_frame_index > _opt->black_after) { - (*i)->make_black (); - } - shared_ptr<Subtitle> sub; if (_timed_subtitle && _timed_subtitle->displayed_at (double (video_frame_index()) / _film->frames_per_second())) { sub = _timed_subtitle->subtitle (); diff --git a/src/lib/decoder.h b/src/lib/decoder.h index 6cd7757b6..e8e73cc9f 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -76,7 +76,7 @@ public: virtual int sample_aspect_ratio_denominator () const = 0; void process_begin (); - bool pass (); + virtual bool pass () = 0; void process_end (); void go (); @@ -105,8 +105,6 @@ public: protected: - /** perform a single pass at our content */ - virtual bool do_pass () = 0; virtual PixelFormat pixel_format () const = 0; void process_video (AVFrame *); diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 09f699543..198925bd3 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -218,7 +218,7 @@ FFmpegDecoder::setup_subtitle () bool -FFmpegDecoder::do_pass () +FFmpegDecoder::pass () { int r = av_read_frame (_format_context, &_packet); diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index c04dba5b3..3f96c1632 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -69,7 +69,7 @@ public: private: - bool do_pass (); + bool pass (); PixelFormat pixel_format () const; int time_base_numerator () const; int time_base_denominator () const; diff --git a/src/lib/film.cc b/src/lib/film.cc index d29c04465..da664a5a5 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -82,7 +82,8 @@ Film::Film (string d, bool must_exist) , _dcp_content_type (0) , _format (0) , _scaler (Scaler::from_id ("bicubic")) - , _dcp_trim_action (CUT) + , _dcp_trim_start (0) + , _dcp_trim_end (0) , _dcp_ab (false) , _audio_stream (-1) , _audio_gain (0) @@ -142,8 +143,8 @@ Film::Film (Film const & o) , _crop (o._crop) , _filters (o._filters) , _scaler (o._scaler) - , _dcp_frames (o._dcp_frames) - , _dcp_trim_action (o._dcp_trim_action) + , _dcp_trim_start (o._dcp_trim_start) + , _dcp_trim_end (o._dcp_trim_end) , _dcp_ab (o._dcp_ab) , _audio_stream (o._audio_stream) , _audio_gain (o._audio_gain) @@ -254,21 +255,6 @@ Film::make_dcp (bool transcode) shared_ptr<Options> o (new Options (j2k_dir(), ".j2c", dir ("wavs"))); o->out_size = format()->dcp_size (); - if (!dcp_frames()) { - /* Decode the whole film, no blacking */ - o->black_after = 0; - } else { - switch (dcp_trim_action()) { - case CUT: - /* Decode only part of the film, no blacking */ - o->black_after = 0; - break; - case BLACK_OUT: - /* Decode the whole film, but black some frames out */ - o->black_after = dcp_frames().get (); - } - } - o->padding = format()->dcp_padding (shared_from_this ()); o->ratio = format()->ratio_as_float (shared_from_this ()); o->decode_subtitles = with_subtitles (); @@ -420,18 +406,8 @@ Film::write_metadata () const f << "filter " << (*i)->id () << "\n"; } f << "scaler " << _scaler->id () << "\n"; - f << "dcp_frames " << _dcp_frames.get_value_or(0) << "\n"; - - f << "dcp_trim_action "; - switch (_dcp_trim_action) { - case CUT: - f << "cut\n"; - break; - case BLACK_OUT: - f << "black_out\n"; - break; - } - + f << "dcp_trim_start " << _dcp_trim_start << "\n"; + f << "dcp_trim_end " << _dcp_trim_end << "\n"; f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n"; f << "selected_audio_stream " << _audio_stream << "\n"; f << "audio_gain " << _audio_gain << "\n"; @@ -510,17 +486,10 @@ Film::read_metadata () _filters.push_back (Filter::from_id (v)); } else if (k == "scaler") { _scaler = Scaler::from_id (v); - } else if (k == "dcp_frames") { - int const vv = atoi (v.c_str ()); - if (vv) { - _dcp_frames = vv; - } - } else if (k == "dcp_trim_action") { - if (v == "cut") { - _dcp_trim_action = CUT; - } else if (v == "black_out") { - _dcp_trim_action = BLACK_OUT; - } + } else if (k == "dcp_trim_start") { + _dcp_trim_start = atoi (v.c_str ()); + } else if (k == "dcp_trim_end") { + _dcp_trim_end = atoi (v.c_str ()); } else if (k == "dcp_ab") { _dcp_ab = (v == "1"); } else if (k == "selected_audio_stream") { @@ -736,11 +705,7 @@ Film::dcp_length () const return boost::optional<int> (); } - if (dcp_frames()) { - return min (dcp_frames().get(), length().get()); - } - - return length(); + return length().get() - dcp_trim_start() - dcp_trim_end(); } /** @return a DCI-compliant name for a DCP of this film */ @@ -1049,33 +1014,23 @@ Film::set_scaler (Scaler const * s) } void -Film::set_dcp_frames (int f) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _dcp_frames = f; - } - signal_changed (DCP_FRAMES); -} - -void -Film::unset_dcp_frames () +Film::set_dcp_trim_start (int t) { { boost::mutex::scoped_lock lm (_state_mutex); - _dcp_frames = boost::none; + _dcp_trim_start = t; } - signal_changed (DCP_FRAMES); + signal_changed (DCP_TRIM_START); } void -Film::set_dcp_trim_action (TrimAction a) +Film::set_dcp_trim_end (int t) { { boost::mutex::scoped_lock lm (_state_mutex); - _dcp_trim_action = a; + _dcp_trim_end = t; } - signal_changed (DCP_TRIM_ACTION); + signal_changed (DCP_TRIM_END); } void diff --git a/src/lib/film.h b/src/lib/film.h index f3ddc652a..eeaae2acd 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -38,7 +38,6 @@ extern "C" { #include "dcp_content_type.h" #include "util.h" #include "stream.h" -#include "trim_action.h" class Format; class Job; @@ -118,8 +117,8 @@ public: CROP, FILTERS, SCALER, - DCP_FRAMES, - DCP_TRIM_ACTION, + DCP_TRIM_START, + DCP_TRIM_END, DCP_AB, AUDIO_STREAM, AUDIO_GAIN, @@ -188,16 +187,16 @@ public: return _scaler; } - boost::optional<int> dcp_frames () const { + int dcp_trim_start () const { boost::mutex::scoped_lock lm (_state_mutex); - return _dcp_frames; + return _dcp_trim_start; } - TrimAction dcp_trim_action () const { + int dcp_trim_end () const { boost::mutex::scoped_lock lm (_state_mutex); - return _dcp_trim_action; + return _dcp_trim_end; } - + bool dcp_ab () const { boost::mutex::scoped_lock lm (_state_mutex); return _dcp_ab; @@ -351,9 +350,8 @@ public: void set_bottom_crop (int); void set_filters (std::vector<Filter const *>); void set_scaler (Scaler const *); - void set_dcp_frames (int); - void unset_dcp_frames (); - void set_dcp_trim_action (TrimAction); + void set_dcp_trim_start (int); + void set_dcp_trim_end (int); void set_dcp_ab (bool); void set_audio_stream (int); void set_audio_gain (float); @@ -424,10 +422,8 @@ private: std::vector<Filter const *> _filters; /** Scaler algorithm to use */ Scaler const * _scaler; - /** Maximum number of frames to put in the DCP, if applicable */ - boost::optional<int> _dcp_frames; - /** What to do with audio when trimming DCPs */ - TrimAction _dcp_trim_action; + int _dcp_trim_start; + int _dcp_trim_end; /** true to create an A/B comparison DCP, where the left half of the image is the video without any filters or post-processing, and the right half has the specified filters and post-processing. diff --git a/src/lib/imagemagick_decoder.cc b/src/lib/imagemagick_decoder.cc index 76d89b7d8..8abefdbb9 100644 --- a/src/lib/imagemagick_decoder.cc +++ b/src/lib/imagemagick_decoder.cc @@ -41,7 +41,7 @@ ImageMagickDecoder::native_size () const } bool -ImageMagickDecoder::do_pass () +ImageMagickDecoder::pass () { using namespace MagickCore; diff --git a/src/lib/imagemagick_decoder.h b/src/lib/imagemagick_decoder.h index 13b53b685..c8e47d47d 100644 --- a/src/lib/imagemagick_decoder.h +++ b/src/lib/imagemagick_decoder.h @@ -59,7 +59,7 @@ public: } protected: - bool do_pass (); + bool pass (); PixelFormat pixel_format () const; int time_base_numerator () const { diff --git a/src/lib/options.h b/src/lib/options.h index f4381ef68..aef9ca112 100644 --- a/src/lib/options.h +++ b/src/lib/options.h @@ -39,7 +39,6 @@ public: Options (std::string f, std::string e, std::string m) : padding (0) , apply_crop (true) - , black_after (0) , decode_video_skip (0) , decode_audio (true) , decode_subtitles (false) @@ -97,7 +96,6 @@ 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 black_after; ///< first frame for which to output a black frame, rather than the actual video content, or 0 for none int decode_video_skip; ///< skip frames such that we don't decode any frame where (index % decode_video_skip) != 0; e.g. ///< 1 for every frame, 2 for every other frame, etc. bool decode_audio; ///< true to decode audio, otherwise false diff --git a/src/lib/tiff_decoder.cc b/src/lib/tiff_decoder.cc index 1500b9b48..7d8559a7c 100644 --- a/src/lib/tiff_decoder.cc +++ b/src/lib/tiff_decoder.cc @@ -131,7 +131,7 @@ TIFFDecoder::audio_channel_layout () const } bool -TIFFDecoder::do_pass () +TIFFDecoder::pass () { if (_iter == _files.end ()) { return true; diff --git a/src/lib/tiff_decoder.h b/src/lib/tiff_decoder.h index 1c287ee06..7bbff7dfe 100644 --- a/src/lib/tiff_decoder.h +++ b/src/lib/tiff_decoder.h @@ -56,7 +56,7 @@ public: } private: - bool do_pass (); + bool pass (); PixelFormat pixel_format () const; int time_base_numerator () const; int time_base_denominator () const; diff --git a/src/lib/trim_action.h b/src/lib/trim_action.h deleted file mode 100644 index 405d31bbc..000000000 --- a/src/lib/trim_action.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2012 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef DVDOMATIC_TRIM_ACTION_H -#define DVDOMATIC_TRIM_ACTION_H - -enum TrimAction { - CUT, ///< cut everything out after dcp_frames - BLACK_OUT ///< black out after dcp_frames so that the film stays the same length (and audio continues) -}; - -#endif |
