summaryrefslogtreecommitdiff
path: root/apps/codecs/libwmapro/libavutil
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libwmapro/libavutil')
-rw-r--r--apps/codecs/libwmapro/libavutil/attributes.h113
-rw-r--r--apps/codecs/libwmapro/libavutil/avutil.h89
-rw-r--r--apps/codecs/libwmapro/libavutil/bswap.h101
-rw-r--r--apps/codecs/libwmapro/libavutil/common.h297
-rw-r--r--apps/codecs/libwmapro/libavutil/internal.h207
-rw-r--r--apps/codecs/libwmapro/libavutil/intreadwrite.h516
-rw-r--r--apps/codecs/libwmapro/libavutil/log.c92
-rw-r--r--apps/codecs/libwmapro/libavutil/log.h115
-rw-r--r--apps/codecs/libwmapro/libavutil/mathematics.c174
-rw-r--r--apps/codecs/libwmapro/libavutil/mathematics.h98
-rw-r--r--apps/codecs/libwmapro/libavutil/mem.c176
-rw-r--r--apps/codecs/libwmapro/libavutil/mem.h125
12 files changed, 2103 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..1523de6753
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/avutil.h
@@ -0,0 +1,89 @@
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_GLUE(a, b) a ## b
34#define AV_JOIN(a, b) AV_GLUE(a, b)
35
36#define AV_PRAGMA(s) _Pragma(#s)
37
38#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c)
39#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c
40#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41
42#define LIBAVUTIL_VERSION_MAJOR 50
43#define LIBAVUTIL_VERSION_MINOR 14
44#define LIBAVUTIL_VERSION_MICRO 0
45
46#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
47 LIBAVUTIL_VERSION_MINOR, \
48 LIBAVUTIL_VERSION_MICRO)
49#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \
50 LIBAVUTIL_VERSION_MINOR, \
51 LIBAVUTIL_VERSION_MICRO)
52#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
53
54#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
55
56/**
57 * Returns the LIBAVUTIL_VERSION_INT constant.
58 */
59unsigned avutil_version(void);
60
61/**
62 * Returns the libavutil build-time configuration.
63 */
64const char *avutil_configuration(void);
65
66/**
67 * Returns the libavutil license.
68 */
69const char *avutil_license(void);
70
71enum AVMediaType {
72 AVMEDIA_TYPE_UNKNOWN = -1,
73 AVMEDIA_TYPE_VIDEO,
74 AVMEDIA_TYPE_AUDIO,
75 AVMEDIA_TYPE_DATA,
76 AVMEDIA_TYPE_SUBTITLE,
77 AVMEDIA_TYPE_ATTACHMENT,
78 AVMEDIA_TYPE_NB
79};
80
81#include "common.h"
82#include "error.h"
83#include "mathematics.h"
84#include "rational.h"
85#include "intfloat_readwrite.h"
86#include "log.h"
87#include "pixfmt.h"
88
89#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..74c7af3026
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/bswap.h
@@ -0,0 +1,101 @@
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 "config.h"
31#include "attributes.h"
32
33#if ARCH_ARM
34# include "arm/bswap.h"
35#elif ARCH_AVR32
36# include "avr32/bswap.h"
37#elif ARCH_BFIN
38# include "bfin/bswap.h"
39#elif ARCH_SH4
40# include "sh4/bswap.h"
41#elif ARCH_X86
42# include "x86/bswap.h"
43#endif
44
45#ifndef bswap_16
46static av_always_inline av_const uint16_t bswap_16(uint16_t x)
47{
48 x= (x>>8) | (x<<8);
49 return x;
50}
51#endif
52
53#ifndef bswap_32
54static av_always_inline av_const uint32_t bswap_32(uint32_t x)
55{
56 x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
57 x= (x>>16) | (x<<16);
58 return x;
59}
60#endif
61
62#ifndef bswap_64
63static inline uint64_t av_const bswap_64(uint64_t x)
64{
65#if 0
66 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
67 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
68 return (x>>32) | (x<<32);
69#else
70 union {
71 uint64_t ll;
72 uint32_t l[2];
73 } w, r;
74 w.ll = x;
75 r.l[0] = bswap_32 (w.l[1]);
76 r.l[1] = bswap_32 (w.l[0]);
77 return r.ll;
78#endif
79}
80#endif
81
82// be2me ... big-endian to machine-endian
83// le2me ... little-endian to machine-endian
84
85#if HAVE_BIGENDIAN
86#define be2me_16(x) (x)
87#define be2me_32(x) (x)
88#define be2me_64(x) (x)
89#define le2me_16(x) bswap_16(x)
90#define le2me_32(x) bswap_32(x)
91#define le2me_64(x) bswap_64(x)
92#else
93#define be2me_16(x) bswap_16(x)
94#define be2me_32(x) bswap_32(x)
95#define be2me_64(x) bswap_64(x)
96#define le2me_16(x) (x)
97#define le2me_32(x) (x)
98#define le2me_64(x) (x)
99#endif
100
101#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..fae0b5b09b
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/common.h
@@ -0,0 +1,297 @@
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
39//rounded division & shift
40#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
41/* assume b>0 */
42#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
43#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
44#define FFSIGN(a) ((a) > 0 ? 1 : -1)
45
46#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
47#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
48#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
49#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
50
51#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
52#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
53#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
54
55/* misc math functions */
56extern const uint8_t ff_log2_tab[256];
57
58extern const uint8_t av_reverse[256];
59
60static inline av_const int av_log2_c(unsigned int v)
61{
62 int n = 0;
63 if (v & 0xffff0000) {
64 v >>= 16;
65 n += 16;
66 }
67 if (v & 0xff00) {
68 v >>= 8;
69 n += 8;
70 }
71 n += ff_log2_tab[v];
72
73 return n;
74}
75
76static inline av_const int av_log2_16bit_c(unsigned int v)
77{
78 int n = 0;
79 if (v & 0xff00) {
80 v >>= 8;
81 n += 8;
82 }
83 n += ff_log2_tab[v];
84
85 return n;
86}
87
88#ifdef HAVE_AV_CONFIG_H
89# include "config.h"
90# include "intmath.h"
91#endif
92
93#ifndef av_log2
94# define av_log2 av_log2_c
95#endif
96#ifndef av_log2_16bit
97# define av_log2_16bit av_log2_16bit_c
98#endif
99
100/**
101 * Clips a signed integer value into the amin-amax range.
102 * @param a value to clip
103 * @param amin minimum value of the clip range
104 * @param amax maximum value of the clip range
105 * @return clipped value
106 */
107static inline av_const int av_clip(int a, int amin, int amax)
108{
109 if (a < amin) return amin;
110 else if (a > amax) return amax;
111 else return a;
112}
113
114/**
115 * Clips a signed integer value into the 0-255 range.
116 * @param a value to clip
117 * @return clipped value
118 */
119static inline av_const uint8_t av_clip_uint8(int a)
120{
121 if (a&(~255)) return (-a)>>31;
122 else return a;
123}
124
125/**
126 * Clips a signed integer value into the 0-65535 range.
127 * @param a value to clip
128 * @return clipped value
129 */
130static inline av_const uint16_t av_clip_uint16(int a)
131{
132 if (a&(~65535)) return (-a)>>31;
133 else return a;
134}
135
136/**
137 * Clips a signed integer value into the -32768,32767 range.
138 * @param a value to clip
139 * @return clipped value
140 */
141static inline av_const int16_t av_clip_int16(int a)
142{
143 if ((a+32768) & ~65535) return (a>>31) ^ 32767;
144 else return a;
145}
146
147/**
148 * Clips a float value into the amin-amax range.
149 * @param a value to clip
150 * @param amin minimum value of the clip range
151 * @param amax maximum value of the clip range
152 * @return clipped value
153 */
154static inline av_const float av_clipf(float a, float amin, float amax)
155{
156 if (a < amin) return amin;
157 else if (a > amax) return amax;
158 else return a;
159}
160
161/** Computes ceil(log2(x)).
162 * @param x value used to compute ceil(log2(x))
163 * @return computed ceiling of log2(x)
164 */
165static inline av_const int av_ceil_log2(int x)
166{
167 return av_log2((x - 1) << 1);
168}
169
170#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
171#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
172
173/*!
174 * \def GET_UTF8(val, GET_BYTE, ERROR)
175 * Converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form
176 * \param val is the output and should be of type uint32_t. It holds the converted
177 * UCS-4 character and should be a left value.
178 * \param GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be
179 * a function or a statement whose return value or evaluated value is of type
180 * uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range,
181 * and up to 7 times in the general case.
182 * \param ERROR action that should be taken when an invalid UTF-8 byte is returned
183 * from GET_BYTE. It should be a statement that jumps out of the macro,
184 * like exit(), goto, return, break, or continue.
185 */
186#define GET_UTF8(val, GET_BYTE, ERROR)\
187 val= GET_BYTE;\
188 {\
189 int ones= 7 - av_log2(val ^ 255);\
190 if(ones==1)\
191 ERROR\
192 val&= 127>>ones;\
193 while(--ones > 0){\
194 int tmp= GET_BYTE - 128;\
195 if(tmp>>6)\
196 ERROR\
197 val= (val<<6) + tmp;\
198 }\
199 }
200
201/*!
202 * \def GET_UTF16(val, GET_16BIT, ERROR)
203 * Converts a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form
204 * \param val is the output and should be of type uint32_t. It holds the converted
205 * UCS-4 character and should be a left value.
206 * \param GET_16BIT gets two bytes of UTF-16 encoded data converted to native endianness.
207 * It can be a function or a statement whose return value or evaluated value is of type
208 * uint16_t. It will be executed up to 2 times.
209 * \param ERROR action that should be taken when an invalid UTF-16 surrogate is
210 * returned from GET_BYTE. It should be a statement that jumps out of the macro,
211 * like exit(), goto, return, break, or continue.
212 */
213#define GET_UTF16(val, GET_16BIT, ERROR)\
214 val = GET_16BIT;\
215 {\
216 unsigned int hi = val - 0xD800;\
217 if (hi < 0x800) {\
218 val = GET_16BIT - 0xDC00;\
219 if (val > 0x3FFU || hi > 0x3FFU)\
220 ERROR\
221 val += (hi<<10) + 0x10000;\
222 }\
223 }\
224
225/*!
226 * \def PUT_UTF8(val, tmp, PUT_BYTE)
227 * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
228 * \param val is an input-only argument and should be of type uint32_t. It holds
229 * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
230 * val is given as a function it is executed only once.
231 * \param tmp is a temporary variable and should be of type uint8_t. It
232 * represents an intermediate value during conversion that is to be
233 * output by PUT_BYTE.
234 * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
235 * It could be a function or a statement, and uses tmp as the input byte.
236 * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
237 * executed up to 4 times for values in the valid UTF-8 range and up to
238 * 7 times in the general case, depending on the length of the converted
239 * Unicode character.
240 */
241#define PUT_UTF8(val, tmp, PUT_BYTE)\
242 {\
243 int bytes, shift;\
244 uint32_t in = val;\
245 if (in < 0x80) {\
246 tmp = in;\
247 PUT_BYTE\
248 } else {\
249 bytes = (av_log2(in) + 4) / 5;\
250 shift = (bytes - 1) * 6;\
251 tmp = (256 - (256 >> bytes)) | (in >> shift);\
252 PUT_BYTE\
253 while (shift >= 6) {\
254 shift -= 6;\
255 tmp = 0x80 | ((in >> shift) & 0x3f);\
256 PUT_BYTE\
257 }\
258 }\
259 }
260
261/*!
262 * \def PUT_UTF16(val, tmp, PUT_16BIT)
263 * Converts a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
264 * \param val is an input-only argument and should be of type uint32_t. It holds
265 * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If
266 * val is given as a function it is executed only once.
267 * \param tmp is a temporary variable and should be of type uint16_t. It
268 * represents an intermediate value during conversion that is to be
269 * output by PUT_16BIT.
270 * \param PUT_16BIT writes the converted UTF-16 data to any proper destination
271 * in desired endianness. It could be a function or a statement, and uses tmp
272 * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;"
273 * PUT_BYTE will be executed 1 or 2 times depending on input character.
274 */
275#define PUT_UTF16(val, tmp, PUT_16BIT)\
276 {\
277 uint32_t in = val;\
278 if (in < 0x10000) {\
279 tmp = in;\
280 PUT_16BIT\
281 } else {\
282 tmp = 0xD800 | ((in - 0x10000) >> 10);\
283 PUT_16BIT\
284 tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\
285 PUT_16BIT\
286 }\
287 }\
288
289
290
291#include "mem.h"
292
293#ifdef HAVE_AV_CONFIG_H
294# include "internal.h"
295#endif /* HAVE_AV_CONFIG_H */
296
297#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..b47db3d8c6
--- /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..c8026f0872
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/intreadwrite.h
@@ -0,0 +1,516 @@
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 "config.h"
24#include "bswap.h"
25#include "common.h"
26
27typedef union {
28 uint64_t u64;
29 uint32_t u32[2];
30 uint16_t u16[4];
31 uint8_t u8 [8];
32 double f64;
33 float f32[2];
34} av_alias av_alias64;
35
36typedef union {
37 uint32_t u32;
38 uint16_t u16[2];
39 uint8_t u8 [4];
40 float f32;
41} av_alias av_alias32;
42
43typedef union {
44 uint16_t u16;
45 uint8_t u8 [2];
46} av_alias av_alias16;
47
48/*
49 * Arch-specific headers can provide any combination of
50 * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros.
51 * Preprocessor symbols must be defined, even if these are implemented
52 * as inline functions.
53 */
54
55#if ARCH_ARM
56# include "arm/intreadwrite.h"
57#elif ARCH_AVR32
58# include "avr32/intreadwrite.h"
59#elif ARCH_MIPS
60# include "mips/intreadwrite.h"
61#elif ARCH_PPC
62# include "ppc/intreadwrite.h"
63#elif ARCH_TOMI
64# include "tomi/intreadwrite.h"
65#elif ARCH_X86
66# include "x86/intreadwrite.h"
67#endif
68
69/*
70 * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
71 */
72
73#if HAVE_BIGENDIAN
74
75# if defined(AV_RN16) && !defined(AV_RB16)
76# define AV_RB16(p) AV_RN16(p)
77# elif !defined(AV_RN16) && defined(AV_RB16)
78# define AV_RN16(p) AV_RB16(p)
79# endif
80
81# if defined(AV_WN16) && !defined(AV_WB16)
82# define AV_WB16(p, v) AV_WN16(p, v)
83# elif !defined(AV_WN16) && defined(AV_WB16)
84# define AV_WN16(p, v) AV_WB16(p, v)
85# endif
86
87# if defined(AV_RN24) && !defined(AV_RB24)
88# define AV_RB24(p) AV_RN24(p)
89# elif !defined(AV_RN24) && defined(AV_RB24)
90# define AV_RN24(p) AV_RB24(p)
91# endif
92
93# if defined(AV_WN24) && !defined(AV_WB24)
94# define AV_WB24(p, v) AV_WN24(p, v)
95# elif !defined(AV_WN24) && defined(AV_WB24)
96# define AV_WN24(p, v) AV_WB24(p, v)
97# endif
98
99# if defined(AV_RN32) && !defined(AV_RB32)
100# define AV_RB32(p) AV_RN32(p)
101# elif !defined(AV_RN32) && defined(AV_RB32)
102# define AV_RN32(p) AV_RB32(p)
103# endif
104
105# if defined(AV_WN32) && !defined(AV_WB32)
106# define AV_WB32(p, v) AV_WN32(p, v)
107# elif !defined(AV_WN32) && defined(AV_WB32)
108# define AV_WN32(p, v) AV_WB32(p, v)
109# endif
110
111# if defined(AV_RN64) && !defined(AV_RB64)
112# define AV_RB64(p) AV_RN64(p)
113# elif !defined(AV_RN64) && defined(AV_RB64)
114# define AV_RN64(p) AV_RB64(p)
115# endif
116
117# if defined(AV_WN64) && !defined(AV_WB64)
118# define AV_WB64(p, v) AV_WN64(p, v)
119# elif !defined(AV_WN64) && defined(AV_WB64)
120# define AV_WN64(p, v) AV_WB64(p, v)
121# endif
122
123#else /* HAVE_BIGENDIAN */
124
125# if defined(AV_RN16) && !defined(AV_RL16)
126# define AV_RL16(p) AV_RN16(p)
127# elif !defined(AV_RN16) && defined(AV_RL16)
128# define AV_RN16(p) AV_RL16(p)
129# endif
130
131# if defined(AV_WN16) && !defined(AV_WL16)
132# define AV_WL16(p, v) AV_WN16(p, v)
133# elif !defined(AV_WN16) && defined(AV_WL16)
134# define AV_WN16(p, v) AV_WL16(p, v)
135# endif
136
137# if defined(AV_RN24) && !defined(AV_RL24)
138# define AV_RL24(p) AV_RN24(p)
139# elif !defined(AV_RN24) && defined(AV_RL24)
140# define AV_RN24(p) AV_RL24(p)
141# endif
142
143# if defined(AV_WN24) && !defined(AV_WL24)
144# define AV_WL24(p, v) AV_WN24(p, v)
145# elif !defined(AV_WN24) && defined(AV_WL24)
146# define AV_WN24(p, v) AV_WL24(p, v)
147# endif
148
149# if defined(AV_RN32) && !defined(AV_RL32)
150# define AV_RL32(p) AV_RN32(p)
151# elif !defined(AV_RN32) && defined(AV_RL32)
152# define AV_RN32(p) AV_RL32(p)
153# endif
154
155# if defined(AV_WN32) && !defined(AV_WL32)
156# define AV_WL32(p, v) AV_WN32(p, v)
157# elif !defined(AV_WN32) && defined(AV_WL32)
158# define AV_WN32(p, v) AV_WL32(p, v)
159# endif
160
161# if defined(AV_RN64) && !defined(AV_RL64)
162# define AV_RL64(p) AV_RN64(p)
163# elif !defined(AV_RN64) && defined(AV_RL64)
164# define AV_RN64(p) AV_RL64(p)
165# endif
166
167# if defined(AV_WN64) && !defined(AV_WL64)
168# define AV_WL64(p, v) AV_WN64(p, v)
169# elif !defined(AV_WN64) && defined(AV_WL64)
170# define AV_WN64(p, v) AV_WL64(p, v)
171# endif
172
173#endif /* !HAVE_BIGENDIAN */
174
175/*
176 * Define AV_[RW]N helper macros to simplify definitions not provided
177 * by per-arch headers.
178 */
179
180#if HAVE_ATTRIBUTE_PACKED
181
182union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
183union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
184union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
185
186# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
187# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
188
189#elif defined(__DECC)
190
191# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
192# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
193
194#elif HAVE_FAST_UNALIGNED
195
196# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)
197# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v))
198
199#else
200
201#ifndef AV_RB16
202# define AV_RB16(x) \
203 ((((const uint8_t*)(x))[0] << 8) | \
204 ((const uint8_t*)(x))[1])
205#endif
206#ifndef AV_WB16
207# define AV_WB16(p, d) do { \
208 ((uint8_t*)(p))[1] = (d); \
209 ((uint8_t*)(p))[0] = (d)>>8; \
210 } while(0)
211#endif
212
213#ifndef AV_RL16
214# define AV_RL16(x) \
215 ((((const uint8_t*)(x))[1] << 8) | \
216 ((const uint8_t*)(x))[0])
217#endif
218#ifndef AV_WL16
219# define AV_WL16(p, d) do { \
220 ((uint8_t*)(p))[0] = (d); \
221 ((uint8_t*)(p))[1] = (d)>>8; \
222 } while(0)
223#endif
224
225#ifndef AV_RB32
226# define AV_RB32(x) \
227 ((((const uint8_t*)(x))[0] << 24) | \
228 (((const uint8_t*)(x))[1] << 16) | \
229 (((const uint8_t*)(x))[2] << 8) | \
230 ((const uint8_t*)(x))[3])
231#endif
232#ifndef AV_WB32
233# define AV_WB32(p, d) do { \
234 ((uint8_t*)(p))[3] = (d); \
235 ((uint8_t*)(p))[2] = (d)>>8; \
236 ((uint8_t*)(p))[1] = (d)>>16; \
237 ((uint8_t*)(p))[0] = (d)>>24; \
238 } while(0)
239#endif
240
241#ifndef AV_RL32
242# define AV_RL32(x) \
243 ((((const uint8_t*)(x))[3] << 24) | \
244 (((const uint8_t*)(x))[2] << 16) | \
245 (((const uint8_t*)(x))[1] << 8) | \
246 ((const uint8_t*)(x))[0])
247#endif
248#ifndef AV_WL32
249# define AV_WL32(p, d) do { \
250 ((uint8_t*)(p))[0] = (d); \
251 ((uint8_t*)(p))[1] = (d)>>8; \
252 ((uint8_t*)(p))[2] = (d)>>16; \
253 ((uint8_t*)(p))[3] = (d)>>24; \
254 } while(0)
255#endif
256
257#ifndef AV_RB64
258# define AV_RB64(x) \
259 (((uint64_t)((const uint8_t*)(x))[0] << 56) | \
260 ((uint64_t)((const uint8_t*)(x))[1] << 48) | \
261 ((uint64_t)((const uint8_t*)(x))[2] << 40) | \
262 ((uint64_t)((const uint8_t*)(x))[3] << 32) | \
263 ((uint64_t)((const uint8_t*)(x))[4] << 24) | \
264 ((uint64_t)((const uint8_t*)(x))[5] << 16) | \
265 ((uint64_t)((const uint8_t*)(x))[6] << 8) | \
266 (uint64_t)((const uint8_t*)(x))[7])
267#endif
268#ifndef AV_WB64
269# define AV_WB64(p, d) do { \
270 ((uint8_t*)(p))[7] = (d); \
271 ((uint8_t*)(p))[6] = (d)>>8; \
272 ((uint8_t*)(p))[5] = (d)>>16; \
273 ((uint8_t*)(p))[4] = (d)>>24; \
274 ((uint8_t*)(p))[3] = (d)>>32; \
275 ((uint8_t*)(p))[2] = (d)>>40; \
276 ((uint8_t*)(p))[1] = (d)>>48; \
277 ((uint8_t*)(p))[0] = (d)>>56; \
278 } while(0)
279#endif
280
281#ifndef AV_RL64
282# define AV_RL64(x) \
283 (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
284 ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
285 ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
286 ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
287 ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
288 ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
289 ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
290 (uint64_t)((const uint8_t*)(x))[0])
291#endif
292#ifndef AV_WL64
293# define AV_WL64(p, d) do { \
294 ((uint8_t*)(p))[0] = (d); \
295 ((uint8_t*)(p))[1] = (d)>>8; \
296 ((uint8_t*)(p))[2] = (d)>>16; \
297 ((uint8_t*)(p))[3] = (d)>>24; \
298 ((uint8_t*)(p))[4] = (d)>>32; \
299 ((uint8_t*)(p))[5] = (d)>>40; \
300 ((uint8_t*)(p))[6] = (d)>>48; \
301 ((uint8_t*)(p))[7] = (d)>>56; \
302 } while(0)
303#endif
304
305#if HAVE_BIGENDIAN
306# define AV_RN(s, p) AV_RB##s(p)
307# define AV_WN(s, p, v) AV_WB##s(p, v)
308#else
309# define AV_RN(s, p) AV_RL##s(p)
310# define AV_WN(s, p, v) AV_WL##s(p, v)
311#endif
312
313#endif /* HAVE_FAST_UNALIGNED */
314
315#ifndef AV_RN16
316# define AV_RN16(p) AV_RN(16, p)
317#endif
318
319#ifndef AV_RN32
320# define AV_RN32(p) AV_RN(32, p)
321#endif
322
323#ifndef AV_RN64
324# define AV_RN64(p) AV_RN(64, p)
325#endif
326
327#ifndef AV_WN16
328# define AV_WN16(p, v) AV_WN(16, p, v)
329#endif
330
331#ifndef AV_WN32
332# define AV_WN32(p, v) AV_WN(32, p, v)
333#endif
334
335#ifndef AV_WN64
336# define AV_WN64(p, v) AV_WN(64, p, v)
337#endif
338
339#if HAVE_BIGENDIAN
340# define AV_RB(s, p) AV_RN##s(p)
341# define AV_WB(s, p, v) AV_WN##s(p, v)
342# define AV_RL(s, p) bswap_##s(AV_RN##s(p))
343# define AV_WL(s, p, v) AV_WN##s(p, bswap_##s(v))
344#else
345# define AV_RB(s, p) bswap_##s(AV_RN##s(p))
346# define AV_WB(s, p, v) AV_WN##s(p, bswap_##s(v))
347# define AV_RL(s, p) AV_RN##s(p)
348# define AV_WL(s, p, v) AV_WN##s(p, v)
349#endif
350
351#define AV_RB8(x) (((const uint8_t*)(x))[0])
352#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)
353
354#define AV_RL8(x) AV_RB8(x)
355#define AV_WL8(p, d) AV_WB8(p, d)
356
357#ifndef AV_RB16
358# define AV_RB16(p) AV_RB(16, p)
359#endif
360#ifndef AV_WB16
361# define AV_WB16(p, v) AV_WB(16, p, v)
362#endif
363
364#ifndef AV_RL16
365# define AV_RL16(p) AV_RL(16, p)
366#endif
367#ifndef AV_WL16
368# define AV_WL16(p, v) AV_WL(16, p, v)
369#endif
370
371#ifndef AV_RB32
372# define AV_RB32(p) AV_RB(32, p)
373#endif
374#ifndef AV_WB32
375# define AV_WB32(p, v) AV_WB(32, p, v)
376#endif
377
378#ifndef AV_RL32
379# define AV_RL32(p) AV_RL(32, p)
380#endif
381#ifndef AV_WL32
382# define AV_WL32(p, v) AV_WL(32, p, v)
383#endif
384
385#ifndef AV_RB64
386# define AV_RB64(p) AV_RB(64, p)
387#endif
388#ifndef AV_WB64
389# define AV_WB64(p, v) AV_WB(64, p, v)
390#endif
391
392#ifndef AV_RL64
393# define AV_RL64(p) AV_RL(64, p)
394#endif
395#ifndef AV_WL64
396# define AV_WL64(p, v) AV_WL(64, p, v)
397#endif
398
399#ifndef AV_RB24
400# define AV_RB24(x) \
401 ((((const uint8_t*)(x))[0] << 16) | \
402 (((const uint8_t*)(x))[1] << 8) | \
403 ((const uint8_t*)(x))[2])
404#endif
405#ifndef AV_WB24
406# define AV_WB24(p, d) do { \
407 ((uint8_t*)(p))[2] = (d); \
408 ((uint8_t*)(p))[1] = (d)>>8; \
409 ((uint8_t*)(p))[0] = (d)>>16; \
410 } while(0)
411#endif
412
413#ifndef AV_RL24
414# define AV_RL24(x) \
415 ((((const uint8_t*)(x))[2] << 16) | \
416 (((const uint8_t*)(x))[1] << 8) | \
417 ((const uint8_t*)(x))[0])
418#endif
419#ifndef AV_WL24
420# define AV_WL24(p, d) do { \
421 ((uint8_t*)(p))[0] = (d); \
422 ((uint8_t*)(p))[1] = (d)>>8; \
423 ((uint8_t*)(p))[2] = (d)>>16; \
424 } while(0)
425#endif
426
427/*
428 * The AV_[RW]NA macros access naturally aligned data
429 * in a type-safe way.
430 */
431
432#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s)
433#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v))
434
435#ifndef AV_RN16A
436# define AV_RN16A(p) AV_RNA(16, p)
437#endif
438
439#ifndef AV_RN32A
440# define AV_RN32A(p) AV_RNA(32, p)
441#endif
442
443#ifndef AV_RN64A
444# define AV_RN64A(p) AV_RNA(64, p)
445#endif
446
447#ifndef AV_WN16A
448# define AV_WN16A(p, v) AV_WNA(16, p, v)
449#endif
450
451#ifndef AV_WN32A
452# define AV_WN32A(p, v) AV_WNA(32, p, v)
453#endif
454
455#ifndef AV_WN64A
456# define AV_WN64A(p, v) AV_WNA(64, p, v)
457#endif
458
459/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
460 * naturally aligned. They may be implemented using MMX,
461 * so emms_c() must be called before using any float code
462 * afterwards.
463 */
464
465#define AV_COPY(n, d, s) \
466 (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
467
468#ifndef AV_COPY16
469# define AV_COPY16(d, s) AV_COPY(16, d, s)
470#endif
471
472#ifndef AV_COPY32
473# define AV_COPY32(d, s) AV_COPY(32, d, s)
474#endif
475
476#ifndef AV_COPY64
477# define AV_COPY64(d, s) AV_COPY(64, d, s)
478#endif
479
480#ifndef AV_COPY128
481# define AV_COPY128(d, s) \
482 do { \
483 AV_COPY64(d, s); \
484 AV_COPY64((char*)(d)+8, (char*)(s)+8); \
485 } while(0)
486#endif
487
488#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
489
490#ifndef AV_SWAP64
491# define AV_SWAP64(a, b) AV_SWAP(64, a, b)
492#endif
493
494#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
495
496#ifndef AV_ZERO16
497# define AV_ZERO16(d) AV_ZERO(16, d)
498#endif
499
500#ifndef AV_ZERO32
501# define AV_ZERO32(d) AV_ZERO(32, d)
502#endif
503
504#ifndef AV_ZERO64
505# define AV_ZERO64(d) AV_ZERO(64, d)
506#endif
507
508#ifndef AV_ZERO128
509# define AV_ZERO128(d) \
510 do { \
511 AV_ZERO64(d); \
512 AV_ZERO64((char*)(d)+8); \
513 } while(0)
514#endif
515
516#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..166e724b07
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/log.c
@@ -0,0 +1,92 @@
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
30#if LIBAVUTIL_VERSION_MAJOR > 50
31static
32#endif
33int av_log_level = AV_LOG_INFO;
34
35void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
36{
37 static int print_prefix=1;
38 static int count;
39 static char line[1024], prev[1024];
40 AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
41 if(level>av_log_level)
42 return;
43#undef fprintf
44 if(print_prefix && avc) {
45 snprintf(line, sizeof(line), "[%s @ %p]", avc->item_name(ptr), ptr);
46 }else
47 line[0]=0;
48
49 vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
50
51 print_prefix= line[strlen(line)-1] == '\n';
52 if(print_prefix && !strcmp(line, prev)){
53 count++;
54 return;
55 }
56 if(count>0){
57 fprintf(stderr, " Last message repeated %d times\n", count);
58 count=0;
59 }
60 fputs(line, stderr);
61 strcpy(prev, line);
62}
63
64static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
65
66void av_log(void* avcl, int level, const char *fmt, ...)
67{
68 va_list vl;
69 va_start(vl, fmt);
70 av_vlog(avcl, level, fmt, vl);
71 va_end(vl);
72}
73
74void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
75{
76 av_log_callback(avcl, level, fmt, vl);
77}
78
79int av_log_get_level(void)
80{
81 return av_log_level;
82}
83
84void av_log_set_level(int level)
85{
86 av_log_level = level;
87}
88
89void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
90{
91 av_log_callback = callback;
92}
diff --git a/apps/codecs/libwmapro/libavutil/log.h b/apps/codecs/libwmapro/libavutil/log.h
new file mode 100644
index 0000000000..b0a1493607
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/log.h
@@ -0,0 +1,115 @@
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 {
33 /**
34 * The name of the class; usually it is the same name as the
35 * context structure type to which the AVClass is associated.
36 */
37 const char* class_name;
38
39 /**
40 * A pointer to a function which returns the name of a context
41 * instance ctx associated with the class.
42 */
43 const char* (*item_name)(void* ctx);
44
45 /**
46 * a pointer to the first option specified in the class if any or NULL
47 *
48 * @see av_set_default_options()
49 */
50 const struct AVOption *option;
51} AVClass;
52
53/* av_log API */
54
55#define AV_LOG_QUIET -8
56
57/**
58 * Something went really wrong and we will crash now.
59 */
60#define AV_LOG_PANIC 0
61
62/**
63 * Something went wrong and recovery is not possible.
64 * For example, no header was found for a format which depends
65 * on headers or an illegal combination of parameters is used.
66 */
67#define AV_LOG_FATAL 8
68
69/**
70 * Something went wrong and cannot losslessly be recovered.
71 * However, not all future data is affected.
72 */
73#define AV_LOG_ERROR 16
74
75/**
76 * Something somehow does not look correct. This may or may not
77 * lead to problems. An example would be the use of '-vstrict -2'.
78 */
79#define AV_LOG_WARNING 24
80
81#define AV_LOG_INFO 32
82#define AV_LOG_VERBOSE 40
83
84/**
85 * Stuff which is only useful for libav* developers.
86 */
87#define AV_LOG_DEBUG 48
88
89/**
90 * Sends the specified message to the log if the level is less than or equal
91 * to the current av_log_level. By default, all logging messages are sent to
92 * stderr. This behavior can be altered by setting a different av_vlog callback
93 * function.
94 *
95 * @param avcl A pointer to an arbitrary struct of which the first field is a
96 * pointer to an AVClass struct.
97 * @param level The importance level of the message, lower values signifying
98 * higher importance.
99 * @param fmt The format string (printf-compatible) that specifies how
100 * subsequent arguments are converted to output.
101 * @see av_vlog
102 */
103#ifdef __GNUC__
104void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
105#else
106void av_log(void*, int level, const char *fmt, ...);
107#endif
108
109void av_vlog(void*, int level, const char *fmt, va_list);
110int av_log_get_level(void);
111void av_log_set_level(int);
112void av_log_set_callback(void (*)(void*, int, const char*, va_list));
113void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
114
115#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..81d47c1bf1
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/mathematics.c
@@ -0,0 +1,174 @@
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
133int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
134 int64_t b= bq.num * (int64_t)cq.den;
135 int64_t c= cq.num * (int64_t)bq.den;
136 return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
137}
138
139int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){
140 int64_t a= tb_a.num * (int64_t)tb_b.den;
141 int64_t b= tb_b.num * (int64_t)tb_a.den;
142 if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1;
143 if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1;
144 return 0;
145}
146
147#ifdef TEST
148#include "integer.h"
149#undef printf
150int main(void){
151 int64_t a,b,c,d,e;
152
153 for(a=7; a<(1LL<<62); a+=a/3+1){
154 for(b=3; b<(1LL<<62); b+=b/4+1){
155 for(c=9; c<(1LL<<62); c+=(c*2)/5+3){
156 int64_t r= c/2;
157 AVInteger ai;
158 ai= av_mul_i(av_int2i(a), av_int2i(b));
159 ai= av_add_i(ai, av_int2i(r));
160
161 d= av_i2int(av_div_i(ai, av_int2i(c)));
162
163 e= av_rescale(a,b,c);
164
165 if((double)a * (double)b / (double)c > (1LL<<63))
166 continue;
167
168 if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e);
169 }
170 }
171 }
172 return 0;
173}
174#endif
diff --git a/apps/codecs/libwmapro/libavutil/mathematics.h b/apps/codecs/libwmapro/libavutil/mathematics.h
new file mode 100644
index 0000000000..e198aef8cb
--- /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 */
87int64_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 */
95int 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..4d776d4450
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/mem.c
@@ -0,0 +1,176 @@
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 "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 "avutil.h"
37#include "mem.h"
38
39/* here we can use OS-dependent allocation functions */
40#undef free
41#undef malloc
42#undef realloc
43
44#ifdef MALLOC_PREFIX
45
46#define malloc AV_JOIN(MALLOC_PREFIX, malloc)
47#define memalign AV_JOIN(MALLOC_PREFIX, memalign)
48#define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign)
49#define realloc AV_JOIN(MALLOC_PREFIX, realloc)
50#define free AV_JOIN(MALLOC_PREFIX, free)
51
52void *malloc(size_t size);
53void *memalign(size_t align, size_t size);
54int posix_memalign(void **ptr, size_t align, size_t size);
55void *realloc(void *ptr, size_t size);
56void free(void *ptr);
57
58#endif /* MALLOC_PREFIX */
59
60/* You can redefine av_malloc and av_free in your project to use your
61 memory allocator. You do not need to suppress this file because the
62 linker will do it automatically. */
63
64void *av_malloc(unsigned int size)
65{
66 void *ptr = NULL;
67#if CONFIG_MEMALIGN_HACK
68 long diff;
69#endif
70
71 /* let's disallow possible ambiguous cases */
72 if(size > (INT_MAX-16) )
73 return NULL;
74
75#if CONFIG_MEMALIGN_HACK
76 ptr = malloc(size+16);
77 if(!ptr)
78 return ptr;
79 diff= ((-(long)ptr - 1)&15) + 1;
80 ptr = (char*)ptr + diff;
81 ((char*)ptr)[-1]= diff;
82#elif HAVE_POSIX_MEMALIGN
83 if (posix_memalign(&ptr,16,size))
84 ptr = NULL;
85#elif HAVE_MEMALIGN
86 ptr = memalign(16,size);
87 /* Why 64?
88 Indeed, we should align it:
89 on 4 for 386
90 on 16 for 486
91 on 32 for 586, PPro - K6-III
92 on 64 for K7 (maybe for P3 too).
93 Because L1 and L2 caches are aligned on those values.
94 But I don't want to code such logic here!
95 */
96 /* Why 16?
97 Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs
98 it will just trigger an exception and the unaligned load will be done in the
99 exception handler or it will just segfault (SSE2 on P4).
100 Why not larger? Because I did not see a difference in benchmarks ...
101 */
102 /* benchmarks with P3
103 memalign(64)+1 3071,3051,3032
104 memalign(64)+2 3051,3032,3041
105 memalign(64)+4 2911,2896,2915
106 memalign(64)+8 2545,2554,2550
107 memalign(64)+16 2543,2572,2563
108 memalign(64)+32 2546,2545,2571
109 memalign(64)+64 2570,2533,2558
110
111 BTW, malloc seems to do 8-byte alignment by default here.
112 */
113#else
114 ptr = malloc(size);
115#endif
116 return ptr;
117}
118
119void *av_realloc(void *ptr, unsigned int size)
120{
121#if CONFIG_MEMALIGN_HACK
122 int diff;
123#endif
124
125 /* let's disallow possible ambiguous cases */
126 if(size > (INT_MAX-16) )
127 return NULL;
128
129#if CONFIG_MEMALIGN_HACK
130 //FIXME this isn't aligned correctly, though it probably isn't needed
131 if(!ptr) return av_malloc(size);
132 diff= ((char*)ptr)[-1];
133 return (char*)realloc((char*)ptr - diff, size + diff) + diff;
134#else
135 return realloc(ptr, size);
136#endif
137}
138
139void av_free(void *ptr)
140{
141 /* XXX: this test should not be needed on most libcs */
142 if (ptr)
143#if CONFIG_MEMALIGN_HACK
144 free((char*)ptr - ((char*)ptr)[-1]);
145#else
146 free(ptr);
147#endif
148}
149
150void av_freep(void *arg)
151{
152 void **ptr= (void**)arg;
153 av_free(*ptr);
154 *ptr = NULL;
155}
156
157void *av_mallocz(unsigned int size)
158{
159 void *ptr = av_malloc(size);
160 if (ptr)
161 memset(ptr, 0, size);
162 return ptr;
163}
164
165char *av_strdup(const char *s)
166{
167 char *ptr= NULL;
168 if(s){
169 int len = strlen(s) + 1;
170 ptr = av_malloc(len);
171 if (ptr)
172 memcpy(ptr, s, len);
173 }
174 return ptr;
175}
176
diff --git a/apps/codecs/libwmapro/libavutil/mem.h b/apps/codecs/libwmapro/libavutil/mem.h
new file mode 100644
index 0000000000..fffbb872ae
--- /dev/null
+++ b/apps/codecs/libwmapro/libavutil/mem.h
@@ -0,0 +1,125 @@
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 "attributes.h"
30
31#if defined(__ICC) || defined(__SUNPRO_C)
32 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
33 #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
34#elif defined(__TI_COMPILER_VERSION__)
35 #define DECLARE_ALIGNED(n,t,v) \
36 AV_PRAGMA(DATA_ALIGN(v,n)) \
37 t __attribute__((aligned(n))) v
38 #define DECLARE_ASM_CONST(n,t,v) \
39 AV_PRAGMA(DATA_ALIGN(v,n)) \
40 static const t __attribute__((aligned(n))) v
41#elif defined(__GNUC__)
42 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
43 #define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v
44#elif defined(_MSC_VER)
45 #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
46 #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
47#else
48 #define DECLARE_ALIGNED(n,t,v) t v
49 #define DECLARE_ASM_CONST(n,t,v) static const t v
50#endif
51
52#if AV_GCC_VERSION_AT_LEAST(3,1)
53 #define av_malloc_attrib __attribute__((__malloc__))
54#else
55 #define av_malloc_attrib
56#endif
57
58#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3)
59 #define av_alloc_size(n) __attribute__((alloc_size(n)))
60#else
61 #define av_alloc_size(n)
62#endif
63
64/**
65 * Allocates a block of size bytes with alignment suitable for all
66 * memory accesses (including vectors if available on the CPU).
67 * @param size Size in bytes for the memory block to be allocated.
68 * @return Pointer to the allocated block, NULL if the block cannot
69 * be allocated.
70 * @see av_mallocz()
71 */
72void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1);
73
74/**
75 * Allocates or reallocates a block of memory.
76 * If ptr is NULL and size > 0, allocates a new block. If
77 * size is zero, frees the memory block pointed to by ptr.
78 * @param size Size in bytes for the memory block to be allocated or
79 * reallocated.
80 * @param ptr Pointer to a memory block already allocated with
81 * av_malloc(z)() or av_realloc() or NULL.
82 * @return Pointer to a newly reallocated block or NULL if the block
83 * cannot be reallocated or the function is used to free the memory block.
84 * @see av_fast_realloc()
85 */
86void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2);
87
88/**
89 * Frees a memory block which has been allocated with av_malloc(z)() or
90 * av_realloc().
91 * @param ptr Pointer to the memory block which should be freed.
92 * @note ptr = NULL is explicitly allowed.
93 * @note It is recommended that you use av_freep() instead.
94 * @see av_freep()
95 */
96void av_free(void *ptr);
97
98/**
99 * Allocates a block of size bytes with alignment suitable for all
100 * memory accesses (including vectors if available on the CPU) and
101 * zeroes all the bytes of the block.
102 * @param size Size in bytes for the memory block to be allocated.
103 * @return Pointer to the allocated block, NULL if it cannot be allocated.
104 * @see av_malloc()
105 */
106void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1);
107
108/**
109 * Duplicates the string s.
110 * @param s string to be duplicated
111 * @return Pointer to a newly allocated string containing a
112 * copy of s or NULL if the string cannot be allocated.
113 */
114char *av_strdup(const char *s) av_malloc_attrib;
115
116/**
117 * Frees a memory block which has been allocated with av_malloc(z)() or
118 * av_realloc() and set the pointer pointing to it to NULL.
119 * @param ptr Pointer to the pointer to the memory block which should
120 * be freed.
121 * @see av_free()
122 */
123void av_freep(void *ptr);
124
125#endif /* AVUTIL_MEM_H */