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