diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-10-01 14:34:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-01 14:34:26 +0200 |
commit | 79b00fc33b5cb6d56d29b50efac6d62ce3a89018 (patch) | |
tree | 77d8179bb3d9d76d9ec4fcfe396a35afcc8f73cd /media/ffvpx/libavutil/mem.c | |
parent | ab881a3bf513e591b6cc2966560cdab2b63a0f2a (diff) | |
parent | 7d1ee0e5e4958175ccde5d153b025f97a17caeb2 (diff) | |
download | UXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.tar UXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.tar.gz UXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.tar.lz UXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.tar.xz UXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.zip |
Merge pull request #801 from trav90/update-from-upstream
Update ffvpx code to 4.0.2
Diffstat (limited to 'media/ffvpx/libavutil/mem.c')
-rw-r--r-- | media/ffvpx/libavutil/mem.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/media/ffvpx/libavutil/mem.c b/media/ffvpx/libavutil/mem.c index 36740f115..6149755a6 100644 --- a/media/ffvpx/libavutil/mem.c +++ b/media/ffvpx/libavutil/mem.c @@ -61,7 +61,7 @@ void free(void *ptr); #include "mem_internal.h" -#define ALIGN (HAVE_AVX ? 32 : 16) +#define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 32 : 16)) /* NOTE: if you want to override these functions with your own * implementations (not recommended) you have to link libav* as @@ -181,6 +181,20 @@ int av_reallocp(void *ptr, size_t size) return 0; } +void *av_malloc_array(size_t nmemb, size_t size) +{ + if (!size || nmemb >= INT_MAX / size) + return NULL; + return av_malloc(nmemb * size); +} + +void *av_mallocz_array(size_t nmemb, size_t size) +{ + if (!size || nmemb >= INT_MAX / size) + return NULL; + return av_mallocz(nmemb * size); +} + void *av_realloc_array(void *ptr, size_t nmemb, size_t size) { if (!size || nmemb >= INT_MAX / size) @@ -449,10 +463,15 @@ void av_memcpy_backptr(uint8_t *dst, int back, int cnt) void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) { - if (min_size < *size) + if (min_size <= *size) return ptr; - min_size = FFMAX(min_size + min_size / 16 + 32, min_size); + 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 |