ffmpeg: store divided frames in memory cache

Since users will most likely be working with a divider most of the time,
there's no reason to waste memory space with undivided frames considering
the dividing process is quite fast.
This commit is contained in:
itsmattkc
2020-08-18 04:55:23 +10:00
parent d9851dc329
commit f3f81eb2be
7 changed files with 147 additions and 52 deletions
+7 -3
View File
@@ -76,7 +76,7 @@ public:
void ClearFrameCache();
FFmpegFramePool::ElementPtr RetrieveFrame(const int64_t &target_ts, bool cache_is_locked);
FFmpegFramePool::ElementPtr RetrieveFrame(const int64_t &target_ts, int divider, bool cache_is_locked);
/**
* @brief Uses the FFmpeg API to retrieve a packet (stored in pkt_) and decode it (stored in frame_)
@@ -98,11 +98,17 @@ private:
void Seek(int64_t timestamp);
void InitScaler(int divider);
void FreeScaler();
AVFormatContext* fmt_ctx_;
AVCodecContext* codec_ctx_;
AVStream* avstream_;
AVDictionary* opts_;
SwsContext* scale_ctx_;
int scale_divider_;
int64_t second_ts_;
QWaitCondition cache_wait_cond_;
@@ -179,8 +185,6 @@ private:
FramePtr RetrieveStillImage(const rational& timecode, const int& divider);
static int GetScaledDimension(int dim, int divider);
static PixelFormat::Format GetNativePixelFormat(AVPixelFormat pix_fmt);
static uint64_t ValidateChannelLayout(AVStream *stream);