• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • 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 
00041 #ifndef attribute_align_arg
00042 #if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,2)
00043 #    define attribute_align_arg __attribute__((force_align_arg_pointer))
00044 #else
00045 #    define attribute_align_arg
00046 #endif
00047 #endif
00048 
00049 #ifndef attribute_used
00050 #if AV_GCC_VERSION_AT_LEAST(3,1)
00051 #    define attribute_used __attribute__((used))
00052 #else
00053 #    define attribute_used
00054 #endif
00055 #endif
00056 
00057 #ifndef av_alias
00058 #if HAVE_ATTRIBUTE_MAY_ALIAS && (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(3,3)
00059 #   define av_alias __attribute__((may_alias))
00060 #else
00061 #   define av_alias
00062 #endif
00063 #endif
00064 
00065 #ifndef INT16_MIN
00066 #define INT16_MIN       (-0x7fff - 1)
00067 #endif
00068 
00069 #ifndef INT16_MAX
00070 #define INT16_MAX       0x7fff
00071 #endif
00072 
00073 #ifndef INT32_MIN
00074 #define INT32_MIN       (-0x7fffffff - 1)
00075 #endif
00076 
00077 #ifndef INT32_MAX
00078 #define INT32_MAX       0x7fffffff
00079 #endif
00080 
00081 #ifndef UINT32_MAX
00082 #define UINT32_MAX      0xffffffff
00083 #endif
00084 
00085 #ifndef INT64_MIN
00086 #define INT64_MIN       (-0x7fffffffffffffffLL - 1)
00087 #endif
00088 
00089 #ifndef INT64_MAX
00090 #define INT64_MAX INT64_C(9223372036854775807)
00091 #endif
00092 
00093 #ifndef UINT64_MAX
00094 #define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF)
00095 #endif
00096 
00097 #ifndef INT_BIT
00098 #    define INT_BIT (CHAR_BIT * sizeof(int))
00099 #endif
00100 
00101 #ifndef offsetof
00102 #    define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F))
00103 #endif
00104 
00105 /* Use to export labels from asm. */
00106 #define LABEL_MANGLE(a) EXTERN_PREFIX #a
00107 
00108 // Use rip-relative addressing if compiling PIC code on x86-64.
00109 #if ARCH_X86_64 && defined(PIC)
00110 #    define LOCAL_MANGLE(a) #a "(%%rip)"
00111 #else
00112 #    define LOCAL_MANGLE(a) #a
00113 #endif
00114 
00115 #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
00116 
00117 /* debug stuff */
00118 
00119 /* dprintf macros */
00120 #ifdef DEBUG
00121 #    define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
00122 #else
00123 #    define dprintf(pctx, ...)
00124 #endif
00125 
00126 #define av_abort()      do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
00127 
00128 /* math */
00129 
00130 #if ARCH_X86
00131 #define MASK_ABS(mask, level)\
00132             __asm__ volatile(\
00133                 "cltd                   \n\t"\
00134                 "xorl %1, %0            \n\t"\
00135                 "subl %1, %0            \n\t"\
00136                 : "+a" (level), "=&d" (mask)\
00137             );
00138 #else
00139 #define MASK_ABS(mask, level)\
00140             mask  = level >> 31;\
00141             level = (level ^ mask) - mask;
00142 #endif
00143 
00144 /* avoid usage of dangerous/inappropriate system functions */
00145 #undef  malloc
00146 #define malloc please_use_av_malloc
00147 #undef  free
00148 #define free please_use_av_free
00149 #undef  realloc
00150 #define realloc please_use_av_realloc
00151 #undef  time
00152 #define time time_is_forbidden_due_to_security_issues
00153 #undef  rand
00154 #define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get
00155 #undef  srand
00156 #define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init
00157 #undef  random
00158 #define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get
00159 #undef  sprintf
00160 #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
00161 #undef  strcat
00162 #define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat
00163 #undef  exit
00164 #define exit exit_is_forbidden
00165 #ifndef LIBAVFORMAT_BUILD
00166 #undef  printf
00167 #define printf please_use_av_log_instead_of_printf
00168 #undef  fprintf
00169 #define fprintf please_use_av_log_instead_of_fprintf
00170 #undef  puts
00171 #define puts please_use_av_log_instead_of_puts
00172 #undef  perror
00173 #define perror please_use_av_log_instead_of_perror
00174 #endif
00175 
00176 #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\
00177 {\
00178     p = av_malloc(size);\
00179     if (p == NULL && (size) != 0) {\
00180         av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
00181         goto label;\
00182     }\
00183 }
00184 
00185 #define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\
00186 {\
00187     p = av_mallocz(size);\
00188     if (p == NULL && (size) != 0) {\
00189         av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
00190         goto label;\
00191     }\
00192 }
00193 
00194 #include "libm.h"
00195 
00201 #if CONFIG_SMALL
00202 #   define NULL_IF_CONFIG_SMALL(x) NULL
00203 #else
00204 #   define NULL_IF_CONFIG_SMALL(x) x
00205 #endif
00206 
00207 #if HAVE_SYMVER_ASM_LABEL
00208 #   define FF_SYMVER(type, name, args, ver)                     \
00209     type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver);  \
00210     type ff_##name args
00211 #elif HAVE_SYMVER_GNU_ASM
00212 #   define FF_SYMVER(type, name, args, ver)                             \
00213     __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver);      \
00214     type ff_##name args;                                                \
00215     type ff_##name args
00216 #endif
00217 
00218 #endif /* AVUTIL_INTERNAL_H */

Generated on Fri Sep 16 2011 17:17:38 for FFmpeg by  doxygen 1.7.1