~ubuntu-branches/ubuntu/utopic/ffmpeg-debian/utopic

« back to all changes in this revision

Viewing changes to libavutil/internal.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-01-20 09:20:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120092053-izz63p40hc98qfgp
Tags: 3:0.svn20090119-1ubuntu1
* merge from debian. LP: #318501
* new version fixes CVE-2008-3230, LP: #253767

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <stdint.h>
34
34
#include <stddef.h>
35
35
#include <assert.h>
 
36
#include "common.h"
 
37
#include "timer.h"
36
38
 
37
39
#ifndef attribute_align_arg
38
 
#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1)
 
40
#if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,2)
39
41
#    define attribute_align_arg __attribute__((force_align_arg_pointer))
40
42
#else
41
43
#    define attribute_align_arg
43
45
#endif
44
46
 
45
47
#ifndef attribute_used
46
 
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
 
48
#if AV_GCC_VERSION_AT_LEAST(3,1)
47
49
#    define attribute_used __attribute__((used))
48
50
#else
49
51
#    define attribute_used
95
97
#endif
96
98
 
97
99
#include "config.h"
98
 
#include "intreadwrite.h"
99
 
#include "bswap.h"
100
100
 
101
101
#ifndef offsetof
102
102
#    define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F))
103
103
#endif
104
104
 
105
105
// Use rip-relative addressing if compiling PIC code on x86-64.
106
 
#if defined(ARCH_X86_64) && defined(PIC)
 
106
#if ARCH_X86_64 && defined(PIC)
107
107
#    define LOCAL_MANGLE(a) #a "(%%rip)"
108
108
#else
109
109
#    define LOCAL_MANGLE(a) #a
126
126
 
127
127
extern const uint32_t ff_inverse[256];
128
128
 
129
 
#if defined(ARCH_X86)
 
129
#if ARCH_X86
130
130
#    define FASTDIV(a,b) \
131
131
    ({\
132
132
        int ret,dmy;\
137
137
            );\
138
138
        ret;\
139
139
    })
140
 
#elif defined(HAVE_ARMV6)
 
140
#elif HAVE_ARMV6
141
141
static inline av_const int FASTDIV(int a, int b)
142
142
{
143
143
    int r, t;
148
148
                     : "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse));
149
149
    return r;
150
150
}
151
 
#elif defined(ARCH_ARMV4L)
152
 
#    define FASTDIV(a,b) \
153
 
    ({\
154
 
        int ret,dmy;\
155
 
        __asm__ volatile(\
156
 
            "umull %1, %0, %2, %3"\
157
 
            :"=&r"(ret),"=&r"(dmy)\
158
 
            :"r"(a),"r"(ff_inverse[b])\
159
 
            );\
160
 
        ret;\
161
 
    })
162
 
#elif defined(CONFIG_FASTDIV)
 
151
#elif ARCH_ARM
 
152
static inline av_const int FASTDIV(int a, int b)
 
153
{
 
154
    int r, t;
 
155
    __asm__ volatile ("umull %1, %0, %2, %3"
 
156
                      : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b]));
 
157
    return r;
 
158
}
 
159
#elif CONFIG_FASTDIV
163
160
#    define FASTDIV(a,b)   ((uint32_t)((((uint64_t)a)*ff_inverse[b])>>32))
164
161
#else
165
162
#    define FASTDIV(a,b)   ((a)/(b))
175
172
 
176
173
    if(a<255) return (ff_sqrt_tab[a+1]-1)>>4;
177
174
    else if(a<(1<<12)) b= ff_sqrt_tab[a>>4 ]>>2;
178
 
#ifndef CONFIG_SMALL
 
175
#if !CONFIG_SMALL
179
176
    else if(a<(1<<14)) b= ff_sqrt_tab[a>>6 ]>>1;
180
177
    else if(a<(1<<16)) b= ff_sqrt_tab[a>>8 ]   ;
181
178
#endif
189
186
    return b - (a<b*b);
190
187
}
191
188
 
192
 
#if defined(ARCH_X86)
 
189
#if ARCH_X86
193
190
#define MASK_ABS(mask, level)\
194
191
            __asm__ volatile(\
195
192
                "cltd                   \n\t"\
203
200
            level= (level^mask)-mask;
204
201
#endif
205
202
 
206
 
#ifdef HAVE_CMOV
 
203
#if HAVE_CMOV
207
204
#define COPY3_IF_LT(x,y,a,b,c,d)\
208
205
__asm__ volatile (\
209
206
    "cmpl %0, %3        \n\t"\
263
260
    }\
264
261
}
265
262
 
266
 
#ifndef HAVE_LLRINT
 
263
#if !HAVE_LLRINT
267
264
static av_always_inline av_const long long llrint(double x)
268
265
{
269
266
    return rint(x);
270
267
}
271
268
#endif /* HAVE_LLRINT */
272
269
 
273
 
#ifndef HAVE_LRINT
 
270
#if !HAVE_LRINT
274
271
static av_always_inline av_const long int lrint(double x)
275
272
{
276
273
    return rint(x);
277
274
}
278
275
#endif /* HAVE_LRINT */
279
276
 
280
 
#ifndef HAVE_LRINTF
 
277
#if !HAVE_LRINTF
281
278
static av_always_inline av_const long int lrintf(float x)
282
279
{
283
280
    return (int)(rint(x));
284
281
}
285
282
#endif /* HAVE_LRINTF */
286
283
 
287
 
#ifndef HAVE_ROUND
 
284
#if !HAVE_ROUND
288
285
static av_always_inline av_const double round(double x)
289
286
{
290
287
    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
291
288
}
292
289
#endif /* HAVE_ROUND */
293
290
 
294
 
#ifndef HAVE_ROUNDF
 
291
#if !HAVE_ROUNDF
295
292
static av_always_inline av_const float roundf(float x)
296
293
{
297
294
    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
298
295
}
299
296
#endif /* HAVE_ROUNDF */
300
297
 
 
298
#if !HAVE_TRUNCF
 
299
static av_always_inline av_const float truncf(float x)
 
300
{
 
301
    return (x > 0) ? floor(x) : ceil(x);
 
302
}
 
303
#endif /* HAVE_TRUNCF */
 
304
 
 
305
/**
 
306
 * Returns NULL if CONFIG_SMALL is true otherwise the argument
 
307
 * without modifications, used to disable the definition of strings
 
308
 * (for example AVCodec long_names).
 
309
 */
 
310
#if CONFIG_SMALL
 
311
#   define NULL_IF_CONFIG_SMALL(x) NULL
 
312
#else
 
313
#   define NULL_IF_CONFIG_SMALL(x) x
 
314
#endif
 
315
 
301
316
#endif /* AVUTIL_INTERNAL_H */