Fix initial display to be frame 1, not 2.
authorCarl Hetherington <cth@carlh.net>
Wed, 10 Jul 2013 10:49:07 +0000 (11:49 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 10 Jul 2013 10:49:07 +0000 (11:49 +0100)
src/lib/ffmpeg.cc
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_examiner.cc
src/lib/player.cc
src/wx/film_viewer.cc

index a39de391af92abafbe3d9e39f355752875a13f72..77bf7501840afb8213bd613c7d63b67c6981ecd4 100644 (file)
@@ -30,6 +30,7 @@ extern "C" {
 #include "i18n.h"
 
 using std::string;
+using std::cout;
 using std::stringstream;
 using boost::shared_ptr;
 
index bcd1e738a46bbff94976afbc2fe178b8f3ff2cd3..785a805f4f5b2aba6c41615dae79d8616df678ea 100644 (file)
@@ -294,6 +294,11 @@ FFmpegDecoder::seek (VideoContent::Frame frame, bool accurate)
 
        _just_sought = true;
 
+       if (frame == 0) {
+               /* We're already there; from here on we can only seek non-zero amounts */
+               return;
+       }
+
        if (accurate) {
                while (1) {
                        int r = av_read_frame (_format_context, &_packet);
@@ -372,7 +377,7 @@ FFmpegDecoder::decode_video_packet ()
        if (avcodec_decode_video2 (video_codec_context(), _frame, &frame_finished, &_packet) < 0 || !frame_finished) {
                return false;
        }
-               
+
        boost::mutex::scoped_lock lm (_filter_graphs_mutex);
 
        shared_ptr<FilterGraph> graph;
index f45b0fe52e6dad125de259ca773d2f2c45eb8689..ceeaee112fdeba0d66680f9fa557a7833789d643 100644 (file)
@@ -69,8 +69,6 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c)
                int frame_finished;
                avcodec_get_frame_defaults (_frame);
 
-               cout << "got packet " << _packet.stream_index << "\n";
-
                AVCodecContext* context = _format_context->streams[_packet.stream_index]->codec;
 
                if (_packet.stream_index == _video_stream && !_first_video) {
@@ -94,11 +92,11 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c)
                        ++i;
                }
 
+               av_free_packet (&_packet);
+               
                if (_first_video && have_all_audio) {
                        break;
                }
-
-               av_free_packet (&_packet);
        }
 }
 
index fd697b522b1762c72fd86d7606182ab424ce9740..26ded61b8b6f94dcee125068d212c02ed3eea3da 100644 (file)
@@ -121,7 +121,7 @@ Player::pass ()
        }
 
 #ifdef DEBUG_PLAYER
-       cout << "= PASS " << this << "\n";
+       cout << "= PASS\n";
 #endif 
 
         Time earliest_t = TIME_MAX;
index 62bad81959d773dd9bd97e51bee3680954e9c629..185c3c53f8703d369117aff5a5e709345c211f30 100644 (file)
@@ -132,7 +132,6 @@ FilmViewer::set_film (shared_ptr<Film> f)
        _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this));
 
        calculate_sizes ();
-       fetch_current_frame_again ();
 }
 
 void
@@ -277,7 +276,7 @@ FilmViewer::process_video (shared_ptr<const Image> image, bool, Time t)
        double const fps = _film->dcp_video_frame_rate ();
        /* Count frame number from 1 ... not sure if this is the best idea */
        _frame_number->SetLabel (wxString::Format (wxT("%d"), int (rint (t * fps / TIME_HZ)) + 1));
-
+       
        double w = static_cast<double>(t) / TIME_HZ;
        int const h = (w / 3600);
        w -= h * 3600;