add buffer flush to ffmpeg seek, clear loop_session on load replace mode
authorGood Guy <[email protected]>
Tue, 30 Jun 2015 20:41:59 +0000 (14:41 -0600)
committerGood Guy <[email protected]>
Tue, 30 Jun 2015 20:41:59 +0000 (14:41 -0600)
cinelerra-5.0/cinelerra/ffmpeg.C
cinelerra-5.0/cinelerra/ffmpeg.h
cinelerra-5.0/cinelerra/mwindow.C

index 26ed21a44d23649e147aeae1e5e58ea8dcce67a7..16d6fe056c4e06c952ed062414a8017b68b4b0c0 100644 (file)
@@ -548,14 +548,14 @@ int FFAudioStream::audio_seek(int64_t pos)
                return 0;
        }
        if( pos == curr_pos ) return 0;
+       avcodec_flush_buffers(st->codec);
        double secs = (double)pos / sample_rate;
        int64_t tstmp = secs * st->time_base.den / st->time_base.num;
        if( nudge != AV_NOPTS_VALUE ) tstmp += nudge;
        avformat_seek_file(fmt_ctx, st->index, -INT64_MAX, tstmp, INT64_MAX, 0);
        seek_pos = curr_pos = pos;
-       mbsz = 0;
-       reset();
-       st_eof(0);
+       reset();  st_eof(0);
+       mbsz = 0; flushed = 0;  need_packet = 1;
        return 1;
 }
 
@@ -646,6 +646,7 @@ int FFVideoStream::video_seek(int64_t pos)
        if( gop < 4 ) gop = 4;
        if( gop > 64 ) gop = 64;
        if( pos >= curr_pos && pos <= curr_pos + gop ) return 0;
+       avcodec_flush_buffers(st->codec);
 // back up a few frames to read up to current to help repair damages
        if( (pos-=gop) < 0 ) pos = 0;
        double secs = (double)pos / frame_rate;
@@ -654,6 +655,7 @@ int FFVideoStream::video_seek(int64_t pos)
        avformat_seek_file(fmt_ctx, st->index, -INT64_MAX, tstmp, INT64_MAX, 0);
        seek_pos = curr_pos = pos;
        st_eof(0);
+       flushed = 0;  need_packet = 1;
        return 1;
 }
 
index 41941e730e61f50e449cadf2ddd2e0dcf3405ce5..040bdcda3dfd148e16e0baa049f4eb04a33e6ad7 100644 (file)
@@ -126,13 +126,8 @@ public:
        int reading, writing;
        int eof;
 
-       int st_eof() {
-               return eof;
-       }
-       void st_eof(int v) {
-               if( !v ) { flushed = 0;  need_packet = 1; }
-               eof = v;
-       }
+       int st_eof() { return eof; }
+       void st_eof(int v) { eof = v; }
 };
 
 class FFAudioStream : public FFStream {
index 1a1d4dbae293db9ba4543dc807f828c3c1b40976..e992fe1d475a49dfcabbee1861cff989ca42b1b1 100644 (file)
@@ -1422,6 +1422,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
                select_asset(0, 0);
                edl->local_session->preview_start = 0;
                edl->local_session->preview_end = edl->tracks->total_playable_length();
+               edl->local_session->loop_playback = 0;
                edl->local_session->set_selectionstart(0);
                edl->local_session->set_selectionend(0);
                fit_selection();