diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-11-14 15:04:04 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-11-14 15:04:04 +0100 |
commit | 7c888ae746da0d9f6a11bab9758c01d641b49d7b (patch) | |
tree | 22862c9f615cb2e636feec9ffd1d5e2a675295ed /libavcodec | |
parent | 2925571278bf09702564dfedd5e7731a112dd1f0 (diff) | |
parent | cce3e0a49f0dd030262c28d9c53de0bd2fd909c4 (diff) | |
download | ffmpeg-7c888ae746da0d9f6a11bab9758c01d641b49d7b.tar.gz |
Merge commit 'cce3e0a49f0dd030262c28d9c53de0bd2fd909c4'
* commit 'cce3e0a49f0dd030262c28d9c53de0bd2fd909c4':
Move av_fast_{m,re}alloc from lavc to lavu.
Conflicts:
libavcodec/avcodec.h
libavcodec/utils.c
libavutil/mem.c
libavutil/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 25 | ||||
-rw-r--r-- | libavcodec/utils.c | 28 | ||||
-rw-r--r-- | libavcodec/version.h | 3 |
3 files changed, 15 insertions, 41 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 18a41256d8..67dc49f4ed 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -37,6 +37,10 @@ #include "libavutil/dict.h" #include "libavutil/frame.h" #include "libavutil/log.h" +#if FF_API_FAST_MALLOC +// to provide fast_*alloc +#include "libavutil/mem.h" +#endif #include "libavutil/pixfmt.h" #include "libavutil/rational.h" @@ -4869,27 +4873,6 @@ AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); /* memory */ /** - * Reallocate the given block if it is not large enough, otherwise do nothing. - * - * @see av_realloc - */ -void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); - -/** - * Allocate a buffer, reusing the given one if large enough. - * - * Contrary to av_fast_realloc the current buffer contents might not be - * preserved and on error the old buffer is freed, thus no special - * handling to avoid memleaks is necessary. - * - * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer - * @param size size of the buffer *ptr points to - * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and - * *size 0 if an error occurred. - */ -void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); - -/** * Same behaviour av_fast_malloc but the buffer has additional * FF_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0. * diff --git a/libavcodec/utils.c b/libavcodec/utils.c index d20ce3dc15..d52c96cb32 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -117,24 +117,17 @@ static int volatile entangled_thread_counter = 0; static void *codec_mutex; static void *avformat_mutex; -void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) +#if FF_API_FAST_MALLOC && CONFIG_SHARED && HAVE_SYMVER +FF_SYMVER(void*, av_fast_realloc, (void *ptr, unsigned int *size, size_t min_size), "LIBAVCODEC_55") { - if (min_size < *size) - return ptr; - - min_size = FFMAX(17 * 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 av_fast_realloc(ptr, size, min_size); +} - return ptr; +FF_SYMVER(void, av_fast_malloc, (void *ptr, unsigned int *size, size_t min_size), "LIBAVCODEC_55") +{ + av_fast_malloc(ptr, size, min_size); } +#endif static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc) { @@ -150,11 +143,6 @@ static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, return 1; } -void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size) -{ - ff_fast_malloc(ptr, size, min_size, 0); -} - void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) { uint8_t **p = ptr; diff --git a/libavcodec/version.h b/libavcodec/version.h index 6f2d5da07e..19cefac482 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -132,5 +132,8 @@ #ifndef FF_API_MAX_BFRAMES #define FF_API_MAX_BFRAMES (LIBAVCODEC_VERSION_MAJOR < 56) #endif +#ifndef FF_API_FAST_MALLOC +#define FF_API_FAST_MALLOC (LIBAVCODEC_VERSION_MAJOR < 56) +#endif #endif /* AVCODEC_VERSION_H */ |