ffmpeg - av_fast_realloc 比 av_realloc 快吗?

标签 ffmpeg

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

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/

相关文章:

c++ - av_seek_frame 仅每 12 帧搜索一次

ffmpeg 颜色、大小和幅度

video - SVT-AV1 垂直 4k 视频

android - 如何为 Android 构建 SDL 库

r - 导入 png 文件并在 R 中转换为动画(.mp4)

python - 具有数百个削减的 ffmpeg 性能 (atrim)

python - 从 ffmpeg.input() 对象获取输入文件名

amazon-s3 - 如何将 h265 视频从 ffmpeg 流式传输到 amazon s3?

audio - FFMPEG:4 channel 音频工作流程建议?

audio - 如何用ffmpeg覆盖两个音频?