From 011198e5b6182245f05a15a8e85b7fde4c402e13 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sun, 22 Apr 2012 13:31:47 +0000 Subject: updates and extension for ffmpeg-0.8 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2867 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/lib/ffmpeg-0.10/libavutil/dict.pas | 68 --------------------------- src/lib/ffmpeg-0.10/libavutil/mathematics.pas | 25 ---------- src/lib/ffmpeg-0.10/libavutil/mem.pas | 48 +++++++++++++++++-- src/lib/ffmpeg-0.10/libavutil/opt.pas | 26 ---------- 4 files changed, 45 insertions(+), 122 deletions(-) (limited to 'src/lib/ffmpeg-0.10') diff --git a/src/lib/ffmpeg-0.10/libavutil/dict.pas b/src/lib/ffmpeg-0.10/libavutil/dict.pas index b5608576..e2626e50 100644 --- a/src/lib/ffmpeg-0.10/libavutil/dict.pas +++ b/src/lib/ffmpeg-0.10/libavutil/dict.pas @@ -23,66 +23,6 @@ * *) -unit dict; - -{$IFDEF FPC} - {$MODE DELPHI} - {$PACKENUM 4} (* use 4-byte enums *) - {$PACKRECORDS C} (* C/C++-compatible record packing *) -{$ELSE} - {$MINENUMSIZE 4} (* use 4-byte enums *) -{$ENDIF} - -interface - -uses - ctypes, - UConfig; - -(** - * @file - * Public dictionary API. - * @deprecated - * AVDictionary is provided for compatibility with libav. It is both in - * implementation as well as API inefficient. It does not scale and is - * extremely slow with large dictionaries. - * It is recommended that new code uses our tree container from tree.c/h - * where applicable, which uses AVL trees to achieve O(log n) performance. - *) - -(** - * @addtogroup lavu_dict AVDictionary - * @ingroup lavu_data - * - * @brief Simple key:value store - * - * @{ - * Dictionaries are used for storing key:value pairs. To create - * an AVDictionary, simply pass an address of a NULL pointer to - * av_dict_set(). NULL can be used as an empty dictionary wherever - * a pointer to an AVDictionary is required. - * Use av_dict_get() to retrieve an entry or iterate over all - * entries and finally av_dict_free() to free the dictionary - * and all its contents. - * - * @code - * AVDictionary *d = NULL; // "create" an empty dictionary - * av_dict_set(&d, "foo", "bar", 0); // add an entry - * - * char *k = av_strdup("key"); // if your strings are already allocated, - * char *v = av_strdup("value"); // you can avoid copying them like this - * av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); - * - * AVDictionaryEntry *t = NULL; - * while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { - * <....> // iterate over all entries in d - * } - * - * av_dict_free(&d); - * @endcode - * - *) - const AV_DICT_MATCH_CASE = 1; AV_DICT_IGNORE_SUFFIX = 2; @@ -151,11 +91,3 @@ procedure av_dict_copy(var dst: PAVDictionary; src: PAVDictionary; flags: cint); *) procedure av_dict_free(var m: PAVDictionary); cdecl; external av__util; - -(** - * @} - *) - -implementation - -end. diff --git a/src/lib/ffmpeg-0.10/libavutil/mathematics.pas b/src/lib/ffmpeg-0.10/libavutil/mathematics.pas index 0ebdf262..3859311b 100644 --- a/src/lib/ffmpeg-0.10/libavutil/mathematics.pas +++ b/src/lib/ffmpeg-0.10/libavutil/mathematics.pas @@ -26,23 +26,6 @@ * *) -unit mathematics; - -{$IFDEF FPC} - {$MODE DELPHI } - {$PACKENUM 4} (* use 4-byte enums *) - {$PACKRECORDS C} (* C/C++-compatible record packing *) -{$ELSE} - {$MINENUMSIZE 4} (* use 4-byte enums *) -{$ENDIF} - -interface - -uses - ctypes, - rational, - UConfig; - const M_E = 2.7182818284590452354; // e M_LN2 = 0.69314718055994530942; // log_e 2 @@ -118,11 +101,3 @@ function av_compare_ts(ts_a: cint64; tb_a: TAVRational; ts_b: cint64; tb_b: TAVR *) function av_compare_mod(a: cuint64; b: cuint64; modVar: cuint64): cint64; cdecl; external av__util; - -(** - * @} - *) - -implementation - -end. diff --git a/src/lib/ffmpeg-0.10/libavutil/mem.pas b/src/lib/ffmpeg-0.10/libavutil/mem.pas index 5cc1dc1b..d71dd3d3 100644 --- a/src/lib/ffmpeg-0.10/libavutil/mem.pas +++ b/src/lib/ffmpeg-0.10/libavutil/mem.pas @@ -30,9 +30,6 @@ (* memory handling functions *) -type - FF_INTERNAL_MEM_TYPE = cuint; - (** * Allocate a block of size bytes with alignment suitable for all * memory accesses (including vectors if available on the CPU). @@ -59,6 +56,19 @@ function av_malloc(size: FF_INTERNAL_MEM_TYPE): pointer; function av_realloc(ptr: pointer; size: FF_INTERNAL_MEM_TYPE): pointer; cdecl; external av__util; {av_alloc_size(2)} +(** + * Allocate or reallocate a block of memory. + * This function does the same thing as av_realloc, except: + * - It takes two arguments and checks the result of the multiplication for + * integer overflow. + * - It frees the input block in case of failure, thus avoiding the memory + * leak with the classic "buf = realloc(buf); if (!buf) return -1;". + *) +{ available only in 0.8.5 - 0.8.10 +function av_realloc_f(ptr: pointer; nelem: size_t; size: size_t): pointer; + cdecl; external av__util; +} + (** * Free a memory block which has been allocated with av_malloc(z)() or * av_realloc(). @@ -81,6 +91,21 @@ procedure av_free(ptr: pointer); function av_mallocz(size: FF_INTERNAL_MEM_TYPE): pointer; cdecl; external av__util; {av_malloc_attrib av_alloc_size(1)} +(** + * Allocate a block of nmemb * size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU) and + * zero all the bytes of the block. + * The allocation will fail if nmemb * size is greater than or equal + * to INT_MAX. + * @param nmemb + * @param size + * @return Pointer to the allocated block, NULL if it cannot be allocated. + *) +(* available only in 0.8.5 - 0.8.10 +function av_calloc(nmemb: size_t; size: size_t): pointer; + cdecl; external av__util; {av_malloc_attrib} +*) + (** * Duplicate the string s. * @param s string to be duplicated. @@ -109,3 +134,20 @@ procedure av_freep (ptr: pointer); *) procedure av_dynarray_add(tab_ptr: pointer; nb_ptr: PCint; elem: pointer); cdecl; external av__util; + +(** + * Multiply two size_t values checking for overflow. + * @return 0 if success, AVERROR(EINVAL) if overflow. + *) +{ available only in 0.8.5 - 0.8.10 +//static inline int av_size_mult(size_t a, size_t b, size_t *r) +} +{ + size_t t = a * b; + /* Hack inspired from glibc: only try the division if nelem and elsize + * are both greater than sqrt(SIZE_MAX). */ + if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b) + return AVERROR(EINVAL); + *r = t; + return 0; +} diff --git a/src/lib/ffmpeg-0.10/libavutil/opt.pas b/src/lib/ffmpeg-0.10/libavutil/opt.pas index 6d5b3c89..61af0754 100644 --- a/src/lib/ffmpeg-0.10/libavutil/opt.pas +++ b/src/lib/ffmpeg-0.10/libavutil/opt.pas @@ -27,24 +27,6 @@ * *) -unit opt; - -{$IFDEF FPC} - {$MODE DELPHI} - {$PACKENUM 4} (* use 4-byte enums *) - {$PACKRECORDS C} (* C/C++-compatible record packing *) -{$ELSE} - {$MINENUMSIZE 4} (* use 4-byte enums *) -{$ENDIF} - -interface - -uses - ctypes, - dict, - rational, - UConfig; - (** * @defgroup avoptions AVOptions * @ingroup lavu_data @@ -649,11 +631,3 @@ function av_opt_get_q (obj: pointer; name: {const} PAnsiChar; search_flags: procedure av_opt_ptr(avclass: {const} PAVClass; obj: pointer; name: {const} PAnsiChar); cdecl; external av__util; *) - -(** - * @} - *) - -implementation - -end. \ No newline at end of file -- cgit v1.2.3