ffmpegdecoder: added helper functions for memory handling

This commit is contained in:
itsmattkc
2020-02-21 01:18:21 +11:00
parent 3cffffdcee
commit 7797bf4971
2 changed files with 24 additions and 0 deletions
+22
View File
@@ -1007,6 +1007,28 @@ void FFmpegDecoder::CacheFrameToDisk(AVFrame *f)
}
}
void FFmpegDecoder::RemoveFirstFromFrameCache()
{
if (cached_frames_.isEmpty()) {
return;
}
av_frame_free(&cached_frames_.first());
cached_frames_.removeFirst();
cache_at_zero_ = false;
}
void FFmpegDecoder::RemoveLastFromFrameCache()
{
if (cached_frames_.isEmpty()) {
return;
}
av_frame_free(&cached_frames_.last());
cached_frames_.removeLast();
cache_at_eof_ = false;
}
void FFmpegDecoder::ClearFrameCache()
{
for (int i=0;i<cached_frames_.size();i++) {
+2
View File
@@ -104,6 +104,8 @@ private:
void CacheFrameToDisk(AVFrame* f);
void RemoveFirstFromFrameCache();
void RemoveLastFromFrameCache();
void ClearFrameCache();
AVFormatContext* fmt_ctx_;