From: Good Guy Date: Sat, 12 Sep 2020 20:01:52 +0000 (-0600) Subject: purge file_cache when starting rev read cache burst X-Git-Tag: 2020-09~10 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=588649236b6ae38da7c8627ff7439aeff3c78798;p=goodguy%2Fcinelerra.git purge file_cache when starting rev read cache burst --- diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C index 57232271..f0eea9c5 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.C +++ b/cinelerra-5.1/cinelerra/ffmpeg.C @@ -1225,13 +1225,15 @@ int FFVideoStream::load(VFrame *vframe, int64_t pos) while( ret>=0 && !flushed && curr_pos<=pos && --i>=0 ) { ret = read_frame(frame); if( ret > 0 ) { - if( frame->key_frame && seeking < 0 ) + if( frame->key_frame && seeking < 0 ) { seeking = 1; - if( ffmpeg->file_base->get_use_cache() && seeking > 0 && curr_pos < pos ) { - VFrame *cache_frame = ffmpeg->file_base->new_cache_frame(vframe, curr_pos); + ffmpeg->purge_cache(); + } + if( ffmpeg->get_use_cache() && seeking > 0 && curr_pos < pos ) { + VFrame *cache_frame = ffmpeg->new_cache_frame(vframe, curr_pos); if( cache_frame ) { ret = convert_cmodel(cache_frame, frame); - ffmpeg->file_base->put_cache_frame(); + ffmpeg->put_cache_frame(); } } ++curr_pos; @@ -2231,6 +2233,26 @@ int FFMPEG::scan_options(const char *options, AVDictionary *&opts, AVStream *st) return ret; } +VFrame *FFMPEG::new_cache_frame(VFrame *vframe, int64_t position) +{ + return file_base->file->new_cache_frame(vframe, position, 0); +} + +void FFMPEG::put_cache_frame() +{ + return file_base->file->put_cache_frame(); +} + +int FFMPEG::get_use_cache() +{ + return file_base->file->get_use_cache(); +} + +void FFMPEG::purge_cache() +{ + file_base->file->purge_cache(); +} + FFCodecRemap::FFCodecRemap() { old_codec = 0; diff --git a/cinelerra-5.1/cinelerra/ffmpeg.h b/cinelerra-5.1/cinelerra/ffmpeg.h index aa01785a..9ceef154 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.h +++ b/cinelerra-5.1/cinelerra/ffmpeg.h @@ -368,6 +368,11 @@ public: static double to_secs(int64_t time, AVRational time_base); int info(char *text, int len); + VFrame *new_cache_frame(VFrame *vframe, int64_t position); + void put_cache_frame(); + int get_use_cache(); + void purge_cache(); + int init_decoder(const char *filename); int open_decoder(); int init_encoder(const char *filename); diff --git a/cinelerra-5.1/cinelerra/filebase.C b/cinelerra-5.1/cinelerra/filebase.C index e2e14891..dc73ccc5 100644 --- a/cinelerra-5.1/cinelerra/filebase.C +++ b/cinelerra-5.1/cinelerra/filebase.C @@ -299,17 +299,3 @@ int64_t FileBase::base_memory_usage() history_allocated * history_channels * sizeof(double); } - -VFrame *FileBase::new_cache_frame(VFrame *vframe, int64_t position) -{ - return file->new_cache_frame(vframe, position, 0); -} -void FileBase::put_cache_frame() -{ - return file->put_cache_frame(); -} -int FileBase::get_use_cache() -{ - return file->get_use_cache(); -} - diff --git a/cinelerra-5.1/cinelerra/filebase.h b/cinelerra-5.1/cinelerra/filebase.h index 77893f9e..3fb8be42 100644 --- a/cinelerra-5.1/cinelerra/filebase.h +++ b/cinelerra-5.1/cinelerra/filebase.h @@ -132,10 +132,6 @@ public: int channel, int64_t len); void allocate_history(int len); -// create cache frames - VFrame *new_cache_frame(VFrame *vframe, int64_t position); - void put_cache_frame(); - int get_use_cache(); // For static functions to access it Asset *asset;