ffmpegdecoder: frame pool by dimensions/format rather than stream

Memory optimization.
This commit is contained in:
itsmattkc
2020-08-26 17:42:10 +10:00
parent f86ab6a965
commit c99eb68d45
2 changed files with 42 additions and 11 deletions
+19 -1
View File
@@ -158,6 +158,17 @@ public:
virtual bool ConformAudio(const QAtomicInt* cancelled, const AudioParams& p) override;
struct FFmpegFramePoolKey {
int width;
int height;
AVPixelFormat format;
bool operator==(const FFmpegFramePoolKey& k) const
{
return width == k.width && height == k.height && format == k.format;
}
};
private:
/**
* @brief Handle an error
@@ -199,12 +210,19 @@ private:
AVPixelFormat ideal_pix_fmt_;
PixelFormat::Format native_pix_fmt_;
struct FFmpegFramePoolValue {
FFmpegFramePool* pool = nullptr;
int handles = 0;
};
static QHash< Stream*, QList<FFmpegDecoderInstance*> > instance_map_;
static QHash< Stream*, FFmpegFramePool* > frame_pool_map_;
static QHash< FFmpegFramePoolKey, FFmpegFramePoolValue > frame_pool_map_;
static QMutex instance_map_lock_;
};
uint qHash(const FFmpegDecoder::FFmpegFramePoolKey& r);
OLIVE_NAMESPACE_EXIT
#endif // FFMPEGDECODER_H