Revert "Skipping hacks."
authorCarl Hetherington <cth@carlh.net>
Sun, 16 Dec 2012 14:43:16 +0000 (14:43 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 16 Dec 2012 14:43:16 +0000 (14:43 +0000)
This reverts commit 89319eb1217c8caca80dc22ca770766f6d2f26c0.

src/lib/encoder.cc
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_decoder.h
src/lib/film.cc
src/lib/imagemagick_encoder.cc
src/lib/options.h
src/lib/transcoder.cc
src/lib/transcoder.h
src/wx/wx_util.cc

index dfb154f72b215e03b3e4be07542512d859bfe100..17a6726a6841db8c3bd753b35d5f9ac1686b1991 100644 (file)
@@ -107,6 +107,11 @@ Encoder::frame_skipped ()
 void
 Encoder::process_video (shared_ptr<Image> i, boost::shared_ptr<Subtitle> s)
 {
+       if (_opt->decode_video_skip != 0 && (_video_frame % _opt->decode_video_skip) != 0) {
+               ++_video_frame;
+               return;
+       }
+
        if (_opt->video_decode_range) {
                pair<SourceFrame, SourceFrame> const r = _opt->video_decode_range.get();
                if (_video_frame < r.first || _video_frame >= r.second) {
index 1e473b6a3190a43cf64401d0b1386535c0bddf08..acaf149f43ade599dff78d95c109d36c86133097 100644 (file)
@@ -265,10 +265,46 @@ FFmpegDecoder::pass ()
                                _film->log()->log (String::compose ("Used only %1 bytes of %2 in packet", r, _packet.size));
                        }
 
-                       if (_opt->rough_decode_video_skip) {
-                               rough_video_output ();
+                       /* Where we are in the output, in seconds */
+                       double const out_pts_seconds = video_frame() / frames_per_second();
+
+                       /* Where we are in the source, in seconds */
+                       double const source_pts_seconds = av_q2d (_format_context->streams[_packet.stream_index]->time_base)
+                               * av_frame_get_best_effort_timestamp(_frame);
+
+                       _film->log()->log (
+                               String::compose ("Source video frame ready; source at %1, output at %2", source_pts_seconds, out_pts_seconds),
+                               Log::VERBOSE
+                               );
+
+                       if (!_first_video) {
+                               _first_video = source_pts_seconds;
+                       }
+
+                       /* Difference between where we are and where we should be */
+                       double const delta = source_pts_seconds - _first_video.get() - out_pts_seconds;
+                       double const one_frame = 1 / frames_per_second();
+
+                       /* Insert frames if required to get out_pts_seconds up to pts_seconds */
+                       if (delta > one_frame) {
+                               int const extra = rint (delta / one_frame);
+                               for (int i = 0; i < extra; ++i) {
+                                       repeat_last_video ();
+                                       _film->log()->log (
+                                               String::compose (
+                                                       "Extra video frame inserted at %1s; source frame %2, source PTS %3 (at %4 fps)",
+                                                       out_pts_seconds, video_frame(), source_pts_seconds, frames_per_second()
+                                                       )
+                                               );
+                               }
+                       }
+
+                       if (delta > -one_frame) {
+                               /* Process this frame */
+                               filter_and_emit_video (_frame);
                        } else {
-                               precise_video_output ();
+                               /* Otherwise we are omitting a frame to keep things right */
+                               _film->log()->log (String::compose ("Frame removed at %1s", out_pts_seconds));
                        }
                }
 
@@ -601,70 +637,3 @@ FFmpegDecoder::length () const
 {
        return (double(_format_context->duration) / AV_TIME_BASE) * frames_per_second();
 }
-
-void
-FFmpegDecoder::precise_video_output ()
-{
-       /* Where we are in the output, in seconds */
-       double const out_pts_seconds = video_frame() / frames_per_second();
-       
-       /* Where we are in the source, in seconds */
-       double const source_pts_seconds = av_q2d (_format_context->streams[_packet.stream_index]->time_base)
-               * av_frame_get_best_effort_timestamp(_frame);
-       
-       _film->log()->log (
-               String::compose ("Source video frame ready; source at %1, output at %2", source_pts_seconds, out_pts_seconds),
-               Log::VERBOSE
-               );
-       
-       if (!_first_video) {
-               _first_video = source_pts_seconds;
-       }
-       
-       /* Difference between where we are and where we should be */
-       double const delta = source_pts_seconds - _first_video.get() - out_pts_seconds;
-       double const one_frame = 1 / frames_per_second();
-       
-       /* Insert frames if required to get out_pts_seconds up to pts_seconds */
-       if (delta > one_frame) {
-               int const extra = rint (delta / one_frame);
-               for (int i = 0; i < extra; ++i) {
-                       repeat_last_video ();
-                       _film->log()->log (
-                               String::compose (
-                                       "Extra video frame inserted at %1s; source frame %2, source PTS %3 (at %4 fps)",
-                                       out_pts_seconds, video_frame(), source_pts_seconds, frames_per_second()
-                                       )
-                               );
-               }
-       }
-       
-       if (delta > -one_frame) {
-               /* Process this frame */
-               filter_and_emit_video (_frame);
-       } else {
-               /* Otherwise we are omitting a frame to keep things right */
-               _film->log()->log (String::compose ("Frame removed at %1s", out_pts_seconds));
-       }
-}
-
-void
-FFmpegDecoder::rough_video_output ()
-{
-       /* Where we are in the source, in seconds */
-       double const source_pts_seconds = av_q2d (_format_context->streams[_packet.stream_index]->time_base)
-               * av_frame_get_best_effort_timestamp(_frame);
-
-       if (!_last_rough_output || _last_rough_output.get() != source_pts_seconds) {
-               filter_and_emit_video (_frame);
-               _last_rough_output = source_pts_seconds;
-       }
-       
-       int64_t const t = static_cast<int64_t>(f) / (av_q2d (_format_context->streams[_video_stream]->time_base) * frames_per_second());
-       cout << "seek to " << t << " in stream tb\n";
-       int const r = av_seek_frame (_format_context, _video_stream, t, 0);
-       avcodec_flush_buffers (_video_codec_context);
-       if (r < 0) {
-               cout << "seek to " << t << " failed.\n";
-       }
-}
index 141b40da0da5e00a5de3289f3077d00c76c158a0..1771551fcf1080cb5bb7b38b5d0744d3992c3d65 100644 (file)
@@ -105,8 +105,6 @@ private:
        AVSampleFormat audio_sample_format () const;
        int bytes_per_audio_sample () const;
 
-       void rough_video_output ();
-       void precise_video_output ();
        void filter_and_emit_video (AVFrame *);
 
        void setup_general ();
@@ -135,7 +133,6 @@ private:
 
        boost::optional<double> _first_video;
        boost::optional<double> _first_audio;
-       boost::optional<double> _last_rough_output;
 
        std::list<boost::shared_ptr<FilterGraph> > _filter_graphs;
 };
index ecf37f033e8b24129bf23c408a1d0a656f38be91..e2a4cbeda60efda1089f2b8e840c6a64940f5702 100644 (file)
@@ -1003,7 +1003,7 @@ Film::set_trust_content_header (bool t)
        
        signal_changed (TRUST_CONTENT_HEADER);
 
-       if (!_trust_content_header && !content().empty()) {
+       if (!_trust_content_header) && !content().empty()) {
                /* We just said that we don't trust the content's header */
                examine_content ();
        }
index 4fa702369f65c391b947d28e3e2b4ae963970070..480dec8bc741e9305b270567e6c5b067071ea829 100644 (file)
@@ -38,7 +38,6 @@
 
 using std::string;
 using std::ofstream;
-using std::cout;
 using boost::shared_ptr;
 
 /** @param f Film that we are encoding.
@@ -56,8 +55,6 @@ ImageMagickEncoder::do_process_video (shared_ptr<Image> image, shared_ptr<Subtit
        shared_ptr<Image> scaled = image->scale_and_convert_to_rgb (_opt->out_size, _opt->padding, _film->scaler());
        shared_ptr<Image> compact (new CompactImage (scaled));
 
-       cout << "IME writes frame " << _video_frame << "\n";
-
        string tmp_file = _opt->frame_out_path (_video_frame, true);
        Magick::Image thumb (compact->size().width, compact->size().height, "RGB", MagickCore::CharPixel, compact->data()[0]);
        thumb.magick ("PNG");
index 2fc3e5599f0b936b978235e40458701e681454f7..29b3b71cd4a91e01bc8d76494608d076d6c4452c 100644 (file)
@@ -104,14 +104,9 @@ public:
        boost::optional<std::pair<int64_t, int64_t> > audio_decode_range;
        
        /** 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.  With the `precise' skip, we do it
-        *  by running the decoder without seeking and throwing away frames that we don't want.
+        *  1 for every frame, 2 for every other frame, etc.
         */
-       boost::optional<SourceFrame> precise_decode_video_skip;
-       /** As for precise_decode_video_skip, except that it is achieved by skipping the decoder, so
-        *  things are made less precise by the presence of keyframes and other complications.
-        */
-       boost::optional<SourceFrame> rough_decode_video_skip;
+       SourceFrame decode_video_skip; 
        bool decode_audio;          ///< true to decode audio, otherwise false
        bool decode_subtitles;
 
index f764c65fb17dc3fcc6d5eb6feda800dc8a5ab509..a7e79b05f74d6338cd2c5debfe6d77381b905839 100644 (file)
@@ -49,9 +49,7 @@ using boost::dynamic_pointer_cast;
  *  @param e Encoder to use.
  */
 Transcoder::Transcoder (shared_ptr<Film> f, shared_ptr<const Options> o, Job* j, shared_ptr<Encoder> e)
-       : _film (f)
-       , _opt (o)
-       , _job (j)
+       : _job (j)
        , _encoder (e)
        , _decoders (decoder_factory (f, o, j))
 {
@@ -92,8 +90,6 @@ void
 Transcoder::go ()
 {
        _encoder->process_begin ();
-       SourceFrame s = 0;
-       
        try {
                bool done[2] = { false, false };
                
index 43c70df0066be67e26fe5f9d921422204930f902..4a9667b3c5165b95aa9f8aeea2786b206f184b56 100644 (file)
@@ -54,8 +54,6 @@ public:
        }
 
 protected:
-       boost::shared_ptr<Film> _film;
-       boost::shared_ptr<const Options> _opt;
        /** A Job that is running this Transcoder, or 0 */
        Job* _job;
        /** The encoder that we will use */
index b9a462801103957b8fbe1cee1e1c4a08ded73377..186e9c86b5b6fba09a9618ce9c7fe4ff6f2dcc38 100644 (file)
@@ -155,10 +155,7 @@ checked_set (wxComboBox* widget, int value)
 void
 checked_set (wxComboBox* widget, string value)
 {
-       wxClientData* o = 0;
-       if (widget->GetSelection() != -1) {
-               o = widget->GetClientObject (widget->GetSelection ());
-       }
+       wxClientData* o = widget->GetClientObject (widget->GetSelection ());
        
        if (!o || string_client_data(o) != value) {
                for (unsigned int i = 0; i < widget->GetCount(); ++i) {