diff options
Diffstat (limited to 'lib/rbcodec/codecs/libwmavoice/libavutil')
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/attributes.h | 121 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/avutil.h | 89 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h | 124 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/common.h | 346 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/internal.h | 234 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/intreadwrite.h | 522 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/log.c | 150 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/log.h | 138 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/lzo.c | 280 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/lzo.h | 66 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.c | 183 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.h | 112 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/mem.c | 176 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libwmavoice/libavutil/mem.h | 126 |
14 files changed, 2667 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/attributes.h b/lib/rbcodec/codecs/libwmavoice/libavutil/attributes.h new file mode 100644 index 0000000000..a95bb02e89 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/attributes.h | |||
@@ -0,0 +1,121 @@ | |||
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 | ||
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_alias | ||
100 | #if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(3,3) | ||
101 | # define av_alias __attribute__((may_alias)) | ||
102 | #else | ||
103 | # define av_alias | ||
104 | #endif | ||
105 | #endif | ||
106 | |||
107 | #ifndef av_uninit | ||
108 | #if defined(__GNUC__) && !defined(__ICC) | ||
109 | # define av_uninit(x) x=x | ||
110 | #else | ||
111 | # define av_uninit(x) x | ||
112 | #endif | ||
113 | #endif | ||
114 | |||
115 | #ifdef __GNUC__ | ||
116 | # define av_builtin_constant_p __builtin_constant_p | ||
117 | #else | ||
118 | # define av_builtin_constant_p(x) 0 | ||
119 | #endif | ||
120 | |||
121 | #endif /* AVUTIL_ATTRIBUTES_H */ | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/avutil.h b/lib/rbcodec/codecs/libwmavoice/libavutil/avutil.h new file mode 100644 index 0000000000..457829ac7f --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/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 | ||
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 23 | ||
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 | * Return the LIBAVUTIL_VERSION_INT constant. | ||
58 | */ | ||
59 | unsigned avutil_version(void); | ||
60 | |||
61 | /** | ||
62 | * Return the libavutil build-time configuration. | ||
63 | */ | ||
64 | const char *avutil_configuration(void); | ||
65 | |||
66 | /** | ||
67 | * Return the libavutil license. | ||
68 | */ | ||
69 | const char *avutil_license(void); | ||
70 | |||
71 | enum 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/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h b/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h new file mode 100644 index 0000000000..303bcf3532 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h | |||
@@ -0,0 +1,124 @@ | |||
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 | ||
23 | * byte swapping routines | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_BSWAP_H | ||
27 | #define AVUTIL_BSWAP_H | ||
28 | |||
29 | #include <stdint.h> | ||
30 | #include "libavutil/avconfig.h" | ||
31 | #include "attributes.h" | ||
32 | |||
33 | #ifdef HAVE_AV_CONFIG_H | ||
34 | |||
35 | #include "config.h" | ||
36 | |||
37 | #if ARCH_ARM | ||
38 | # include "arm/bswap.h" | ||
39 | #elif ARCH_AVR32 | ||
40 | # include "avr32/bswap.h" | ||
41 | #elif ARCH_BFIN | ||
42 | # include "bfin/bswap.h" | ||
43 | #elif ARCH_SH4 | ||
44 | # include "sh4/bswap.h" | ||
45 | #elif ARCH_X86 | ||
46 | # include "x86/bswap.h" | ||
47 | #endif | ||
48 | |||
49 | #endif /* HAVE_AV_CONFIG_H */ | ||
50 | |||
51 | #define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff)) | ||
52 | #define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16)) | ||
53 | #define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32)) | ||
54 | |||
55 | #define AV_BSWAPC(s, x) AV_BSWAP##s##C(x) | ||
56 | |||
57 | #ifndef av_bswap16 | ||
58 | static av_always_inline av_const uint16_t av_bswap16(uint16_t x) | ||
59 | { | ||
60 | x= (x>>8) | (x<<8); | ||
61 | return x; | ||
62 | } | ||
63 | #endif | ||
64 | |||
65 | #ifndef av_bswap32 | ||
66 | static av_always_inline av_const uint32_t av_bswap32(uint32_t x) | ||
67 | { | ||
68 | x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); | ||
69 | x= (x>>16) | (x<<16); | ||
70 | return x; | ||
71 | } | ||
72 | #endif | ||
73 | |||
74 | #ifndef av_bswap64 | ||
75 | static inline uint64_t av_const av_bswap64(uint64_t x) | ||
76 | { | ||
77 | #if 0 | ||
78 | x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); | ||
79 | x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); | ||
80 | return (x>>32) | (x<<32); | ||
81 | #else | ||
82 | union { | ||
83 | uint64_t ll; | ||
84 | uint32_t l[2]; | ||
85 | } w, r; | ||
86 | w.ll = x; | ||
87 | r.l[0] = av_bswap32 (w.l[1]); | ||
88 | r.l[1] = av_bswap32 (w.l[0]); | ||
89 | return r.ll; | ||
90 | #endif | ||
91 | } | ||
92 | #endif | ||
93 | |||
94 | // be2ne ... big-endian to native-endian | ||
95 | // le2ne ... little-endian to native-endian | ||
96 | |||
97 | #if AV_HAVE_BIGENDIAN | ||
98 | #define av_be2ne16(x) (x) | ||
99 | #define av_be2ne32(x) (x) | ||
100 | #define av_be2ne64(x) (x) | ||
101 | #define av_le2ne16(x) av_bswap16(x) | ||
102 | #define av_le2ne32(x) av_bswap32(x) | ||
103 | #define av_le2ne64(x) av_bswap64(x) | ||
104 | #define AV_BE2NEC(s, x) (x) | ||
105 | #define AV_LE2NEC(s, x) AV_BSWAPC(s, x) | ||
106 | #else | ||
107 | #define av_be2ne16(x) av_bswap16(x) | ||
108 | #define av_be2ne32(x) av_bswap32(x) | ||
109 | #define av_be2ne64(x) av_bswap64(x) | ||
110 | #define av_le2ne16(x) (x) | ||
111 | #define av_le2ne32(x) (x) | ||
112 | #define av_le2ne64(x) (x) | ||
113 | #define AV_BE2NEC(s, x) AV_BSWAPC(s, x) | ||
114 | #define AV_LE2NEC(s, x) (x) | ||
115 | #endif | ||
116 | |||
117 | #define AV_BE2NE16C(x) AV_BE2NEC(16, x) | ||
118 | #define AV_BE2NE32C(x) AV_BE2NEC(32, x) | ||
119 | #define AV_BE2NE64C(x) AV_BE2NEC(64, x) | ||
120 | #define AV_LE2NE16C(x) AV_LE2NEC(16, x) | ||
121 | #define AV_LE2NE32C(x) AV_LE2NEC(32, x) | ||
122 | #define AV_LE2NE64C(x) AV_LE2NEC(64, x) | ||
123 | |||
124 | #endif /* AVUTIL_BSWAP_H */ | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/common.h b/lib/rbcodec/codecs/libwmavoice/libavutil/common.h new file mode 100644 index 0000000000..f9c03db559 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/common.h | |||
@@ -0,0 +1,346 @@ | |||
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 | ||
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 */ | ||
56 | extern const uint8_t ff_log2_tab[256]; | ||
57 | |||
58 | extern const uint8_t av_reverse[256]; | ||
59 | |||
60 | static 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 | |||
76 | static 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 | /* Pull in unguarded fallback defines at the end of this file. */ | ||
94 | #include "common.h" | ||
95 | |||
96 | /** | ||
97 | * Clip a signed integer value into the amin-amax range. | ||
98 | * @param a value to clip | ||
99 | * @param amin minimum value of the clip range | ||
100 | * @param amax maximum value of the clip range | ||
101 | * @return clipped value | ||
102 | */ | ||
103 | static inline av_const int av_clip_c(int a, int amin, int amax) | ||
104 | { | ||
105 | if (a < amin) return amin; | ||
106 | else if (a > amax) return amax; | ||
107 | else return a; | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * Clip a signed integer value into the 0-255 range. | ||
112 | * @param a value to clip | ||
113 | * @return clipped value | ||
114 | */ | ||
115 | static inline av_const uint8_t av_clip_uint8_c(int a) | ||
116 | { | ||
117 | if (a&(~0xFF)) return (-a)>>31; | ||
118 | else return a; | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * Clip a signed integer value into the -128,127 range. | ||
123 | * @param a value to clip | ||
124 | * @return clipped value | ||
125 | */ | ||
126 | static inline av_const int8_t av_clip_int8_c(int a) | ||
127 | { | ||
128 | if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F; | ||
129 | else return a; | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * Clip a signed integer value into the 0-65535 range. | ||
134 | * @param a value to clip | ||
135 | * @return clipped value | ||
136 | */ | ||
137 | static inline av_const uint16_t av_clip_uint16_c(int a) | ||
138 | { | ||
139 | if (a&(~0xFFFF)) return (-a)>>31; | ||
140 | else return a; | ||
141 | } | ||
142 | |||
143 | /** | ||
144 | * Clip a signed integer value into the -32768,32767 range. | ||
145 | * @param a value to clip | ||
146 | * @return clipped value | ||
147 | */ | ||
148 | static inline av_const int16_t av_clip_int16_c(int a) | ||
149 | { | ||
150 | if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF; | ||
151 | else return a; | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * Clip a signed 64-bit integer value into the -2147483648,2147483647 range. | ||
156 | * @param a value to clip | ||
157 | * @return clipped value | ||
158 | */ | ||
159 | static inline av_const int32_t av_clipl_int32_c(int64_t a) | ||
160 | { | ||
161 | if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF; | ||
162 | else return a; | ||
163 | } | ||
164 | |||
165 | /** | ||
166 | * Clip a float value into the amin-amax range. | ||
167 | * @param a value to clip | ||
168 | * @param amin minimum value of the clip range | ||
169 | * @param amax maximum value of the clip range | ||
170 | * @return clipped value | ||
171 | */ | ||
172 | static inline av_const float av_clipf_c(float a, float amin, float amax) | ||
173 | { | ||
174 | if (a < amin) return amin; | ||
175 | else if (a > amax) return amax; | ||
176 | else return a; | ||
177 | } | ||
178 | |||
179 | /** Compute ceil(log2(x)). | ||
180 | * @param x value used to compute ceil(log2(x)) | ||
181 | * @return computed ceiling of log2(x) | ||
182 | */ | ||
183 | static inline av_const int av_ceil_log2_c(int x) | ||
184 | { | ||
185 | return av_log2((x - 1) << 1); | ||
186 | } | ||
187 | |||
188 | #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) | ||
189 | #define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24)) | ||
190 | |||
191 | /** | ||
192 | * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. | ||
193 | * | ||
194 | * @param val Output value, must be an lvalue of type uint32_t. | ||
195 | * @param GET_BYTE Expression reading one byte from the input. | ||
196 | * Evaluated up to 7 times (4 for the currently | ||
197 | * assigned Unicode range). With a memory buffer | ||
198 | * input, this could be *ptr++. | ||
199 | * @param ERROR Expression to be evaluated on invalid input, | ||
200 | * typically a goto statement. | ||
201 | */ | ||
202 | #define GET_UTF8(val, GET_BYTE, ERROR)\ | ||
203 | val= GET_BYTE;\ | ||
204 | {\ | ||
205 | int ones= 7 - av_log2(val ^ 255);\ | ||
206 | if(ones==1)\ | ||
207 | ERROR\ | ||
208 | val&= 127>>ones;\ | ||
209 | while(--ones > 0){\ | ||
210 | int tmp= GET_BYTE - 128;\ | ||
211 | if(tmp>>6)\ | ||
212 | ERROR\ | ||
213 | val= (val<<6) + tmp;\ | ||
214 | }\ | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form. | ||
219 | * | ||
220 | * @param val Output value, must be an lvalue of type uint32_t. | ||
221 | * @param GET_16BIT Expression returning two bytes of UTF-16 data converted | ||
222 | * to native byte order. Evaluated one or two times. | ||
223 | * @param ERROR Expression to be evaluated on invalid input, | ||
224 | * typically a goto statement. | ||
225 | */ | ||
226 | #define GET_UTF16(val, GET_16BIT, ERROR)\ | ||
227 | val = GET_16BIT;\ | ||
228 | {\ | ||
229 | unsigned int hi = val - 0xD800;\ | ||
230 | if (hi < 0x800) {\ | ||
231 | val = GET_16BIT - 0xDC00;\ | ||
232 | if (val > 0x3FFU || hi > 0x3FFU)\ | ||
233 | ERROR\ | ||
234 | val += (hi<<10) + 0x10000;\ | ||
235 | }\ | ||
236 | }\ | ||
237 | |||
238 | /*! | ||
239 | * \def PUT_UTF8(val, tmp, PUT_BYTE) | ||
240 | * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). | ||
241 | * \param val is an input-only argument and should be of type uint32_t. It holds | ||
242 | * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If | ||
243 | * val is given as a function it is executed only once. | ||
244 | * \param tmp is a temporary variable and should be of type uint8_t. It | ||
245 | * represents an intermediate value during conversion that is to be | ||
246 | * output by PUT_BYTE. | ||
247 | * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. | ||
248 | * It could be a function or a statement, and uses tmp as the input byte. | ||
249 | * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be | ||
250 | * executed up to 4 times for values in the valid UTF-8 range and up to | ||
251 | * 7 times in the general case, depending on the length of the converted | ||
252 | * Unicode character. | ||
253 | */ | ||
254 | #define PUT_UTF8(val, tmp, PUT_BYTE)\ | ||
255 | {\ | ||
256 | int bytes, shift;\ | ||
257 | uint32_t in = val;\ | ||
258 | if (in < 0x80) {\ | ||
259 | tmp = in;\ | ||
260 | PUT_BYTE\ | ||
261 | } else {\ | ||
262 | bytes = (av_log2(in) + 4) / 5;\ | ||
263 | shift = (bytes - 1) * 6;\ | ||
264 | tmp = (256 - (256 >> bytes)) | (in >> shift);\ | ||
265 | PUT_BYTE\ | ||
266 | while (shift >= 6) {\ | ||
267 | shift -= 6;\ | ||
268 | tmp = 0x80 | ((in >> shift) & 0x3f);\ | ||
269 | PUT_BYTE\ | ||
270 | }\ | ||
271 | }\ | ||
272 | } | ||
273 | |||
274 | /*! | ||
275 | * \def PUT_UTF16(val, tmp, PUT_16BIT) | ||
276 | * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). | ||
277 | * \param val is an input-only argument and should be of type uint32_t. It holds | ||
278 | * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If | ||
279 | * val is given as a function it is executed only once. | ||
280 | * \param tmp is a temporary variable and should be of type uint16_t. It | ||
281 | * represents an intermediate value during conversion that is to be | ||
282 | * output by PUT_16BIT. | ||
283 | * \param PUT_16BIT writes the converted UTF-16 data to any proper destination | ||
284 | * in desired endianness. It could be a function or a statement, and uses tmp | ||
285 | * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" | ||
286 | * PUT_BYTE will be executed 1 or 2 times depending on input character. | ||
287 | */ | ||
288 | #define PUT_UTF16(val, tmp, PUT_16BIT)\ | ||
289 | {\ | ||
290 | uint32_t in = val;\ | ||
291 | if (in < 0x10000) {\ | ||
292 | tmp = in;\ | ||
293 | PUT_16BIT\ | ||
294 | } else {\ | ||
295 | tmp = 0xD800 | ((in - 0x10000) >> 10);\ | ||
296 | PUT_16BIT\ | ||
297 | tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ | ||
298 | PUT_16BIT\ | ||
299 | }\ | ||
300 | }\ | ||
301 | |||
302 | |||
303 | |||
304 | #include "mem.h" | ||
305 | |||
306 | #ifdef HAVE_AV_CONFIG_H | ||
307 | # include "internal.h" | ||
308 | #endif /* HAVE_AV_CONFIG_H */ | ||
309 | |||
310 | #endif /* AVUTIL_COMMON_H */ | ||
311 | |||
312 | /* | ||
313 | * The following definitions are outside the multiple inclusion guard | ||
314 | * to ensure they are immediately available in intmath.h. | ||
315 | */ | ||
316 | |||
317 | #ifndef av_log2 | ||
318 | # define av_log2 av_log2_c | ||
319 | #endif | ||
320 | #ifndef av_log2_16bit | ||
321 | # define av_log2_16bit av_log2_16bit_c | ||
322 | #endif | ||
323 | #ifndef av_ceil_log2 | ||
324 | # define av_ceil_log2 av_ceil_log2_c | ||
325 | #endif | ||
326 | #ifndef av_clip | ||
327 | # define av_clip av_clip_c | ||
328 | #endif | ||
329 | #ifndef av_clip_uint8 | ||
330 | # define av_clip_uint8 av_clip_uint8_c | ||
331 | #endif | ||
332 | #ifndef av_clip_int8 | ||
333 | # define av_clip_int8 av_clip_int8_c | ||
334 | #endif | ||
335 | #ifndef av_clip_uint16 | ||
336 | # define av_clip_uint16 av_clip_uint16_c | ||
337 | #endif | ||
338 | #ifndef av_clip_int16 | ||
339 | # define av_clip_int16 av_clip_int16_c | ||
340 | #endif | ||
341 | #ifndef av_clipl_int32 | ||
342 | # define av_clipl_int32 av_clipl_int32_c | ||
343 | #endif | ||
344 | #ifndef av_clipf | ||
345 | # define av_clipf av_clipf_c | ||
346 | #endif | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/internal.h b/lib/rbcodec/codecs/libwmavoice/libavutil/internal.h new file mode 100644 index 0000000000..53d2b94c50 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/internal.h | |||
@@ -0,0 +1,234 @@ | |||
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 | ||
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 ARCH_X86_32 && (!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 | |||
50 | /** | ||
51 | * Mark a variable as used and prevent the compiler from optimizing it away. | ||
52 | * This is useful for asm that accesses varibles in ways that the compiler does not | ||
53 | * understand | ||
54 | */ | ||
55 | #ifndef attribute_used | ||
56 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
57 | # define attribute_used __attribute__((used)) | ||
58 | #else | ||
59 | # define attribute_used | ||
60 | #endif | ||
61 | #endif | ||
62 | |||
63 | #ifndef INT16_MIN | ||
64 | #define INT16_MIN (-0x7fff - 1) | ||
65 | #endif | ||
66 | |||
67 | #ifndef INT16_MAX | ||
68 | #define INT16_MAX 0x7fff | ||
69 | #endif | ||
70 | |||
71 | #ifndef INT32_MIN | ||
72 | #define INT32_MIN (-0x7fffffff - 1) | ||
73 | #endif | ||
74 | |||
75 | #ifndef INT32_MAX | ||
76 | #define INT32_MAX 0x7fffffff | ||
77 | #endif | ||
78 | |||
79 | #ifndef UINT32_MAX | ||
80 | #define UINT32_MAX 0xffffffff | ||
81 | #endif | ||
82 | |||
83 | #ifndef INT64_MIN | ||
84 | #define INT64_MIN (-0x7fffffffffffffffLL - 1) | ||
85 | #endif | ||
86 | |||
87 | #ifndef INT64_MAX | ||
88 | #define INT64_MAX INT64_C(9223372036854775807) | ||
89 | #endif | ||
90 | |||
91 | #ifndef UINT64_MAX | ||
92 | #define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) | ||
93 | #endif | ||
94 | |||
95 | #ifndef INT_BIT | ||
96 | # define INT_BIT (CHAR_BIT * sizeof(int)) | ||
97 | #endif | ||
98 | |||
99 | #ifndef offsetof | ||
100 | # define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F)) | ||
101 | #endif | ||
102 | |||
103 | /* Use to export labels from asm. */ | ||
104 | #define LABEL_MANGLE(a) EXTERN_PREFIX #a | ||
105 | |||
106 | // Use rip-relative addressing if compiling PIC code on x86-64. | ||
107 | #if ARCH_X86_64 && defined(PIC) | ||
108 | # define LOCAL_MANGLE(a) #a "(%%rip)" | ||
109 | #else | ||
110 | # define LOCAL_MANGLE(a) #a | ||
111 | #endif | ||
112 | |||
113 | #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) | ||
114 | |||
115 | /* debug stuff */ | ||
116 | |||
117 | /* dprintf macros */ | ||
118 | #ifdef DEBUG | ||
119 | # define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) | ||
120 | #else | ||
121 | # define dprintf(pctx, ...) | ||
122 | #endif | ||
123 | |||
124 | #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) | ||
125 | |||
126 | /* math */ | ||
127 | |||
128 | #if ARCH_X86 | ||
129 | #define MASK_ABS(mask, level)\ | ||
130 | __asm__ volatile(\ | ||
131 | "cltd \n\t"\ | ||
132 | "xorl %1, %0 \n\t"\ | ||
133 | "subl %1, %0 \n\t"\ | ||
134 | : "+a" (level), "=&d" (mask)\ | ||
135 | ); | ||
136 | #else | ||
137 | #define MASK_ABS(mask, level)\ | ||
138 | mask = level >> 31;\ | ||
139 | level = (level ^ mask) - mask; | ||
140 | #endif | ||
141 | |||
142 | /* avoid usage of dangerous/inappropriate system functions */ | ||
143 | #undef malloc | ||
144 | #define malloc please_use_av_malloc | ||
145 | #undef free | ||
146 | #define free please_use_av_free | ||
147 | #undef realloc | ||
148 | #define realloc please_use_av_realloc | ||
149 | #undef time | ||
150 | #define time time_is_forbidden_due_to_security_issues | ||
151 | #undef rand | ||
152 | #define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get | ||
153 | #undef srand | ||
154 | #define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init | ||
155 | #undef random | ||
156 | #define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get | ||
157 | #undef sprintf | ||
158 | #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf | ||
159 | #undef strcat | ||
160 | #define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat | ||
161 | #undef exit | ||
162 | #define exit exit_is_forbidden | ||
163 | #ifndef LIBAVFORMAT_BUILD | ||
164 | #undef printf | ||
165 | #define printf please_use_av_log_instead_of_printf | ||
166 | #undef fprintf | ||
167 | #define fprintf please_use_av_log_instead_of_fprintf | ||
168 | #undef puts | ||
169 | #define puts please_use_av_log_instead_of_puts | ||
170 | #undef perror | ||
171 | #define perror please_use_av_log_instead_of_perror | ||
172 | #endif | ||
173 | |||
174 | #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\ | ||
175 | {\ | ||
176 | p = av_malloc(size);\ | ||
177 | if (p == NULL && (size) != 0) {\ | ||
178 | av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ | ||
179 | goto label;\ | ||
180 | }\ | ||
181 | } | ||
182 | |||
183 | #define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\ | ||
184 | {\ | ||
185 | p = av_mallocz(size);\ | ||
186 | if (p == NULL && (size) != 0) {\ | ||
187 | av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ | ||
188 | goto label;\ | ||
189 | }\ | ||
190 | } | ||
191 | |||
192 | #include "libm.h" | ||
193 | |||
194 | /** | ||
195 | * Return NULL if CONFIG_SMALL is true, otherwise the argument | ||
196 | * without modification. Used to disable the definition of strings | ||
197 | * (for example AVCodec long_names). | ||
198 | */ | ||
199 | #if CONFIG_SMALL | ||
200 | # define NULL_IF_CONFIG_SMALL(x) NULL | ||
201 | #else | ||
202 | # define NULL_IF_CONFIG_SMALL(x) x | ||
203 | #endif | ||
204 | |||
205 | |||
206 | /** | ||
207 | * Define a function with only the non-default version specified. | ||
208 | * | ||
209 | * On systems with ELF shared libraries, all symbols exported from | ||
210 | * FFmpeg libraries are tagged with the name and major version of the | ||
211 | * library to which they belong. If a function is moved from one | ||
212 | * library to another, a wrapper must be retained in the original | ||
213 | * location to preserve binary compatibility. | ||
214 | * | ||
215 | * Functions defined with this macro will never be used to resolve | ||
216 | * symbols by the build-time linker. | ||
217 | * | ||
218 | * @param type return type of function | ||
219 | * @param name name of function | ||
220 | * @param args argument list of function | ||
221 | * @param ver version tag to assign function | ||
222 | */ | ||
223 | #if HAVE_SYMVER_ASM_LABEL | ||
224 | # define FF_SYMVER(type, name, args, ver) \ | ||
225 | type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \ | ||
226 | type ff_##name args | ||
227 | #elif HAVE_SYMVER_GNU_ASM | ||
228 | # define FF_SYMVER(type, name, args, ver) \ | ||
229 | __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \ | ||
230 | type ff_##name args; \ | ||
231 | type ff_##name args | ||
232 | #endif | ||
233 | |||
234 | #endif /* AVUTIL_INTERNAL_H */ | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/intreadwrite.h b/lib/rbcodec/codecs/libwmavoice/libavutil/intreadwrite.h new file mode 100644 index 0000000000..1849a64661 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/intreadwrite.h | |||
@@ -0,0 +1,522 @@ | |||
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 "libavutil/avconfig.h" | ||
24 | #include "attributes.h" | ||
25 | #include "bswap.h" | ||
26 | |||
27 | typedef 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 | |||
36 | typedef union { | ||
37 | uint32_t u32; | ||
38 | uint16_t u16[2]; | ||
39 | uint8_t u8 [4]; | ||
40 | float f32; | ||
41 | } av_alias av_alias32; | ||
42 | |||
43 | typedef 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 | #ifdef HAVE_AV_CONFIG_H | ||
56 | |||
57 | #include "config.h" | ||
58 | |||
59 | #if ARCH_ARM | ||
60 | # include "arm/intreadwrite.h" | ||
61 | #elif ARCH_AVR32 | ||
62 | # include "avr32/intreadwrite.h" | ||
63 | #elif ARCH_MIPS | ||
64 | # include "mips/intreadwrite.h" | ||
65 | #elif ARCH_PPC | ||
66 | # include "ppc/intreadwrite.h" | ||
67 | #elif ARCH_TOMI | ||
68 | # include "tomi/intreadwrite.h" | ||
69 | #elif ARCH_X86 | ||
70 | # include "x86/intreadwrite.h" | ||
71 | #endif | ||
72 | |||
73 | #endif /* HAVE_AV_CONFIG_H */ | ||
74 | |||
75 | /* | ||
76 | * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. | ||
77 | */ | ||
78 | |||
79 | #if AV_HAVE_BIGENDIAN | ||
80 | |||
81 | # if defined(AV_RN16) && !defined(AV_RB16) | ||
82 | # define AV_RB16(p) AV_RN16(p) | ||
83 | # elif !defined(AV_RN16) && defined(AV_RB16) | ||
84 | # define AV_RN16(p) AV_RB16(p) | ||
85 | # endif | ||
86 | |||
87 | # if defined(AV_WN16) && !defined(AV_WB16) | ||
88 | # define AV_WB16(p, v) AV_WN16(p, v) | ||
89 | # elif !defined(AV_WN16) && defined(AV_WB16) | ||
90 | # define AV_WN16(p, v) AV_WB16(p, v) | ||
91 | # endif | ||
92 | |||
93 | # if defined(AV_RN24) && !defined(AV_RB24) | ||
94 | # define AV_RB24(p) AV_RN24(p) | ||
95 | # elif !defined(AV_RN24) && defined(AV_RB24) | ||
96 | # define AV_RN24(p) AV_RB24(p) | ||
97 | # endif | ||
98 | |||
99 | # if defined(AV_WN24) && !defined(AV_WB24) | ||
100 | # define AV_WB24(p, v) AV_WN24(p, v) | ||
101 | # elif !defined(AV_WN24) && defined(AV_WB24) | ||
102 | # define AV_WN24(p, v) AV_WB24(p, v) | ||
103 | # endif | ||
104 | |||
105 | # if defined(AV_RN32) && !defined(AV_RB32) | ||
106 | # define AV_RB32(p) AV_RN32(p) | ||
107 | # elif !defined(AV_RN32) && defined(AV_RB32) | ||
108 | # define AV_RN32(p) AV_RB32(p) | ||
109 | # endif | ||
110 | |||
111 | # if defined(AV_WN32) && !defined(AV_WB32) | ||
112 | # define AV_WB32(p, v) AV_WN32(p, v) | ||
113 | # elif !defined(AV_WN32) && defined(AV_WB32) | ||
114 | # define AV_WN32(p, v) AV_WB32(p, v) | ||
115 | # endif | ||
116 | |||
117 | # if defined(AV_RN64) && !defined(AV_RB64) | ||
118 | # define AV_RB64(p) AV_RN64(p) | ||
119 | # elif !defined(AV_RN64) && defined(AV_RB64) | ||
120 | # define AV_RN64(p) AV_RB64(p) | ||
121 | # endif | ||
122 | |||
123 | # if defined(AV_WN64) && !defined(AV_WB64) | ||
124 | # define AV_WB64(p, v) AV_WN64(p, v) | ||
125 | # elif !defined(AV_WN64) && defined(AV_WB64) | ||
126 | # define AV_WN64(p, v) AV_WB64(p, v) | ||
127 | # endif | ||
128 | |||
129 | #else /* AV_HAVE_BIGENDIAN */ | ||
130 | |||
131 | # if defined(AV_RN16) && !defined(AV_RL16) | ||
132 | # define AV_RL16(p) AV_RN16(p) | ||
133 | # elif !defined(AV_RN16) && defined(AV_RL16) | ||
134 | # define AV_RN16(p) AV_RL16(p) | ||
135 | # endif | ||
136 | |||
137 | # if defined(AV_WN16) && !defined(AV_WL16) | ||
138 | # define AV_WL16(p, v) AV_WN16(p, v) | ||
139 | # elif !defined(AV_WN16) && defined(AV_WL16) | ||
140 | # define AV_WN16(p, v) AV_WL16(p, v) | ||
141 | # endif | ||
142 | |||
143 | # if defined(AV_RN24) && !defined(AV_RL24) | ||
144 | # define AV_RL24(p) AV_RN24(p) | ||
145 | # elif !defined(AV_RN24) && defined(AV_RL24) | ||
146 | # define AV_RN24(p) AV_RL24(p) | ||
147 | # endif | ||
148 | |||
149 | # if defined(AV_WN24) && !defined(AV_WL24) | ||
150 | # define AV_WL24(p, v) AV_WN24(p, v) | ||
151 | # elif !defined(AV_WN24) && defined(AV_WL24) | ||
152 | # define AV_WN24(p, v) AV_WL24(p, v) | ||
153 | # endif | ||
154 | |||
155 | # if defined(AV_RN32) && !defined(AV_RL32) | ||
156 | # define AV_RL32(p) AV_RN32(p) | ||
157 | # elif !defined(AV_RN32) && defined(AV_RL32) | ||
158 | # define AV_RN32(p) AV_RL32(p) | ||
159 | # endif | ||
160 | |||
161 | # if defined(AV_WN32) && !defined(AV_WL32) | ||
162 | # define AV_WL32(p, v) AV_WN32(p, v) | ||
163 | # elif !defined(AV_WN32) && defined(AV_WL32) | ||
164 | # define AV_WN32(p, v) AV_WL32(p, v) | ||
165 | # endif | ||
166 | |||
167 | # if defined(AV_RN64) && !defined(AV_RL64) | ||
168 | # define AV_RL64(p) AV_RN64(p) | ||
169 | # elif !defined(AV_RN64) && defined(AV_RL64) | ||
170 | # define AV_RN64(p) AV_RL64(p) | ||
171 | # endif | ||
172 | |||
173 | # if defined(AV_WN64) && !defined(AV_WL64) | ||
174 | # define AV_WL64(p, v) AV_WN64(p, v) | ||
175 | # elif !defined(AV_WN64) && defined(AV_WL64) | ||
176 | # define AV_WN64(p, v) AV_WL64(p, v) | ||
177 | # endif | ||
178 | |||
179 | #endif /* !AV_HAVE_BIGENDIAN */ | ||
180 | |||
181 | /* | ||
182 | * Define AV_[RW]N helper macros to simplify definitions not provided | ||
183 | * by per-arch headers. | ||
184 | */ | ||
185 | |||
186 | #if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__) | ||
187 | |||
188 | union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; | ||
189 | union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; | ||
190 | union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; | ||
191 | |||
192 | # define AV_RN(s, p) (((const union unaligned_##s *) (p))->l) | ||
193 | # define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v)) | ||
194 | |||
195 | #elif defined(__DECC) | ||
196 | |||
197 | # define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) | ||
198 | # define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) | ||
199 | |||
200 | #elif AV_HAVE_FAST_UNALIGNED | ||
201 | |||
202 | # define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) | ||
203 | # define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) | ||
204 | |||
205 | #else | ||
206 | |||
207 | #ifndef AV_RB16 | ||
208 | # define AV_RB16(x) \ | ||
209 | ((((const uint8_t*)(x))[0] << 8) | \ | ||
210 | ((const uint8_t*)(x))[1]) | ||
211 | #endif | ||
212 | #ifndef AV_WB16 | ||
213 | # define AV_WB16(p, d) do { \ | ||
214 | ((uint8_t*)(p))[1] = (d); \ | ||
215 | ((uint8_t*)(p))[0] = (d)>>8; \ | ||
216 | } while(0) | ||
217 | #endif | ||
218 | |||
219 | #ifndef AV_RL16 | ||
220 | # define AV_RL16(x) \ | ||
221 | ((((const uint8_t*)(x))[1] << 8) | \ | ||
222 | ((const uint8_t*)(x))[0]) | ||
223 | #endif | ||
224 | #ifndef AV_WL16 | ||
225 | # define AV_WL16(p, d) do { \ | ||
226 | ((uint8_t*)(p))[0] = (d); \ | ||
227 | ((uint8_t*)(p))[1] = (d)>>8; \ | ||
228 | } while(0) | ||
229 | #endif | ||
230 | |||
231 | #ifndef AV_RB32 | ||
232 | # define AV_RB32(x) \ | ||
233 | ((((const uint8_t*)(x))[0] << 24) | \ | ||
234 | (((const uint8_t*)(x))[1] << 16) | \ | ||
235 | (((const uint8_t*)(x))[2] << 8) | \ | ||
236 | ((const uint8_t*)(x))[3]) | ||
237 | #endif | ||
238 | #ifndef AV_WB32 | ||
239 | # define AV_WB32(p, d) do { \ | ||
240 | ((uint8_t*)(p))[3] = (d); \ | ||
241 | ((uint8_t*)(p))[2] = (d)>>8; \ | ||
242 | ((uint8_t*)(p))[1] = (d)>>16; \ | ||
243 | ((uint8_t*)(p))[0] = (d)>>24; \ | ||
244 | } while(0) | ||
245 | #endif | ||
246 | |||
247 | #ifndef AV_RL32 | ||
248 | # define AV_RL32(x) \ | ||
249 | ((((const uint8_t*)(x))[3] << 24) | \ | ||
250 | (((const uint8_t*)(x))[2] << 16) | \ | ||
251 | (((const uint8_t*)(x))[1] << 8) | \ | ||
252 | ((const uint8_t*)(x))[0]) | ||
253 | #endif | ||
254 | #ifndef AV_WL32 | ||
255 | # define AV_WL32(p, d) do { \ | ||
256 | ((uint8_t*)(p))[0] = (d); \ | ||
257 | ((uint8_t*)(p))[1] = (d)>>8; \ | ||
258 | ((uint8_t*)(p))[2] = (d)>>16; \ | ||
259 | ((uint8_t*)(p))[3] = (d)>>24; \ | ||
260 | } while(0) | ||
261 | #endif | ||
262 | |||
263 | #ifndef AV_RB64 | ||
264 | # define AV_RB64(x) \ | ||
265 | (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ | ||
266 | ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ | ||
267 | ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ | ||
268 | ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ | ||
269 | ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ | ||
270 | ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ | ||
271 | ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ | ||
272 | (uint64_t)((const uint8_t*)(x))[7]) | ||
273 | #endif | ||
274 | #ifndef AV_WB64 | ||
275 | # define AV_WB64(p, d) do { \ | ||
276 | ((uint8_t*)(p))[7] = (d); \ | ||
277 | ((uint8_t*)(p))[6] = (d)>>8; \ | ||
278 | ((uint8_t*)(p))[5] = (d)>>16; \ | ||
279 | ((uint8_t*)(p))[4] = (d)>>24; \ | ||
280 | ((uint8_t*)(p))[3] = (d)>>32; \ | ||
281 | ((uint8_t*)(p))[2] = (d)>>40; \ | ||
282 | ((uint8_t*)(p))[1] = (d)>>48; \ | ||
283 | ((uint8_t*)(p))[0] = (d)>>56; \ | ||
284 | } while(0) | ||
285 | #endif | ||
286 | |||
287 | #ifndef AV_RL64 | ||
288 | # define AV_RL64(x) \ | ||
289 | (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ | ||
290 | ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ | ||
291 | ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ | ||
292 | ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ | ||
293 | ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ | ||
294 | ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ | ||
295 | ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ | ||
296 | (uint64_t)((const uint8_t*)(x))[0]) | ||
297 | #endif | ||
298 | #ifndef AV_WL64 | ||
299 | # define AV_WL64(p, d) do { \ | ||
300 | ((uint8_t*)(p))[0] = (d); \ | ||
301 | ((uint8_t*)(p))[1] = (d)>>8; \ | ||
302 | ((uint8_t*)(p))[2] = (d)>>16; \ | ||
303 | ((uint8_t*)(p))[3] = (d)>>24; \ | ||
304 | ((uint8_t*)(p))[4] = (d)>>32; \ | ||
305 | ((uint8_t*)(p))[5] = (d)>>40; \ | ||
306 | ((uint8_t*)(p))[6] = (d)>>48; \ | ||
307 | ((uint8_t*)(p))[7] = (d)>>56; \ | ||
308 | } while(0) | ||
309 | #endif | ||
310 | |||
311 | #if AV_HAVE_BIGENDIAN | ||
312 | # define AV_RN(s, p) AV_RB##s(p) | ||
313 | # define AV_WN(s, p, v) AV_WB##s(p, v) | ||
314 | #else | ||
315 | # define AV_RN(s, p) AV_RL##s(p) | ||
316 | # define AV_WN(s, p, v) AV_WL##s(p, v) | ||
317 | #endif | ||
318 | |||
319 | #endif /* HAVE_FAST_UNALIGNED */ | ||
320 | |||
321 | #ifndef AV_RN16 | ||
322 | # define AV_RN16(p) AV_RN(16, p) | ||
323 | #endif | ||
324 | |||
325 | #ifndef AV_RN32 | ||
326 | # define AV_RN32(p) AV_RN(32, p) | ||
327 | #endif | ||
328 | |||
329 | #ifndef AV_RN64 | ||
330 | # define AV_RN64(p) AV_RN(64, p) | ||
331 | #endif | ||
332 | |||
333 | #ifndef AV_WN16 | ||
334 | # define AV_WN16(p, v) AV_WN(16, p, v) | ||
335 | #endif | ||
336 | |||
337 | #ifndef AV_WN32 | ||
338 | # define AV_WN32(p, v) AV_WN(32, p, v) | ||
339 | #endif | ||
340 | |||
341 | #ifndef AV_WN64 | ||
342 | # define AV_WN64(p, v) AV_WN(64, p, v) | ||
343 | #endif | ||
344 | |||
345 | #if AV_HAVE_BIGENDIAN | ||
346 | # define AV_RB(s, p) AV_RN##s(p) | ||
347 | # define AV_WB(s, p, v) AV_WN##s(p, v) | ||
348 | # define AV_RL(s, p) av_bswap##s(AV_RN##s(p)) | ||
349 | # define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v)) | ||
350 | #else | ||
351 | # define AV_RB(s, p) av_bswap##s(AV_RN##s(p)) | ||
352 | # define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v)) | ||
353 | # define AV_RL(s, p) AV_RN##s(p) | ||
354 | # define AV_WL(s, p, v) AV_WN##s(p, v) | ||
355 | #endif | ||
356 | |||
357 | #define AV_RB8(x) (((const uint8_t*)(x))[0]) | ||
358 | #define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) | ||
359 | |||
360 | #define AV_RL8(x) AV_RB8(x) | ||
361 | #define AV_WL8(p, d) AV_WB8(p, d) | ||
362 | |||
363 | #ifndef AV_RB16 | ||
364 | # define AV_RB16(p) AV_RB(16, p) | ||
365 | #endif | ||
366 | #ifndef AV_WB16 | ||
367 | # define AV_WB16(p, v) AV_WB(16, p, v) | ||
368 | #endif | ||
369 | |||
370 | #ifndef AV_RL16 | ||
371 | # define AV_RL16(p) AV_RL(16, p) | ||
372 | #endif | ||
373 | #ifndef AV_WL16 | ||
374 | # define AV_WL16(p, v) AV_WL(16, p, v) | ||
375 | #endif | ||
376 | |||
377 | #ifndef AV_RB32 | ||
378 | # define AV_RB32(p) AV_RB(32, p) | ||
379 | #endif | ||
380 | #ifndef AV_WB32 | ||
381 | # define AV_WB32(p, v) AV_WB(32, p, v) | ||
382 | #endif | ||
383 | |||
384 | #ifndef AV_RL32 | ||
385 | # define AV_RL32(p) AV_RL(32, p) | ||
386 | #endif | ||
387 | #ifndef AV_WL32 | ||
388 | # define AV_WL32(p, v) AV_WL(32, p, v) | ||
389 | #endif | ||
390 | |||
391 | #ifndef AV_RB64 | ||
392 | # define AV_RB64(p) AV_RB(64, p) | ||
393 | #endif | ||
394 | #ifndef AV_WB64 | ||
395 | # define AV_WB64(p, v) AV_WB(64, p, v) | ||
396 | #endif | ||
397 | |||
398 | #ifndef AV_RL64 | ||
399 | # define AV_RL64(p) AV_RL(64, p) | ||
400 | #endif | ||
401 | #ifndef AV_WL64 | ||
402 | # define AV_WL64(p, v) AV_WL(64, p, v) | ||
403 | #endif | ||
404 | |||
405 | #ifndef AV_RB24 | ||
406 | # define AV_RB24(x) \ | ||
407 | ((((const uint8_t*)(x))[0] << 16) | \ | ||
408 | (((const uint8_t*)(x))[1] << 8) | \ | ||
409 | ((const uint8_t*)(x))[2]) | ||
410 | #endif | ||
411 | #ifndef AV_WB24 | ||
412 | # define AV_WB24(p, d) do { \ | ||
413 | ((uint8_t*)(p))[2] = (d); \ | ||
414 | ((uint8_t*)(p))[1] = (d)>>8; \ | ||
415 | ((uint8_t*)(p))[0] = (d)>>16; \ | ||
416 | } while(0) | ||
417 | #endif | ||
418 | |||
419 | #ifndef AV_RL24 | ||
420 | # define AV_RL24(x) \ | ||
421 | ((((const uint8_t*)(x))[2] << 16) | \ | ||
422 | (((const uint8_t*)(x))[1] << 8) | \ | ||
423 | ((const uint8_t*)(x))[0]) | ||
424 | #endif | ||
425 | #ifndef AV_WL24 | ||
426 | # define AV_WL24(p, d) do { \ | ||
427 | ((uint8_t*)(p))[0] = (d); \ | ||
428 | ((uint8_t*)(p))[1] = (d)>>8; \ | ||
429 | ((uint8_t*)(p))[2] = (d)>>16; \ | ||
430 | } while(0) | ||
431 | #endif | ||
432 | |||
433 | /* | ||
434 | * The AV_[RW]NA macros access naturally aligned data | ||
435 | * in a type-safe way. | ||
436 | */ | ||
437 | |||
438 | #define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s) | ||
439 | #define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v)) | ||
440 | |||
441 | #ifndef AV_RN16A | ||
442 | # define AV_RN16A(p) AV_RNA(16, p) | ||
443 | #endif | ||
444 | |||
445 | #ifndef AV_RN32A | ||
446 | # define AV_RN32A(p) AV_RNA(32, p) | ||
447 | #endif | ||
448 | |||
449 | #ifndef AV_RN64A | ||
450 | # define AV_RN64A(p) AV_RNA(64, p) | ||
451 | #endif | ||
452 | |||
453 | #ifndef AV_WN16A | ||
454 | # define AV_WN16A(p, v) AV_WNA(16, p, v) | ||
455 | #endif | ||
456 | |||
457 | #ifndef AV_WN32A | ||
458 | # define AV_WN32A(p, v) AV_WNA(32, p, v) | ||
459 | #endif | ||
460 | |||
461 | #ifndef AV_WN64A | ||
462 | # define AV_WN64A(p, v) AV_WNA(64, p, v) | ||
463 | #endif | ||
464 | |||
465 | /* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be | ||
466 | * naturally aligned. They may be implemented using MMX, | ||
467 | * so emms_c() must be called before using any float code | ||
468 | * afterwards. | ||
469 | */ | ||
470 | |||
471 | #define AV_COPY(n, d, s) \ | ||
472 | (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n) | ||
473 | |||
474 | #ifndef AV_COPY16 | ||
475 | # define AV_COPY16(d, s) AV_COPY(16, d, s) | ||
476 | #endif | ||
477 | |||
478 | #ifndef AV_COPY32 | ||
479 | # define AV_COPY32(d, s) AV_COPY(32, d, s) | ||
480 | #endif | ||
481 | |||
482 | #ifndef AV_COPY64 | ||
483 | # define AV_COPY64(d, s) AV_COPY(64, d, s) | ||
484 | #endif | ||
485 | |||
486 | #ifndef AV_COPY128 | ||
487 | # define AV_COPY128(d, s) \ | ||
488 | do { \ | ||
489 | AV_COPY64(d, s); \ | ||
490 | AV_COPY64((char*)(d)+8, (char*)(s)+8); \ | ||
491 | } while(0) | ||
492 | #endif | ||
493 | |||
494 | #define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b)) | ||
495 | |||
496 | #ifndef AV_SWAP64 | ||
497 | # define AV_SWAP64(a, b) AV_SWAP(64, a, b) | ||
498 | #endif | ||
499 | |||
500 | #define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0) | ||
501 | |||
502 | #ifndef AV_ZERO16 | ||
503 | # define AV_ZERO16(d) AV_ZERO(16, d) | ||
504 | #endif | ||
505 | |||
506 | #ifndef AV_ZERO32 | ||
507 | # define AV_ZERO32(d) AV_ZERO(32, d) | ||
508 | #endif | ||
509 | |||
510 | #ifndef AV_ZERO64 | ||
511 | # define AV_ZERO64(d) AV_ZERO(64, d) | ||
512 | #endif | ||
513 | |||
514 | #ifndef AV_ZERO128 | ||
515 | # define AV_ZERO128(d) \ | ||
516 | do { \ | ||
517 | AV_ZERO64(d); \ | ||
518 | AV_ZERO64((char*)(d)+8); \ | ||
519 | } while(0) | ||
520 | #endif | ||
521 | |||
522 | #endif /* AVUTIL_INTREADWRITE_H */ | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/log.c b/lib/rbcodec/codecs/libwmavoice/libavutil/log.c new file mode 100644 index 0000000000..2e225b3b50 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/log.c | |||
@@ -0,0 +1,150 @@ | |||
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 | ||
24 | * logging functions | ||
25 | */ | ||
26 | |||
27 | #include <unistd.h> | ||
28 | #include <stdlib.h> | ||
29 | #include "avutil.h" | ||
30 | #include "log.h" | ||
31 | |||
32 | #if LIBAVUTIL_VERSION_MAJOR > 50 | ||
33 | static | ||
34 | #endif | ||
35 | int av_log_level = AV_LOG_INFO; | ||
36 | |||
37 | #if defined(_WIN32) && !defined(__MINGW32CE__) | ||
38 | #include <windows.h> | ||
39 | static const uint8_t color[] = {12,12,12,14,7,7,7}; | ||
40 | static int16_t background, attr_orig; | ||
41 | static HANDLE con; | ||
42 | #define set_color(x) SetConsoleTextAttribute(con, background | color[x]) | ||
43 | #define reset_color() SetConsoleTextAttribute(con, attr_orig) | ||
44 | #else | ||
45 | static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9}; | ||
46 | #define set_color(x) fprintf(stderr, "\033[%d;3%dm", color[x]>>4, color[x]&15) | ||
47 | #define reset_color() fprintf(stderr, "\033[0m") | ||
48 | #endif | ||
49 | static int use_color=-1; | ||
50 | |||
51 | #undef fprintf | ||
52 | static void colored_fputs(int level, const char *str){ | ||
53 | if(use_color<0){ | ||
54 | #if defined(_WIN32) && !defined(__MINGW32CE__) | ||
55 | CONSOLE_SCREEN_BUFFER_INFO con_info; | ||
56 | con = GetStdHandle(STD_ERROR_HANDLE); | ||
57 | use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR"); | ||
58 | if (use_color) { | ||
59 | GetConsoleScreenBufferInfo(con, &con_info); | ||
60 | attr_orig = con_info.wAttributes; | ||
61 | background = attr_orig & 0xF0; | ||
62 | } | ||
63 | #elif HAVE_ISATTY | ||
64 | use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2); | ||
65 | #else | ||
66 | use_color= 0; | ||
67 | #endif | ||
68 | } | ||
69 | |||
70 | if(use_color){ | ||
71 | set_color(level); | ||
72 | } | ||
73 | fputs(str, stderr); | ||
74 | if(use_color){ | ||
75 | reset_color(); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | const char* av_default_item_name(void* ptr){ | ||
80 | return (*(AVClass**)ptr)->class_name; | ||
81 | } | ||
82 | |||
83 | void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) | ||
84 | { | ||
85 | static int print_prefix=1; | ||
86 | static int count; | ||
87 | static char line[1024], prev[1024]; | ||
88 | AVClass* avc= ptr ? *(AVClass**)ptr : NULL; | ||
89 | if(level>av_log_level) | ||
90 | return; | ||
91 | line[0]=0; | ||
92 | #undef fprintf | ||
93 | if(print_prefix && avc) { | ||
94 | if(avc->version >= (50<<16 | 15<<8 | 3) && avc->parent_log_context_offset){ | ||
95 | AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset); | ||
96 | if(parent && *parent){ | ||
97 | snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent); | ||
98 | } | ||
99 | } | ||
100 | snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr); | ||
101 | } | ||
102 | |||
103 | vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); | ||
104 | |||
105 | print_prefix= line[strlen(line)-1] == '\n'; | ||
106 | if(print_prefix && !strcmp(line, prev)){ | ||
107 | count++; | ||
108 | fprintf(stderr, " Last message repeated %d times\r", count); | ||
109 | return; | ||
110 | } | ||
111 | if(count>0){ | ||
112 | fprintf(stderr, " Last message repeated %d times\n", count); | ||
113 | count=0; | ||
114 | } | ||
115 | colored_fputs(av_clip(level>>3, 0, 6), line); | ||
116 | strcpy(prev, line); | ||
117 | } | ||
118 | |||
119 | static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; | ||
120 | |||
121 | void av_log(void* avcl, int level, const char *fmt, ...) | ||
122 | { | ||
123 | AVClass* avc= avcl ? *(AVClass**)avcl : NULL; | ||
124 | va_list vl; | ||
125 | va_start(vl, fmt); | ||
126 | if(avc && avc->version >= (50<<16 | 15<<8 | 2) && avc->log_level_offset_offset && level>=AV_LOG_FATAL) | ||
127 | level += *(int*)(((uint8_t*)avcl) + avc->log_level_offset_offset); | ||
128 | av_vlog(avcl, level, fmt, vl); | ||
129 | va_end(vl); | ||
130 | } | ||
131 | |||
132 | void av_vlog(void* avcl, int level, const char *fmt, va_list vl) | ||
133 | { | ||
134 | av_log_callback(avcl, level, fmt, vl); | ||
135 | } | ||
136 | |||
137 | int av_log_get_level(void) | ||
138 | { | ||
139 | return av_log_level; | ||
140 | } | ||
141 | |||
142 | void av_log_set_level(int level) | ||
143 | { | ||
144 | av_log_level = level; | ||
145 | } | ||
146 | |||
147 | void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)) | ||
148 | { | ||
149 | av_log_callback = callback; | ||
150 | } | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/log.h b/lib/rbcodec/codecs/libwmavoice/libavutil/log.h new file mode 100644 index 0000000000..831c26eae6 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/log.h | |||
@@ -0,0 +1,138 @@ | |||
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 | * Describe 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 | */ | ||
32 | typedef 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 | |||
52 | /** | ||
53 | * LIBAVUTIL_VERSION with which this structure was created. | ||
54 | * This is used to allow fields to be added without requiring major | ||
55 | * version bumps everywhere. | ||
56 | */ | ||
57 | |||
58 | int version; | ||
59 | |||
60 | /** | ||
61 | * Offset in the structure where log_level_offset is stored. | ||
62 | * 0 means there is no such variable | ||
63 | */ | ||
64 | int log_level_offset_offset; | ||
65 | |||
66 | /** | ||
67 | * Offset in the structure where a pointer to the parent context for loging is stored. | ||
68 | * for example a decoder that uses eval.c could pass its AVCodecContext to eval as such | ||
69 | * parent context. And a av_log() implementation could then display the parent context | ||
70 | * can be NULL of course | ||
71 | */ | ||
72 | int parent_log_context_offset; | ||
73 | } AVClass; | ||
74 | |||
75 | /* av_log API */ | ||
76 | |||
77 | #define AV_LOG_QUIET -8 | ||
78 | |||
79 | /** | ||
80 | * Something went really wrong and we will crash now. | ||
81 | */ | ||
82 | #define AV_LOG_PANIC 0 | ||
83 | |||
84 | /** | ||
85 | * Something went wrong and recovery is not possible. | ||
86 | * For example, no header was found for a format which depends | ||
87 | * on headers or an illegal combination of parameters is used. | ||
88 | */ | ||
89 | #define AV_LOG_FATAL 8 | ||
90 | |||
91 | /** | ||
92 | * Something went wrong and cannot losslessly be recovered. | ||
93 | * However, not all future data is affected. | ||
94 | */ | ||
95 | #define AV_LOG_ERROR 16 | ||
96 | |||
97 | /** | ||
98 | * Something somehow does not look correct. This may or may not | ||
99 | * lead to problems. An example would be the use of '-vstrict -2'. | ||
100 | */ | ||
101 | #define AV_LOG_WARNING 24 | ||
102 | |||
103 | #define AV_LOG_INFO 32 | ||
104 | #define AV_LOG_VERBOSE 40 | ||
105 | |||
106 | /** | ||
107 | * Stuff which is only useful for libav* developers. | ||
108 | */ | ||
109 | #define AV_LOG_DEBUG 48 | ||
110 | |||
111 | /** | ||
112 | * Send the specified message to the log if the level is less than or equal | ||
113 | * to the current av_log_level. By default, all logging messages are sent to | ||
114 | * stderr. This behavior can be altered by setting a different av_vlog callback | ||
115 | * function. | ||
116 | * | ||
117 | * @param avcl A pointer to an arbitrary struct of which the first field is a | ||
118 | * pointer to an AVClass struct. | ||
119 | * @param level The importance level of the message, lower values signifying | ||
120 | * higher importance. | ||
121 | * @param fmt The format string (printf-compatible) that specifies how | ||
122 | * subsequent arguments are converted to output. | ||
123 | * @see av_vlog | ||
124 | */ | ||
125 | #ifdef __GNUC__ | ||
126 | void av_log(void *avcl, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); | ||
127 | #else | ||
128 | void av_log(void *avcl, int level, const char *fmt, ...); | ||
129 | #endif | ||
130 | |||
131 | void av_vlog(void *avcl, int level, const char *fmt, va_list); | ||
132 | int av_log_get_level(void); | ||
133 | void av_log_set_level(int); | ||
134 | void av_log_set_callback(void (*)(void*, int, const char*, va_list)); | ||
135 | void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); | ||
136 | const char* av_default_item_name(void* ctx); | ||
137 | |||
138 | #endif /* AVUTIL_LOG_H */ | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.c b/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.c new file mode 100644 index 0000000000..7f07cc2ee5 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.c | |||
@@ -0,0 +1,280 @@ | |||
1 | /* | ||
2 | * LZO 1x decompression | ||
3 | * Copyright (c) 2006 Reimar Doeffinger | ||
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 | #include "avutil.h" | ||
23 | #include "common.h" | ||
24 | //! Avoid e.g. MPlayers fast_memcpy, it slows things down here. | ||
25 | #undef memcpy | ||
26 | #include <string.h> | ||
27 | #include "lzo.h" | ||
28 | |||
29 | //! Define if we may write up to 12 bytes beyond the output buffer. | ||
30 | #define OUTBUF_PADDED 1 | ||
31 | //! Define if we may read up to 8 bytes beyond the input buffer. | ||
32 | #define INBUF_PADDED 1 | ||
33 | typedef struct LZOContext { | ||
34 | const uint8_t *in, *in_end; | ||
35 | uint8_t *out_start, *out, *out_end; | ||
36 | int error; | ||
37 | } LZOContext; | ||
38 | |||
39 | /** | ||
40 | * \brief Reads one byte from the input buffer, avoiding an overrun. | ||
41 | * \return byte read | ||
42 | */ | ||
43 | static inline int get_byte(LZOContext *c) { | ||
44 | if (c->in < c->in_end) | ||
45 | return *c->in++; | ||
46 | c->error |= AV_LZO_INPUT_DEPLETED; | ||
47 | return 1; | ||
48 | } | ||
49 | |||
50 | #ifdef INBUF_PADDED | ||
51 | #define GETB(c) (*(c).in++) | ||
52 | #else | ||
53 | #define GETB(c) get_byte(&(c)) | ||
54 | #endif | ||
55 | |||
56 | /** | ||
57 | * \brief Decodes a length value in the coding used by lzo. | ||
58 | * \param x previous byte value | ||
59 | * \param mask bits used from x | ||
60 | * \return decoded length value | ||
61 | */ | ||
62 | static inline int get_len(LZOContext *c, int x, int mask) { | ||
63 | int cnt = x & mask; | ||
64 | if (!cnt) { | ||
65 | while (!(x = get_byte(c))) cnt += 255; | ||
66 | cnt += mask + x; | ||
67 | } | ||
68 | return cnt; | ||
69 | } | ||
70 | |||
71 | //#define UNALIGNED_LOADSTORE | ||
72 | #define BUILTIN_MEMCPY | ||
73 | #ifdef UNALIGNED_LOADSTORE | ||
74 | #define COPY2(d, s) *(uint16_t *)(d) = *(uint16_t *)(s); | ||
75 | #define COPY4(d, s) *(uint32_t *)(d) = *(uint32_t *)(s); | ||
76 | #elif defined(BUILTIN_MEMCPY) | ||
77 | #define COPY2(d, s) memcpy(d, s, 2); | ||
78 | #define COPY4(d, s) memcpy(d, s, 4); | ||
79 | #else | ||
80 | #define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; | ||
81 | #define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3]; | ||
82 | #endif | ||
83 | |||
84 | /** | ||
85 | * \brief Copies bytes from input to output buffer with checking. | ||
86 | * \param cnt number of bytes to copy, must be >= 0 | ||
87 | */ | ||
88 | static inline void copy(LZOContext *c, int cnt) { | ||
89 | register const uint8_t *src = c->in; | ||
90 | register uint8_t *dst = c->out; | ||
91 | if (cnt > c->in_end - src) { | ||
92 | cnt = FFMAX(c->in_end - src, 0); | ||
93 | c->error |= AV_LZO_INPUT_DEPLETED; | ||
94 | } | ||
95 | if (cnt > c->out_end - dst) { | ||
96 | cnt = FFMAX(c->out_end - dst, 0); | ||
97 | c->error |= AV_LZO_OUTPUT_FULL; | ||
98 | } | ||
99 | #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) | ||
100 | COPY4(dst, src); | ||
101 | src += 4; | ||
102 | dst += 4; | ||
103 | cnt -= 4; | ||
104 | if (cnt > 0) | ||
105 | #endif | ||
106 | memcpy(dst, src, cnt); | ||
107 | c->in = src + cnt; | ||
108 | c->out = dst + cnt; | ||
109 | } | ||
110 | |||
111 | static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); | ||
112 | |||
113 | /** | ||
114 | * \brief Copies previously decoded bytes to current position. | ||
115 | * \param back how many bytes back we start | ||
116 | * \param cnt number of bytes to copy, must be >= 0 | ||
117 | * | ||
118 | * cnt > back is valid, this will copy the bytes we just copied, | ||
119 | * thus creating a repeating pattern with a period length of back. | ||
120 | */ | ||
121 | static inline void copy_backptr(LZOContext *c, int back, int cnt) { | ||
122 | register const uint8_t *src = &c->out[-back]; | ||
123 | register uint8_t *dst = c->out; | ||
124 | if (src < c->out_start || src > dst) { | ||
125 | c->error |= AV_LZO_INVALID_BACKPTR; | ||
126 | return; | ||
127 | } | ||
128 | if (cnt > c->out_end - dst) { | ||
129 | cnt = FFMAX(c->out_end - dst, 0); | ||
130 | c->error |= AV_LZO_OUTPUT_FULL; | ||
131 | } | ||
132 | memcpy_backptr(dst, back, cnt); | ||
133 | c->out = dst + cnt; | ||
134 | } | ||
135 | |||
136 | static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) { | ||
137 | const uint8_t *src = &dst[-back]; | ||
138 | if (back == 1) { | ||
139 | memset(dst, *src, cnt); | ||
140 | } else { | ||
141 | #ifdef OUTBUF_PADDED | ||
142 | COPY2(dst, src); | ||
143 | COPY2(dst + 2, src + 2); | ||
144 | src += 4; | ||
145 | dst += 4; | ||
146 | cnt -= 4; | ||
147 | if (cnt > 0) { | ||
148 | COPY2(dst, src); | ||
149 | COPY2(dst + 2, src + 2); | ||
150 | COPY2(dst + 4, src + 4); | ||
151 | COPY2(dst + 6, src + 6); | ||
152 | src += 8; | ||
153 | dst += 8; | ||
154 | cnt -= 8; | ||
155 | } | ||
156 | #endif | ||
157 | if (cnt > 0) { | ||
158 | int blocklen = back; | ||
159 | while (cnt > blocklen) { | ||
160 | memcpy(dst, src, blocklen); | ||
161 | dst += blocklen; | ||
162 | cnt -= blocklen; | ||
163 | blocklen <<= 1; | ||
164 | } | ||
165 | memcpy(dst, src, cnt); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | |||
170 | void av_memcpy_backptr(uint8_t *dst, int back, int cnt) { | ||
171 | memcpy_backptr(dst, back, cnt); | ||
172 | } | ||
173 | |||
174 | int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | ||
175 | int state= 0; | ||
176 | int x; | ||
177 | LZOContext c; | ||
178 | c.in = in; | ||
179 | c.in_end = (const uint8_t *)in + *inlen; | ||
180 | c.out = c.out_start = out; | ||
181 | c.out_end = (uint8_t *)out + * outlen; | ||
182 | c.error = 0; | ||
183 | x = GETB(c); | ||
184 | if (x > 17) { | ||
185 | copy(&c, x - 17); | ||
186 | x = GETB(c); | ||
187 | if (x < 16) c.error |= AV_LZO_ERROR; | ||
188 | } | ||
189 | if (c.in > c.in_end) | ||
190 | c.error |= AV_LZO_INPUT_DEPLETED; | ||
191 | while (!c.error) { | ||
192 | int cnt, back; | ||
193 | if (x > 15) { | ||
194 | if (x > 63) { | ||
195 | cnt = (x >> 5) - 1; | ||
196 | back = (GETB(c) << 3) + ((x >> 2) & 7) + 1; | ||
197 | } else if (x > 31) { | ||
198 | cnt = get_len(&c, x, 31); | ||
199 | x = GETB(c); | ||
200 | back = (GETB(c) << 6) + (x >> 2) + 1; | ||
201 | } else { | ||
202 | cnt = get_len(&c, x, 7); | ||
203 | back = (1 << 14) + ((x & 8) << 11); | ||
204 | x = GETB(c); | ||
205 | back += (GETB(c) << 6) + (x >> 2); | ||
206 | if (back == (1 << 14)) { | ||
207 | if (cnt != 1) | ||
208 | c.error |= AV_LZO_ERROR; | ||
209 | break; | ||
210 | } | ||
211 | } | ||
212 | } else if(!state){ | ||
213 | cnt = get_len(&c, x, 15); | ||
214 | copy(&c, cnt + 3); | ||
215 | x = GETB(c); | ||
216 | if (x > 15) | ||
217 | continue; | ||
218 | cnt = 1; | ||
219 | back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1; | ||
220 | } else { | ||
221 | cnt = 0; | ||
222 | back = (GETB(c) << 2) + (x >> 2) + 1; | ||
223 | } | ||
224 | copy_backptr(&c, back, cnt + 2); | ||
225 | state= | ||
226 | cnt = x & 3; | ||
227 | copy(&c, cnt); | ||
228 | x = GETB(c); | ||
229 | } | ||
230 | *inlen = c.in_end - c.in; | ||
231 | if (c.in > c.in_end) | ||
232 | *inlen = 0; | ||
233 | *outlen = c.out_end - c.out; | ||
234 | return c.error; | ||
235 | } | ||
236 | |||
237 | #ifdef TEST | ||
238 | #include <stdio.h> | ||
239 | #include <lzo/lzo1x.h> | ||
240 | #include "log.h" | ||
241 | #define MAXSZ (10*1024*1024) | ||
242 | |||
243 | /* Define one of these to 1 if you wish to benchmark liblzo | ||
244 | * instead of our native implementation. */ | ||
245 | #define BENCHMARK_LIBLZO_SAFE 0 | ||
246 | #define BENCHMARK_LIBLZO_UNSAFE 0 | ||
247 | |||
248 | int main(int argc, char *argv[]) { | ||
249 | FILE *in = fopen(argv[1], "rb"); | ||
250 | uint8_t *orig = av_malloc(MAXSZ + 16); | ||
251 | uint8_t *comp = av_malloc(2*MAXSZ + 16); | ||
252 | uint8_t *decomp = av_malloc(MAXSZ + 16); | ||
253 | size_t s = fread(orig, 1, MAXSZ, in); | ||
254 | lzo_uint clen = 0; | ||
255 | long tmp[LZO1X_MEM_COMPRESS]; | ||
256 | int inlen, outlen; | ||
257 | int i; | ||
258 | av_log_set_level(AV_LOG_DEBUG); | ||
259 | lzo1x_999_compress(orig, s, comp, &clen, tmp); | ||
260 | for (i = 0; i < 300; i++) { | ||
261 | START_TIMER | ||
262 | inlen = clen; outlen = MAXSZ; | ||
263 | #if BENCHMARK_LIBLZO_SAFE | ||
264 | if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL)) | ||
265 | #elif BENCHMARK_LIBLZO_UNSAFE | ||
266 | if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL)) | ||
267 | #else | ||
268 | if (av_lzo1x_decode(decomp, &outlen, comp, &inlen)) | ||
269 | #endif | ||
270 | av_log(NULL, AV_LOG_ERROR, "decompression error\n"); | ||
271 | STOP_TIMER("lzod") | ||
272 | } | ||
273 | if (memcmp(orig, decomp, s)) | ||
274 | av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n"); | ||
275 | else | ||
276 | av_log(NULL, AV_LOG_ERROR, "decompression OK\n"); | ||
277 | fclose(in); | ||
278 | return 0; | ||
279 | } | ||
280 | #endif | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.h b/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.h new file mode 100644 index 0000000000..6788054bff --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.h | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * LZO 1x decompression | ||
3 | * copyright (c) 2006 Reimar Doeffinger | ||
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 | #ifndef AVUTIL_LZO_H | ||
23 | #define AVUTIL_LZO_H | ||
24 | |||
25 | #include <stdint.h> | ||
26 | |||
27 | /** \defgroup errflags Error flags returned by av_lzo1x_decode | ||
28 | * \{ */ | ||
29 | //! end of the input buffer reached before decoding finished | ||
30 | #define AV_LZO_INPUT_DEPLETED 1 | ||
31 | //! decoded data did not fit into output buffer | ||
32 | #define AV_LZO_OUTPUT_FULL 2 | ||
33 | //! a reference to previously decoded data was wrong | ||
34 | #define AV_LZO_INVALID_BACKPTR 4 | ||
35 | //! a non-specific error in the compressed bitstream | ||
36 | #define AV_LZO_ERROR 8 | ||
37 | /** \} */ | ||
38 | |||
39 | #define AV_LZO_INPUT_PADDING 8 | ||
40 | #define AV_LZO_OUTPUT_PADDING 12 | ||
41 | |||
42 | /** | ||
43 | * \brief Decodes LZO 1x compressed data. | ||
44 | * \param out output buffer | ||
45 | * \param outlen size of output buffer, number of bytes left are returned here | ||
46 | * \param in input buffer | ||
47 | * \param inlen size of input buffer, number of bytes left are returned here | ||
48 | * \return 0 on success, otherwise a combination of the error flags above | ||
49 | * | ||
50 | * Make sure all buffers are appropriately padded, in must provide | ||
51 | * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes. | ||
52 | */ | ||
53 | int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); | ||
54 | |||
55 | /** | ||
56 | * \brief deliberately overlapping memcpy implementation | ||
57 | * \param dst destination buffer; must be padded with 12 additional bytes | ||
58 | * \param back how many bytes back we start (the initial size of the overlapping window) | ||
59 | * \param cnt number of bytes to copy, must be >= 0 | ||
60 | * | ||
61 | * cnt > back is valid, this will copy the bytes we just copied, | ||
62 | * thus creating a repeating pattern with a period length of back. | ||
63 | */ | ||
64 | void av_memcpy_backptr(uint8_t *dst, int back, int cnt); | ||
65 | |||
66 | #endif /* AVUTIL_LZO_H */ | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.c b/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.c new file mode 100644 index 0000000000..c4fbe3b7bc --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.c | |||
@@ -0,0 +1,183 @@ | |||
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 | ||
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 | |||
31 | const 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, | ||
34 | 128,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, | ||
35 | 157,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, | ||
36 | 182,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, | ||
37 | 203,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, | ||
38 | 222,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, | ||
39 | 240,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 | |||
42 | const 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 | |||
53 | const uint8_t av_reverse[256]={ | ||
54 | 0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0, | ||
55 | 0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8, | ||
56 | 0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4, | ||
57 | 0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC, | ||
58 | 0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2, | ||
59 | 0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA, | ||
60 | 0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6, | ||
61 | 0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE, | ||
62 | 0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1, | ||
63 | 0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9, | ||
64 | 0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5, | ||
65 | 0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD, | ||
66 | 0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3, | ||
67 | 0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB, | ||
68 | 0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7, | ||
69 | 0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF, | ||
70 | }; | ||
71 | |||
72 | int64_t av_gcd(int64_t a, int64_t b){ | ||
73 | if(b) return av_gcd(b, a%b); | ||
74 | else return a; | ||
75 | } | ||
76 | |||
77 | int64_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((unsigned)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 | |||
129 | int64_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 | ||
134 | int64_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 | |||
140 | int 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 | #endif | ||
148 | |||
149 | int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){ | ||
150 | int64_t c= (a-b) & (mod-1); | ||
151 | if(c > (mod>>1)) | ||
152 | c-= mod; | ||
153 | return c; | ||
154 | } | ||
155 | |||
156 | #ifdef TEST | ||
157 | #include "integer.h" | ||
158 | #undef printf | ||
159 | int main(void){ | ||
160 | int64_t a,b,c,d,e; | ||
161 | |||
162 | for(a=7; a<(1LL<<62); a+=a/3+1){ | ||
163 | for(b=3; b<(1LL<<62); b+=b/4+1){ | ||
164 | for(c=9; c<(1LL<<62); c+=(c*2)/5+3){ | ||
165 | int64_t r= c/2; | ||
166 | AVInteger ai; | ||
167 | ai= av_mul_i(av_int2i(a), av_int2i(b)); | ||
168 | ai= av_add_i(ai, av_int2i(r)); | ||
169 | |||
170 | d= av_i2int(av_div_i(ai, av_int2i(c))); | ||
171 | |||
172 | e= av_rescale(a,b,c); | ||
173 | |||
174 | if((double)a * (double)b / (double)c > (1LL<<63)) | ||
175 | continue; | ||
176 | |||
177 | if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | return 0; | ||
182 | } | ||
183 | #endif | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.h b/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.h new file mode 100644 index 0000000000..e07d4fe807 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.h | |||
@@ -0,0 +1,112 @@ | |||
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_PHI | ||
42 | #define M_PHI 1.61803398874989484820 /* phi / golden ratio */ | ||
43 | #endif | ||
44 | #ifndef M_PI | ||
45 | #define M_PI 3.14159265358979323846 /* pi */ | ||
46 | #endif | ||
47 | #ifndef M_SQRT1_2 | ||
48 | #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ | ||
49 | #endif | ||
50 | #ifndef M_SQRT2 | ||
51 | #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ | ||
52 | #endif | ||
53 | #ifndef NAN | ||
54 | #define NAN (0.0/0.0) | ||
55 | #endif | ||
56 | #ifndef INFINITY | ||
57 | #define INFINITY (1.0/0.0) | ||
58 | #endif | ||
59 | |||
60 | enum AVRounding { | ||
61 | AV_ROUND_ZERO = 0, ///< Round toward zero. | ||
62 | AV_ROUND_INF = 1, ///< Round away from zero. | ||
63 | AV_ROUND_DOWN = 2, ///< Round toward -infinity. | ||
64 | AV_ROUND_UP = 3, ///< Round toward +infinity. | ||
65 | AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero. | ||
66 | }; | ||
67 | |||
68 | /** | ||
69 | * Return the greatest common divisor of a and b. | ||
70 | * If both a and b are 0 or either or both are <0 then behavior is | ||
71 | * undefined. | ||
72 | */ | ||
73 | int64_t av_const av_gcd(int64_t a, int64_t b); | ||
74 | |||
75 | /** | ||
76 | * Rescale a 64-bit integer with rounding to nearest. | ||
77 | * A simple a*b/c isn't possible as it can overflow. | ||
78 | */ | ||
79 | int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; | ||
80 | |||
81 | /** | ||
82 | * Rescale a 64-bit integer with specified rounding. | ||
83 | * A simple a*b/c isn't possible as it can overflow. | ||
84 | */ | ||
85 | int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const; | ||
86 | |||
87 | /** | ||
88 | * Rescale a 64-bit integer by 2 rational numbers. | ||
89 | */ | ||
90 | //int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; | ||
91 | |||
92 | /** | ||
93 | * Compare 2 timestamps each in its own timebases. | ||
94 | * The result of the function is undefined if one of the timestamps | ||
95 | * is outside the int64_t range when represented in the others timebase. | ||
96 | * @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 | ||
97 | */ | ||
98 | //int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); | ||
99 | |||
100 | /** | ||
101 | * Compare 2 integers modulo mod. | ||
102 | * That is we compare integers a and b for which only the least | ||
103 | * significant log2(mod) bits are known. | ||
104 | * | ||
105 | * @param mod must be a power of 2 | ||
106 | * @return a negative value if a is smaller than b | ||
107 | * a positive value if a is greater than b | ||
108 | * 0 if a equals b | ||
109 | */ | ||
110 | int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod); | ||
111 | |||
112 | #endif /* AVUTIL_MATHEMATICS_H */ | ||
diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/mem.c b/lib/rbcodec/codecs/libwmavoice/libavutil/mem.c new file mode 100644 index 0000000000..a9a3283775 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/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 | ||
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 | |||
52 | void *malloc(size_t size); | ||
53 | void *memalign(size_t align, size_t size); | ||
54 | int posix_memalign(void **ptr, size_t align, size_t size); | ||
55 | void *realloc(void *ptr, size_t size); | ||
56 | void 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 | |||
64 | void *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 | |||
119 | void *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 | |||
139 | void 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 | |||
150 | void av_freep(void *arg) | ||
151 | { | ||
152 | void **ptr= (void**)arg; | ||
153 | av_free(*ptr); | ||
154 | *ptr = NULL; | ||
155 | } | ||
156 | |||
157 | void *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 | |||
165 | char *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/lib/rbcodec/codecs/libwmavoice/libavutil/mem.h b/lib/rbcodec/codecs/libwmavoice/libavutil/mem.h new file mode 100644 index 0000000000..c5ec2ab3c3 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/mem.h | |||
@@ -0,0 +1,126 @@ | |||
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 | ||
23 | * memory handling functions | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_MEM_H | ||
27 | #define AVUTIL_MEM_H | ||
28 | |||
29 | #include "attributes.h" | ||
30 | #include "avutil.h" | ||
31 | |||
32 | #if defined(__ICC) && _ICC < 1200 || defined(__SUNPRO_C) | ||
33 | #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v | ||
34 | #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v | ||
35 | #elif defined(__TI_COMPILER_VERSION__) | ||
36 | #define DECLARE_ALIGNED(n,t,v) \ | ||
37 | AV_PRAGMA(DATA_ALIGN(v,n)) \ | ||
38 | t __attribute__((aligned(n))) v | ||
39 | #define DECLARE_ASM_CONST(n,t,v) \ | ||
40 | AV_PRAGMA(DATA_ALIGN(v,n)) \ | ||
41 | static const t __attribute__((aligned(n))) v | ||
42 | #elif defined(__GNUC__) | ||
43 | #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v | ||
44 | #define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v | ||
45 | #elif defined(_MSC_VER) | ||
46 | #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v | ||
47 | #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v | ||
48 | #else | ||
49 | #define DECLARE_ALIGNED(n,t,v) t v | ||
50 | #define DECLARE_ASM_CONST(n,t,v) static const t v | ||
51 | #endif | ||
52 | |||
53 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
54 | #define av_malloc_attrib __attribute__((__malloc__)) | ||
55 | #else | ||
56 | #define av_malloc_attrib | ||
57 | #endif | ||
58 | |||
59 | #if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3) | ||
60 | #define av_alloc_size(n) __attribute__((alloc_size(n))) | ||
61 | #else | ||
62 | #define av_alloc_size(n) | ||
63 | #endif | ||
64 | |||
65 | /** | ||
66 | * Allocate a block of size bytes with alignment suitable for all | ||
67 | * memory accesses (including vectors if available on the CPU). | ||
68 | * @param size Size in bytes for the memory block to be allocated. | ||
69 | * @return Pointer to the allocated block, NULL if the block cannot | ||
70 | * be allocated. | ||
71 | * @see av_mallocz() | ||
72 | */ | ||
73 | void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
74 | |||
75 | /** | ||
76 | * Allocate or reallocate a block of memory. | ||
77 | * If ptr is NULL and size > 0, allocate a new block. If | ||
78 | * size is zero, free the memory block pointed to by ptr. | ||
79 | * @param size Size in bytes for the memory block to be allocated or | ||
80 | * reallocated. | ||
81 | * @param ptr Pointer to a memory block already allocated with | ||
82 | * av_malloc(z)() or av_realloc() or NULL. | ||
83 | * @return Pointer to a newly reallocated block or NULL if the block | ||
84 | * cannot be reallocated or the function is used to free the memory block. | ||
85 | * @see av_fast_realloc() | ||
86 | */ | ||
87 | void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); | ||
88 | |||
89 | /** | ||
90 | * Free a memory block which has been allocated with av_malloc(z)() or | ||
91 | * av_realloc(). | ||
92 | * @param ptr Pointer to the memory block which should be freed. | ||
93 | * @note ptr = NULL is explicitly allowed. | ||
94 | * @note It is recommended that you use av_freep() instead. | ||
95 | * @see av_freep() | ||
96 | */ | ||
97 | void av_free(void *ptr); | ||
98 | |||
99 | /** | ||
100 | * Allocate a block of size bytes with alignment suitable for all | ||
101 | * memory accesses (including vectors if available on the CPU) and | ||
102 | * zero all the bytes of the block. | ||
103 | * @param size Size in bytes for the memory block to be allocated. | ||
104 | * @return Pointer to the allocated block, NULL if it cannot be allocated. | ||
105 | * @see av_malloc() | ||
106 | */ | ||
107 | void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
108 | |||
109 | /** | ||
110 | * Duplicate the string s. | ||
111 | * @param s string to be duplicated | ||
112 | * @return Pointer to a newly allocated string containing a | ||
113 | * copy of s or NULL if the string cannot be allocated. | ||
114 | */ | ||
115 | char *av_strdup(const char *s) av_malloc_attrib; | ||
116 | |||
117 | /** | ||
118 | * Free a memory block which has been allocated with av_malloc(z)() or | ||
119 | * av_realloc() and set the pointer pointing to it to NULL. | ||
120 | * @param ptr Pointer to the pointer to the memory block which should | ||
121 | * be freed. | ||
122 | * @see av_free() | ||
123 | */ | ||
124 | void av_freep(void *ptr); | ||
125 | |||
126 | #endif /* AVUTIL_MEM_H */ | ||