diff libavutil/internal.h @ 2:897f711a7157

rearrange to work with autoconf
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Tue, 25 Sep 2012 15:55:33 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libavutil/internal.h	Tue Sep 25 15:55:33 2012 +0200
     1.3 @@ -0,0 +1,168 @@
     1.4 +/*
     1.5 + * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
     1.6 + *
     1.7 + * This file is part of FFmpeg.
     1.8 + *
     1.9 + * FFmpeg is free software; you can redistribute it and/or
    1.10 + * modify it under the terms of the GNU Lesser General Public
    1.11 + * License as published by the Free Software Foundation; either
    1.12 + * version 2.1 of the License, or (at your option) any later version.
    1.13 + *
    1.14 + * FFmpeg is distributed in the hope that it will be useful,
    1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.17 + * Lesser General Public License for more details.
    1.18 + *
    1.19 + * You should have received a copy of the GNU Lesser General Public
    1.20 + * License along with FFmpeg; if not, write to the Free Software
    1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    1.22 + */
    1.23 +
    1.24 +/**
    1.25 + * @file
    1.26 + * common internal API header
    1.27 + */
    1.28 +
    1.29 +#ifndef AVUTIL_INTERNAL_H
    1.30 +#define AVUTIL_INTERNAL_H
    1.31 +
    1.32 +#if !defined(DEBUG) && !defined(NDEBUG)
    1.33 +#    define NDEBUG
    1.34 +#endif
    1.35 +
    1.36 +#include <limits.h>
    1.37 +#include <stdint.h>
    1.38 +#include <stddef.h>
    1.39 +#include <assert.h>
    1.40 +#include "config.h"
    1.41 +#include "attributes.h"
    1.42 +#include "timer.h"
    1.43 +
    1.44 +
    1.45 +
    1.46 +#ifndef INT16_MIN
    1.47 +#define INT16_MIN       (-0x7fff - 1)
    1.48 +#endif
    1.49 +
    1.50 +#ifndef INT16_MAX
    1.51 +#define INT16_MAX       0x7fff
    1.52 +#endif
    1.53 +
    1.54 +#ifndef INT32_MIN
    1.55 +#define INT32_MIN       (-0x7fffffff - 1)
    1.56 +#endif
    1.57 +
    1.58 +#ifndef INT32_MAX
    1.59 +#define INT32_MAX       0x7fffffff
    1.60 +#endif
    1.61 +
    1.62 +#ifndef UINT32_MAX
    1.63 +#define UINT32_MAX      0xffffffff
    1.64 +#endif
    1.65 +
    1.66 +#ifndef INT64_MIN
    1.67 +#define INT64_MIN       (-0x7fffffffffffffffLL - 1)
    1.68 +#endif
    1.69 +
    1.70 +#ifndef INT64_MAX
    1.71 +#define INT64_MAX INT64_C(9223372036854775807)
    1.72 +#endif
    1.73 +
    1.74 +#ifndef UINT64_MAX
    1.75 +#define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF)
    1.76 +#endif
    1.77 +
    1.78 +#ifndef INT_BIT
    1.79 +#    define INT_BIT (CHAR_BIT * sizeof(int))
    1.80 +#endif
    1.81 +
    1.82 +#ifndef offsetof
    1.83 +#    define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F))
    1.84 +#endif
    1.85 +
    1.86 +/* Use to export labels from asm. */
    1.87 +#define LABEL_MANGLE(a) #a
    1.88 +#define LOCAL_MANGLE(a) #a
    1.89 +#define MANGLE(a) #a
    1.90 +
    1.91 +// Use rip-relative addressing if compiling PIC code on x86-64.
    1.92 +// #if ARCH_X86_64 && defined(PIC)
    1.93 +// #    define LOCAL_MANGLE(a) #a "(%%rip)"
    1.94 +// #else
    1.95 +// #    define LOCAL_MANGLE(a) #a
    1.96 +// #endif
    1.97 +// 
    1.98 +// #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
    1.99 +
   1.100 +/* debug stuff */
   1.101 +
   1.102 +/* dprintf macros */
   1.103 +#ifdef DEBUG
   1.104 +#    define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
   1.105 +#else
   1.106 +#    define dprintf(pctx, ...)
   1.107 +#endif
   1.108 +
   1.109 +#define av_abort()      do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
   1.110 +
   1.111 +/* math */
   1.112 +
   1.113 +
   1.114 +/* avoid usage of dangerous/inappropriate system functions */
   1.115 +// #undef  malloc
   1.116 +// #define malloc please_use_av_malloc
   1.117 +// #undef  free
   1.118 +// #define free please_use_av_free
   1.119 +#undef  realloc
   1.120 +#define realloc please_use_av_realloc
   1.121 +#undef  time
   1.122 +#define time time_is_forbidden_due_to_security_issues
   1.123 +#undef  rand
   1.124 +#define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get
   1.125 +#undef  srand
   1.126 +#define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init
   1.127 +#undef  random
   1.128 +#define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get
   1.129 +#undef  sprintf
   1.130 +#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
   1.131 +//#undef  exit
   1.132 +//#define exit exit_is_forbidden
   1.133 +#ifndef LIBAVFORMAT_BUILD
   1.134 +
   1.135 +#undef  puts
   1.136 +#define puts please_use_av_log_instead_of_puts
   1.137 +#undef  perror
   1.138 +#define perror please_use_av_log_instead_of_perror
   1.139 +#endif
   1.140 +
   1.141 +#define FF_ALLOC_OR_GOTO(p, size, label)\
   1.142 +{\
   1.143 +    p = av_malloc(size);\
   1.144 +    if (p == NULL && (size) != 0) {\
   1.145 +        av_log(AV_LOG_ERROR, "Cannot allocate memory.\n");\
   1.146 +        goto label;\
   1.147 +    }\
   1.148 +}
   1.149 +
   1.150 +#define FF_ALLOCZ_OR_GOTO(p, size, label)\
   1.151 +{\
   1.152 +    p = av_mallocz(size);\
   1.153 +    if (p == NULL && (size) != 0) {\
   1.154 +        av_log(AV_LOG_ERROR, "Cannot allocate memory.\n");\
   1.155 +        goto label;\
   1.156 +    }\
   1.157 +}
   1.158 +
   1.159 +
   1.160 +/**
   1.161 + * Returns NULL if CONFIG_SMALL is true, otherwise the argument
   1.162 + * without modification. Used to disable the definition of strings
   1.163 + * (for example AVCodec long_names).
   1.164 + */
   1.165 +#if CONFIG_SMALL
   1.166 +#   define NULL_IF_CONFIG_SMALL(x) NULL
   1.167 +#else
   1.168 +#   define NULL_IF_CONFIG_SMALL(x) x
   1.169 +#endif
   1.170 +
   1.171 +#endif /* AVUTIL_INTERNAL_H */