gpt4 book ai didi

ffmpeg - av_fast_realloc 比 av_realloc 快吗?

转载 作者:行者123 更新时间:2023-12-04 23:02:51 28 4
gpt4 key购买 nike

我应该改用它吗?看起来它只是更紧凑。

https://ffmpeg.org/doxygen/trunk/group__lavu__mem__funcs.html

最佳答案

这是最新版本的整个函数,它实际上调用了av_realloc但首先检查提供的缓冲区是否像文档中所说的那样大,如果是,则不执行 av_realloc ,实际上它在这种情况下除了返回相同的缓冲区之外什么也不做。希望有帮助。

void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
{
if (min_size <= *size)
return ptr;

if (min_size > max_alloc_size - 32) {
*size = 0;
return NULL;
}

min_size = FFMIN(max_alloc_size - 32, FFMAX(min_size + min_size / 16 + 32, min_size));

ptr = av_realloc(ptr, min_size);
/* we could set this to the unmodified min_size but this is safer
* if the user lost the ptr and uses NULL now
*/
if (!ptr)
min_size = 0;

*size = min_size;

return ptr;
}

关于ffmpeg - av_fast_realloc 比 av_realloc 快吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48297132/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com