Revert "Remove minimal flag."
authorCarl Hetherington <cth@carlh.net>
Sun, 4 Nov 2012 17:09:43 +0000 (17:09 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 4 Nov 2012 17:09:43 +0000 (17:09 +0000)
This reverts commit ac712b45bad948fc8f38cf4fa48a529f2024c7f5.

12 files changed:
src/lib/decoder.cc
src/lib/decoder.h
src/lib/decoder_factory.cc
src/lib/decoder_factory.h
src/lib/examine_content_job.cc
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_decoder.h
src/lib/film.cc
src/lib/imagemagick_decoder.cc
src/lib/imagemagick_decoder.h
src/lib/tiff_decoder.cc
src/lib/tiff_decoder.h

index 34c04b260502ab75c424dc9635c2aee3e1515956..ee2beb3f3ce4c52eb766da6da22afd4c8a9a6bbb 100644 (file)
@@ -46,11 +46,14 @@ using boost::shared_ptr;
 /** @param f Film.
  *  @param o Options.
  *  @param j Job that we are running within, or 0
+ *  @param minimal true to do the bare minimum of work; just run through the content.  Useful for acquiring
+ *  accurate frame counts as quickly as possible.  This generates no video or audio output.
  */
-Decoder::Decoder (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j)
+Decoder::Decoder (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j, bool minimal)
        : _film (f)
        , _opt (o)
        , _job (j)
+       , _minimal (minimal)
        , _video_frame_index (0)
        , _delay_line (0)
        , _delay_in_bytes (0)
@@ -247,6 +250,11 @@ Decoder::process_video (AVFrame* frame)
 {
        assert (_film->length());
        
+       if (_minimal) {
+               ++_video_frame_index;
+               return;
+       }
+
        /* Use Film::length here as our one may be wrong */
 
        if (_opt->decode_video_skip != 0 && (_video_frame_index % _opt->decode_video_skip) != 0) {
index fe8149af93deb3a633a133ff0ebbdefb149a8dc0..5750858dfea2efb75c84c0a1cb9df42bc2102eff 100644 (file)
@@ -52,7 +52,7 @@ class FilterGraph;
 class Decoder
 {
 public:
-       Decoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *);
+       Decoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool);
        virtual ~Decoder ();
 
        /* Methods to query our input video */
@@ -121,6 +121,11 @@ protected:
        /** associated Job, or 0 */
        Job* _job;
 
+       /** true to do the bare minimum of work; just run through the content.  Useful for acquiring
+        *  accurate frame counts as quickly as possible.  This generates no video or audio output.
+        */
+       bool _minimal;
+
 private:
        void emit_audio (uint8_t* data, int size);
        
index c3a6965e63af4976661da37ad6b719c2727e8481..287bba0da9b1759a638e9317be188c14d2ff764f 100644 (file)
@@ -31,16 +31,18 @@ using std::string;
 using boost::shared_ptr;
 
 shared_ptr<Decoder>
-decoder_factory (shared_ptr<Film> f, shared_ptr<const Options> o, Job* j)
+decoder_factory (
+       shared_ptr<Film> f, shared_ptr<const Options> o, Job* j, bool minimal = false
+       )
 {
        if (boost::filesystem::is_directory (f->content_path ())) {
                /* Assume a directory contains TIFFs */
-               return shared_ptr<Decoder> (new TIFFDecoder (f, o, j));
+               return shared_ptr<Decoder> (new TIFFDecoder (f, o, j, minimal));
        }
 
        if (f->content_type() == STILL) {
-               return shared_ptr<Decoder> (new ImageMagickDecoder (f, o, j));
+               return shared_ptr<Decoder> (new ImageMagickDecoder (f, o, j, minimal));
        }
        
-       return shared_ptr<Decoder> (new FFmpegDecoder (f, o, j));
+       return shared_ptr<Decoder> (new FFmpegDecoder (f, o, j, minimal));
 }
index 3c16d0ec0071347233eec1b5c9651fb5dde77c93..b86c60c70f224b1f9b5a7825efb8541388aa2aae 100644 (file)
@@ -25,5 +25,8 @@ class Decoder;
 class Film;
 class Options;
 class Job;
+class Log;
 
-extern boost::shared_ptr<Decoder> decoder_factory (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *);
+extern boost::shared_ptr<Decoder> decoder_factory (
+       boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool minimal = false
+       );
index e71ab361aecf623090012aabc5969e1fedebdb5f..ec0d2409bb5fc059c597cdfa1f8bec3866ca5841 100644 (file)
@@ -66,7 +66,7 @@ ExamineContentJob::run ()
 
        descend (0.5);
 
-       _decoder = decoder_factory (_film, o, this);
+       _decoder = decoder_factory (_film, o, this, true);
        _decoder->go ();
 
        _film->set_length (_decoder->video_frame_index());
index 77e8f365fe934ae6888bfdb755d510909e11b4d8..f0e652cbe60663439c51b206547124e6378db478 100644 (file)
@@ -55,8 +55,8 @@ using std::vector;
 using std::stringstream;
 using boost::shared_ptr;
 
-FFmpegDecoder::FFmpegDecoder (shared_ptr<Film> f, shared_ptr<const Options> o, Job* j)
-       : Decoder (f, o, j)
+FFmpegDecoder::FFmpegDecoder (shared_ptr<Film> f, shared_ptr<const Options> o, Job* j, bool minimal)
+       : Decoder (f, o, j, minimal)
        , _format_context (0)
        , _video_stream (-1)
        , _audio_stream (-1)
index 0265f747804154d3d7ec43715eb7de710a710888..fbd9e5255b57342b7cc3ef3a9c66985b59a75b54 100644 (file)
@@ -52,7 +52,7 @@ class Log;
 class FFmpegDecoder : public Decoder
 {
 public:
-       FFmpegDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *);
+       FFmpegDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool);
        ~FFmpegDecoder ();
 
        /* Methods to query our input video */
index cd5fc6535053bb46e87413d13c0516ce96524ed0..cacd307643363657b180ef348c0b37bc9a7b0682 100644 (file)
@@ -877,7 +877,7 @@ Film::set_content (string c)
                shared_ptr<Options> o (new Options ("", "", ""));
                o->out_size = Size (1024, 1024);
                
-               shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0);
+               shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0, 0);
                
                set_size (d->native_size ());
                set_frames_per_second (d->frames_per_second ());
