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
+9 -18
View File
@@ -26,30 +26,21 @@ extern "C" {
OLIVE_NAMESPACE_ENTER
FFmpegFramePool::FFmpegFramePool(int element_count, int width, int height, AVPixelFormat format) :
FFmpegFramePool::FFmpegFramePool(int element_count) :
MemoryPool(element_count),
width_(width),
height_(height),
format_(format)
width_(0),
height_(0),
format_(AV_PIX_FMT_NONE)
{
}
FFmpegFramePool::ElementPtr FFmpegFramePool::Get(AVFrame *copy)
void FFmpegFramePool::SetParameters(int width, int height, AVPixelFormat format)
{
ElementPtr ele = MemoryPool::Get();
Clear();
if (ele) {
av_image_copy_to_buffer(ele->data(),
GetElementSize(),
copy->data,
copy->linesize,
format_,
width_,
height_,
1);
}
return ele;
width_ = width;
height_ = height;
format_ = format;
}
size_t FFmpegFramePool::GetElementSize()