From: Good Guy Date: Tue, 30 Jun 2015 20:41:59 +0000 (-0600) Subject: add buffer flush to ffmpeg seek, clear loop_session on load replace mode X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=fe44dc1d43f34e4440f4c398bbf2475a07f80ffc;p=goodguy%2Fhistory.git add buffer flush to ffmpeg seek, clear loop_session on load replace mode --- diff --git a/cinelerra-5.0/cinelerra/ffmpeg.C b/cinelerra-5.0/cinelerra/ffmpeg.C index 26ed21a4..16d6fe05 100644 --- a/cinelerra-5.0/cinelerra/ffmpeg.C +++ b/cinelerra-5.0/cinelerra/ffmpeg.C @@ -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; } diff --git a/cinelerra-5.0/cinelerra/ffmpeg.h b/cinelerra-5.0/cinelerra/ffmpeg.h index 41941e73..040bdcda 100644 --- a/cinelerra-5.0/cinelerra/ffmpeg.h +++ b/cinelerra-5.0/cinelerra/ffmpeg.h @@ -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 { diff --git a/cinelerra-5.0/cinelerra/mwindow.C b/cinelerra-5.0/cinelerra/mwindow.C index 1a1d4dba..e992fe1d 100644 --- a/cinelerra-5.0/cinelerra/mwindow.C +++ b/cinelerra-5.0/cinelerra/mwindow.C @@ -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();