Updated build of ffmpeg library (v 2.0.2). Builded with mingw (gcc 4.6.1) with
folowing additional options: --enable-w32threads, --arch=i686 (for 32-bit library, workaround for http://trac.ffmpeg.org/ticket/2363)
This commit is contained in:
129
3rdparty/include/ffmpeg_/libavutil/mem.h
vendored
129
3rdparty/include/ffmpeg_/libavutil/mem.h
vendored
@@ -26,6 +26,9 @@
|
||||
#ifndef AVUTIL_MEM_H
|
||||
#define AVUTIL_MEM_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "error.h"
|
||||
#include "avutil.h"
|
||||
@@ -64,9 +67,9 @@
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,3)
|
||||
#define av_alloc_size(n) __attribute__((alloc_size(n)))
|
||||
#define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__)))
|
||||
#else
|
||||
#define av_alloc_size(n)
|
||||
#define av_alloc_size(...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -79,6 +82,22 @@
|
||||
*/
|
||||
void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
|
||||
|
||||
/**
|
||||
* Helper function to allocate a block of size * nmemb bytes with
|
||||
* using av_malloc()
|
||||
* @param nmemb Number of elements
|
||||
* @param size Size of the single element
|
||||
* @return Pointer to the allocated block, NULL if the block cannot
|
||||
* be allocated.
|
||||
* @see av_malloc()
|
||||
*/
|
||||
av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size)
|
||||
{
|
||||
if (size <= 0 || nmemb >= INT_MAX / size)
|
||||
return NULL;
|
||||
return av_malloc(nmemb * size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate or reallocate a block of memory.
|
||||
* If ptr is NULL and size > 0, allocate a new block. If
|
||||
@@ -103,6 +122,32 @@ void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
|
||||
*/
|
||||
void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
|
||||
|
||||
/**
|
||||
* Allocate or reallocate an array.
|
||||
* If ptr is NULL and nmemb > 0, allocate a new block. If
|
||||
* nmemb is zero, free the memory block pointed to by ptr.
|
||||
* @param ptr Pointer to a memory block already allocated with
|
||||
* av_malloc(z)() or av_realloc() or NULL.
|
||||
* @param nmemb Number of elements
|
||||
* @param size Size of the single element
|
||||
* @return Pointer to a newly reallocated block or NULL if the block
|
||||
* cannot be reallocated or the function is used to free the memory block.
|
||||
*/
|
||||
av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* Allocate or reallocate an array.
|
||||
* If *ptr is NULL and nmemb > 0, allocate a new block. If
|
||||
* nmemb is zero, free the memory block pointed to by ptr.
|
||||
* @param ptr Pointer to a pointer to a memory block already allocated
|
||||
* with av_malloc(z)() or av_realloc(), or pointer to a pointer to NULL.
|
||||
* The pointer is updated on success, or freed on failure.
|
||||
* @param nmemb Number of elements
|
||||
* @param size Size of the single element
|
||||
* @return Zero on success, an AVERROR error code on failure.
|
||||
*/
|
||||
av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* Free a memory block which has been allocated with av_malloc(z)() or
|
||||
* av_realloc().
|
||||
@@ -135,6 +180,23 @@ void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
|
||||
*/
|
||||
void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
|
||||
|
||||
/**
|
||||
* Helper function to allocate a block of size * nmemb bytes with
|
||||
* using av_mallocz()
|
||||
* @param nmemb Number of elements
|
||||
* @param size Size of the single element
|
||||
* @return Pointer to the allocated block, NULL if the block cannot
|
||||
* be allocated.
|
||||
* @see av_mallocz()
|
||||
* @see av_malloc_array()
|
||||
*/
|
||||
av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size)
|
||||
{
|
||||
if (size <= 0 || nmemb >= INT_MAX / size)
|
||||
return NULL;
|
||||
return av_mallocz(nmemb * size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the string s.
|
||||
* @param s string to be duplicated
|
||||
@@ -143,6 +205,14 @@ void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
|
||||
*/
|
||||
char *av_strdup(const char *s) av_malloc_attrib;
|
||||
|
||||
/**
|
||||
* Duplicate the buffer p.
|
||||
* @param p buffer to be duplicated
|
||||
* @return Pointer to a newly allocated buffer containing a
|
||||
* copy of p or NULL if the buffer cannot be allocated.
|
||||
*/
|
||||
void *av_memdup(const void *p, size_t size);
|
||||
|
||||
/**
|
||||
* Free a memory block which has been allocated with av_malloc(z)() or
|
||||
* av_realloc() and set the pointer pointing to it to NULL.
|
||||
@@ -155,12 +225,50 @@ void av_freep(void *ptr);
|
||||
/**
|
||||
* Add an element to a dynamic array.
|
||||
*
|
||||
* @param tab_ptr Pointer to the array.
|
||||
* @param nb_ptr Pointer to the number of elements in the array.
|
||||
* @param elem Element to be added.
|
||||
* The array to grow is supposed to be an array of pointers to
|
||||
* structures, and the element to add must be a pointer to an already
|
||||
* allocated structure.
|
||||
*
|
||||
* The array is reallocated when its size reaches powers of 2.
|
||||
* Therefore, the amortized cost of adding an element is constant.
|
||||
*
|
||||
* In case of success, the pointer to the array is updated in order to
|
||||
* point to the new grown array, and the number pointed to by nb_ptr
|
||||
* is incremented.
|
||||
* In case of failure, the array is freed, *tab_ptr is set to NULL and
|
||||
* *nb_ptr is set to 0.
|
||||
*
|
||||
* @param tab_ptr pointer to the array to grow
|
||||
* @param nb_ptr pointer to the number of elements in the array
|
||||
* @param elem element to add
|
||||
* @see av_dynarray2_add()
|
||||
*/
|
||||
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem);
|
||||
|
||||
/**
|
||||
* Add an element of size elem_size to a dynamic array.
|
||||
*
|
||||
* The array is reallocated when its number of elements reaches powers of 2.
|
||||
* Therefore, the amortized cost of adding an element is constant.
|
||||
*
|
||||
* In case of success, the pointer to the array is updated in order to
|
||||
* point to the new grown array, and the number pointed to by nb_ptr
|
||||
* is incremented.
|
||||
* In case of failure, the array is freed, *tab_ptr is set to NULL and
|
||||
* *nb_ptr is set to 0.
|
||||
*
|
||||
* @param tab_ptr pointer to the array to grow
|
||||
* @param nb_ptr pointer to the number of elements in the array
|
||||
* @param elem_size size in bytes of the elements in the array
|
||||
* @param elem_data pointer to the data of the element to add. If NULL, the space of
|
||||
* the new added element is not filled.
|
||||
* @return pointer to the data of the element to copy in the new allocated space.
|
||||
* If NULL, the new allocated space is left uninitialized."
|
||||
* @see av_dynarray_add()
|
||||
*/
|
||||
void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size,
|
||||
const uint8_t *elem_data);
|
||||
|
||||
/**
|
||||
* Multiply two size_t values checking for overflow.
|
||||
* @return 0 if success, AVERROR(EINVAL) if overflow.
|
||||
@@ -181,6 +289,17 @@ static inline int av_size_mult(size_t a, size_t b, size_t *r)
|
||||
*/
|
||||
void av_max_alloc(size_t max);
|
||||
|
||||
/**
|
||||
* @brief deliberately overlapping memcpy implementation
|
||||
* @param dst destination buffer
|
||||
* @param back how many bytes back we start (the initial size of the overlapping window), must be > 0
|
||||
* @param cnt number of bytes to copy, must be >= 0
|
||||
*
|
||||
* cnt > back is valid, this will copy the bytes we just copied,
|
||||
* thus creating a repeating pattern with a period length of back.
|
||||
*/
|
||||
void av_memcpy_backptr(uint8_t *dst, int back, int cnt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user