Mercurial > libavutil.hg
annotate common.h @ 75:09ed77540442 libavutil
indent
author | mru |
---|---|
date | Fri, 14 Jul 2006 00:28:16 +0000 |
parents | a298a8eae4f2 |
children | 624fc3ad183a |
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; |
71 | 97 typedef signed long long int64_t; |
98 typedef unsigned long long uint64_t; | |
3 | 99 #endif /* EMULATE_INTTYPES */ |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
100 |
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
|
101 #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
|
102 #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
|
103 #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
|
104 |
8
2dd915c714fa
fix for systems not defining PRIu64, not everyone knows C99.
mmu_man
parents:
7
diff
changeset
|
105 #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
|
106 #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
|
107 #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
|
108 |
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 #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
|
110 #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
|
111 #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
|
112 |
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 #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
|
114 #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
|
115 #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
|
116 |
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 #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
|
118 #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
|
119 #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
|
120 |
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 #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
|
122 #define PRIdFAST32 PRId32 |
8
2dd915c714fa
fix for systems not defining PRIu64, not everyone knows C99.
mmu_man
parents:
7
diff
changeset
|
123 #endif |
2dd915c714fa
fix for systems not defining PRIu64, not everyone knows C99.
mmu_man
parents:
7
diff
changeset
|
124 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
125 #ifndef INT16_MIN |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
126 #define INT16_MIN (-0x7fff-1) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
127 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
128 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
129 #ifndef INT16_MAX |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
130 #define INT16_MAX 0x7fff |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
131 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
132 |
33 | 133 #ifndef INT32_MIN |
134 #define INT32_MIN (-0x7fffffff-1) | |
135 #endif | |
136 | |
137 #ifndef INT32_MAX | |
138 #define INT32_MAX 0x7fffffff | |
139 #endif | |
140 | |
141 #ifndef UINT32_MAX | |
142 #define UINT32_MAX 0xffffffff | |
143 #endif | |
144 | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
145 #ifndef INT64_MIN |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
146 #define INT64_MIN (-0x7fffffffffffffffLL-1) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
147 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
148 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
149 #ifndef INT64_MAX |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
150 #define INT64_MAX int64_t_C(9223372036854775807) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
151 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
152 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
153 #ifndef UINT64_MAX |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
154 #define UINT64_MAX uint64_t_C(0xFFFFFFFFFFFFFFFF) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
155 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
156 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
157 #ifdef EMULATE_FAST_INT |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
158 typedef signed char int_fast8_t; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
159 typedef signed int int_fast16_t; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
160 typedef signed int int_fast32_t; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
161 typedef unsigned char uint_fast8_t; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
162 typedef unsigned int uint_fast16_t; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
163 typedef unsigned int uint_fast32_t; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
164 typedef uint64_t uint_fast64_t; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
165 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
166 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
167 #ifndef INT_BIT |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
168 # if INT_MAX != 2147483647 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
169 # define INT_BIT 64 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
170 # else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
171 # define INT_BIT 32 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
172 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
173 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
174 |
74 | 175 #ifndef int64_t_C |
176 #define int64_t_C(c) (c ## LL) | |
177 #define uint64_t_C(c) (c ## ULL) | |
178 #endif | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
179 |
74 | 180 #ifdef HAVE_AV_CONFIG_H |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
181 |
74 | 182 #ifdef __MINGW32__ |
75 | 183 # ifdef _DEBUG |
184 # define DEBUG | |
185 # endif | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
186 |
75 | 187 # define snprintf _snprintf |
188 # define vsnprintf _vsnprintf | |
19 | 189 |
75 | 190 # ifdef CONFIG_WINCE |
191 # define perror(a) | |
192 # endif | |
19 | 193 |
66
c619660c74ab
CONFIG_WIN32 implies MinGW and Cygwin and possibly more, so use just
diego
parents:
65
diff
changeset
|
194 /* __MINGW32__ end */ |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
195 #elif defined (CONFIG_OS2) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
196 /* OS/2 EMX */ |
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 #include <float.h> |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
199 |
73 | 200 #endif /* !__MINGW32__ && CONFIG_OS2 */ |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
201 |
73 | 202 # ifdef USE_FASTMEMCPY |
203 # include "fastmemcpy.h" | |
204 # endif | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
205 |
22
3b56407b3f96
On MinGW it is not possible to build shared and static libraries at once.
diego
parents:
19
diff
changeset
|
206 #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
|
207 # 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
|
208 #else |
3b56407b3f96
On MinGW it is not possible to build shared and static libraries at once.
diego
parents:
19
diff
changeset
|
209 # define FF_IMPORT_ATTR |
3b56407b3f96
On MinGW it is not possible to build shared and static libraries at once.
diego
parents:
19
diff
changeset
|
210 #endif |
3b56407b3f96
On MinGW it is not possible to build shared and static libraries at once.
diego
parents:
19
diff
changeset
|
211 |
3b56407b3f96
On MinGW it is not possible to build shared and static libraries at once.
diego
parents:
19
diff
changeset
|
212 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
213 # include "bswap.h" |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
214 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
215 // 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
|
216 # if defined(__MINGW32__) || defined(__CYGWIN__) || \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
217 defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
218 # if defined(ARCH_X86_64) && defined(PIC) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
219 # define MANGLE(a) "_" #a"(%%rip)" |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
220 # else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
221 # define MANGLE(a) "_" #a |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
222 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
223 # else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
224 # if defined(ARCH_X86_64) && defined(PIC) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
225 # define MANGLE(a) #a"(%%rip)" |
31
7b1170d0da89
Proper mangling information for symbols in OS X Mach-O shared objects.
diego
parents:
22
diff
changeset
|
226 # elif defined(CONFIG_DARWIN) |
7b1170d0da89
Proper mangling information for symbols in OS X Mach-O shared objects.
diego
parents:
22
diff
changeset
|
227 # define MANGLE(a) "_" #a |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
228 # else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
229 # define MANGLE(a) #a |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
230 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
231 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
232 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
233 /* debug stuff */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
234 |
44
96a4efa91a4d
make sure NDEBUG is not defined already before defining it
gpoirier
parents:
39
diff
changeset
|
235 # if !defined(DEBUG) && !defined(NDEBUG) |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
236 # define NDEBUG |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
237 # endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
238 # include <assert.h> |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
239 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
240 /* dprintf macros */ |
65 | 241 # ifdef DEBUG |
242 # define dprintf(fmt,...) av_log(NULL, AV_LOG_DEBUG, fmt, __VA_ARGS__) | |
243 # else | |
244 # define dprintf(fmt,...) | |
245 # endif | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
246 |
19 | 247 # ifdef CONFIG_WINCE |
248 # define abort() | |
249 # endif | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
250 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
251 # 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
|
252 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
253 //rounded divison & shift |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
254 #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
|
255 /* assume b>0 */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
256 #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
|
257 #define ABS(a) ((a) >= 0 ? (a) : (-(a))) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
258 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
259 #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
260 #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
261 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
262 extern const uint32_t inverse[256]; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
263 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
264 #if defined(ARCH_X86) || defined(ARCH_X86_64) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
265 # define FASTDIV(a,b) \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
266 ({\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
267 int ret,dmy;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
268 asm volatile(\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
269 "mull %3"\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
270 :"=d"(ret),"=a"(dmy)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
271 :"1"(a),"g"(inverse[b])\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
272 );\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
273 ret;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
274 }) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
275 #elif defined(CONFIG_FASTDIV) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
276 # 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
|
277 #else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
278 # define FASTDIV(a,b) ((a)/(b)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
279 #endif |
12 | 280 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
281 /* misc math functions */ |
22
3b56407b3f96
On MinGW it is not possible to build shared and static libraries at once.
diego
parents:
19
diff
changeset
|
282 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
|
283 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
284 static inline int av_log2(unsigned int v) |
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 int n; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
287 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
288 n = 0; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
289 if (v & 0xffff0000) { |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
290 v >>= 16; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
291 n += 16; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
292 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
293 if (v & 0xff00) { |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
294 v >>= 8; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
295 n += 8; |
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 n += ff_log2_tab[v]; |
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 return n; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
300 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
301 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
302 static inline int av_log2_16bit(unsigned int v) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
303 { |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
304 int n; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
305 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
306 n = 0; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
307 if (v & 0xff00) { |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
308 v >>= 8; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
309 n += 8; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
310 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
311 n += ff_log2_tab[v]; |
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 return n; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
314 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
315 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
316 /* median of 3 */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
317 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
|
318 { |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
319 #if 0 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
320 int t= (a-b)&((a-b)>>31); |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
321 a-=t; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
322 b+=t; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
323 b-= (b-c)&((b-c)>>31); |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
324 b+= (a-b)&((a-b)>>31); |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
325 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
326 return b; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
327 #else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
328 if(a>b){ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
329 if(c>b){ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
330 if(c>a) b=a; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
331 else b=c; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
332 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
333 }else{ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
334 if(b>c){ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
335 if(c>a) b=c; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
336 else b=a; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
337 } |
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 return b; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
340 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
341 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
342 |
39 | 343 /** |
344 * clip a signed integer value into the amin-amax range | |
345 * @param a value to clip | |
346 * @param amin minimum value of the clip range | |
347 * @param amax maximum value of the clip range | |
348 * @return cliped value | |
349 */ | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
350 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
|
351 { |
63 | 352 if (a < amin) return amin; |
353 else if (a > amax) return amax; | |
354 else return a; | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
355 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
356 |
39 | 357 /** |
358 * clip a signed integer value into the 0-255 range | |
359 * @param a value to clip | |
360 * @return cliped value | |
361 */ | |
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
|
362 static inline uint8_t clip_uint8(int a) |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
363 { |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
364 if (a&(~255)) return (-a)>>31; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
365 else return a; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
366 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
367 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
368 /* math */ |
22
3b56407b3f96
On MinGW it is not possible to build shared and static libraries at once.
diego
parents:
19
diff
changeset
|
369 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
|
370 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
371 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
|
372 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
373 static inline int ff_sqrt(int a) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
374 { |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
375 int ret=0; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
376 int s; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
377 int ret_sq=0; |
12 | 378 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
379 if(a<128) return ff_sqrt_tab[a]; |
12 | 380 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
381 for(s=15; s>=0; s--){ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
382 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
|
383 if(b<=a){ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
384 ret_sq=b; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
385 ret+= 1<<s; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
386 } |
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 return ret; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
389 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
390 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
391 /** |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
392 * converts fourcc string to int |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
393 */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
394 static inline int ff_get_fourcc(const char *s){ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
395 assert( strlen(s)==4 ); |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
396 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
397 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
|
398 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
399 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
400 #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
|
401 #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
|
402 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
403 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
404 #if defined(ARCH_X86) || defined(ARCH_X86_64) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
405 #define MASK_ABS(mask, level)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
406 asm volatile(\ |
13 | 407 "cdq \n\t"\ |
408 "xorl %1, %0 \n\t"\ | |
409 "subl %1, %0 \n\t"\ | |
410 : "+a" (level), "=&d" (mask)\ | |
411 ); | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
412 #else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
413 #define MASK_ABS(mask, level)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
414 mask= level>>31;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
415 level= (level^mask)-mask; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
416 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
417 |
60 | 418 #define GET_UTF8(val, GET_BYTE, ERROR)\ |
419 val= GET_BYTE;\ | |
420 {\ | |
421 int ones= 7 - av_log2(val ^ 255);\ | |
422 if(ones==1)\ | |
423 ERROR\ | |
424 val&= 127>>ones;\ | |
425 while(--ones > 0){\ | |
426 int tmp= GET_BYTE - 128;\ | |
427 if(tmp>>6)\ | |
428 ERROR\ | |
429 val= (val<<6) + tmp;\ | |
430 }\ | |
431 } | |
0
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 #if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
434 #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
|
435 asm volatile (\ |
13 | 436 "cmpl %0, %3 \n\t"\ |
437 "cmovl %3, %0 \n\t"\ | |
438 "cmovl %4, %1 \n\t"\ | |
439 "cmovl %5, %2 \n\t"\ | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
440 : "+r" (x), "+r" (a), "+r" (c)\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
441 : "r" (y), "r" (b), "r" (d)\ |
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 #else |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
444 #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
|
445 if((y)<(x)){\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
446 (x)=(y);\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
447 (a)=(b);\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
448 (c)=(d);\ |
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 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
451 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
452 #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
|
453 #if defined(ARCH_X86_64) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
454 static inline uint64_t read_time(void) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
455 { |
13 | 456 uint64_t a, d; |
457 asm volatile( "rdtsc\n\t" | |
458 : "=a" (a), "=d" (d) | |
459 ); | |
460 return (d << 32) | (a & 0xffffffff); | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
461 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
462 #elif defined(ARCH_X86) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
463 static inline long long read_time(void) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
464 { |
13 | 465 long long l; |
466 asm volatile( "rdtsc\n\t" | |
467 : "=A" (l) | |
468 ); | |
469 return l; | |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
470 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
471 #else //FIXME check ppc64 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
472 static inline uint64_t read_time(void) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
473 { |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
474 uint32_t tbu, tbl, temp; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
475 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
476 /* 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
|
477 __asm__ __volatile__( |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
478 "1:\n" |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
479 "mftbu %2\n" |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
480 "mftb %0\n" |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
481 "mftbu %1\n" |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
482 "cmpw %2,%1\n" |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
483 "bne 1b\n" |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
484 : "=r"(tbl), "=r"(tbu), "=r"(temp) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
485 : |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
486 : "cc"); |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
487 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
488 return (((uint64_t)tbu)<<32) | (uint64_t)tbl; |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
489 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
490 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
491 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
492 #define START_TIMER \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
493 uint64_t tend;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
494 uint64_t tstart= read_time();\ |
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 #define STOP_TIMER(id) \ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
497 tend= read_time();\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
498 {\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
499 static uint64_t tsum=0;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
500 static int tcount=0;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
501 static int tskip_count=0;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
502 if(tcount<2 || tend - tstart < 8*tsum/tcount){\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
503 tsum+= tend - tstart;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
504 tcount++;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
505 }else\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
506 tskip_count++;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
507 if(256*256*256*64%(tcount+tskip_count)==0){\ |
7 | 508 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
|
509 }\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
510 } |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
511 #else |
12 | 512 #define START_TIMER |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
513 #define STOP_TIMER(id) {} |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
514 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
515 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
516 /* avoid usage of various functions */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
517 #define malloc please_use_av_malloc |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
518 #define free please_use_av_free |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
519 #define realloc please_use_av_realloc |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
520 #define time time_is_forbidden_due_to_security_issues |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
521 #define rand rand_is_forbidden_due_to_state_trashing |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
522 #define srand srand_is_forbidden_due_to_state_trashing |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
523 #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
|
524 #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
|
525 #if !(defined(LIBAVFORMAT_BUILD) || defined(_FRAMEHOOK_H)) |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
526 #define printf please_use_av_log |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
527 #define fprintf please_use_av_log |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
528 #endif |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
529 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
530 #define CHECKED_ALLOCZ(p, size)\ |
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 p= av_mallocz(size);\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
533 if(p==NULL && (size)!=0){\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
534 perror("malloc");\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
535 goto fail;\ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
536 }\ |
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 |
4
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
539 #ifndef HAVE_LRINTF |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
540 /* 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
|
541 /* better than nothing implementation. */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
542 /* 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
|
543 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
|
544 { |
66
c619660c74ab
CONFIG_WIN32 implies MinGW and Cygwin and possibly more, so use just
diego
parents:
65
diff
changeset
|
545 #ifdef __MINGW32__ |
4
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
546 # ifdef ARCH_X86 |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
547 int32_t i; |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
548 asm volatile( |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
549 "fistpl %0\n\t" |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
550 : "=m" (i) : "t" (x) : "st" |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
551 ); |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
552 return i; |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
553 # else |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
554 /* XXX: incorrect, but make it compile */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
555 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
|
556 # endif /* ARCH_X86 */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
557 #else |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
558 return (int)(rint(x)); |
66
c619660c74ab
CONFIG_WIN32 implies MinGW and Cygwin and possibly more, so use just
diego
parents:
65
diff
changeset
|
559 #endif /* __MINGW32__ */ |
4
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
560 } |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
561 #endif /* HAVE_LRINTF */ |
26a00aee5eac
Move lrintf implementation from libavcodec/dsputil.h to libavutil/common.h
diego
parents:
3
diff
changeset
|
562 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
563 #endif /* HAVE_AV_CONFIG_H */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
564 |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
565 #endif /* COMMON_H */ |