From ebd67b1c6f06b93235700bfef0011b331669ee2f Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Fri, 14 Aug 2009 08:12:28 +0000 Subject: Replace av_log() with DEBUGF and drop some now-useless files. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22306 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libatrac/libavutil/common.h | 7 - apps/codecs/libatrac/libavutil/internal.h | 328 ------------------------------ apps/codecs/libatrac/libavutil/log.c | 89 -------- apps/codecs/libatrac/libavutil/log.h | 116 ----------- apps/codecs/libatrac/libavutil/mem.c | 159 --------------- apps/codecs/libatrac/libavutil/mem.h | 104 ---------- 6 files changed, 803 deletions(-) delete mode 100644 apps/codecs/libatrac/libavutil/internal.h delete mode 100644 apps/codecs/libatrac/libavutil/log.c delete mode 100644 apps/codecs/libatrac/libavutil/log.h delete mode 100644 apps/codecs/libatrac/libavutil/mem.c delete mode 100644 apps/codecs/libatrac/libavutil/mem.h (limited to 'apps/codecs/libatrac/libavutil') diff --git a/apps/codecs/libatrac/libavutil/common.h b/apps/codecs/libatrac/libavutil/common.h index 949f093d35..e369b43da7 100644 --- a/apps/codecs/libatrac/libavutil/common.h +++ b/apps/codecs/libatrac/libavutil/common.h @@ -276,11 +276,4 @@ static inline av_const float av_clipf(float a, float amin, float amax) }\ } -#include "mem.h" - -//#ifdef HAVE_AV_CONFIG_H -//# include "ffmpeg_config.h" -# include "internal.h" -//#endif /* HAVE_AV_CONFIG_H */ - #endif /* AVUTIL_COMMON_H */ diff --git a/apps/codecs/libatrac/libavutil/internal.h b/apps/codecs/libatrac/libavutil/internal.h deleted file mode 100644 index c28b6f9a5e..0000000000 --- a/apps/codecs/libatrac/libavutil/internal.h +++ /dev/null @@ -1,328 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavutil/internal.h - * common internal API header - */ - -#ifndef AVUTIL_INTERNAL_H -#define AVUTIL_INTERNAL_H - -#if !defined(DEBUG) && !defined(NDEBUG) -# define NDEBUG -#endif - -#include -#include -#include -#include -//#include "ffmpeg_config.h" -#include "common.h" -#include "mem.h" -//#include "timer.h" - -#ifndef attribute_align_arg -#if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,2) -# define attribute_align_arg __attribute__((force_align_arg_pointer)) -#else -# define attribute_align_arg -#endif -#endif - -#ifndef attribute_used -#if AV_GCC_VERSION_AT_LEAST(3,1) -# define attribute_used __attribute__((used)) -#else -# define attribute_used -#endif -#endif - -#ifndef INT16_MIN -#define INT16_MIN (-0x7fff-1) -#endif - -#ifndef INT16_MAX -#define INT16_MAX 0x7fff -#endif - -#ifndef INT32_MIN -#define INT32_MIN (-0x7fffffff-1) -#endif - -#ifndef INT32_MAX -#define INT32_MAX 0x7fffffff -#endif - -#ifndef UINT32_MAX -#define UINT32_MAX 0xffffffff -#endif - -#ifndef INT64_MIN -#define INT64_MIN (-0x7fffffffffffffffLL-1) -#endif - -#ifndef INT64_MAX -#define INT64_MAX INT64_C(9223372036854775807) -#endif - -#ifndef UINT64_MAX -#define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) -#endif - -#ifndef INT_BIT -# define INT_BIT (CHAR_BIT * sizeof(int)) -#endif - -#if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC) -# define PIC -#endif - -#ifndef offsetof -# define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F)) -#endif - -// Use rip-relative addressing if compiling PIC code on x86-64. -#if ARCH_X86_64 && defined(PIC) -# define LOCAL_MANGLE(a) #a "(%%rip)" -#else -# define LOCAL_MANGLE(a) #a -#endif - -#define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) - -/* debug stuff */ - -/* dprintf macros */ -#ifdef DEBUG -# define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) -#else -# define dprintf(pctx, ...) -#endif - -#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) - -/* math */ - -extern const uint32_t ff_inverse[256]; - -#if ARCH_X86 -# define FASTDIV(a,b) \ - ({\ - int ret,dmy;\ - __asm__ volatile(\ - "mull %3"\ - :"=d"(ret),"=a"(dmy)\ - :"1"(a),"g"(ff_inverse[b])\ - );\ - ret;\ - }) -#elif HAVE_ARMV6 && HAVE_INLINE_ASM -static inline av_const int FASTDIV(int a, int b) -{ - int r, t; - __asm__ volatile("cmp %3, #2 \n\t" - "ldr %1, [%4, %3, lsl #2] \n\t" - "lsrle %0, %2, #1 \n\t" - "smmulgt %0, %1, %2 \n\t" - : "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse)); - return r; -} -#elif ARCH_ARM && HAVE_INLINE_ASM -static inline av_const int FASTDIV(int a, int b) -{ - int r, t; - __asm__ volatile ("umull %1, %0, %2, %3" - : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); - return r; -} -#elif CONFIG_FASTDIV -# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*ff_inverse[b])>>32)) -#else -# define FASTDIV(a,b) ((a)/(b)) -#endif - -extern const uint8_t ff_sqrt_tab[256]; - -static inline av_const unsigned int ff_sqrt(unsigned int a) -{ - unsigned int b; - - if(a<255) return (ff_sqrt_tab[a+1]-1)>>4; - else if(a<(1<<12)) b= ff_sqrt_tab[a>>4 ]>>2; -#if !CONFIG_SMALL - else if(a<(1<<14)) b= ff_sqrt_tab[a>>6 ]>>1; - else if(a<(1<<16)) b= ff_sqrt_tab[a>>8 ] ; -#endif - else{ - int s= av_log2_16bit(a>>16)>>1; - unsigned int c= a>>(s+2); - b= ff_sqrt_tab[c>>(s+8)]; - b= FASTDIV(c,b) + (b<>31;\ - level= (level^mask)-mask; -#endif - -#if HAVE_CMOV -#define COPY3_IF_LT(x,y,a,b,c,d)\ -__asm__ volatile (\ - "cmpl %0, %3 \n\t"\ - "cmovl %3, %0 \n\t"\ - "cmovl %4, %1 \n\t"\ - "cmovl %5, %2 \n\t"\ - : "+&r" (x), "+&r" (a), "+r" (c)\ - : "r" (y), "r" (b), "r" (d)\ -); -#else -#define COPY3_IF_LT(x,y,a,b,c,d)\ -if((y)<(x)){\ - (x)=(y);\ - (a)=(b);\ - (c)=(d);\ -} -#endif - -/* avoid usage of dangerous/inappropriate system functions */ -#undef malloc -#define malloc please_use_av_malloc -#undef free -#define free please_use_av_free -#undef realloc -#define realloc please_use_av_realloc -#undef time -#define time time_is_forbidden_due_to_security_issues -//#undef rand -//#define rand rand_is_forbidden_due_to_state_trashing_use_av_random -//#undef srand -//#define srand srand_is_forbidden_due_to_state_trashing_use_av_random_init -#undef random -#define random random_is_forbidden_due_to_state_trashing_use_av_random -#undef sprintf -#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf -#undef strcat -#define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat -#undef exit -#define exit exit_is_forbidden -#ifndef LIBAVFORMAT_BUILD -//#undef printf -//#define printf please_use_av_log_instead_of_printf -#undef fprintf -#define fprintf please_use_av_log_instead_of_fprintf -#undef puts -#define puts please_use_av_log_instead_of_puts -#undef perror -#define perror please_use_av_log_instead_of_perror -#endif - -#define CHECKED_ALLOCZ(p, size)\ -{\ - p= av_mallocz(size);\ - if(p==NULL && (size)!=0){\ - av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ - goto fail;\ - }\ -} - -#if defined(__ICC) || defined(__SUNPRO_C) - #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) - #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v -#elif defined(__GNUC__) - #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) - #define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n))) -#elif defined(_MSC_VER) - #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v - #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v -#elif HAVE_INLINE_ASM - #error The asm code needs alignment, but we do not know how to do it for this compiler. -#else - #define DECLARE_ALIGNED(n,t,v) t v - #define DECLARE_ASM_CONST(n,t,v) static const t v -#endif - - -#if !HAVE_LLRINT -static av_always_inline av_const long long llrint(double x) -{ - return rint(x); -} -#endif /* HAVE_LLRINT */ - -#if !HAVE_LRINT -static av_always_inline av_const long int lrint(double x) -{ - return rint(x); -} -#endif /* HAVE_LRINT */ - -#if !HAVE_LRINTF -static av_always_inline av_const long int lrintf(float x) -{ - return (int)(rint(x)); -} -#endif /* HAVE_LRINTF */ - -#if !HAVE_ROUND -static av_always_inline av_const double round(double x) -{ - return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); -} -#endif /* HAVE_ROUND */ - -#if !HAVE_ROUNDF -static av_always_inline av_const float roundf(float x) -{ - return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); -} -#endif /* HAVE_ROUNDF */ - -#if !HAVE_TRUNCF -static av_always_inline av_const float truncf(float x) -{ - return (x > 0) ? floor(x) : ceil(x); -} -#endif /* HAVE_TRUNCF */ - -/** - * Returns NULL if CONFIG_SMALL is true, otherwise the argument - * without modification. Used to disable the definition of strings - * (for example AVCodec long_names). - */ -#if CONFIG_SMALL -# define NULL_IF_CONFIG_SMALL(x) NULL -#else -# define NULL_IF_CONFIG_SMALL(x) x -#endif - -#endif /* AVUTIL_INTERNAL_H */ diff --git a/apps/codecs/libatrac/libavutil/log.c b/apps/codecs/libatrac/libavutil/log.c deleted file mode 100644 index 4bb9652c2c..0000000000 --- a/apps/codecs/libatrac/libavutil/log.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * log functions - * Copyright (c) 2003 Michel Bardiaux - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavutil/log.c - * logging functions - */ - -#include "avutil.h" -#include "log.h" - -int av_log_level = AV_LOG_INFO; - -void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) -{ - static int print_prefix=1; - static int count; - static char line[1024], prev[1024]; - AVClass* avc= ptr ? *(AVClass**)ptr : NULL; - if(level>av_log_level) - return; -#undef fprintf - if(print_prefix && avc) { - snprintf(line, sizeof(line), "[%s @ %p]", avc->item_name(ptr), ptr); - }else - line[0]=0; - - vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); - - print_prefix= line[strlen(line)-1] == '\n'; - if(print_prefix && !strcmp(line, prev)){ - count++; - return; - } - if(count>0){ - fprintf(stderr, " Last message repeated %d times\n", count); - count=0; - } - fputs(line, stderr); - strcpy(prev, line); -} - -static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; - -void av_log(void* avcl, int level, const char *fmt, ...) -{ - va_list vl; - va_start(vl, fmt); - av_vlog(avcl, level, fmt, vl); - va_end(vl); -} - -void av_vlog(void* avcl, int level, const char *fmt, va_list vl) -{ - av_log_callback(avcl, level, fmt, vl); -} - -int av_log_get_level(void) -{ - return av_log_level; -} - -void av_log_set_level(int level) -{ - av_log_level = level; -} - -void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)) -{ - av_log_callback = callback; -} diff --git a/apps/codecs/libatrac/libavutil/log.h b/apps/codecs/libatrac/libavutil/log.h deleted file mode 100644 index 1206a2fc38..0000000000 --- a/apps/codecs/libatrac/libavutil/log.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_LOG_H -#define AVUTIL_LOG_H - -#include -#include "avutil.h" - -/** - * Describes the class of an AVClass context structure. That is an - * arbitrary struct of which the first field is a pointer to an - * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). - */ -typedef struct AVCLASS AVClass; -struct AVCLASS { - /** - * The name of the class; usually it is the same name as the - * context structure type to which the AVClass is associated. - */ - const char* class_name; - - /** - * A pointer to a function which returns the name of a context - * instance \p ctx associated with the class. - */ - const char* (*item_name)(void* ctx); - - /** - * a pointer to the first option specified in the class if any or NULL - * - * @see av_set_default_options() - */ - const struct AVOption *option; -}; - -/* av_log API */ - -#define AV_LOG_QUIET -8 - -/** - * Something went really wrong and we will crash now. - */ -#define AV_LOG_PANIC 0 - -/** - * Something went wrong and recovery is not possible. - * For example, no header was found for a format which depends - * on headers or an illegal combination of parameters is used. - */ -#define AV_LOG_FATAL 8 - -/** - * Something went wrong and cannot losslessly be recovered. - * However, not all future data is affected. - */ -#define AV_LOG_ERROR 16 - -/** - * Something somehow does not look correct. This may or may not - * lead to problems. An example would be the use of '-vstrict -2'. - */ -#define AV_LOG_WARNING 24 - -#define AV_LOG_INFO 32 -#define AV_LOG_VERBOSE 40 - -/** - * Stuff which is only useful for libav* developers. - */ -#define AV_LOG_DEBUG 48 - -/** - * Sends the specified message to the log if the level is less than or equal - * to the current av_log_level. By default, all logging messages are sent to - * stderr. This behavior can be altered by setting a different av_vlog callback - * function. - * - * @param avcl A pointer to an arbitrary struct of which the first field is a - * pointer to an AVClass struct. - * @param level The importance level of the message, lower values signifying - * higher importance. - * @param fmt The format string (printf-compatible) that specifies how - * subsequent arguments are converted to output. - * @see av_vlog - */ -#ifdef __GNUC__ -void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); -#else -void av_log(void*, int level, const char *fmt, ...); -#endif - -void av_vlog(void*, int level, const char *fmt, va_list); -int av_log_get_level(void); -void av_log_set_level(int); -void av_log_set_callback(void (*)(void*, int, const char*, va_list)); -void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); - -#endif /* AVUTIL_LOG_H */ diff --git a/apps/codecs/libatrac/libavutil/mem.c b/apps/codecs/libatrac/libavutil/mem.c deleted file mode 100644 index 9721222e50..0000000000 --- a/apps/codecs/libatrac/libavutil/mem.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * default memory allocator for libavutil - * Copyright (c) 2002 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavutil/mem.c - * default memory allocator for libavutil - */ - -//#include "ffmpeg_config.h" - -#include -#include -#include -#if HAVE_MALLOC_H -#include -#endif - -#include "mem.h" - -/* here we can use OS-dependent allocation functions */ -#undef free -#undef malloc -#undef realloc - -/* You can redefine av_malloc and av_free in your project to use your - memory allocator. You do not need to suppress this file because the - linker will do it automatically. */ - -void *av_malloc(unsigned int size) -{ - void *ptr = NULL; -#if CONFIG_MEMALIGN_HACK - long diff; -#endif - - /* let's disallow possible ambiguous cases */ - if(size > (INT_MAX-16) ) - return NULL; - -#if CONFIG_MEMALIGN_HACK - ptr = malloc(size+16); - if(!ptr) - return ptr; - diff= ((-(long)ptr - 1)&15) + 1; - ptr = (char*)ptr + diff; - ((char*)ptr)[-1]= diff; -#elif HAVE_POSIX_MEMALIGN - if (posix_memalign(&ptr,16,size)) - ptr = NULL; -#elif HAVE_MEMALIGN - ptr = memalign(16,size); - /* Why 64? - Indeed, we should align it: - on 4 for 386 - on 16 for 486 - on 32 for 586, PPro - K6-III - on 64 for K7 (maybe for P3 too). - Because L1 and L2 caches are aligned on those values. - But I don't want to code such logic here! - */ - /* Why 16? - Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs - it will just trigger an exception and the unaligned load will be done in the - exception handler or it will just segfault (SSE2 on P4). - Why not larger? Because I did not see a difference in benchmarks ... - */ - /* benchmarks with P3 - memalign(64)+1 3071,3051,3032 - memalign(64)+2 3051,3032,3041 - memalign(64)+4 2911,2896,2915 - memalign(64)+8 2545,2554,2550 - memalign(64)+16 2543,2572,2563 - memalign(64)+32 2546,2545,2571 - memalign(64)+64 2570,2533,2558 - - BTW, malloc seems to do 8-byte alignment by default here. - */ -#else - ptr = malloc(size); -#endif - return ptr; -} - -void *av_realloc(void *ptr, unsigned int size) -{ -#if CONFIG_MEMALIGN_HACK - int diff; -#endif - - /* let's disallow possible ambiguous cases */ - if(size > (INT_MAX-16) ) - return NULL; - -#if CONFIG_MEMALIGN_HACK - //FIXME this isn't aligned correctly, though it probably isn't needed - if(!ptr) return av_malloc(size); - diff= ((char*)ptr)[-1]; - return (char*)realloc((char*)ptr - diff, size + diff) + diff; -#else - return realloc(ptr, size); -#endif -} - -void av_free(void *ptr) -{ - /* XXX: this test should not be needed on most libcs */ - if (ptr) -#if CONFIG_MEMALIGN_HACK - free((char*)ptr - ((char*)ptr)[-1]); -#else - free(ptr); -#endif -} - -void av_freep(void *arg) -{ - void **ptr= (void**)arg; - av_free(*ptr); - *ptr = NULL; -} - -void *av_mallocz(unsigned int size) -{ - void *ptr = av_malloc(size); - if (ptr) - memset(ptr, 0, size); - return ptr; -} - -char *av_strdup(const char *s) -{ - char *ptr= NULL; - if(s){ - int len = strlen(s) + 1; - ptr = av_malloc(len); - if (ptr) - memcpy(ptr, s, len); - } - return ptr; -} - diff --git a/apps/codecs/libatrac/libavutil/mem.h b/apps/codecs/libatrac/libavutil/mem.h deleted file mode 100644 index e50553aefe..0000000000 --- a/apps/codecs/libatrac/libavutil/mem.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavutil/mem.h - * memory handling functions - */ - -#ifndef AVUTIL_MEM_H -#define AVUTIL_MEM_H - -#include "common.h" - -#if AV_GCC_VERSION_AT_LEAST(3,1) - #define av_malloc_attrib __attribute__((__malloc__)) -#else - #define av_malloc_attrib -#endif - -#if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,3) - #define av_alloc_size(n) __attribute__((alloc_size(n))) -#else - #define av_alloc_size(n) -#endif - -/** - * Allocates a block of \p size bytes with alignment suitable for all - * memory accesses (including vectors if available on the CPU). - * @param size Size in bytes for the memory block to be allocated. - * @return Pointer to the allocated block, NULL if the block cannot - * be allocated. - * @see av_mallocz() - */ -void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); - -/** - * Allocates or reallocates a block of memory. - * If \p ptr is NULL and \p size > 0, allocates a new block. If \p - * size is zero, frees the memory block pointed to by \p ptr. - * @param size Size in bytes for the memory block to be allocated or - * reallocated. - * @param ptr Pointer to a memory block already allocated with - * av_malloc(z)() or av_realloc() or NULL. - * @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. - * @see av_fast_realloc() - */ -void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); - -/** - * Frees a memory block which has been allocated with av_malloc(z)() or - * av_realloc(). - * @param ptr Pointer to the memory block which should be freed. - * @note ptr = NULL is explicitly allowed. - * @note It is recommended that you use av_freep() instead. - * @see av_freep() - */ -void av_free(void *ptr); - -/** - * Allocates a block of \p size bytes with alignment suitable for all - * memory accesses (including vectors if available on the CPU) and - * zeroes all the bytes of the block. - * @param size Size in bytes for the memory block to be allocated. - * @return Pointer to the allocated block, NULL if it cannot be allocated. - * @see av_malloc() - */ -void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); - -/** - * Duplicates the string \p s. - * @param s string to be duplicated - * @return Pointer to a newly allocated string containing a - * copy of \p s or NULL if the string cannot be allocated. - */ -char *av_strdup(const char *s) av_malloc_attrib; - -/** - * Frees a memory block which has been allocated with av_malloc(z)() or - * av_realloc() and set the pointer pointing to it to NULL. - * @param ptr Pointer to the pointer to the memory block which should - * be freed. - * @see av_free() - */ -void av_freep(void *ptr); - -#endif /* AVUTIL_MEM_H */ -- cgit v1.2.3