index cc2fd9d231fa0bd718b785be655cec4c40f740b7..81349beca72e3ceb8a4ff37cd136698b78439140 100644 (file)
@@ -27,8 +27,8 @@ using namespace std;
 using namespace boost;
 
 ImageMagickDecoder::ImageMagickDecoder (
-       boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j)
-       : Decoder (f, o, j)
+       boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j, bool minimal)
+       : Decoder (f, o, j, minimal)
        , _done (false)
 {
        _magick_image = new Magick::Image (_film->content_path ());
index b7ab9af18119cf0c1677d3c6a0993f2b48335463..85bcf4c5bc29811ee9acd36e0507315f10739dc4 100644 (file)
@@ -26,7 +26,7 @@ namespace Magick {
 class ImageMagickDecoder : public Decoder
 {
 public:
-       ImageMagickDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *);
+       ImageMagickDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool);
 
        float frames_per_second () const {
                return static_frames_per_second ();
index 7cca511dda884d0cdceb84178aea0030940f76fb..2c050def67e8098e63056640fac2d095b7ad650d 100644 (file)
@@ -44,9 +44,11 @@ using namespace boost;
 /** @param f Our Film.
  *  @param o Options.
  *  @param j Job that we are associated with, or 0.
+ *  @param minimal true to do the bare minimum of work; just run through the content.  Useful for acquiring
+ *  accurate frame counts as quickly as possible.  This generates no video or audio output.
  */
-TIFFDecoder::TIFFDecoder (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j)
-       : Decoder (f, o, j)
+TIFFDecoder::TIFFDecoder (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j, bool minimal)
+       : Decoder (f, o, j, minimal)
 {
        string const dir = _film->content_path ();
        
index 1c33443cf17518d5e636fca8f087a4260f61a153..c02a1d03d72c7373f776b9c71408a0b70b9cb883 100644 (file)
@@ -42,7 +42,7 @@ class Image;
 class TIFFDecoder : public Decoder
 {
 public:
-       TIFFDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *);
+       TIFFDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool);
 
        /* Methods to query our input video */
        float frames_per_second () const;