00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #ifndef AVUTIL_INTERNAL_H
00027 #define AVUTIL_INTERNAL_H
00028
00029 #if !defined(DEBUG) && !defined(NDEBUG)
00030 # define NDEBUG
00031 #endif
00032
00033 #include <limits.h>
00034 #include <stdint.h>
00035 #include <stddef.h>
00036 #include <assert.h>
00037 #include "config.h"
00038 #include "attributes.h"
00039 #include "timer.h"
00040 #include "cpu.h"
00041 #include "dict.h"
00042
00043 #ifndef attribute_align_arg
00044 #if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2)
00045 # define attribute_align_arg __attribute__((force_align_arg_pointer))
00046 #else
00047 # define attribute_align_arg
00048 #endif
00049 #endif
00050
00051 #ifndef INT_BIT
00052 # define INT_BIT (CHAR_BIT * sizeof(int))
00053 #endif
00054
00055
00056 #undef malloc
00057 #define malloc please_use_av_malloc
00058 #undef free
00059 #define free please_use_av_free
00060 #undef realloc
00061 #define realloc please_use_av_realloc
00062 #undef time
00063 #define time time_is_forbidden_due_to_security_issues
00064 #undef rand
00065 #define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get
00066 #undef srand
00067 #define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init
00068 #undef random
00069 #define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get
00070 #undef sprintf
00071 #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
00072 #undef strcat
00073 #define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat
00074 #undef strncpy
00075 #define strncpy strncpy_is_forbidden_due_to_security_issues_use_av_strlcpy
00076 #undef exit
00077 #define exit exit_is_forbidden
00078 #undef printf
00079 #define printf please_use_av_log_instead_of_printf
00080 #undef fprintf
00081 #define fprintf please_use_av_log_instead_of_fprintf
00082 #undef puts
00083 #define puts please_use_av_log_instead_of_puts
00084 #undef perror
00085 #define perror please_use_av_log_instead_of_perror
00086 #undef strcasecmp
00087 #define strcasecmp please_use_av_strcasecmp
00088 #undef strncasecmp
00089 #define strncasecmp please_use_av_strncasecmp
00090
00091 #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\
00092 {\
00093 p = av_malloc(size);\
00094 if (p == NULL && (size) != 0) {\
00095 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
00096 goto label;\
00097 }\
00098 }
00099
00100 #define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\
00101 {\
00102 p = av_mallocz(size);\
00103 if (p == NULL && (size) != 0) {\
00104 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
00105 goto label;\
00106 }\
00107 }
00108
00109 #include "libm.h"
00110
00116 #if CONFIG_SMALL
00117 # define NULL_IF_CONFIG_SMALL(x) NULL
00118 #else
00119 # define NULL_IF_CONFIG_SMALL(x) x
00120 #endif
00121
00139 #if HAVE_SYMVER_ASM_LABEL
00140 # define FF_SYMVER(type, name, args, ver) \
00141 type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \
00142 type ff_##name args
00143 #elif HAVE_SYMVER_GNU_ASM
00144 # define FF_SYMVER(type, name, args, ver) \
00145 __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \
00146 type ff_##name args; \
00147 type ff_##name args
00148 #endif
00149
00155 #if HAVE_THREADS
00156 # define ONLY_IF_THREADS_ENABLED(x) x
00157 #else
00158 # define ONLY_IF_THREADS_ENABLED(x) NULL
00159 #endif
00160
00161 #if HAVE_MMX_INLINE
00167 static av_always_inline void emms_c(void)
00168 {
00169 if(av_get_cpu_flags() & AV_CPU_FLAG_MMX)
00170 __asm__ volatile ("emms" ::: "memory");
00171 }
00172 #elif HAVE_MMX && HAVE_MM_EMPTY
00173 # include <mmintrin.h>
00174 # define emms_c _mm_empty
00175 #else
00176 # define emms_c()
00177 #endif
00178
00179 #endif