• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavutil/internal.h

Go to the documentation of this file.
00001 /*
00002  * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
00003  *
00004  * This file is part of FFmpeg.
00005  *
00006  * FFmpeg is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * FFmpeg is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with FFmpeg; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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 /* Use to export labels from asm. */
00097 #define LABEL_MANGLE(a) EXTERN_PREFIX #a
00098 
00099 // Use rip-relative addressing if compiling PIC code on x86-64.
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 /* debug stuff */
00109 
00110 #define av_abort()      do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
00111 
00112 /* math */
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 /* avoid usage of dangerous/inappropriate system functions */
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 
00160 #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\
00161 {\
00162     p = av_malloc(size);\
00163     if (p == NULL && (size) != 0) {\
00164         av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
00165         goto label;\
00166     }\
00167 }
00168 
00169 #define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\
00170 {\
00171     p = av_mallocz(size);\
00172     if (p == NULL && (size) != 0) {\
00173         av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
00174         goto label;\
00175     }\
00176 }
00177 
00178 #include "libm.h"
00179 
00185 #if CONFIG_SMALL
00186 #   define NULL_IF_CONFIG_SMALL(x) NULL
00187 #else
00188 #   define NULL_IF_CONFIG_SMALL(x) x
00189 #endif
00190 
00208 #if HAVE_SYMVER_ASM_LABEL
00209 #   define FF_SYMVER(type, name, args, ver)                     \
00210     type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver);  \
00211     type ff_##name args
00212 #elif HAVE_SYMVER_GNU_ASM
00213 #   define FF_SYMVER(type, name, args, ver)                             \
00214     __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver);      \
00215     type ff_##name args;                                                \
00216     type ff_##name args
00217 #endif
00218 
00224 #if HAVE_THREADS
00225 #   define ONLY_IF_THREADS_ENABLED(x) x
00226 #else
00227 #   define ONLY_IF_THREADS_ENABLED(x) NULL
00228 #endif
00229 
00230 #if HAVE_MMX
00231 
00236 static av_always_inline void emms_c(void)
00237 {
00238     if(av_get_cpu_flags() & AV_CPU_FLAG_MMX)
00239         __asm__ volatile ("emms" ::: "memory");
00240 }
00241 #else /* HAVE_MMX */
00242 #define emms_c()
00243 #endif /* HAVE_MMX */
00244 
00245 #endif /* AVUTIL_INTERNAL_H */

Generated on Fri Feb 22 2013 07:24:27 for FFmpeg by  doxygen 1.7.1