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 struct AVDictionary {
00044 int count;
00045 AVDictionaryEntry *elems;
00046 };
00047
00048 #ifndef attribute_align_arg
00049 #if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2)
00050 # define attribute_align_arg __attribute__((force_align_arg_pointer))
00051 #else
00052 # define attribute_align_arg
00053 #endif
00054 #endif
00055
00056 #ifndef INT16_MIN
00057 #define INT16_MIN (-0x7fff - 1)
00058 #endif
00059
00060 #ifndef INT16_MAX
00061 #define INT16_MAX 0x7fff
00062 #endif
00063
00064 #ifndef INT32_MIN
00065 #define INT32_MIN (-0x7fffffff - 1)
00066 #endif
00067
00068 #ifndef INT32_MAX
00069 #define INT32_MAX 0x7fffffff
00070 #endif
00071
00072 #ifndef UINT32_MAX
00073 #define UINT32_MAX 0xffffffff
00074 #endif
00075
00076 #ifndef INT64_MIN
00077 #define INT64_MIN (-0x7fffffffffffffffLL - 1)
00078 #endif
00079
00080 #ifndef INT64_MAX
00081 #define INT64_MAX INT64_C(9223372036854775807)
00082 #endif
00083
00084 #ifndef UINT64_MAX
00085 #define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF)
00086 #endif
00087
00088 #ifndef INT_BIT
00089 # define INT_BIT (CHAR_BIT * sizeof(int))
00090 #endif
00091
00092 #ifndef offsetof
00093 # define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F))
00094 #endif
00095
00096
00097 #define LABEL_MANGLE(a) EXTERN_PREFIX #a
00098
00099
00100 #if ARCH_X86_64 && defined(PIC)
00101 # define LOCAL_MANGLE(a) #a "(%%rip)"
00102 #else
00103 # define LOCAL_MANGLE(a) #a
00104 #endif
00105
00106 #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
00107
00108
00109
00110 #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
00111
00112
00113
00114 #if ARCH_X86
00115 #define MASK_ABS(mask, level)\
00116 __asm__ volatile(\
00117 "cltd \n\t"\
00118 "xorl %1, %0 \n\t"\
00119 "subl %1, %0 \n\t"\
00120 : "+a" (level), "=&d" (mask)\
00121 );
00122 #else
00123 #define MASK_ABS(mask, level)\
00124 mask = level >> 31;\
00125 level = (level ^ mask) - mask;
00126 #endif
00127
00128
00129 #undef malloc
00130 #define malloc please_use_av_malloc
00131 #undef free
00132 #define free please_use_av_free
00133 #undef realloc
00134 #define realloc please_use_av_realloc
00135 #undef time
00136 #define time time_is_forbidden_due_to_security_issues
00137 #undef rand
00138 #define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get
00139 #undef srand
00140 #define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init
00141 #undef random
00142 #define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get
00143 #undef sprintf
00144 #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
00145 #undef strcat
00146 #define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat
00147 #undef strncpy
00148 #define strncpy strncpy_is_forbidden_due_to_security_issues_use_av_strlcpy
00149 #undef exit
00150 #define exit exit_is_forbidden
00151 #undef printf
00152 #define printf please_use_av_log_instead_of_printf
00153 #undef fprintf
00154 #define fprintf please_use_av_log_instead_of_fprintf
00155 #undef puts
00156 #define puts please_use_av_log_instead_of_puts
00157 #undef perror
00158 #define perror please_use_av_log_instead_of_perror
00159 #undef strcasecmp
00160 #define strcasecmp please_use_av_strcasecmp
00161 #undef strncasecmp
00162 #define strncasecmp please_use_av_strncasecmp
00163
00164 #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\
00165 {\
00166 p = av_malloc(size);\
00167 if (p == NULL && (size) != 0) {\
00168 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
00169 goto label;\
00170 }\
00171 }
00172
00173 #define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\
00174 {\
00175 p = av_mallocz(size);\
00176 if (p == NULL && (size) != 0) {\
00177 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
00178 goto label;\
00179 }\
00180 }
00181
00182 #include "libm.h"
00183
00189 #if CONFIG_SMALL
00190 # define NULL_IF_CONFIG_SMALL(x) NULL
00191 #else
00192 # define NULL_IF_CONFIG_SMALL(x) x
00193 #endif
00194
00212 #if HAVE_SYMVER_ASM_LABEL
00213 # define FF_SYMVER(type, name, args, ver) \
00214 type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \
00215 type ff_##name args
00216 #elif HAVE_SYMVER_GNU_ASM
00217 # define FF_SYMVER(type, name, args, ver) \
00218 __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \
00219 type ff_##name args; \
00220 type ff_##name args
00221 #endif
00222
00228 #if HAVE_THREADS
00229 # define ONLY_IF_THREADS_ENABLED(x) x
00230 #else
00231 # define ONLY_IF_THREADS_ENABLED(x) NULL
00232 #endif
00233
00234 #if HAVE_MMX
00240 static av_always_inline void emms_c(void)
00241 {
00242 if(av_get_cpu_flags() & AV_CPU_FLAG_MMX)
00243 __asm__ volatile ("emms" ::: "memory");
00244 }
00245 #else
00246 #define emms_c()
00247 #endif
00248
00249 #endif