Merge master.
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index dd47d306a6e54c0611e0abde6b6ab802cab4e77b..4e5d9bb1ed271760e858b4a37d62fcde110fa1d4 100644 (file)
@@ -56,7 +56,6 @@ extern "C" {
 using std::cout;
 using std::string;
 using std::vector;
-using std::stringstream;
 using std::list;
 using std::min;
 using std::pair;
@@ -296,10 +295,11 @@ FFmpegDecoder::seek (ContentTime time, bool accurate)
 
        ContentTime pre_roll = accurate ? ContentTime::from_seconds (2) : ContentTime (0);
        time -= pre_roll;
-       if (time < ContentTime (0)) {
-               time = ContentTime (0);
-       }
 
+       /* XXX: it seems debatable whether PTS should be used here...
+          http://www.mjbshaw.com/2012/04/seeking-in-ffmpeg-know-your-timestamp.html
+       */
+       
        ContentTime const u = time - _pts_offset;
        int64_t s = u.seconds() / av_q2d (_format_context->streams[_video_stream]->time_base);
 
@@ -309,12 +309,6 @@ FFmpegDecoder::seek (ContentTime time, bool accurate)
                        );
        }
 
-       /* Ridiculous empirical hack */
-       s--;
-       if (s < 0) {
-               s = 0;
-       }
-
        av_seek_frame (_format_context, _video_stream, s, 0);
 
        avcodec_flush_buffers (video_codec_context());