From 588649236b6ae38da7c8627ff7439aeff3c78798 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sat, 12 Sep 2020 14:01:52 -0600 Subject: [PATCH] purge file_cache when starting rev read cache burst --- cinelerra-5.1/cinelerra/ffmpeg.C | 30 ++++++++++++++++++++++++++---- cinelerra-5.1/cinelerra/ffmpeg.h | 5 +++++ cinelerra-5.1/cinelerra/filebase.C | 14 -------------- cinelerra-5.1/cinelerra/filebase.h | 4 ---- 4 files changed, 31 insertions(+), 22 deletions(-) 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; -- 2.26.2