annotate common.h @ 151:d6f1b361d2c2 libavutil

spelling cosmetics: cliped --> clipped
author diego
date Sat, 02 Dec 2006 14:19:49 +0000
parents 7e143f348a72
children 37eadd4352e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
108
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
1 /*
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
3 *
116
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 113
diff changeset
4 * This file is part of FFmpeg.
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 113
diff changeset
5 *
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 113
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
108
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
8 * License as published by the Free Software Foundation; either
116
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 113
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
108
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
10 *
116
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 113
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
108
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
14 * Lesser General Public License for more details.
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
15 *
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
116
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 113
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
108
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
19 */
11be8e0d1344 Add official LGPL license headers to the files that were missing them.
diego
parents: 104
diff changeset
20
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
21 /**
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
22 * @file common.h
80
624fc3ad183a Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents: 75
diff changeset
23 * common internal and external api header.
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
24 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
25
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
26 #ifndef COMMON_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
27 #define COMMON_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
28
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
29 #ifndef M_PI
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
30 #define M_PI 3.14159265358979323846
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
31 #endif
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 #ifdef HAVE_AV_CONFIG_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
34 /* only include the following when compiling package */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
35 # include "config.h"
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 <stdlib.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
38 # include <stdio.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
39 # include <string.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
40 # include <ctype.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
41 # include <limits.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
42 # ifndef __BEOS__
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
43 # include <errno.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
44 # else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
45 # include "berrno.h"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
46 # endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
47 # include <math.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
48 #endif /* HAVE_AV_CONFIG_H */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
49
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
50 /* 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
51 #ifndef restrict
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
52 # define restrict
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
53 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
54
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
55 #ifndef always_inline
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
56 #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
57 # define always_inline __attribute__((always_inline)) inline
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
58 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
59 # define always_inline inline
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
60 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
61 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
62
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
63 #ifndef attribute_used
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
64 #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
65 # define attribute_used __attribute__((used))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
66 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
67 # define attribute_used
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
68 #endif
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
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
71 #ifndef attribute_unused
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
72 #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
73 # define attribute_unused __attribute__((unused))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
74 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
75 # define attribute_unused
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
76 #endif
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
100
5d02abb9a7e5 attribute_deprecated
michael
parents: 99
diff changeset
79 #ifndef attribute_deprecated
5d02abb9a7e5 attribute_deprecated
michael
parents: 99
diff changeset
80 #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
5d02abb9a7e5 attribute_deprecated
michael
parents: 99
diff changeset
81 # define attribute_deprecated __attribute__((deprecated))
5d02abb9a7e5 attribute_deprecated
michael
parents: 99
diff changeset
82 #else
5d02abb9a7e5 attribute_deprecated
michael
parents: 99
diff changeset
83 # define attribute_deprecated
5d02abb9a7e5 attribute_deprecated
michael
parents: 99
diff changeset
84 #endif
5d02abb9a7e5 attribute_deprecated
michael
parents: 99
diff changeset
85 #endif
5d02abb9a7e5 attribute_deprecated
michael
parents: 99
diff changeset
86
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
87 # include <inttypes.h>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
88
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
89 #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
90 #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
91 #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
92
8
2dd915c714fa fix for systems not defining PRIu64, not everyone knows C99.
mmu_man
parents: 7
diff changeset
93 #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
94 #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
95 #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
96
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
97 #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
98 #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
99 #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
100
127
c1916b2259c5 Define fallback for PRIX64, taken from a patch by Steve L'Homme.
diego
parents: 126
diff changeset
101 #ifndef PRIX64
c1916b2259c5 Define fallback for PRIX64, taken from a patch by Steve L'Homme.
diego
parents: 126
diff changeset
102 #define PRIX64 "llX"
c1916b2259c5 Define fallback for PRIX64, taken from a patch by Steve L'Homme.
diego
parents: 126
diff changeset
103 #endif
c1916b2259c5 Define fallback for PRIX64, taken from a patch by Steve L'Homme.
diego
parents: 126
diff changeset
104
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
105 #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
106 #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
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 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
110 #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
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 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
114 #define PRIdFAST32 PRId32
8
2dd915c714fa fix for systems not defining PRIu64, not everyone knows C99.
mmu_man
parents: 7
diff changeset
115 #endif
2dd915c714fa fix for systems not defining PRIu64, not everyone knows C99.
mmu_man
parents: 7
diff changeset
116
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
117 #ifndef INT16_MIN
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
118 #define INT16_MIN (-0x7fff-1)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
119 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
120
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
121 #ifndef INT16_MAX
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
122 #define INT16_MAX 0x7fff
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
123 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
124
33
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
125 #ifndef INT32_MIN
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
126 #define INT32_MIN (-0x7fffffff-1)
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
127 #endif
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
128
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
129 #ifndef INT32_MAX
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
130 #define INT32_MAX 0x7fffffff
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
131 #endif
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
132
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
133 #ifndef UINT32_MAX
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
134 #define UINT32_MAX 0xffffffff
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
135 #endif
59ae491910a5 #define [U]INT32_{MIN,MAX} if missing
mru
parents: 31
diff changeset
136
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
137 #ifndef INT64_MIN
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
138 #define INT64_MIN (-0x7fffffffffffffffLL-1)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
139 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
140
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
141 #ifndef INT64_MAX
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
142 #define INT64_MAX int64_t_C(9223372036854775807)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
143 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
144
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
145 #ifndef UINT64_MAX
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
146 #define UINT64_MAX uint64_t_C(0xFFFFFFFFFFFFFFFF)
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 INT_BIT
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
150 # if INT_MAX != 2147483647
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
151 # define INT_BIT 64
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
152 # else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
153 # define INT_BIT 32
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
154 # endif
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
74
a298a8eae4f2 simplify
mru
parents: 73
diff changeset
157 #ifndef int64_t_C
a298a8eae4f2 simplify
mru
parents: 73
diff changeset
158 #define int64_t_C(c) (c ## LL)
a298a8eae4f2 simplify
mru
parents: 73
diff changeset
159 #define uint64_t_C(c) (c ## ULL)
a298a8eae4f2 simplify
mru
parents: 73
diff changeset
160 #endif
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
161
22
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
162 #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
163 # 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
164 #else
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
165 # define FF_IMPORT_ATTR
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
166 #endif
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
167
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
168
80
624fc3ad183a Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents: 75
diff changeset
169 #ifdef HAVE_AV_CONFIG_H
624fc3ad183a Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents: 75
diff changeset
170 /* only include the following when compiling package */
624fc3ad183a Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents: 75
diff changeset
171 # include "internal.h"
624fc3ad183a Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents: 75
diff changeset
172 #endif
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
173
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
174 //rounded divison & shift
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
175 #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
176 /* assume b>0 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
177 #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
120
f42a6347df1d Rename ABS macro to FFABS.
diego
parents: 119
diff changeset
178 #define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
119
7d5463d9530a Rename SIGN macro to FFSIGN to avoid clashes with system headers.
diego
parents: 117
diff changeset
179 #define FFSIGN(a) ((a) > 0 ? 1 : -1)
0
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 #define FFMAX(a,b) ((a) > (b) ? (a) : (b))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
182 #define FFMIN(a,b) ((a) > (b) ? (b) : (a))
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
183
126
28a98fbd027f Rename SWAP macro to FFSWAP.
diego
parents: 125
diff changeset
184 #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
99
michael
parents: 89
diff changeset
185
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
186 /* misc math functions */
22
3b56407b3f96 On MinGW it is not possible to build shared and static libraries at once.
diego
parents: 19
diff changeset
187 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
188
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
189 static inline int av_log2(unsigned int v)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
190 {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
191 int n;
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 n = 0;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
194 if (v & 0xffff0000) {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
195 v >>= 16;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
196 n += 16;
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 if (v & 0xff00) {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
199 v >>= 8;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
200 n += 8;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
201 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
202 n += ff_log2_tab[v];
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
203
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
204 return n;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
205 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
206
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
207 static inline int av_log2_16bit(unsigned int v)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
208 {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
209 int n;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
210
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
211 n = 0;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
212 if (v & 0xff00) {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
213 v >>= 8;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
214 n += 8;
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 n += ff_log2_tab[v];
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
217
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
218 return n;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
219 }
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 /* median of 3 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
222 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
223 {
121
69714d5e1561 Protect code that uses CMOV instructions with HAVE_CMOV,
gpoirier
parents: 120
diff changeset
224 #if HAVE_CMOV
111
6199da3bf29e simplify asm mid_pred, as suggested by michaelni.
lorenm
parents: 109
diff changeset
225 int i=b;
109
a2ef0ea8643b asm implementation of mid_pred.
lorenm
parents: 108
diff changeset
226 asm volatile(
111
6199da3bf29e simplify asm mid_pred, as suggested by michaelni.
lorenm
parents: 109
diff changeset
227 "cmp %2, %1 \n\t"
6199da3bf29e simplify asm mid_pred, as suggested by michaelni.
lorenm
parents: 109
diff changeset
228 "cmovg %1, %0 \n\t"
6199da3bf29e simplify asm mid_pred, as suggested by michaelni.
lorenm
parents: 109
diff changeset
229 "cmovg %2, %1 \n\t"
6199da3bf29e simplify asm mid_pred, as suggested by michaelni.
lorenm
parents: 109
diff changeset
230 "cmp %3, %1 \n\t"
109
a2ef0ea8643b asm implementation of mid_pred.
lorenm
parents: 108
diff changeset
231 "cmovl %3, %1 \n\t"
111
6199da3bf29e simplify asm mid_pred, as suggested by michaelni.
lorenm
parents: 109
diff changeset
232 "cmp %1, %0 \n\t"
6199da3bf29e simplify asm mid_pred, as suggested by michaelni.
lorenm
parents: 109
diff changeset
233 "cmovg %1, %0 \n\t"
6199da3bf29e simplify asm mid_pred, as suggested by michaelni.
lorenm
parents: 109
diff changeset
234 :"+&r"(i), "+&r"(a)
6199da3bf29e simplify asm mid_pred, as suggested by michaelni.
lorenm
parents: 109
diff changeset
235 :"r"(b), "r"(c)
109
a2ef0ea8643b asm implementation of mid_pred.
lorenm
parents: 108
diff changeset
236 );
a2ef0ea8643b asm implementation of mid_pred.
lorenm
parents: 108
diff changeset
237 return i;
a2ef0ea8643b asm implementation of mid_pred.
lorenm
parents: 108
diff changeset
238 #elif 0
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
239 int t= (a-b)&((a-b)>>31);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
240 a-=t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
241 b+=t;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
242 b-= (b-c)&((b-c)>>31);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
243 b+= (a-b)&((a-b)>>31);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
244
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
245 return b;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
246 #else
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
247 if(a>b){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
248 if(c>b){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
249 if(c>a) b=a;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
250 else b=c;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
251 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
252 }else{
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
253 if(b>c){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
254 if(c>a) b=c;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
255 else b=a;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
256 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
257 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
258 return b;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
259 #endif
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
39
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
262 /**
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
263 * clip a signed integer value into the amin-amax range
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
264 * @param a value to clip
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
265 * @param amin minimum value of the clip range
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
266 * @param amax maximum value of the clip range
151
d6f1b361d2c2 spelling cosmetics: cliped --> clipped
diego
parents: 147
diff changeset
267 * @return clipped value
39
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
268 */
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
269 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
270 {
63
e5a312df8a07 cosmetic
michael
parents: 62
diff changeset
271 if (a < amin) return amin;
e5a312df8a07 cosmetic
michael
parents: 62
diff changeset
272 else if (a > amax) return amax;
e5a312df8a07 cosmetic
michael
parents: 62
diff changeset
273 else return a;
0
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
39
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
276 /**
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
277 * clip a signed integer value into the 0-255 range
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
278 * @param a value to clip
151
d6f1b361d2c2 spelling cosmetics: cliped --> clipped
diego
parents: 147
diff changeset
279 * @return clipped value
39
c25cab283094 document clip functions
aurel
parents: 38
diff changeset
280 */
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
281 static inline uint8_t clip_uint8(int a)
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
282 {
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
283 if (a&(~255)) return (-a)>>31;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
284 else return a;
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
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
287 /* math */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
288 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
289
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
290 /**
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
291 * converts fourcc string to int
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 static inline int ff_get_fourcc(const char *s){
80
624fc3ad183a Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents: 75
diff changeset
294 #ifdef HAVE_AV_CONFIG_H
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
295 assert( strlen(s)==4 );
80
624fc3ad183a Split common.h in two parts, purely internal stuff (internal.h) and things
reimar
parents: 75
diff changeset
296 #endif
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
297
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
298 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
299 }
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 #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
302 #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
303
132
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
304 /*!
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
305 * \def GET_UTF8(val, GET_BYTE, ERROR)
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
306 * converts a utf-8 character (up to 4 bytes long) to its 32-bit ucs-4 encoded form
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
307 * \param val is the output and should be of type uint32_t. It holds the converted
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
308 * ucs-4 character and should be a left value.
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
309 * \param GET_BYTE gets utf-8 encoded bytes from any proper source. It can be
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
310 * a function or a statement whose return value or evaluated value is of type
147
7e143f348a72 Correct GET/PUT_UTF8 comment: the get/put functions might be called up
reimar
parents: 146
diff changeset
311 * uint8_t. It will be executed up to 4 times for values in the valid utf-8 range,
7e143f348a72 Correct GET/PUT_UTF8 comment: the get/put functions might be called up
reimar
parents: 146
diff changeset
312 * and up to 7 times in the general case.
132
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
313 * \param ERROR action that should be taken when an invalid utf-8 byte is returned
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
314 * from GET_BYTE. It should be a statement that jumps out of the macro,
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
315 * like exit(), goto, return, break, or continue.
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
316 */
130
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
317 #define GET_UTF8(val, GET_BYTE, ERROR)\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
318 val= GET_BYTE;\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
319 {\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
320 int ones= 7 - av_log2(val ^ 255);\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
321 if(ones==1)\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
322 ERROR\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
323 val&= 127>>ones;\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
324 while(--ones > 0){\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
325 int tmp= GET_BYTE - 128;\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
326 if(tmp>>6)\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
327 ERROR\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
328 val= (val<<6) + tmp;\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
329 }\
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
330 }
dc1ff57e1b08 woops, fix missplaced doxy comment
gpoirier
parents: 129
diff changeset
331
129
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
332 /*!
131
e10026931162 Fix wrong params name in PUT_UTF8 doxy comments
gpoirier
parents: 130
diff changeset
333 * \def PUT_UTF8(val, tmp, PUT_BYTE)
132
589af48c86f4 Add doxy comments for macro GET_UTF8
gpoirier
parents: 131
diff changeset
334 * converts a 32-bit unicode character to its utf-8 encoded form (up to 4 bytes long).
129
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
335 * \param val is an input only argument and should be of type uint32_t. It holds
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
336 * a ucs4 encoded unicode character that is to be converted to utf-8. If
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
337 * val is given as a function it's executed only once.
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
338 * \param tmp is a temporary variable and should be of type uint8_t. It
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
339 * represents an intermediate value during conversion that is to be
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
340 * outputted by PUT_BYTE.
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
341 * \param PUT_BYTE writes the converted utf-8 bytes to any proper destination.
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
342 * It could be a function or a statement, and uses tmp as the input byte.
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
343 * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
147
7e143f348a72 Correct GET/PUT_UTF8 comment: the get/put functions might be called up
reimar
parents: 146
diff changeset
344 * executed up to 4 times for values in the valid utf-8 range and up to
7e143f348a72 Correct GET/PUT_UTF8 comment: the get/put functions might be called up
reimar
parents: 146
diff changeset
345 * 7 times in the general case, depending on the length of the converted
129
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
346 * unicode character.
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
347 */
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
348 #define PUT_UTF8(val, tmp, PUT_BYTE)\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
349 {\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
350 int bytes, shift;\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
351 uint32_t in = val;\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
352 if (in < 0x80) {\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
353 tmp = in;\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
354 PUT_BYTE\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
355 } else {\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
356 bytes = (av_log2(in) + 4) / 5;\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
357 shift = (bytes - 1) * 6;\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
358 tmp = (256 - (256 >> bytes)) | (in >> shift);\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
359 PUT_BYTE\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
360 while (shift >= 6) {\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
361 shift -= 6;\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
362 tmp = 0x80 | ((in >> shift) & 0x3f);\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
363 PUT_BYTE\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
364 }\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
365 }\
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
366 }
ccae53673692 Fix ASF format parser's broken UTF-16 string handling
gpoirier
parents: 127
diff changeset
367
125
172cf2494db7 Use common define for x86_32 and x86_64.
diego
parents: 124
diff changeset
368 #if defined(ARCH_X86) || defined(ARCH_POWERPC)
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
369 #if defined(ARCH_X86_64)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
370 static inline uint64_t read_time(void)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
371 {
13
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
372 uint64_t a, d;
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
373 asm volatile( "rdtsc\n\t"
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
374 : "=a" (a), "=d" (d)
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
375 );
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
376 return (d << 32) | (a & 0xffffffff);
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
377 }
124
bd1ecfd747bc Add ARCH_X86_32 as a new define for 32 bit x86 architectures and change
diego
parents: 121
diff changeset
378 #elif defined(ARCH_X86_32)
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
379 static inline long long read_time(void)
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
380 {
13
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
381 long long l;
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
382 asm volatile( "rdtsc\n\t"
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
383 : "=A" (l)
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
384 );
aedb6bd881b9 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 12
diff changeset
385 return l;
0
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 #else //FIXME check ppc64
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
388 static inline uint64_t read_time(void)
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 uint32_t tbu, tbl, temp;
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 /* 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
393 __asm__ __volatile__(
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
394 "1:\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
395 "mftbu %2\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
396 "mftb %0\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
397 "mftbu %1\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
398 "cmpw %2,%1\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
399 "bne 1b\n"
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
400 : "=r"(tbl), "=r"(tbu), "=r"(temp)
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 : "cc");
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 return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
405 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
406 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
407
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
408 #define START_TIMER \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
409 uint64_t tend;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
410 uint64_t tstart= read_time();\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
411
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
412 #define STOP_TIMER(id) \
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
413 tend= read_time();\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
414 {\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
415 static uint64_t tsum=0;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
416 static int tcount=0;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
417 static int tskip_count=0;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
418 if(tcount<2 || tend - tstart < 8*tsum/tcount){\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
419 tsum+= tend - tstart;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
420 tcount++;\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
421 }else\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
422 tskip_count++;\
112
aedf5cf3de93 remove a division from STOP_TIMER
lorenm
parents: 111
diff changeset
423 if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\
7
5ac9c20533c3 Fixed format specifier in STOP_TIMER macro.
al
parents: 4
diff changeset
424 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
425 }\
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
426 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
427 #else
12
ce8f9f4390c3 COSMETICS: Remove all trailing whitespace.
diego
parents: 11
diff changeset
428 #define START_TIMER
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
429 #define STOP_TIMER(id) {}
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
430 #endif
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
431
82
8fb151c4d4c7 Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents: 80
diff changeset
432 /* memory */
104
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
433
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
434 #ifdef __GNUC__
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
435 #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
436 #else
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
437 #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
438 #endif
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
439
113
8fc54918226e move memory functions from avcodec to avutil
lu_zero
parents: 112
diff changeset
440 /* memory */
82
8fb151c4d4c7 Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents: 80
diff changeset
441 void *av_malloc(unsigned int size);
8fb151c4d4c7 Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents: 80
diff changeset
442 void *av_realloc(void *ptr, unsigned int size);
8fb151c4d4c7 Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents: 80
diff changeset
443 void av_free(void *ptr);
8fb151c4d4c7 Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents: 80
diff changeset
444
113
8fc54918226e move memory functions from avcodec to avutil
lu_zero
parents: 112
diff changeset
445 void *av_mallocz(unsigned int size);
8fc54918226e move memory functions from avcodec to avutil
lu_zero
parents: 112
diff changeset
446 char *av_strdup(const char *s);
8fc54918226e move memory functions from avcodec to avutil
lu_zero
parents: 112
diff changeset
447 void av_freep(void *ptr);
8fc54918226e move memory functions from avcodec to avutil
lu_zero
parents: 112
diff changeset
448
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
449 #endif /* COMMON_H */