annotate common.h @ 64:57b9709f6455 libavutil

Remove old MSVC remnants.
author diego
date Tue, 11 Jul 2006 14:15:56 +0000
parents e5a312df8a07
children 2840042b3f5d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
1 /**
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
2 * @file common.h
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
3 * common internal api header.
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
4 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
5
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
6 #ifndef COMMON_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
7 #define COMMON_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
8
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
9 #ifndef M_PI
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
10 #define M_PI 3.14159265358979323846
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
11 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
12
57
4d00c7c7d07d Make ffmpeg better support pic - from Diego Petten <flameeyes@gentoo.org>
lu_zero
parents: 55
diff changeset
13 #if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC)
4d00c7c7d07d Make ffmpeg better support pic - from Diego Petten <flameeyes@gentoo.org>
lu_zero
parents: 55
diff changeset
14 # define PIC
4d00c7c7d07d Make ffmpeg better support pic - from Diego Petten <flameeyes@gentoo.org>
lu_zero
parents: 55
diff changeset
15 #endif
4d00c7c7d07d Make ffmpeg better support pic - from Diego Petten <flameeyes@gentoo.org>
lu_zero
parents: 55
diff changeset
16
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
17 #ifdef HAVE_AV_CONFIG_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
18 /* only include the following when compiling package */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
19 # include "config.h"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
20
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
21 # include <stdlib.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
22 # include <stdio.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
23 # include <string.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
24 # include <ctype.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
25 # include <limits.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
26 # ifndef __BEOS__
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
27 # include <errno.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
28 # else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
29 # include "berrno.h"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
30 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
31 # include <math.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
32
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
33 # ifndef ENODATA
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
34 # define ENODATA 61
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
35 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
36
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
37 #include <stddef.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
38 #ifndef offsetof
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
39 # define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
40 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
41
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
42 #define AVOPTION_CODEC_BOOL(name, help, field) \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
43 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_BOOL }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
44 #define AVOPTION_CODEC_DOUBLE(name, help, field, minv, maxv, defval) \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
45 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_DOUBLE, minv, maxv, defval }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
46 #define AVOPTION_CODEC_FLAG(name, help, field, flag, defval) \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
47 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_FLAG, flag, 0, defval }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
48 #define AVOPTION_CODEC_INT(name, help, field, minv, maxv, defval) \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
49 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_INT, minv, maxv, defval }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
50 #define AVOPTION_CODEC_STRING(name, help, field, str, val) \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
51 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_STRING, .defval = val, .defstr = str }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
52 #define AVOPTION_CODEC_RCOVERRIDE(name, help, field) \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
53 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_RCOVERRIDE, .defval = 0, .defstr = NULL }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
54 #define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
55 #define AVOPTION_END() AVOPTION_SUB(NULL)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
56
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
57 #endif /* HAVE_AV_CONFIG_H */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
58
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
59 /* Suppress restrict if it was not defined in config.h. */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
60 #ifndef restrict
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
61 # define restrict
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
62 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
63
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
64 #ifndef always_inline
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
65 #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
66 # define always_inline __attribute__((always_inline)) inline
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
67 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
68 # define always_inline inline
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
69 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
70 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
71
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
72 #ifndef attribute_used
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
73 #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
74 # define attribute_used __attribute__((used))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
75 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
76 # define attribute_used
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
77 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
78 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
79
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
80 #ifndef attribute_unused
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
81 #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
82 # define attribute_unused __attribute__((unused))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
83 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
84 # define attribute_unused
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
85 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
86 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
87
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
88 #ifndef EMULATE_INTTYPES
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
89 # include <inttypes.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
90 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
91 typedef signed char int8_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
92 typedef signed short int16_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
93 typedef signed int int32_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
94 typedef unsigned char uint8_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
95 typedef unsigned short uint16_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
96 typedef unsigned int uint32_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
97
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
98 # ifdef CONFIG_WIN32
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
99 typedef signed __int64 int64_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
100 typedef unsigned __int64 uint64_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
101 # else /* other OS */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
102 typedef signed long long int64_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
103 typedef unsigned long long uint64_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
104 # endif /* other OS */
3
d4936ecaba90 Wrong comment after #endif.
diego
parents: 0
diff changeset
105 #endif /* EMULATE_INTTYPES */
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
106
11
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
107 #ifndef PRId64
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
108 #define PRId64 "lld"
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
109 #endif
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
110
8
2dd915c714fa fix for systems not defining PRIu64, not everyone knows C99.
mmu_man
parents: 7
diff changeset
111 #ifndef PRIu64
11
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
112 #define PRIu64 "llu"
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
113 #endif
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
114
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
115 #ifndef PRIx64
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
116 #define PRIx64 "llx"
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
117 #endif
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
118
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
119 #ifndef PRId32
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
120 #define PRId32 "d"
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
121 #endif
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
122
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
123 #ifndef PRIdFAST16
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
124 #define PRIdFAST16 PRId32
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
125 #endif
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
126
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
127 #ifndef PRIdFAST32
b5bd7d00de0f Add some more PRIfooNN crap so it builds again here. Why can't ppl add defaults when they use such things ?
mmu_man
parents: 10
diff changeset
128 #define PRIdFAST32 PRId32
8
2dd915c714fa fix for systems not defining PRIu64, not everyone knows C99.
mmu_man
parents: 7
diff changeset
129 #endif
2dd915c714fa fix for systems not defining PRIu64, not everyone knows C99.
mmu_man
parents: 7
diff changeset
130
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
131 #ifndef INT16_MIN
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
132 #define INT16_MIN (-0x7fff-1)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
133 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
134
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
135 #ifndef INT16_MAX
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
136 #define INT16_MAX 0x7fff
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
137 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
138
33
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
139 #ifndef INT32_MIN
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
140 #define INT32_MIN (-0x7fffffff-1)
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
141 #endif
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
142
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
143 #ifndef INT32_MAX
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
144 #define INT32_MAX 0x7fffffff
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
145 #endif
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
146
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
147 #ifndef UINT32_MAX
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
148 #define UINT32_MAX 0xffffffff
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
149 #endif
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
150
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
151 #ifndef INT64_MIN
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
152 #define INT64_MIN (-0x7fffffffffffffffLL-1)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
153 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
154
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
155 #ifndef INT64_MAX
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
156 #define INT64_MAX int64_t_C(9223372036854775807)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
157 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
158
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
159 #ifndef UINT64_MAX
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
160 #define UINT64_MAX uint64_t_C(0xFFFFFFFFFFFFFFFF)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
161 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
162
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
163 #ifdef EMULATE_FAST_INT
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
164 typedef signed char int_fast8_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
165 typedef signed int int_fast16_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
166 typedef signed int int_fast32_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
167 typedef unsigned char uint_fast8_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
168 typedef unsigned int uint_fast16_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
169 typedef unsigned int uint_fast32_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
170 typedef uint64_t uint_fast64_t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
171 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
172
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
173 #ifndef INT_BIT
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
174 # if INT_MAX != 2147483647
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
175 # define INT_BIT 64
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
176 # else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
177 # define INT_BIT 32
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
178 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
179 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
180
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
181 #ifdef CONFIG_WIN32
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
182
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
183 /* windows */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
184
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
185 # if !defined(__MINGW32__) && !defined(__CYGWIN__)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
186 # define int64_t_C(c) (c ## i64)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
187 # define uint64_t_C(c) (c ## i64)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
188
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
189 # ifdef HAVE_AV_CONFIG_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
190 # define inline __inline
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
191 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
192
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
193 # else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
194 # define int64_t_C(c) (c ## LL)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
195 # define uint64_t_C(c) (c ## ULL)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
196 # endif /* __MINGW32__ */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
197
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
198 # ifdef HAVE_AV_CONFIG_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
199 # ifdef _DEBUG
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
200 # define DEBUG
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
201 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
202
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
203 # define snprintf _snprintf
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
204 # define vsnprintf _vsnprintf
19
2a55eb7ca57b WinCE cross-compilation support
diego
parents: 13
diff changeset
205
2a55eb7ca57b WinCE cross-compilation support
diego
parents: 13
diff changeset
206 # ifdef CONFIG_WINCE
2a55eb7ca57b WinCE cross-compilation support
diego
parents: 13
diff changeset
207 # define perror(a)
2a55eb7ca57b WinCE cross-compilation support
diego
parents: 13
diff changeset
208 # endif
2a55eb7ca57b WinCE cross-compilation support
diego
parents: 13
diff changeset
209
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
210 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
211
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
212 /* CONFIG_WIN32 end */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
213 #elif defined (CONFIG_OS2)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
214 /* OS/2 EMX */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
215
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
216 #ifndef int64_t_C
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
217 #define int64_t_C(c) (c ## LL)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
218 #define uint64_t_C(c) (c ## ULL)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
219 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
220
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
221 #ifdef HAVE_AV_CONFIG_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
222
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
223 #ifdef USE_FASTMEMCPY
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
224 #include "fastmemcpy.h"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
225 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
226
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
227 #include <float.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
228
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
229 #endif /* HAVE_AV_CONFIG_H */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
230
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
231 /* CONFIG_OS2 end */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
232 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
233
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
234 /* unix */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
235
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
236 #ifndef int64_t_C
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
237 #define int64_t_C(c) (c ## LL)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
238 #define uint64_t_C(c) (c ## ULL)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
239 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
240
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
241 #ifdef HAVE_AV_CONFIG_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
242
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
243 # ifdef USE_FASTMEMCPY
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
244 # include "fastmemcpy.h"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
245 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
246 # endif /* HAVE_AV_CONFIG_H */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
247
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
248 #endif /* !CONFIG_WIN32 && !CONFIG_OS2 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
249
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
250 #ifdef HAVE_AV_CONFIG_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
251
22
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
252 #if defined(__MINGW32__) && !defined(BUILD_AVUTIL) && defined(BUILD_SHARED_AV)
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
253 # define FF_IMPORT_ATTR __declspec(dllimport)
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
254 #else
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
255 # define FF_IMPORT_ATTR
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
256 #endif
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
257
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
258
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
259 # include "bswap.h"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
260
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
261 // Use rip-relative addressing if compiling PIC code on x86-64.
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
262 # if defined(__MINGW32__) || defined(__CYGWIN__) || \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
263 defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
264 # if defined(ARCH_X86_64) && defined(PIC)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
265 # define MANGLE(a) "_" #a"(%%rip)"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
266 # else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
267 # define MANGLE(a) "_" #a
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
268 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
269 # else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
270 # if defined(ARCH_X86_64) && defined(PIC)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
271 # define MANGLE(a) #a"(%%rip)"
31
7b1170d0da89 Proper mangling information for symbols in OS X Mach-O shared objects.
diego
parents: 22
diff changeset
272 # elif defined(CONFIG_DARWIN)
7b1170d0da89 Proper mangling information for symbols in OS X Mach-O shared objects.
diego
parents: 22
diff changeset
273 # define MANGLE(a) "_" #a
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
274 # else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
275 # define MANGLE(a) #a
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
276 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
277 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
278
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
279 /* debug stuff */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
280
44
96a4efa91a4d make sure NDEBUG is not defined already before defining it
gpoirier
parents: 39
diff changeset
281 # if !defined(DEBUG) && !defined(NDEBUG)
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
282 # define NDEBUG
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
283 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
284 # include <assert.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
285
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
286 /* dprintf macros */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
287 # ifdef DEBUG
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
288 # define dprintf(fmt,...) av_log(NULL, AV_LOG_DEBUG, fmt, __VA_ARGS__)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
289 # else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
290 # define dprintf(fmt,...)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
291 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
292
19
2a55eb7ca57b WinCE cross-compilation support
diego
parents: 13
diff changeset
293 # ifdef CONFIG_WINCE
2a55eb7ca57b WinCE cross-compilation support
diego
parents: 13
diff changeset
294 # define abort()
2a55eb7ca57b WinCE cross-compilation support
diego
parents: 13
diff changeset
295 # endif
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
296
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
297 # define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
298
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
299 //rounded divison & shift
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
300 #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
301 /* assume b>0 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
302 #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
303 #define ABS(a) ((a) >= 0 ? (a) : (-(a)))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
304
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
305 #define FFMAX(a,b) ((a) > (b) ? (a) : (b))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
306 #define FFMIN(a,b) ((a) > (b) ? (b) : (a))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
307
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
308 extern const uint32_t inverse[256];
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
309
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
310 #if defined(ARCH_X86) || defined(ARCH_X86_64)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
311 # define FASTDIV(a,b) \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
312 ({\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
313 int ret,dmy;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
314 asm volatile(\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
315 "mull %3"\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
316 :"=d"(ret),"=a"(dmy)\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
317 :"1"(a),"g"(inverse[b])\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
318 );\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
319 ret;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
320 })
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
321 #elif defined(CONFIG_FASTDIV)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
322 # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*inverse[b])>>32))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
323 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
324 # define FASTDIV(a,b) ((a)/(b))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
325 #endif
12
ce8f9f4390c3 COSMETICS: Remove all trailing whitespace.
diego
parents: 11
diff changeset
326
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
327 /* misc math functions */
22
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
328 extern FF_IMPORT_ATTR const uint8_t ff_log2_tab[256];
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
329
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
330 static inline int av_log2(unsigned int v)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
331 {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
332 int n;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
333
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
334 n = 0;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
335 if (v & 0xffff0000) {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
336 v >>= 16;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
337 n += 16;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
338 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
339 if (v & 0xff00) {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
340 v >>= 8;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
341 n += 8;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
342 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
343 n += ff_log2_tab[v];
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
344
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
345 return n;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
346 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
347
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
348 static inline int av_log2_16bit(unsigned int v)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
349 {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
350 int n;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
351
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
352 n = 0;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
353 if (v & 0xff00) {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
354 v >>= 8;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
355 n += 8;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
356 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
357 n += ff_log2_tab[v];
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
358
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
359 return n;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
360 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
361
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
362 /* median of 3 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
363 static inline int mid_pred(int a, int b, int c)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
364 {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
365 #if 0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
366 int t= (a-b)&((a-b)>>31);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
367 a-=t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
368 b+=t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
369 b-= (b-c)&((b-c)>>31);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
370 b+= (a-b)&((a-b)>>31);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
371
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
372 return b;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
373 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
374 if(a>b){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
375 if(c>b){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
376 if(c>a) b=a;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
377 else b=c;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
378 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
379 }else{
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
380 if(b>c){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
381 if(c>a) b=c;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
382 else b=a;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
383 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
384 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
385 return b;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
386 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
387 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
388
39
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
389 /**
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
390 * clip a signed integer value into the amin-amax range
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
391 * @param a value to clip
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
392 * @param amin minimum value of the clip range
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
393 * @param amax maximum value of the clip range
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
394 * @return cliped value
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
395 */
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
396 static inline int clip(int a, int amin, int amax)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
397 {
63
e5a312df8a07 cosmetic
michael
parents: 62
diff changeset
398 if (a < amin) return amin;
e5a312df8a07 cosmetic
michael
parents: 62
diff changeset
399 else if (a > amax) return amax;
e5a312df8a07 cosmetic
michael
parents: 62
diff changeset
400 else return a;
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
401 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
402
39
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
403 /**
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
404 * clip a signed integer value into the 0-255 range
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
405 * @param a value to clip
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
406 * @return cliped value
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
407 */
38
e7df68ba31a2 clip_uint8 should return an uint8_t instead of an int (patch by Panagiotis Issaris < takis.issaris _at_ uhasselt.be >)
aurel
parents: 33
diff changeset
408 static inline uint8_t clip_uint8(int a)
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
409 {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
410 if (a&(~255)) return (-a)>>31;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
411 else return a;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
412 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
413
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
414 /* math */
22
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
415 extern FF_IMPORT_ATTR const uint8_t ff_sqrt_tab[128];
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
416
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
417 int64_t ff_gcd(int64_t a, int64_t b);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
418
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
419 static inline int ff_sqrt(int a)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
420 {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
421 int ret=0;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
422 int s;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
423 int ret_sq=0;
12
ce8f9f4390c3 COSMETICS: Remove all trailing whitespace.
diego
parents: 11
diff changeset
424
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
425 if(a<128) return ff_sqrt_tab[a];
12
ce8f9f4390c3 COSMETICS: Remove all trailing whitespace.
diego
parents: 11
diff changeset
426
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
427 for(s=15; s>=0; s--){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
428 int b= ret_sq + (1<<(s*2)) + (ret<<s)*2;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
429 if(b<=a){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
430 ret_sq=b;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
431 ret+= 1<<s;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
432 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
433 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
434 return ret;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
435 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
436
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
437 /**
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
438 * converts fourcc string to int
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
439 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
440 static inline int ff_get_fourcc(const char *s){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
441 assert( strlen(s)==4 );
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
442
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
443 return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
444 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
445
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
446 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
447 #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
448
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
449
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
450 #if defined(ARCH_X86) || defined(ARCH_X86_64)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
451 #define MASK_ABS(mask, level)\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
452 asm volatile(\
13
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
453 "cdq \n\t"\
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
454 "xorl %1, %0 \n\t"\
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
455 "subl %1, %0 \n\t"\
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
456 : "+a" (level), "=&d" (mask)\
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
457 );
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
458 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
459 #define MASK_ABS(mask, level)\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
460 mask= level>>31;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
461 level= (level^mask)-mask;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
462 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
463
60
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
464 #define GET_UTF8(val, GET_BYTE, ERROR)\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
465 val= GET_BYTE;\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
466 {\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
467 int ones= 7 - av_log2(val ^ 255);\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
468 if(ones==1)\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
469 ERROR\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
470 val&= 127>>ones;\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
471 while(--ones > 0){\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
472 int tmp= GET_BYTE - 128;\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
473 if(tmp>>6)\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
474 ERROR\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
475 val= (val<<6) + tmp;\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
476 }\
bc66b55033ac moving utf8 reading function to libavutil
michael
parents: 57
diff changeset
477 }
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
478
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
479 #if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
480 #define COPY3_IF_LT(x,y,a,b,c,d)\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
481 asm volatile (\
13
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
482 "cmpl %0, %3 \n\t"\
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
483 "cmovl %3, %0 \n\t"\
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
484 "cmovl %4, %1 \n\t"\
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
485 "cmovl %5, %2 \n\t"\
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
486 : "+r" (x), "+r" (a), "+r" (c)\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
487 : "r" (y), "r" (b), "r" (d)\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
488 );
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
489 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
490 #define COPY3_IF_LT(x,y,a,b,c,d)\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
491 if((y)<(x)){\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
492 (x)=(y);\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
493 (a)=(b);\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
494 (c)=(d);\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
495 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
496 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
497
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
498 #if defined(ARCH_X86) || defined(ARCH_X86_64) || defined(ARCH_POWERPC)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
499 #if defined(ARCH_X86_64)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
500 static inline uint64_t read_time(void)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
501 {
13
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
502 uint64_t a, d;
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
503 asm volatile( "rdtsc\n\t"
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
504 : "=a" (a), "=d" (d)
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
505 );
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
506 return (d << 32) | (a & 0xffffffff);
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
507 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
508 #elif defined(ARCH_X86)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
509 static inline long long read_time(void)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
510 {
13
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
511 long long l;
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
512 asm volatile( "rdtsc\n\t"
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
513 : "=A" (l)
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
514 );
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
515 return l;
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
516 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
517 #else //FIXME check ppc64
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
518 static inline uint64_t read_time(void)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
519 {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
520 uint32_t tbu, tbl, temp;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
521
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
522 /* from section 2.2.1 of the 32-bit PowerPC PEM */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
523 __asm__ __volatile__(
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
524 "1:\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
525 "mftbu %2\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
526 "mftb %0\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
527 "mftbu %1\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
528 "cmpw %2,%1\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
529 "bne 1b\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
530 : "=r"(tbl), "=r"(tbu), "=r"(temp)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
531 :
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
532 : "cc");
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
533
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
534 return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
535 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
536 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
537
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
538 #define START_TIMER \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
539 uint64_t tend;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
540 uint64_t tstart= read_time();\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
541
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
542 #define STOP_TIMER(id) \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
543 tend= read_time();\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
544 {\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
545 static uint64_t tsum=0;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
546 static int tcount=0;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
547 static int tskip_count=0;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
548 if(tcount<2 || tend - tstart < 8*tsum/tcount){\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
549 tsum+= tend - tstart;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
550 tcount++;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
551 }else\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
552 tskip_count++;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
553 if(256*256*256*64%(tcount+tskip_count)==0){\
7
5ac9c20533c3 Fixed format specifier in STOP_TIMER macro.
al
parents: 4
diff changeset
554 av_log(NULL, AV_LOG_DEBUG, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
555 }\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
556 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
557 #else
12
ce8f9f4390c3 COSMETICS: Remove all trailing whitespace.
diego
parents: 11
diff changeset
558 #define START_TIMER
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
559 #define STOP_TIMER(id) {}
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
560 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
561
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
562 /* avoid usage of various functions */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
563 #define malloc please_use_av_malloc
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
564 #define free please_use_av_free
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
565 #define realloc please_use_av_realloc
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
566 #define time time_is_forbidden_due_to_security_issues
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
567 #define rand rand_is_forbidden_due_to_state_trashing
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
568 #define srand srand_is_forbidden_due_to_state_trashing
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
569 #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
570 #define strcat strcat_is_forbidden_due_to_security_issues_use_pstrcat
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
571 #if !(defined(LIBAVFORMAT_BUILD) || defined(_FRAMEHOOK_H))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
572 #define printf please_use_av_log
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
573 #define fprintf please_use_av_log
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
574 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
575
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
576 #define CHECKED_ALLOCZ(p, size)\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
577 {\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
578 p= av_mallocz(size);\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
579 if(p==NULL && (size)!=0){\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
580 perror("malloc");\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
581 goto fail;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
582 }\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
583 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
584
4
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
585 #ifndef HAVE_LRINTF
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
586 /* XXX: add ISOC specific test to avoid specific BSD testing. */
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
587 /* better than nothing implementation. */
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
588 /* btw, rintf() is existing on fbsd too -- alex */
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
589 static always_inline long int lrintf(float x)
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
590 {
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
591 #ifdef CONFIG_WIN32
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
592 # ifdef ARCH_X86
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
593 int32_t i;
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
594 asm volatile(
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
595 "fistpl %0\n\t"
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
596 : "=m" (i) : "t" (x) : "st"
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
597 );
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
598 return i;
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
599 # else
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
600 /* XXX: incorrect, but make it compile */
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
601 return (int)(x + (x < 0 ? -0.5 : 0.5));
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
602 # endif /* ARCH_X86 */
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
603 #else
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
604 return (int)(rint(x));
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
605 #endif /* CONFIG_WIN32 */
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
606 }
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
607 #else
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
608 #ifndef _ISOC9X_SOURCE
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
609 #define _ISOC9X_SOURCE
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
610 #endif
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
611 #include <math.h>
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
612 #endif /* HAVE_LRINTF */
26a00aee5eac Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents: 3
diff changeset
613
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
614 #endif /* HAVE_AV_CONFIG_H */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
615
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
616 #endif /* COMMON_H */