Somewhat riskily remove use of AV_SEEK_BACKWARD. It was causing
authorCarl Hetherington <cth@carlh.net>
Tue, 25 Feb 2014 12:10:27 +0000 (12:10 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 25 Feb 2014 12:10:27 +0000 (12:10 +0000)
seeks at the end of a FFmpegDecoder to go back into the content,
confusing the player (which assumes that the next peek after seek
will be after the seek location).

src/lib/decoder.h
src/lib/ffmpeg_decoder.cc
src/lib/player.cc

index 6646b0e76acc66b14edb78d698bd9c48412e07c4..562073c1ebcbc2bbd75985e3bf7a30d5e769f8ac 100644 (file)
@@ -41,7 +41,7 @@ public:
        Decoder (boost::shared_ptr<const Film>);
        virtual ~Decoder () {}
 
-       /** Seek so that the next get_*() will yield the next thing
+       /** Seek so that the next peek() will yield the next thing
         *  (video/sound frame, subtitle etc.) at or after the requested
         *  time.  Pass accurate = true to try harder to get close to
         *  the request.
@@ -49,13 +49,17 @@ public:
        virtual void seek (ContentTime time, bool accurate);
        
        boost::shared_ptr<Decoded> peek ();
+
+       /* Consume the last peek()ed thing so that it won't be returned
+        * from the next peek().
+        */
        void consume ();
 
 protected:
 
        /** Perform one decode pass of the content, which may or may not
         *  result in a complete quantum (Decoded object) of decoded stuff
-        *  being made ready.
+        *  being added to _pending.
         *  @return true if the decoder is done (i.e. no more data will be
         *  produced by any future calls to pass() without a seek() first).
         */
index 22e1b3bc19587e96b6c8a795a73eb4ee1d50a0a1..d9729ee1ac899eaca53ace8a3494a52db1ee78e4 100644 (file)
@@ -372,13 +372,15 @@ FFmpegDecoder::seek_and_flush (ContentTime t)
                        );
        }
 
+       cout << "S&F " << t << "\n";
+
        /* Ridiculous empirical hack */
        s--;
        if (s < 0) {
                s = 0;
        }
 
-       av_seek_frame (_format_context, _video_stream, s, AVSEEK_FLAG_BACKWARD);
+       av_seek_frame (_format_context, _video_stream, s, 0);
 
        avcodec_flush_buffers (video_codec_context());
        if (audio_codec_context ()) {
index db8be20c2d2365d4a7eadf04c140efa7add20327..5fd3b8ffaf592a97ed7f39b0e5e7e7dbe489e7c0 100644 (file)
@@ -122,8 +122,10 @@ Player::pass ()
                                break;
                        }
 
+
                        dec->set_dcp_times (_film->video_frame_rate(), _film->audio_frame_rate(), (*i)->frc, offset);
                        DCPTime const t = dec->dcp_time - offset;
+                       cout << "Peeked " << (*i)->content->paths()[0] << " for " << t << " cf " << ((*i)->content->full_length() - (*i)->content->trim_end ()) << "\n";
                        if (t >= ((*i)->content->full_length() - (*i)->content->trim_end ())) {
                                /* In the end-trimmed part; decoder has nothing else to give us */
                                dec.reset ();
@@ -173,7 +175,6 @@ Player::pass ()
        shared_ptr<DecodedImageSubtitle> dis = dynamic_pointer_cast<DecodedImageSubtitle> (earliest_decoded);
        shared_ptr<DecodedTextSubtitle> dts = dynamic_pointer_cast<DecodedTextSubtitle> (earliest_decoded);
 
-#if 0  
        if (dv) {
                cout << "Video @ " << dv->dcp_time << " " << (double(dv->dcp_time) / TIME_HZ) << ".\n";
        } else if (da) {
@@ -183,7 +184,6 @@ Player::pass ()
        } else if (dts) {
                cout << "Text sub.\n";
        }
-#endif 
        
        /* Will be set to false if we shouldn't consume the peeked DecodedThing */
        bool consume = true;
@@ -432,6 +432,7 @@ Player::seek (DCPTime t, bool accurate)
                ContentTime ct = (s + (*i)->content->trim_start()) * (*i)->frc.speed_up;
 
                /* And seek the decoder */
+               cout << "seek " << (*i)->content->paths()[0] << " to " << ct << "\n";
                (*i)->decoder->seek (ct, accurate);
        }