summaryrefslogtreecommitdiff
path: root/apps/codecs/libwmapro/libavutil
diff options
context:
space:
mode:
authorMohamed Tarek <mt@rockbox.org>2010-04-27 18:04:34 +0000
committerMohamed Tarek <mt@rockbox.org>2010-04-27 18:04:34 +0000
commitdda7fab1d65e73a6bdbdac1b1d37330b8f0085aa (patch)
tree6446710d45643347d1f301bbfcb914e3ec4a39e4 /apps/codecs/libwmapro/libavutil
parentf96406c5f3aca04f3c0ab95275d857288fd8c2ea (diff)
downloadrockbox-dda7fab1d65e73a6bdbdac1b1d37330b8f0085aa.tar.gz
rockbox-dda7fab1d65e73a6bdbdac1b1d37330b8f0085aa.zip
Add libwmapro to trunk.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25739 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libwmapro/libavutil')
-rw-r--r--apps/codecs/libwmapro/libavutil/attributes.h113
-rw-r--r--apps/codecs/libwmapro/libavutil/avutil.h63
-rw-r--r--apps/codecs/libwmapro/libavutil/bswap.h99
-rw-r--r--apps/codecs/libwmapro/libavutil/common.h299
-rw-r--r--apps/codecs/libwmapro/libavutil/internal.h207
-rw-r--r--apps/codecs/libwmapro/libavutil/intreadwrite.h192
-rw-r--r--apps/codecs/libwmapro/libavutil/log.c89
-rw-r--r--apps/codecs/libwmapro/libavutil/log.h116
-rw-r--r--apps/codecs/libwmapro/libavutil/mathematics.c177
-rw-r--r--apps/codecs/libwmapro/libavutil/mathematics.h98
-rw-r--r--apps/codecs/libwmapro/libavutil/mem.c159
-rw-r--r--apps/codecs/libwmapro/libavutil/mem.h104
12 files changed, 1716 insertions, 0 deletions
diff --git a/apps/codecs/libwmapro/libavutil/attributes.h b/apps/codecs/libwmapro/libavutil/attributes.h
new file mode 100644
index 0000000000..1208bc0c72
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/attributes.h
@@ -0,0 +1,113 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file libavutil/attributes.h
23 * Macro definitions for various function/variable attributes
24 */
25
26#ifndef AVUTIL_ATTRIBUTES_H
27#define AVUTIL_ATTRIBUTES_H
28
29#ifdef __GNUC__
30# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
31#else
32# define AV_GCC_VERSION_AT_LEAST(x,y) 0
33#endif
34
35#ifndef av_always_inline
36#if AV_GCC_VERSION_AT_LEAST(3,1)
37# define av_always_inline __attribute__((always_inline)) inline
38#else
39# define av_always_inline inline
40#endif
41#endif
42
43#ifndef av_noinline
44#if AV_GCC_VERSION_AT_LEAST(3,1)
45# define av_noinline __attribute__((noinline))
46#else
47# define av_noinline
48#endif
49#endif
50
51#ifndef av_pure
52#if AV_GCC_VERSION_AT_LEAST(3,1)
53# define av_pure __attribute__((pure))
54#else
55# define av_pure
56#endif
57#endif
58
59#ifndef av_const
60#if AV_GCC_VERSION_AT_LEAST(2,6)
61# define av_const __attribute__((const))
62#else
63# define av_const
64#endif
65#endif
66
67#ifndef av_cold
68#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3)
69# define av_cold __attribute__((cold))
70#else
71# define av_cold
72#endif
73#endif
74
75#ifndef av_flatten
76#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,1)
77# define av_flatten __attribute__((flatten))
78#else
79# define av_flatten
80#endif
81#endif
82
83#ifndef attribute_deprecated
84#if AV_GCC_VERSION_AT_LEAST(3,1)
85# define attribute_deprecated __attribute__((deprecated))
86#else
87# define attribute_deprecated
88#endif
89#endif
90
91#ifndef av_unused
92#if defined(__GNUC__)
93# define av_unused __attribute__((unused))
94#else
95# define av_unused
96#endif
97#endif
98
99#ifndef av_uninit
100#if defined(__GNUC__) && !defined(__ICC)
101# define av_uninit(x) x=x
102#else
103# define av_uninit(x) x
104#endif
105#endif
106
107#ifdef __GNUC__
108# define av_builtin_constant_p __builtin_constant_p
109#else
110# define av_builtin_constant_p(x) 0
111#endif
112
113#endif /* AVUTIL_ATTRIBUTES_H */
diff --git a/apps/codecs/libwmapro/libavutil/avutil.h b/apps/codecs/libwmapro/libavutil/avutil.h
new file mode 100644
index 0000000000..c07e44d660
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/avutil.h
@@ -0,0 +1,63 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVUTIL_AVUTIL_H
22#define AVUTIL_AVUTIL_H
23
24/**
25 * @file libavutil/avutil.h
26 * external API header
27 */
28
29
30#define AV_STRINGIFY(s) AV_TOSTRING(s)
31#define AV_TOSTRING(s) #s
32
33#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c)
34#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c
35#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
36
37#define LIBAVUTIL_VERSION_MAJOR 50
38#define LIBAVUTIL_VERSION_MINOR 0
39#define LIBAVUTIL_VERSION_MICRO 0
40
41#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
42 LIBAVUTIL_VERSION_MINOR, \
43 LIBAVUTIL_VERSION_MICRO)
44#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \
45 LIBAVUTIL_VERSION_MINOR, \
46 LIBAVUTIL_VERSION_MICRO)
47#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
48
49#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
50
51/**
52 * Returns the LIBAVUTIL_VERSION_INT constant.
53 */
54unsigned avutil_version(void);
55
56#include "common.h"
57//#include "mathematics.h"
58//#include "rational.h"
59//#include "intfloat_readwrite.h"
60#include "log.h"
61//#include "pixfmt.h"
62
63#endif /* AVUTIL_AVUTIL_H */
diff --git a/apps/codecs/libwmapro/libavutil/bswap.h b/apps/codecs/libwmapro/libavutil/bswap.h
new file mode 100644
index 0000000000..9175cb24a5
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/bswap.h
@@ -0,0 +1,99 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file libavutil/bswap.h
23 * byte swapping routines
24 */
25
26#ifndef AVUTIL_BSWAP_H
27#define AVUTIL_BSWAP_H
28
29#include <stdint.h>
30//#include "ffmpeg_config.h"
31#include "common.h"
32
33#if ARCH_ARM
34# include "arm/bswap.h"
35#elif ARCH_BFIN
36# include "bfin/bswap.h"
37#elif ARCH_SH4
38# include "sh4/bswap.h"
39#elif ARCH_X86
40# include "x86/bswap.h"
41#endif
42
43#ifndef bswap_16
44static av_always_inline av_const uint16_t bswap_16(uint16_t x)
45{
46 x= (x>>8) | (x<<8);
47 return x;
48}
49#endif
50
51#ifndef bswap_32
52static av_always_inline av_const uint32_t bswap_32(uint32_t x)
53{
54 x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
55 x= (x>>16) | (x<<16);
56 return x;
57}
58#endif
59
60#ifndef bswap_64
61static inline uint64_t av_const bswap_64(uint64_t x)
62{
63#if 0
64 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
65 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
66 return (x>>32) | (x<<32);
67#else
68 union {
69 uint64_t ll;
70 uint32_t l[2];
71 } w, r;
72 w.ll = x;
73 r.l[0] = bswap_32 (w.l[1]);
74 r.l[1] = bswap_32 (w.l[0]);
75 return r.ll;
76#endif
77}
78#endif
79
80// be2me ... big-endian to machine-endian
81// le2me ... little-endian to machine-endian
82
83#ifdef WORDS_BIGENDIAN
84#define be2me_16(x) (x)
85#define be2me_32(x) (x)
86#define be2me_64(x) (x)
87#define le2me_16(x) bswap_16(x)
88#define le2me_32(x) bswap_32(x)
89#define le2me_64(x) bswap_64(x)
90#else
91#define be2me_16(x) bswap_16(x)
92#define be2me_32(x) bswap_32(x)
93#define be2me_64(x) bswap_64(x)
94#define le2me_16(x) (x)
95#define le2me_32(x) (x)
96#define le2me_64(x) (x)
97#endif
98
99#endif /* AVUTIL_BSWAP_H */
diff --git a/apps/codecs/libwmapro/libavutil/common.h b/apps/codecs/libwmapro/libavutil/common.h
new file mode 100644
index 0000000000..f3bc4ba44b
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/common.h
@@ -0,0 +1,299 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file libavutil/common.h
23 * common internal and external API header
24 */
25
26#ifndef AVUTIL_COMMON_H
27#define AVUTIL_COMMON_H
28
29#include <ctype.h>
30#include <errno.h>
31#include <inttypes.h>
32#include <limits.h>
33#include <math.h>
34#include <stdio.h>
35#include <stdlib.h>
36#include <string.h>
37#include "attributes.h"
38#include "internal.h"
39
40//rounded division & shift
41#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
42/* assume b>0 */
43#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
44#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
45#define FFSIGN(a) ((a) > 0 ? 1 : -1)
46
47#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
48#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
49#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
50#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
51
52#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
53#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
54#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
55
56/* misc math functions */
57extern const uint8_t ff_log2_tab[256];
58
59extern const uint8_t av_reverse[256];
60
61static inline av_const int av_log2_c(unsigned int v)
62{
63 int n = 0;
64 if (v & 0xffff0000) {
65 v >>= 16;
66 n += 16;
67 }
68 if (v & 0xff00) {
69 v >>= 8;
70 n += 8;
71 }
72 n += ff_log2_tab[v];
73
74 return n;
75}
76
77static inline av_const int av_log2_16bit_c(unsigned int v)
78{
79 int n = 0;
80 if (v & 0xff00) {
81 v >>= 8;
82 n += 8;
83 }
84 n += ff_log2_tab[v];
85
86 return n;
87}
88
89#ifdef HAVE_AV_CONFIG_H
90# include "config.h"
91# include "intmath.h"
92#endif
93
94#ifndef av_log2
95# define av_log2 av_log2_c
96#endif
97#ifndef av_log2_16bit
98# define av_log2_16bit av_log2_16bit_c
99#endif
100
101/**
102 * Clips a signed integer value into the amin-amax range.
103 * @param a value to clip
104 * @param amin minimum value of the clip range
105 * @param amax maximum value of the clip range
106 * @return clipped value
107 */
108static inline av_const int av_clip(int a, int amin, int amax)
109{
110 if (a < amin) return amin;
111 else if (a > amax) return amax;
112 else return a;
113}
114
115/**
116 * Clips a signed integer value into the 0-255 range.
117 * @param a value to clip
118 * @return clipped value
119 */
120static inline av_const uint8_t av_clip_uint8(int a)
121{
122 if (a&(~255)) return (-a)>>31;
123 else return a;
124}
125
126/**
127 * Clips a signed integer value into the 0-65535 range.
128 * @param a value to clip
129 * @return clipped value
130 */
131static inline av_const uint16_t av_clip_uint16(int a)
132{
133 if (a&(~65535)) return (-a)>>31;
134 else return a;
135}
136
137/**
138 * Clips a signed integer value into the -32768,32767 range.
139 * @param a value to clip
140 * @return clipped value
141 */
142static inline av_const int16_t av_clip_int16(int a)
143{
144 if ((a+32768) & ~65535) return (a>>31) ^ 32767;
145 else return a;
146}
147
148/**
149 * Clips a float value into the amin-amax range.
150 * @param a value to clip
151 * @param amin minimum value of the clip range
152 * @param amax maximum value of the clip range
153 * @return clipped value
154 */
155static inline av_const float av_clipf(float a, float amin, float amax)
156{
157 if (a < amin) return amin;
158 else if (a > amax) return amax;
159 else return a;
160}
161
162/** Computes ceil(log2(x)).
163 * @param x value used to compute ceil(log2(x))
164 * @return computed ceiling of log2(x)
165 */
166static inline av_const int av_ceil_log2(int x)
167{
168 return av_log2((x - 1) << 1);
169}
170
171#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
172#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
173
174/*!
175 * \def GET_UTF8(val, GET_BYTE, ERROR)
176 * Converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form
177 * \param val is the output and should be of type uint32_t. It holds the converted
178 * UCS-4 character and should be a left value.
179 * \param GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be
180 * a function or a statement whose return value or evaluated value is of type
181 * uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range,
182 * and up to 7 times in the general case.
183 * \param ERROR action that should be taken when an invalid UTF-8 byte is returned
184 * from GET_BYTE. It should be a statement that jumps out of the macro,
185 * like exit(), goto, return, break, or continue.
186 */
187#define GET_UTF8(val, GET_BYTE, ERROR)\
188 val= GET_BYTE;\
189 {\
190 int ones= 7 - av_log2(val ^ 255);\
191 if(ones==1)\
192 ERROR\
193 val&= 127>>ones;\
194 while(--ones > 0){\
195 int tmp= GET_BYTE - 128;\
196 if(tmp>>6)\
197 ERROR\
198 val= (val<<6) + tmp;\
199 }\
200 }
201
202/*!
203 * \def GET_UTF16(val, GET_16BIT, ERROR)
204 * Converts a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form
205 * \param val is the output and should be of type uint32_t. It holds the converted
206 * UCS-4 character and should be a left value.
207 * \param GET_16BIT gets two bytes of UTF-16 encoded data converted to native endianness.
208 * It can be a function or a statement whose return value or evaluated value is of type
209 * uint16_t. It will be executed up to 2 times.
210 * \param ERROR action that should be taken when an invalid UTF-16 surrogate is
211 * returned from GET_BYTE. It should be a statement that jumps out of the macro,
212 * like exit(), goto, return, break, or continue.
213 */
214#define GET_UTF16(val, GET_16BIT, ERROR)\
215 val = GET_16BIT;\
216 {\
217 unsigned int hi = val - 0xD800;\
218 if (hi < 0x800) {\
219 val = GET_16BIT - 0xDC00;\
220 if (val > 0x3FFU || hi > 0x3FFU)\
221 ERROR\
222 val += (hi<<10) + 0x10000;\
223 }\
224 }\
225
226/*!
227 * \def PUT_UTF8(val, tmp, PUT_BYTE)
228 * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
229 * \param val is an input-only argument and should be of type uint32_t. It holds
230 * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
231 * val is given as a function it is executed only once.
232 * \param tmp is a temporary variable and should be of type uint8_t. It
233 * represents an intermediate value during conversion that is to be
234 * output by PUT_BYTE.
235 * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
236 * It could be a function or a statement, and uses tmp as the input byte.
237 * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
238 * executed up to 4 times for values in the valid UTF-8 range and up to
239 * 7 times in the general case, depending on the length of the converted
240 * Unicode character.
241 */
242#define PUT_UTF8(val, tmp, PUT_BYTE)\
243 {\
244 int bytes, shift;\
245 uint32_t in = val;\
246 if (in < 0x80) {\
247 tmp = in;\
248 PUT_BYTE\
249 } else {\
250 bytes = (av_log2(in) + 4) / 5;\
251 shift = (bytes - 1) * 6;\
252 tmp = (256 - (256 >> bytes)) | (in >> shift);\
253 PUT_BYTE\
254 while (shift >= 6) {\
255 shift -= 6;\
256 tmp = 0x80 | ((in >> shift) & 0x3f);\
257 PUT_BYTE\
258 }\
259 }\
260 }
261
262/*!
263 * \def PUT_UTF16(val, tmp, PUT_16BIT)
264 * Converts a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
265 * \param val is an input-only argument and should be of type uint32_t. It holds
266 * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If
267 * val is given as a function it is executed only once.
268 * \param tmp is a temporary variable and should be of type uint16_t. It
269 * represents an intermediate value during conversion that is to be
270 * output by PUT_16BIT.
271 * \param PUT_16BIT writes the converted UTF-16 data to any proper destination
272 * in desired endianness. It could be a function or a statement, and uses tmp
273 * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;"
274 * PUT_BYTE will be executed 1 or 2 times depending on input character.
275 */
276#define PUT_UTF16(val, tmp, PUT_16BIT)\
277 {\
278 uint32_t in = val;\
279 if (in < 0x10000) {\
280 tmp = in;\
281 PUT_16BIT\
282 } else {\
283 tmp = 0xD800 | ((in - 0x10000) >> 10);\
284 PUT_16BIT\
285 tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\
286 PUT_16BIT\
287 }\
288 }\
289
290
291
292#include "mem.h"
293
294#if 0
295#ifdef HAVE_AV_CONFIG_H
296# include "internal.h"
297#endif /* HAVE_AV_CONFIG_H */
298#endif
299#endif /* AVUTIL_COMMON_H */
diff --git a/apps/codecs/libwmapro/libavutil/internal.h b/apps/codecs/libwmapro/libavutil/internal.h
new file mode 100644
index 0000000000..2b8da1d8c2
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/internal.h
@@ -0,0 +1,207 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file libavutil/internal.h
23 * common internal API header
24 */
25
26#ifndef AVUTIL_INTERNAL_H
27#define AVUTIL_INTERNAL_H
28
29#if !defined(DEBUG) && !defined(NDEBUG)
30# define NDEBUG
31#endif
32
33#include <limits.h>
34#include <stdint.h>
35#include <stddef.h>
36#include <assert.h>
37//#include "config.h"
38#include "attributes.h"
39//#include "timer.h"
40
41#ifndef attribute_align_arg
42#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,2)
43# define attribute_align_arg __attribute__((force_align_arg_pointer))
44#else
45# define attribute_align_arg
46#endif
47#endif
48
49#ifndef attribute_used
50#if AV_GCC_VERSION_AT_LEAST(3,1)
51# define attribute_used __attribute__((used))
52#else
53# define attribute_used
54#endif
55#endif
56
57#ifndef av_alias
58#if HAVE_ATTRIBUTE_MAY_ALIAS && (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(3,3)
59# define av_alias __attribute__((may_alias))
60#else
61# define av_alias
62#endif
63#endif
64
65#ifndef INT16_MIN
66#define INT16_MIN (-0x7fff - 1)
67#endif
68
69#ifndef INT16_MAX
70#define INT16_MAX 0x7fff
71#endif
72
73#ifndef INT32_MIN
74#define INT32_MIN (-0x7fffffff - 1)
75#endif
76
77#ifndef INT32_MAX
78#define INT32_MAX 0x7fffffff
79#endif
80
81#ifndef UINT32_MAX
82#define UINT32_MAX 0xffffffff
83#endif
84
85#ifndef INT64_MIN
86#define INT64_MIN (-0x7fffffffffffffffLL - 1)
87#endif
88
89#ifndef INT64_MAX
90#define INT64_MAX INT64_C(9223372036854775807)
91#endif
92
93#ifndef UINT64_MAX
94#define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF)
95#endif
96
97#ifndef INT_BIT
98# define INT_BIT (CHAR_BIT * sizeof(int))
99#endif
100
101#ifndef offsetof
102# define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F))
103#endif
104
105/* Use to export labels from asm. */
106#define LABEL_MANGLE(a) EXTERN_PREFIX #a
107
108// Use rip-relative addressing if compiling PIC code on x86-64.
109#if ARCH_X86_64 && defined(PIC)
110# define LOCAL_MANGLE(a) #a "(%%rip)"
111#else
112# define LOCAL_MANGLE(a) #a
113#endif
114
115#define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
116
117/* debug stuff */
118
119/* dprintf macros */
120#ifdef DEBUG
121# define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
122#else
123# define dprintf(pctx, ...)
124#endif
125
126#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
127
128/* math */
129
130#if ARCH_X86
131#define MASK_ABS(mask, level)\
132 __asm__ volatile(\
133 "cltd \n\t"\
134 "xorl %1, %0 \n\t"\
135 "subl %1, %0 \n\t"\
136 : "+a" (level), "=&d" (mask)\
137 );
138#else
139#define MASK_ABS(mask, level)\
140 mask = level >> 31;\
141 level = (level ^ mask) - mask;
142#endif
143
144/* avoid usage of dangerous/inappropriate system functions */
145#undef malloc
146#define malloc please_use_av_malloc
147#undef free
148#define free please_use_av_free
149#undef realloc
150#define realloc please_use_av_realloc
151#undef time
152#define time time_is_forbidden_due_to_security_issues
153#undef rand
154#define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get
155#undef srand
156#define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init
157#undef random
158#define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get
159#undef sprintf
160#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
161#undef strcat
162#define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat
163#undef exit
164#define exit exit_is_forbidden
165#ifndef LIBAVFORMAT_BUILD
166#undef printf
167#define printf please_use_av_log_instead_of_printf
168#undef fprintf
169#define fprintf please_use_av_log_instead_of_fprintf
170#undef puts
171#define puts please_use_av_log_instead_of_puts
172#undef perror
173#define perror please_use_av_log_instead_of_perror
174#endif
175
176#define FF_ALLOC_OR_GOTO(ctx, p, size, label)\
177{\
178 p = av_malloc(size);\
179 if (p == NULL && (size) != 0) {\
180 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
181 goto label;\
182 }\
183}
184
185#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\
186{\
187 p = av_mallocz(size);\
188 if (p == NULL && (size) != 0) {\
189 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
190 goto label;\
191 }\
192}
193
194//#include "libm.h"
195
196/**
197 * Returns NULL if CONFIG_SMALL is true, otherwise the argument
198 * without modification. Used to disable the definition of strings
199 * (for example AVCodec long_names).
200 */
201#if CONFIG_SMALL
202# define NULL_IF_CONFIG_SMALL(x) NULL
203#else
204# define NULL_IF_CONFIG_SMALL(x) x
205#endif
206
207#endif /* AVUTIL_INTERNAL_H */
diff --git a/apps/codecs/libwmapro/libavutil/intreadwrite.h b/apps/codecs/libwmapro/libavutil/intreadwrite.h
new file mode 100644
index 0000000000..d27a50061e
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/intreadwrite.h
@@ -0,0 +1,192 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVUTIL_INTREADWRITE_H
20#define AVUTIL_INTREADWRITE_H
21
22#include <stdint.h>
23//#include "ffmpeg_config.h"
24#include "bswap.h"
25
26#ifdef __GNUC__
27
28struct unaligned_64 { uint64_t l; } __attribute__((packed));
29struct unaligned_32 { uint32_t l; } __attribute__((packed));
30struct unaligned_16 { uint16_t l; } __attribute__((packed));
31
32#define AV_RN16(a) (((const struct unaligned_16 *) (a))->l)
33#define AV_RN32(a) (((const struct unaligned_32 *) (a))->l)
34#define AV_RN64(a) (((const struct unaligned_64 *) (a))->l)
35
36#define AV_WN16(a, b) (((struct unaligned_16 *) (a))->l) = (b)
37#define AV_WN32(a, b) (((struct unaligned_32 *) (a))->l) = (b)
38#define AV_WN64(a, b) (((struct unaligned_64 *) (a))->l) = (b)
39
40#elif defined(__DECC)
41
42#define AV_RN16(a) (*((const __unaligned uint16_t*)(a)))
43#define AV_RN32(a) (*((const __unaligned uint32_t*)(a)))
44#define AV_RN64(a) (*((const __unaligned uint64_t*)(a)))
45
46#define AV_WN16(a, b) *((__unaligned uint16_t*)(a)) = (b)
47#define AV_WN32(a, b) *((__unaligned uint32_t*)(a)) = (b)
48#define AV_WN64(a, b) *((__unaligned uint64_t*)(a)) = (b)
49
50#else
51
52#define AV_RN16(a) (*((const uint16_t*)(a)))
53#define AV_RN32(a) (*((const uint32_t*)(a)))
54#define AV_RN64(a) (*((const uint64_t*)(a)))
55
56#define AV_WN16(a, b) *((uint16_t*)(a)) = (b)
57#define AV_WN32(a, b) *((uint32_t*)(a)) = (b)
58#define AV_WN64(a, b) *((uint64_t*)(a)) = (b)
59
60#endif /* !__GNUC__ */
61
62/* endian macros */
63#define AV_RB8(x) (((const uint8_t*)(x))[0])
64#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)
65
66#define AV_RL8(x) AV_RB8(x)
67#define AV_WL8(p, d) AV_WB8(p, d)
68
69#if HAVE_FAST_UNALIGNED
70# ifdef WORDS_BIGENDIAN
71# define AV_RB16(x) AV_RN16(x)
72# define AV_WB16(p, d) AV_WN16(p, d)
73
74# define AV_RL16(x) bswap_16(AV_RN16(x))
75# define AV_WL16(p, d) AV_WN16(p, bswap_16(d))
76
77# define AV_RB32(x) AV_RN32(x)
78# define AV_WB32(p, d) AV_WN32(p, d)
79
80# define AV_RL32(x) bswap_32(AV_RN32(x))
81# define AV_WL32(p, d) AV_WN32(p, bswap_32(d))
82
83# define AV_RB64(x) AV_RN64(x)
84# define AV_WB64(p, d) AV_WN64(p, d)
85
86# define AV_RL64(x) bswap_64(AV_RN64(x))
87# define AV_WL64(p, d) AV_WN64(p, bswap_64(d))
88# else /* WORDS_BIGENDIAN */
89# define AV_RB16(x) bswap_16(AV_RN16(x))
90# define AV_WB16(p, d) AV_WN16(p, bswap_16(d))
91
92# define AV_RL16(x) AV_RN16(x)
93# define AV_WL16(p, d) AV_WN16(p, d)
94
95# define AV_RB32(x) bswap_32(AV_RN32(x))
96# define AV_WB32(p, d) AV_WN32(p, bswap_32(d))
97
98# define AV_RL32(x) AV_RN32(x)
99# define AV_WL32(p, d) AV_WN32(p, d)
100
101# define AV_RB64(x) bswap_64(AV_RN64(x))
102# define AV_WB64(p, d) AV_WN64(p, bswap_64(d))
103
104# define AV_RL64(x) AV_RN64(x)
105# define AV_WL64(p, d) AV_WN64(p, d)
106# endif
107#else /* HAVE_FAST_UNALIGNED */
108#define AV_RB16(x) ((((const uint8_t*)(x))[0] << 8) | ((const uint8_t*)(x))[1])
109#define AV_WB16(p, d) do { \
110 ((uint8_t*)(p))[1] = (d); \
111 ((uint8_t*)(p))[0] = (d)>>8; } while(0)
112
113#define AV_RL16(x) ((((const uint8_t*)(x))[1] << 8) | \
114 ((const uint8_t*)(x))[0])
115#define AV_WL16(p, d) do { \
116 ((uint8_t*)(p))[0] = (d); \
117 ((uint8_t*)(p))[1] = (d)>>8; } while(0)
118
119#define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \
120 (((const uint8_t*)(x))[1] << 16) | \
121 (((const uint8_t*)(x))[2] << 8) | \
122 ((const uint8_t*)(x))[3])
123#define AV_WB32(p, d) do { \
124 ((uint8_t*)(p))[3] = (d); \
125 ((uint8_t*)(p))[2] = (d)>>8; \
126 ((uint8_t*)(p))[1] = (d)>>16; \
127 ((uint8_t*)(p))[0] = (d)>>24; } while(0)
128
129#define AV_RL32(x) ((((const uint8_t*)(x))[3] << 24) | \
130 (((const uint8_t*)(x))[2] << 16) | \
131 (((const uint8_t*)(x))[1] << 8) | \
132 ((const uint8_t*)(x))[0])
133#define AV_WL32(p, d) do { \
134 ((uint8_t*)(p))[0] = (d); \
135 ((uint8_t*)(p))[1] = (d)>>8; \
136 ((uint8_t*)(p))[2] = (d)>>16; \
137 ((uint8_t*)(p))[3] = (d)>>24; } while(0)
138
139#define AV_RB64(x) (((uint64_t)((const uint8_t*)(x))[0] << 56) | \
140 ((uint64_t)((const uint8_t*)(x))[1] << 48) | \
141 ((uint64_t)((const uint8_t*)(x))[2] << 40) | \
142 ((uint64_t)((const uint8_t*)(x))[3] << 32) | \
143 ((uint64_t)((const uint8_t*)(x))[4] << 24) | \
144 ((uint64_t)((const uint8_t*)(x))[5] << 16) | \
145 ((uint64_t)((const uint8_t*)(x))[6] << 8) | \
146 (uint64_t)((const uint8_t*)(x))[7])
147#define AV_WB64(p, d) do { \
148 ((uint8_t*)(p))[7] = (d); \
149 ((uint8_t*)(p))[6] = (d)>>8; \
150 ((uint8_t*)(p))[5] = (d)>>16; \
151 ((uint8_t*)(p))[4] = (d)>>24; \
152 ((uint8_t*)(p))[3] = (d)>>32; \
153 ((uint8_t*)(p))[2] = (d)>>40; \
154 ((uint8_t*)(p))[1] = (d)>>48; \
155 ((uint8_t*)(p))[0] = (d)>>56; } while(0)
156
157#define AV_RL64(x) (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
158 ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
159 ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
160 ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
161 ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
162 ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
163 ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
164 (uint64_t)((const uint8_t*)(x))[0])
165#define AV_WL64(p, d) do { \
166 ((uint8_t*)(p))[0] = (d); \
167 ((uint8_t*)(p))[1] = (d)>>8; \
168 ((uint8_t*)(p))[2] = (d)>>16; \
169 ((uint8_t*)(p))[3] = (d)>>24; \
170 ((uint8_t*)(p))[4] = (d)>>32; \
171 ((uint8_t*)(p))[5] = (d)>>40; \
172 ((uint8_t*)(p))[6] = (d)>>48; \
173 ((uint8_t*)(p))[7] = (d)>>56; } while(0)
174#endif /* HAVE_FAST_UNALIGNED */
175
176#define AV_RB24(x) ((((const uint8_t*)(x))[0] << 16) | \
177 (((const uint8_t*)(x))[1] << 8) | \
178 ((const uint8_t*)(x))[2])
179#define AV_WB24(p, d) do { \
180 ((uint8_t*)(p))[2] = (d); \
181 ((uint8_t*)(p))[1] = (d)>>8; \
182 ((uint8_t*)(p))[0] = (d)>>16; } while(0)
183
184#define AV_RL24(x) ((((const uint8_t*)(x))[2] << 16) | \
185 (((const uint8_t*)(x))[1] << 8) | \
186 ((const uint8_t*)(x))[0])
187#define AV_WL24(p, d) do { \
188 ((uint8_t*)(p))[0] = (d); \
189 ((uint8_t*)(p))[1] = (d)>>8; \
190 ((uint8_t*)(p))[2] = (d)>>16; } while(0)
191
192#endif /* AVUTIL_INTREADWRITE_H */
diff --git a/apps/codecs/libwmapro/libavutil/log.c b/apps/codecs/libwmapro/libavutil/log.c
new file mode 100644
index 0000000000..4bb9652c2c
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/log.c
@@ -0,0 +1,89 @@
1/*
2 * log functions
3 * Copyright (c) 2003 Michel Bardiaux
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/**
23 * @file libavutil/log.c
24 * logging functions
25 */
26
27#include "avutil.h"
28#include "log.h"
29
30int av_log_level = AV_LOG_INFO;
31
32void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
33{
34 static int print_prefix=1;
35 static int count;
36 static char line[1024], prev[1024];
37 AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
38 if(level>av_log_level)
39 return;
40#undef fprintf
41 if(print_prefix && avc) {
42 snprintf(line, sizeof(line), "[%s @ %p]", avc->item_name(ptr), ptr);
43 }else
44 line[0]=0;
45
46 vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
47
48 print_prefix= line[strlen(line)-1] == '\n';
49 if(print_prefix && !strcmp(line, prev)){
50 count++;
51 return;
52 }
53 if(count>0){
54 fprintf(stderr, " Last message repeated %d times\n", count);
55 count=0;
56 }
57 fputs(line, stderr);
58 strcpy(prev, line);
59}
60
61static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
62
63void av_log(void* avcl, int level, const char *fmt, ...)
64{
65 va_list vl;
66 va_start(vl, fmt);
67 av_vlog(avcl, level, fmt, vl);
68 va_end(vl);
69}
70
71void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
72{
73 av_log_callback(avcl, level, fmt, vl);
74}
75
76int av_log_get_level(void)
77{
78 return av_log_level;
79}
80
81void av_log_set_level(int level)
82{
83 av_log_level = level;
84}
85
86void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
87{
88 av_log_callback = callback;
89}
diff --git a/apps/codecs/libwmapro/libavutil/log.h b/apps/codecs/libwmapro/libavutil/log.h
new file mode 100644
index 0000000000..1206a2fc38
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/log.h
@@ -0,0 +1,116 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVUTIL_LOG_H
22#define AVUTIL_LOG_H
23
24#include <stdarg.h>
25#include "avutil.h"
26
27/**
28 * Describes the class of an AVClass context structure. That is an
29 * arbitrary struct of which the first field is a pointer to an
30 * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.).
31 */
32typedef struct AVCLASS AVClass;
33struct AVCLASS {
34 /**
35 * The name of the class; usually it is the same name as the
36 * context structure type to which the AVClass is associated.
37 */
38 const char* class_name;
39
40 /**
41 * A pointer to a function which returns the name of a context
42 * instance \p ctx associated with the class.
43 */
44 const char* (*item_name)(void* ctx);
45
46 /**
47 * a pointer to the first option specified in the class if any or NULL
48 *
49 * @see av_set_default_options()
50 */
51 const struct AVOption *option;
52};
53
54/* av_log API */
55
56#define AV_LOG_QUIET -8
57
58/**
59 * Something went really wrong and we will crash now.
60 */
61#define AV_LOG_PANIC 0
62
63/**
64 * Something went wrong and recovery is not possible.
65 * For example, no header was found for a format which depends
66 * on headers or an illegal combination of parameters is used.
67 */
68#define AV_LOG_FATAL 8
69
70/**
71 * Something went wrong and cannot losslessly be recovered.
72 * However, not all future data is affected.
73 */
74#define AV_LOG_ERROR 16
75
76/**
77 * Something somehow does not look correct. This may or may not
78 * lead to problems. An example would be the use of '-vstrict -2'.
79 */
80#define AV_LOG_WARNING 24
81
82#define AV_LOG_INFO 32
83#define AV_LOG_VERBOSE 40
84
85/**
86 * Stuff which is only useful for libav* developers.
87 */
88#define AV_LOG_DEBUG 48
89
90/**
91 * Sends the specified message to the log if the level is less than or equal
92 * to the current av_log_level. By default, all logging messages are sent to
93 * stderr. This behavior can be altered by setting a different av_vlog callback
94 * function.
95 *
96 * @param avcl A pointer to an arbitrary struct of which the first field is a
97 * pointer to an AVClass struct.
98 * @param level The importance level of the message, lower values signifying
99 * higher importance.
100 * @param fmt The format string (printf-compatible) that specifies how
101 * subsequent arguments are converted to output.
102 * @see av_vlog
103 */
104#ifdef __GNUC__
105void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
106#else
107void av_log(void*, int level, const char *fmt, ...);
108#endif
109
110void av_vlog(void*, int level, const char *fmt, va_list);
111int av_log_get_level(void);
112void av_log_set_level(int);
113void av_log_set_callback(void (*)(void*, int, const char*, va_list));
114void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
115
116#endif /* AVUTIL_LOG_H */
diff --git a/apps/codecs/libwmapro/libavutil/mathematics.c b/apps/codecs/libwmapro/libavutil/mathematics.c
new file mode 100644
index 0000000000..6c04db78af
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/mathematics.c
@@ -0,0 +1,177 @@
1/*
2 * Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file libavutil/mathematics.c
23 * miscellaneous math routines and tables
24 */
25
26#include <assert.h>
27#include <stdint.h>
28#include <limits.h>
29#include "mathematics.h"
30
31const uint8_t ff_sqrt_tab[256]={
32 0, 16, 23, 28, 32, 36, 40, 43, 46, 48, 51, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90,
33 91, 92, 94, 95, 96, 98, 99,100,102,103,104,105,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
34128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,144,145,146,147,148,149,150,151,151,152,153,154,155,156,156,
35157,158,159,160,160,161,162,163,164,164,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,179,179,180,181,
36182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202,
37203,204,204,205,205,206,207,207,208,208,209,210,210,211,212,212,213,213,214,215,215,216,216,217,218,218,219,219,220,220,221,222,
38222,223,223,224,224,225,226,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239,
39240,240,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255,255
40};
41
42const uint8_t ff_log2_tab[256]={
43 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
44 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
45 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
46 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
47 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
48 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
49 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
50 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
51};
52
53const uint8_t av_reverse[256]={
540x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
550x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
560x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
570x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
580x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
590x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
600x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
610x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
620x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
630x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
640x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
650x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
660x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
670x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
680x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
690x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF,
70};
71
72int64_t av_gcd(int64_t a, int64_t b){
73 if(b) return av_gcd(b, a%b);
74 else return a;
75}
76
77int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
78 int64_t r=0;
79 assert(c > 0);
80 assert(b >=0);
81 assert(rnd >=0 && rnd<=5 && rnd!=4);
82
83 if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1));
84
85 if(rnd==AV_ROUND_NEAR_INF) r= c/2;
86 else if(rnd&1) r= c-1;
87
88 if(b<=INT_MAX && c<=INT_MAX){
89 if(a<=INT_MAX)
90 return (a * b + r)/c;
91 else
92 return a/c*b + (a%c*b + r)/c;
93 }else{
94#if 1
95 uint64_t a0= a&0xFFFFFFFF;
96 uint64_t a1= a>>32;
97 uint64_t b0= b&0xFFFFFFFF;
98 uint64_t b1= b>>32;
99 uint64_t t1= a0*b1 + a1*b0;
100 uint64_t t1a= t1<<32;
101 int i;
102
103 a0 = a0*b0 + t1a;
104 a1 = a1*b1 + (t1>>32) + (a0<t1a);
105 a0 += r;
106 a1 += a0<r;
107
108 for(i=63; i>=0; i--){
109// int o= a1 & 0x8000000000000000ULL;
110 a1+= a1 + ((a0>>i)&1);
111 t1+=t1;
112 if(/*o || */c <= a1){
113 a1 -= c;
114 t1++;
115 }
116 }
117 return t1;
118 }
119#else
120 AVInteger ai;
121 ai= av_mul_i(av_int2i(a), av_int2i(b));
122 ai= av_add_i(ai, av_int2i(r));
123
124 return av_i2int(av_div_i(ai, av_int2i(c)));
125 }
126#endif
127}
128
129int64_t av_rescale(int64_t a, int64_t b, int64_t c){
130 return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
131}
132
133#if 0
134int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
135 int64_t b= bq.num * (int64_t)cq.den;
136 int64_t c= cq.num * (int64_t)bq.den;
137 return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
138}
139
140int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){
141 int64_t a= tb_a.num * (int64_t)tb_b.den;
142 int64_t b= tb_b.num * (int64_t)tb_a.den;
143 if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1;
144 if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1;
145 return 0;
146}
147
148#ifdef TEST
149#include "integer.h"
150#undef printf
151int main(void){
152 int64_t a,b,c,d,e;
153
154 for(a=7; a<(1LL<<62); a+=a/3+1){
155 for(b=3; b<(1LL<<62); b+=b/4+1){
156 for(c=9; c<(1LL<<62); c+=(c*2)/5+3){
157 int64_t r= c/2;
158 AVInteger ai;
159 ai= av_mul_i(av_int2i(a), av_int2i(b));
160 ai= av_add_i(ai, av_int2i(r));
161
162 d= av_i2int(av_div_i(ai, av_int2i(c)));
163
164 e= av_rescale(a,b,c);
165
166 if((double)a * (double)b / (double)c > (1LL<<63))
167 continue;
168
169 if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e);
170 }
171 }
172 }
173 return 0;
174}
175#endif
176
177#endif /* 0 */
diff --git a/apps/codecs/libwmapro/libavutil/mathematics.h b/apps/codecs/libwmapro/libavutil/mathematics.h
new file mode 100644
index 0000000000..a09d3e9ad8
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/mathematics.h
@@ -0,0 +1,98 @@
1/*
2 * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVUTIL_MATHEMATICS_H
22#define AVUTIL_MATHEMATICS_H
23
24#include <stdint.h>
25#include <math.h>
26#include "attributes.h"
27//#include "rational.h"
28
29#ifndef M_E
30#define M_E 2.7182818284590452354 /* e */
31#endif
32#ifndef M_LN2
33#define M_LN2 0.69314718055994530942 /* log_e 2 */
34#endif
35#ifndef M_LN10
36#define M_LN10 2.30258509299404568402 /* log_e 10 */
37#endif
38#ifndef M_LOG2_10
39#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */
40#endif
41#ifndef M_PI
42#define M_PI 3.14159265358979323846 /* pi */
43#endif
44#ifndef M_SQRT1_2
45#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
46#endif
47#ifndef M_SQRT2
48#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
49#endif
50#ifndef NAN
51#define NAN (0.0/0.0)
52#endif
53#ifndef INFINITY
54#define INFINITY (1.0/0.0)
55#endif
56
57enum AVRounding {
58 AV_ROUND_ZERO = 0, ///< Round toward zero.
59 AV_ROUND_INF = 1, ///< Round away from zero.
60 AV_ROUND_DOWN = 2, ///< Round toward -infinity.
61 AV_ROUND_UP = 3, ///< Round toward +infinity.
62 AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero.
63};
64
65/**
66 * Returns the greatest common divisor of a and b.
67 * If both a and b are 0 or either or both are <0 then behavior is
68 * undefined.
69 */
70int64_t av_const av_gcd(int64_t a, int64_t b);
71
72/**
73 * Rescales a 64-bit integer with rounding to nearest.
74 * A simple a*b/c isn't possible as it can overflow.
75 */
76int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
77
78/**
79 * Rescales a 64-bit integer with specified rounding.
80 * A simple a*b/c isn't possible as it can overflow.
81 */
82int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const;
83
84/**
85 * Rescales a 64-bit integer by 2 rational numbers.
86 */
87//int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
88
89/**
90 * Compares 2 timestamps each in its own timebases.
91 * The result of the function is undefined if one of the timestamps
92 * is outside the int64_t range when represented in the others timebase.
93 * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position
94 */
95//int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
96
97
98#endif /* AVUTIL_MATHEMATICS_H */
diff --git a/apps/codecs/libwmapro/libavutil/mem.c b/apps/codecs/libwmapro/libavutil/mem.c
new file mode 100644
index 0000000000..9721222e50
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/mem.c
@@ -0,0 +1,159 @@
1/*
2 * default memory allocator for libavutil
3 * Copyright (c) 2002 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/**
23 * @file libavutil/mem.c
24 * default memory allocator for libavutil
25 */
26
27//#include "ffmpeg_config.h"
28
29#include <limits.h>
30#include <stdlib.h>
31#include <string.h>
32#if HAVE_MALLOC_H
33#include <malloc.h>
34#endif
35
36#include "mem.h"
37
38/* here we can use OS-dependent allocation functions */
39#undef free
40#undef malloc
41#undef realloc
42
43/* You can redefine av_malloc and av_free in your project to use your
44 memory allocator. You do not need to suppress this file because the
45 linker will do it automatically. */
46
47void *av_malloc(unsigned int size)
48{
49 void *ptr = NULL;
50#if CONFIG_MEMALIGN_HACK
51 long diff;
52#endif
53
54 /* let's disallow possible ambiguous cases */
55 if(size > (INT_MAX-16) )
56 return NULL;
57
58#if CONFIG_MEMALIGN_HACK
59 ptr = malloc(size+16);
60 if(!ptr)
61 return ptr;
62 diff= ((-(long)ptr - 1)&15) + 1;
63 ptr = (char*)ptr + diff;
64 ((char*)ptr)[-1]= diff;
65#elif HAVE_POSIX_MEMALIGN
66 if (posix_memalign(&ptr,16,size))
67 ptr = NULL;
68#elif HAVE_MEMALIGN
69 ptr = memalign(16,size);
70 /* Why 64?
71 Indeed, we should align it:
72 on 4 for 386
73 on 16 for 486
74 on 32 for 586, PPro - K6-III
75 on 64 for K7 (maybe for P3 too).
76 Because L1 and L2 caches are aligned on those values.
77 But I don't want to code such logic here!
78 */
79 /* Why 16?
80 Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs
81 it will just trigger an exception and the unaligned load will be done in the
82 exception handler or it will just segfault (SSE2 on P4).
83 Why not larger? Because I did not see a difference in benchmarks ...
84 */
85 /* benchmarks with P3
86 memalign(64)+1 3071,3051,3032
87 memalign(64)+2 3051,3032,3041
88 memalign(64)+4 2911,2896,2915
89 memalign(64)+8 2545,2554,2550
90 memalign(64)+16 2543,2572,2563
91 memalign(64)+32 2546,2545,2571
92 memalign(64)+64 2570,2533,2558
93
94 BTW, malloc seems to do 8-byte alignment by default here.
95 */
96#else
97 ptr = malloc(size);
98#endif
99 return ptr;
100}
101
102void *av_realloc(void *ptr, unsigned int size)
103{
104#if CONFIG_MEMALIGN_HACK
105 int diff;
106#endif
107
108 /* let's disallow possible ambiguous cases */
109 if(size > (INT_MAX-16) )
110 return NULL;
111
112#if CONFIG_MEMALIGN_HACK
113 //FIXME this isn't aligned correctly, though it probably isn't needed
114 if(!ptr) return av_malloc(size);
115 diff= ((char*)ptr)[-1];
116 return (char*)realloc((char*)ptr - diff, size + diff) + diff;
117#else
118 return realloc(ptr, size);
119#endif
120}
121
122void av_free(void *ptr)
123{
124 /* XXX: this test should not be needed on most libcs */
125 if (ptr)
126#if CONFIG_MEMALIGN_HACK
127 free((char*)ptr - ((char*)ptr)[-1]);
128#else
129 free(ptr);
130#endif
131}
132
133void av_freep(void *arg)
134{
135 void **ptr= (void**)arg;
136 av_free(*ptr);
137 *ptr = NULL;
138}
139
140void *av_mallocz(unsigned int size)
141{
142 void *ptr = av_malloc(size);
143 if (ptr)
144 memset(ptr, 0, size);
145 return ptr;
146}
147
148char *av_strdup(const char *s)
149{
150 char *ptr= NULL;
151 if(s){
152 int len = strlen(s) + 1;
153 ptr = av_malloc(len);
154 if (ptr)
155 memcpy(ptr, s, len);
156 }
157 return ptr;
158}
159
diff --git a/apps/codecs/libwmapro/libavutil/mem.h b/apps/codecs/libwmapro/libavutil/mem.h
new file mode 100644
index 0000000000..e50553aefe
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/mem.h
@@ -0,0 +1,104 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file libavutil/mem.h
23 * memory handling functions
24 */
25
26#ifndef AVUTIL_MEM_H
27#define AVUTIL_MEM_H
28
29#include "common.h"
30
31#if AV_GCC_VERSION_AT_LEAST(3,1)
32 #define av_malloc_attrib __attribute__((__malloc__))
33#else
34 #define av_malloc_attrib
35#endif
36
37#if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,3)
38 #define av_alloc_size(n) __attribute__((alloc_size(n)))
39#else
40 #define av_alloc_size(n)
41#endif
42
43/**
44 * Allocates a block of \p size bytes with alignment suitable for all
45 * memory accesses (including vectors if available on the CPU).
46 * @param size Size in bytes for the memory block to be allocated.
47 * @return Pointer to the allocated block, NULL if the block cannot
48 * be allocated.
49 * @see av_mallocz()
50 */
51void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1);
52
53/**
54 * Allocates or reallocates a block of memory.
55 * If \p ptr is NULL and \p size > 0, allocates a new block. If \p
56 * size is zero, frees the memory block pointed to by \p ptr.
57 * @param size Size in bytes for the memory block to be allocated or
58 * reallocated.
59 * @param ptr Pointer to a memory block already allocated with
60 * av_malloc(z)() or av_realloc() or NULL.
61 * @return Pointer to a newly reallocated block or NULL if the block
62 * cannot be reallocated or the function is used to free the memory block.
63 * @see av_fast_realloc()
64 */
65void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2);
66
67/**
68 * Frees a memory block which has been allocated with av_malloc(z)() or
69 * av_realloc().
70 * @param ptr Pointer to the memory block which should be freed.
71 * @note ptr = NULL is explicitly allowed.
72 * @note It is recommended that you use av_freep() instead.
73 * @see av_freep()
74 */
75void av_free(void *ptr);
76
77/**
78 * Allocates a block of \p size bytes with alignment suitable for all
79 * memory accesses (including vectors if available on the CPU) and
80 * zeroes all the bytes of the block.
81 * @param size Size in bytes for the memory block to be allocated.
82 * @return Pointer to the allocated block, NULL if it cannot be allocated.
83 * @see av_malloc()
84 */
85void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1);
86
87/**
88 * Duplicates the string \p s.
89 * @param s string to be duplicated
90 * @return Pointer to a newly allocated string containing a
91 * copy of \p s or NULL if the string cannot be allocated.
92 */
93char *av_strdup(const char *s) av_malloc_attrib;
94
95/**
96 * Frees a memory block which has been allocated with av_malloc(z)() or
97 * av_realloc() and set the pointer pointing to it to NULL.
98 * @param ptr Pointer to the pointer to the memory block which should
99 * be freed.
100 * @see av_free()
101 */
102void av_freep(void *ptr);
103
104#endif /* AVUTIL_MEM_H */