diff options
Diffstat (limited to 'src/plugins/ffmpeg/libavutil')
50 files changed, 0 insertions, 6144 deletions
diff --git a/src/plugins/ffmpeg/libavutil/Makefile b/src/plugins/ffmpeg/libavutil/Makefile deleted file mode 100644 index c0dfa95..0000000 --- a/src/plugins/ffmpeg/libavutil/Makefile +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | include $(SUBDIR)../config.mak | ||
2 | |||
3 | NAME = avutil | ||
4 | |||
5 | OBJS = adler32.o \ | ||
6 | aes.o \ | ||
7 | base64.o \ | ||
8 | crc.o \ | ||
9 | des.o \ | ||
10 | fifo.o \ | ||
11 | intfloat_readwrite.o \ | ||
12 | lls.o \ | ||
13 | log.o \ | ||
14 | lzo.o \ | ||
15 | mathematics.o \ | ||
16 | md5.o \ | ||
17 | mem.o \ | ||
18 | random.o \ | ||
19 | rational.o \ | ||
20 | rc4.o \ | ||
21 | sha1.o \ | ||
22 | string.o \ | ||
23 | tree.o \ | ||
24 | |||
25 | HEADERS = adler32.h \ | ||
26 | avstring.h \ | ||
27 | avutil.h \ | ||
28 | base64.h \ | ||
29 | common.h \ | ||
30 | crc.h \ | ||
31 | fifo.h \ | ||
32 | intfloat_readwrite.h \ | ||
33 | log.h \ | ||
34 | lzo.h \ | ||
35 | mathematics.h \ | ||
36 | md5.h \ | ||
37 | mem.h \ | ||
38 | random.h \ | ||
39 | rational.h \ | ||
40 | sha1.h | ||
41 | |||
42 | TESTS = $(addsuffix -test$(EXESUF), adler32 aes crc des lls md5 sha1 softfloat tree) | ||
43 | |||
44 | include $(SUBDIR)../subdir.mak | ||
45 | |||
46 | $(SUBDIR)lzo-test$(EXESUF): EXTRALIBS += -llzo2 | ||
47 | |||
48 | CLEANFILES = lzo-test$(EXESUF) | ||
diff --git a/src/plugins/ffmpeg/libavutil/adler32.c b/src/plugins/ffmpeg/libavutil/adler32.c deleted file mode 100644 index 148664e..0000000 --- a/src/plugins/ffmpeg/libavutil/adler32.c +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | /* adler32.c -- compute the Adler-32 checksum of a data stream | ||
2 | * This is a modified version based on adler32.c from the zlib library. | ||
3 | * | ||
4 | * Copyright (C) 1995 Mark Adler | ||
5 | * | ||
6 | * This software is provided 'as-is', without any express or implied | ||
7 | * warranty. In no event will the authors be held liable for any damages | ||
8 | * arising from the use of this software. | ||
9 | * | ||
10 | * Permission is granted to anyone to use this software for any purpose, | ||
11 | * including commercial applications, and to alter it and redistribute it | ||
12 | * freely, subject to the following restrictions: | ||
13 | * | ||
14 | * 1. The origin of this software must not be misrepresented; you must not | ||
15 | * claim that you wrote the original software. If you use this software | ||
16 | * in a product, an acknowledgment in the product documentation would be | ||
17 | * appreciated but is not required. | ||
18 | * 2. Altered source versions must be plainly marked as such, and must not be | ||
19 | * misrepresented as being the original software. | ||
20 | * 3. This notice may not be removed or altered from any source distribution. | ||
21 | */ | ||
22 | |||
23 | #include "common.h" | ||
24 | #include "adler32.h" | ||
25 | |||
26 | #define BASE 65521L /* largest prime smaller than 65536 */ | ||
27 | |||
28 | #define DO1(buf) {s1 += *buf++; s2 += s1;} | ||
29 | #define DO4(buf) DO1(buf); DO1(buf); DO1(buf); DO1(buf); | ||
30 | #define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf); | ||
31 | |||
32 | unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, unsigned int len) | ||
33 | { | ||
34 | unsigned long s1 = adler & 0xffff; | ||
35 | unsigned long s2 = adler >> 16; | ||
36 | |||
37 | while (len>0) { | ||
38 | #ifdef CONFIG_SMALL | ||
39 | while(len>4 && s2 < (1U<<31)){ | ||
40 | DO4(buf); len-=4; | ||
41 | #else | ||
42 | while(len>16 && s2 < (1U<<31)){ | ||
43 | DO16(buf); len-=16; | ||
44 | #endif | ||
45 | } | ||
46 | DO1(buf); len--; | ||
47 | s1 %= BASE; | ||
48 | s2 %= BASE; | ||
49 | } | ||
50 | return (s2 << 16) | s1; | ||
51 | } | ||
52 | |||
53 | #ifdef TEST | ||
54 | #include "log.h" | ||
55 | #define LEN 7001 | ||
56 | volatile int checksum; | ||
57 | int main(void){ | ||
58 | int i; | ||
59 | char data[LEN]; | ||
60 | av_log_level = AV_LOG_DEBUG; | ||
61 | for(i=0; i<LEN; i++) | ||
62 | data[i]= ((i*i)>>3) + 123*i; | ||
63 | for(i=0; i<1000; i++){ | ||
64 | START_TIMER | ||
65 | checksum= av_adler32_update(1, data, LEN); | ||
66 | STOP_TIMER("adler") | ||
67 | } | ||
68 | av_log(NULL, AV_LOG_DEBUG, "%X == 50E6E508\n", checksum); | ||
69 | return 0; | ||
70 | } | ||
71 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/adler32.h b/src/plugins/ffmpeg/libavutil/adler32.h deleted file mode 100644 index 488669d..0000000 --- a/src/plugins/ffmpeg/libavutil/adler32.h +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Mans Rullgard | ||
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 FFMPEG_ADLER32_H | ||
22 | #define FFMPEG_ADLER32_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | #include "common.h" | ||
26 | |||
27 | unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, | ||
28 | unsigned int len) av_pure; | ||
29 | |||
30 | #endif /* FFMPEG_ADLER32_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/aes.c b/src/plugins/ffmpeg/libavutil/aes.c deleted file mode 100644 index 9b1f194..0000000 --- a/src/plugins/ffmpeg/libavutil/aes.c +++ /dev/null | |||
@@ -1,245 +0,0 @@ | |||
1 | #if 0 | ||
2 | /* | ||
3 | * copyright (c) 2007 Michael Niedermayer <michaelni@gmx.at> | ||
4 | * | ||
5 | * some optimization ideas from aes128.c by Reimar Doeffinger | ||
6 | * | ||
7 | * This file is part of FFmpeg. | ||
8 | * | ||
9 | * FFmpeg is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Lesser General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2.1 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * FFmpeg is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with FFmpeg; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | */ | ||
23 | |||
24 | #include "common.h" | ||
25 | #include "aes.h" | ||
26 | |||
27 | typedef struct AVAES{ | ||
28 | // Note: round_key[16] is accessed in the init code, but this only | ||
29 | // overwrites state, which does not matter (see also r7471). | ||
30 | uint8_t round_key[15][4][4]; | ||
31 | uint8_t state[2][4][4]; | ||
32 | int rounds; | ||
33 | }AVAES; | ||
34 | |||
35 | const int av_aes_size= sizeof(AVAES); | ||
36 | |||
37 | static const uint8_t rcon[10] = { | ||
38 | 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 | ||
39 | }; | ||
40 | |||
41 | static uint8_t sbox[256]; | ||
42 | static uint8_t inv_sbox[256]; | ||
43 | #ifdef CONFIG_SMALL | ||
44 | static uint32_t enc_multbl[1][256]; | ||
45 | static uint32_t dec_multbl[1][256]; | ||
46 | #else | ||
47 | static uint32_t enc_multbl[4][256]; | ||
48 | static uint32_t dec_multbl[4][256]; | ||
49 | #endif | ||
50 | |||
51 | static inline void addkey(uint64_t dst[2], uint64_t src[2], uint64_t round_key[2]){ | ||
52 | dst[0] = src[0] ^ round_key[0]; | ||
53 | dst[1] = src[1] ^ round_key[1]; | ||
54 | } | ||
55 | |||
56 | static void subshift(uint8_t s0[2][16], int s, uint8_t *box){ | ||
57 | uint8_t (*s1)[16]= s0[0] - s; | ||
58 | uint8_t (*s3)[16]= s0[0] + s; | ||
59 | s0[0][0]=box[s0[1][ 0]]; s0[0][ 4]=box[s0[1][ 4]]; s0[0][ 8]=box[s0[1][ 8]]; s0[0][12]=box[s0[1][12]]; | ||
60 | s1[0][3]=box[s1[1][ 7]]; s1[0][ 7]=box[s1[1][11]]; s1[0][11]=box[s1[1][15]]; s1[0][15]=box[s1[1][ 3]]; | ||
61 | s0[0][2]=box[s0[1][10]]; s0[0][10]=box[s0[1][ 2]]; s0[0][ 6]=box[s0[1][14]]; s0[0][14]=box[s0[1][ 6]]; | ||
62 | s3[0][1]=box[s3[1][13]]; s3[0][13]=box[s3[1][ 9]]; s3[0][ 9]=box[s3[1][ 5]]; s3[0][ 5]=box[s3[1][ 1]]; | ||
63 | } | ||
64 | |||
65 | static inline int mix_core(uint32_t multbl[4][256], int a, int b, int c, int d){ | ||
66 | #ifdef CONFIG_SMALL | ||
67 | #define ROT(x,s) ((x<<s)|(x>>(32-s))) | ||
68 | return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24); | ||
69 | #else | ||
70 | return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d]; | ||
71 | #endif | ||
72 | } | ||
73 | |||
74 | static inline void mix(uint8_t state[2][4][4], uint32_t multbl[4][256], int s1, int s3){ | ||
75 | ((uint32_t *)(state))[0] = mix_core(multbl, state[1][0][0], state[1][s1 ][1], state[1][2][2], state[1][s3 ][3]); | ||
76 | ((uint32_t *)(state))[1] = mix_core(multbl, state[1][1][0], state[1][s3-1][1], state[1][3][2], state[1][s1-1][3]); | ||
77 | ((uint32_t *)(state))[2] = mix_core(multbl, state[1][2][0], state[1][s3 ][1], state[1][0][2], state[1][s1 ][3]); | ||
78 | ((uint32_t *)(state))[3] = mix_core(multbl, state[1][3][0], state[1][s1-1][1], state[1][1][2], state[1][s3-1][3]); | ||
79 | } | ||
80 | |||
81 | static inline void crypt(AVAES *a, int s, uint8_t *sbox, uint32_t *multbl){ | ||
82 | int r; | ||
83 | |||
84 | for(r=a->rounds-1; r>0; r--){ | ||
85 | mix(a->state, multbl, 3-s, 1+s); | ||
86 | addkey(a->state[1], a->state[0], a->round_key[r]); | ||
87 | } | ||
88 | subshift(a->state[0][0], s, sbox); | ||
89 | } | ||
90 | |||
91 | void av_aes_crypt(AVAES *a, uint8_t *dst, uint8_t *src, int count, uint8_t *iv, int decrypt){ | ||
92 | while(count--){ | ||
93 | addkey(a->state[1], src, a->round_key[a->rounds]); | ||
94 | if(decrypt) { | ||
95 | crypt(a, 0, inv_sbox, dec_multbl); | ||
96 | if(iv){ | ||
97 | addkey(a->state[0], a->state[0], iv); | ||
98 | memcpy(iv, src, 16); | ||
99 | } | ||
100 | addkey(dst, a->state[0], a->round_key[0]); | ||
101 | }else{ | ||
102 | if(iv) addkey(a->state[1], a->state[1], iv); | ||
103 | crypt(a, 2, sbox, enc_multbl); | ||
104 | addkey(dst, a->state[0], a->round_key[0]); | ||
105 | if(iv) memcpy(iv, dst, 16); | ||
106 | } | ||
107 | src+=16; | ||
108 | dst+=16; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | static void init_multbl2(uint8_t tbl[1024], int c[4], uint8_t *log8, uint8_t *alog8, uint8_t *sbox){ | ||
113 | int i, j; | ||
114 | for(i=0; i<1024; i++){ | ||
115 | int x= sbox[i>>2]; | ||
116 | if(x) tbl[i]= alog8[ log8[x] + log8[c[i&3]] ]; | ||
117 | } | ||
118 | #ifndef CONFIG_SMALL | ||
119 | for(j=256; j<1024; j++) | ||
120 | for(i=0; i<4; i++) | ||
121 | tbl[4*j+i]= tbl[4*j + ((i-1)&3) - 1024]; | ||
122 | #endif | ||
123 | } | ||
124 | |||
125 | // this is based on the reference AES code by Paulo Barreto and Vincent Rijmen | ||
126 | int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { | ||
127 | int i, j, t, rconpointer = 0; | ||
128 | uint8_t tk[8][4]; | ||
129 | int KC= key_bits>>5; | ||
130 | int rounds= KC + 6; | ||
131 | uint8_t log8[256]; | ||
132 | uint8_t alog8[512]; | ||
133 | |||
134 | if(!enc_multbl[0][sizeof(enc_multbl)/sizeof(enc_multbl[0][0])-1]){ | ||
135 | j=1; | ||
136 | for(i=0; i<255; i++){ | ||
137 | alog8[i]= | ||
138 | alog8[i+255]= j; | ||
139 | log8[j]= i; | ||
140 | j^= j+j; | ||
141 | if(j>255) j^= 0x11B; | ||
142 | } | ||
143 | for(i=0; i<256; i++){ | ||
144 | j= i ? alog8[255-log8[i]] : 0; | ||
145 | j ^= (j<<1) ^ (j<<2) ^ (j<<3) ^ (j<<4); | ||
146 | j = (j ^ (j>>8) ^ 99) & 255; | ||
147 | inv_sbox[j]= i; | ||
148 | sbox [i]= j; | ||
149 | } | ||
150 | init_multbl2(dec_multbl[0], (int[4]){0xe, 0x9, 0xd, 0xb}, log8, alog8, inv_sbox); | ||
151 | init_multbl2(enc_multbl[0], (int[4]){0x2, 0x1, 0x1, 0x3}, log8, alog8, sbox); | ||
152 | } | ||
153 | |||
154 | if(key_bits!=128 && key_bits!=192 && key_bits!=256) | ||
155 | return -1; | ||
156 | |||
157 | a->rounds= rounds; | ||
158 | |||
159 | memcpy(tk, key, KC*4); | ||
160 | |||
161 | for(t= 0; t < (rounds+1)*16;) { | ||
162 | memcpy(a->round_key[0][0]+t, tk, KC*4); | ||
163 | t+= KC*4; | ||
164 | |||
165 | for(i = 0; i < 4; i++) | ||
166 | tk[0][i] ^= sbox[tk[KC-1][(i+1)&3]]; | ||
167 | tk[0][0] ^= rcon[rconpointer++]; | ||
168 | |||
169 | for(j = 1; j < KC; j++){ | ||
170 | if(KC != 8 || j != KC>>1) | ||
171 | for(i = 0; i < 4; i++) tk[j][i] ^= tk[j-1][i]; | ||
172 | else | ||
173 | for(i = 0; i < 4; i++) tk[j][i] ^= sbox[tk[j-1][i]]; | ||
174 | } | ||
175 | } | ||
176 | |||
177 | if(decrypt){ | ||
178 | for(i=1; i<rounds; i++){ | ||
179 | uint8_t tmp[3][16]; | ||
180 | memcpy(tmp[2], a->round_key[i][0], 16); | ||
181 | subshift(tmp[1], 0, sbox); | ||
182 | mix(tmp, dec_multbl, 1, 3); | ||
183 | memcpy(a->round_key[i][0], tmp[0], 16); | ||
184 | } | ||
185 | }else{ | ||
186 | for(i=0; i<(rounds+1)>>1; i++){ | ||
187 | for(j=0; j<16; j++) | ||
188 | FFSWAP(int, a->round_key[i][0][j], a->round_key[rounds-i][0][j]); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | #ifdef TEST | ||
196 | #include "log.h" | ||
197 | |||
198 | #undef random | ||
199 | |||
200 | int main(void){ | ||
201 | int i,j; | ||
202 | AVAES ae, ad, b; | ||
203 | uint8_t rkey[2][16]= { | ||
204 | {0}, | ||
205 | {0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59}}; | ||
206 | uint8_t pt[16], rpt[2][16]= { | ||
207 | {0x6a, 0x84, 0x86, 0x7c, 0xd7, 0x7e, 0x12, 0xad, 0x07, 0xea, 0x1b, 0xe8, 0x95, 0xc5, 0x3f, 0xa3}, | ||
208 | {0}}; | ||
209 | uint8_t rct[2][16]= { | ||
210 | {0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, 0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf}, | ||
211 | {0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65}}; | ||
212 | uint8_t temp[16]; | ||
213 | |||
214 | av_aes_init(&ae, "PI=3.141592654..", 128, 0); | ||
215 | av_aes_init(&ad, "PI=3.141592654..", 128, 1); | ||
216 | av_log_level= AV_LOG_DEBUG; | ||
217 | |||
218 | for(i=0; i<2; i++){ | ||
219 | av_aes_init(&b, rkey[i], 128, 1); | ||
220 | av_aes_crypt(&b, temp, rct[i], 1, NULL, 1); | ||
221 | for(j=0; j<16; j++) | ||
222 | if(rpt[i][j] != temp[j]) | ||
223 | av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", j, rpt[i][j], temp[j]); | ||
224 | } | ||
225 | |||
226 | for(i=0; i<10000; i++){ | ||
227 | for(j=0; j<16; j++){ | ||
228 | pt[j]= random(); | ||
229 | } | ||
230 | {START_TIMER | ||
231 | av_aes_crypt(&ae, temp, pt, 1, NULL, 0); | ||
232 | if(!(i&(i-1))) | ||
233 | av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]); | ||
234 | av_aes_crypt(&ad, temp, temp, 1, NULL, 1); | ||
235 | STOP_TIMER("aes")} | ||
236 | for(j=0; j<16; j++){ | ||
237 | if(pt[j] != temp[j]){ | ||
238 | av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]); | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | return 0; | ||
243 | } | ||
244 | #endif | ||
245 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/aes.h b/src/plugins/ffmpeg/libavutil/aes.h deleted file mode 100644 index 606311b..0000000 --- a/src/plugins/ffmpeg/libavutil/aes.h +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | #if 0 | ||
2 | /* | ||
3 | * copyright (c) 2007 Michael Niedermayer <michaelni@gmx.at> | ||
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 FFMPEG_AES_H | ||
23 | #define FFMPEG_AES_H | ||
24 | |||
25 | #include <stdint.h> | ||
26 | |||
27 | extern const int av_aes_size; | ||
28 | |||
29 | struct AVAES; | ||
30 | |||
31 | /** | ||
32 | * Initializes an AVAES context. | ||
33 | * @param key_bits 128, 192 or 256 | ||
34 | * @param decrypt 0 for encryption, 1 for decryption | ||
35 | */ | ||
36 | int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt); | ||
37 | |||
38 | /** | ||
39 | * Encrypts / decrypts. | ||
40 | * @param count number of 16 byte blocks | ||
41 | * @param dst destination array, can be equal to src | ||
42 | * @param src source array, can be equal to dst | ||
43 | * @param iv initialization vector for CBC mode, if NULL then ECB will be used | ||
44 | * @param decrypt 0 for encryption, 1 for decryption | ||
45 | */ | ||
46 | void av_aes_crypt(struct AVAES *a, uint8_t *dst, uint8_t *src, int count, uint8_t *iv, int decrypt); | ||
47 | |||
48 | #endif /* FFMPEG_AES_H */ | ||
49 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/avstring.h b/src/plugins/ffmpeg/libavutil/avstring.h deleted file mode 100644 index ecac9e6..0000000 --- a/src/plugins/ffmpeg/libavutil/avstring.h +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2007 Mans Rullgard | ||
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 FFMPEG_AVSTRING_H | ||
22 | #define FFMPEG_AVSTRING_H | ||
23 | |||
24 | #include <stddef.h> | ||
25 | |||
26 | /** | ||
27 | * Return non-zero if pfx is a prefix of str. If it is, *ptr is set to | ||
28 | * the address of the first character in str after the prefix. | ||
29 | * | ||
30 | * @param str input string | ||
31 | * @param pfx prefix to test | ||
32 | * @param ptr updated after the prefix in str in there is a match | ||
33 | * @return non-zero if the prefix matches, zero otherwise | ||
34 | */ | ||
35 | int av_strstart(const char *str, const char *pfx, const char **ptr); | ||
36 | |||
37 | /** | ||
38 | * Return non-zero if pfx is a prefix of str independent of case. If | ||
39 | * it is, *ptr is set to the address of the first character in str | ||
40 | * after the prefix. | ||
41 | * | ||
42 | * @param str input string | ||
43 | * @param pfx prefix to test | ||
44 | * @param ptr updated after the prefix in str in there is a match | ||
45 | * @return non-zero if the prefix matches, zero otherwise | ||
46 | */ | ||
47 | int av_stristart(const char *str, const char *pfx, const char **ptr); | ||
48 | |||
49 | /** | ||
50 | * Copy the string src to dst, but no more than size - 1 bytes, and | ||
51 | * null terminate dst. | ||
52 | * | ||
53 | * This function is the same as BSD strlcpy(). | ||
54 | * | ||
55 | * @param dst destination buffer | ||
56 | * @param src source string | ||
57 | * @param size size of destination buffer | ||
58 | * @return the length of src | ||
59 | */ | ||
60 | size_t av_strlcpy(char *dst, const char *src, size_t size); | ||
61 | |||
62 | /** | ||
63 | * Append the string src to the string dst, but to a total length of | ||
64 | * no more than size - 1 bytes, and null terminate dst. | ||
65 | * | ||
66 | * This function is similar to BSD strlcat(), but differs when | ||
67 | * size <= strlen(dst). | ||
68 | * | ||
69 | * @param dst destination buffer | ||
70 | * @param src source string | ||
71 | * @param size size of destination buffer | ||
72 | * @return the total length of src and dst | ||
73 | */ | ||
74 | size_t av_strlcat(char *dst, const char *src, size_t size); | ||
75 | |||
76 | /** | ||
77 | * Append output to a string, according to a format. Never write out of | ||
78 | * the destination buffer, and and always put a terminating 0 within | ||
79 | * the buffer. | ||
80 | * @param dst destination buffer (string to which the output is | ||
81 | * appended) | ||
82 | * @param size total size of the destination buffer | ||
83 | * @param fmt printf-compatible format string, specifying how the | ||
84 | * following parameters are used | ||
85 | * @return the length of the string that would have been generated | ||
86 | * if enough space had been available | ||
87 | */ | ||
88 | size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...); | ||
89 | |||
90 | #endif /* FFMPEG_AVSTRING_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/avutil.h b/src/plugins/ffmpeg/libavutil/avutil.h deleted file mode 100644 index 6ce70ac..0000000 --- a/src/plugins/ffmpeg/libavutil/avutil.h +++ /dev/null | |||
@@ -1,143 +0,0 @@ | |||
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 FFMPEG_AVUTIL_H | ||
22 | #define FFMPEG_AVUTIL_H | ||
23 | |||
24 | /** | ||
25 | * @file avutil.h | ||
26 | * external API header | ||
27 | */ | ||
28 | |||
29 | |||
30 | #define AV_STRINGIFY(s) AV_TOSTRING(s) | ||
31 | #define AV_TOSTRING(s) #s | ||
32 | |||
33 | #define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) | ||
34 | #define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c | ||
35 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) | ||
36 | |||
37 | #define LIBAVUTIL_VERSION_MAJOR 49 | ||
38 | #define LIBAVUTIL_VERSION_MINOR 7 | ||
39 | #define LIBAVUTIL_VERSION_MICRO 0 | ||
40 | |||
41 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | ||
42 | LIBAVUTIL_VERSION_MINOR, \ | ||
43 | LIBAVUTIL_VERSION_MICRO) | ||
44 | #define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \ | ||
45 | LIBAVUTIL_VERSION_MINOR, \ | ||
46 | LIBAVUTIL_VERSION_MICRO) | ||
47 | #define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT | ||
48 | |||
49 | #define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) | ||
50 | |||
51 | |||
52 | #include "common.h" | ||
53 | #include "mathematics.h" | ||
54 | #include "rational.h" | ||
55 | #include "intfloat_readwrite.h" | ||
56 | #include "log.h" | ||
57 | |||
58 | /** | ||
59 | * Pixel format. Notes: | ||
60 | * | ||
61 | * PIX_FMT_RGB32 is handled in an endian-specific manner. A RGBA | ||
62 | * color is put together as: | ||
63 | * (A << 24) | (R << 16) | (G << 8) | B | ||
64 | * This is stored as BGRA on little endian CPU architectures and ARGB on | ||
65 | * big endian CPUs. | ||
66 | * | ||
67 | * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized | ||
68 | * image data is stored in AVFrame.data[0]. The palette is transported in | ||
69 | * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is | ||
70 | * formatted the same as in PIX_FMT_RGB32 described above (i.e., it is | ||
71 | * also endian-specific). Note also that the individual RGB palette | ||
72 | * components stored in AVFrame.data[1] should be in the range 0..255. | ||
73 | * This is important as many custom PAL8 video codecs that were designed | ||
74 | * to run on the IBM VGA graphics adapter use 6-bit palette components. | ||
75 | */ | ||
76 | enum PixelFormat { | ||
77 | PIX_FMT_NONE= -1, | ||
78 | PIX_FMT_YUV420P, ///< Planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) | ||
79 | PIX_FMT_YUYV422, ///< Packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr | ||
80 | PIX_FMT_RGB24, ///< Packed RGB 8:8:8, 24bpp, RGBRGB... | ||
81 | PIX_FMT_BGR24, ///< Packed RGB 8:8:8, 24bpp, BGRBGR... | ||
82 | PIX_FMT_YUV422P, ///< Planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) | ||
83 | PIX_FMT_YUV444P, ///< Planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) | ||
84 | PIX_FMT_RGB32, ///< Packed RGB 8:8:8, 32bpp, (msb)8A 8R 8G 8B(lsb), in cpu endianness | ||
85 | PIX_FMT_YUV410P, ///< Planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) | ||
86 | PIX_FMT_YUV411P, ///< Planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) | ||
87 | PIX_FMT_RGB565, ///< Packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), in cpu endianness | ||
88 | PIX_FMT_RGB555, ///< Packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), in cpu endianness most significant bit to 0 | ||
89 | PIX_FMT_GRAY8, ///< Y , 8bpp | ||
90 | PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black | ||
91 | PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white | ||
92 | PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette | ||
93 | PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0, 12bpp, full scale (jpeg) | ||
94 | PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2, 16bpp, full scale (jpeg) | ||
95 | PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4, 24bpp, full scale (jpeg) | ||
96 | PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h) | ||
97 | PIX_FMT_XVMC_MPEG2_IDCT, | ||
98 | PIX_FMT_UYVY422, ///< Packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 | ||
99 | PIX_FMT_UYYVYY411, ///< Packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 | ||
100 | PIX_FMT_BGR32, ///< Packed RGB 8:8:8, 32bpp, (msb)8A 8B 8G 8R(lsb), in cpu endianness | ||
101 | PIX_FMT_BGR565, ///< Packed RGB 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), in cpu endianness | ||
102 | PIX_FMT_BGR555, ///< Packed RGB 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), in cpu endianness most significant bit to 1 | ||
103 | PIX_FMT_BGR8, ///< Packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) | ||
104 | PIX_FMT_BGR4, ///< Packed RGB 1:2:1, 4bpp, (msb)1B 2G 1R(lsb) | ||
105 | PIX_FMT_BGR4_BYTE, ///< Packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) | ||
106 | PIX_FMT_RGB8, ///< Packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) | ||
107 | PIX_FMT_RGB4, ///< Packed RGB 1:2:1, 4bpp, (msb)2R 3G 3B(lsb) | ||
108 | PIX_FMT_RGB4_BYTE, ///< Packed RGB 1:2:1, 8bpp, (msb)2R 3G 3B(lsb) | ||
109 | PIX_FMT_NV12, ///< Planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 for UV | ||
110 | PIX_FMT_NV21, ///< as above, but U and V bytes are swapped | ||
111 | |||
112 | PIX_FMT_RGB32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8R 8G 8B 8A(lsb), in cpu endianness | ||
113 | PIX_FMT_BGR32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8B 8G 8R 8A(lsb), in cpu endianness | ||
114 | |||
115 | PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian | ||
116 | PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian | ||
117 | PIX_FMT_YUV440P, ///< Planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) | ||
118 | PIX_FMT_YUVJ440P, ///< Planar YUV 4:4:0 full scale (jpeg) | ||
119 | PIX_FMT_YUVA420P, ///< Planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) | ||
120 | PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions | ||
121 | }; | ||
122 | |||
123 | #ifdef WORDS_BIGENDIAN | ||
124 | #define PIX_FMT_RGBA PIX_FMT_RGB32_1 | ||
125 | #define PIX_FMT_BGRA PIX_FMT_BGR32_1 | ||
126 | #define PIX_FMT_ARGB PIX_FMT_RGB32 | ||
127 | #define PIX_FMT_ABGR PIX_FMT_BGR32 | ||
128 | #define PIX_FMT_GRAY16 PIX_FMT_GRAY16BE | ||
129 | #else | ||
130 | #define PIX_FMT_RGBA PIX_FMT_BGR32 | ||
131 | #define PIX_FMT_BGRA PIX_FMT_RGB32 | ||
132 | #define PIX_FMT_ARGB PIX_FMT_BGR32_1 | ||
133 | #define PIX_FMT_ABGR PIX_FMT_RGB32_1 | ||
134 | #define PIX_FMT_GRAY16 PIX_FMT_GRAY16LE | ||
135 | #endif | ||
136 | |||
137 | #if LIBAVUTIL_VERSION_INT < (50<<16) | ||
138 | #define PIX_FMT_UYVY411 PIX_FMT_UYYVYY411 | ||
139 | #define PIX_FMT_RGBA32 PIX_FMT_RGB32 | ||
140 | #define PIX_FMT_YUV422 PIX_FMT_YUYV422 | ||
141 | #endif | ||
142 | |||
143 | #endif /* FFMPEG_AVUTIL_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/base64.c b/src/plugins/ffmpeg/libavutil/base64.c deleted file mode 100644 index a6b44fb..0000000 --- a/src/plugins/ffmpeg/libavutil/base64.c +++ /dev/null | |||
@@ -1,228 +0,0 @@ | |||
1 | /* | ||
2 | * Base64.c | ||
3 | * Copyright (c) 2006 Ryan Martell. (rdm4@martellventures.com) | ||
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 base64.c | ||
24 | * @brief Base64 Encode/Decode | ||
25 | * @author Ryan Martell <rdm4@martellventures.com> (with lots of Michael) | ||
26 | */ | ||
27 | |||
28 | #include "common.h" | ||
29 | #include "base64.h" | ||
30 | |||
31 | /* ---------------- private code */ | ||
32 | static const uint8_t map2[] = | ||
33 | { | ||
34 | 0x3e, 0xff, 0xff, 0xff, 0x3f, 0x34, 0x35, 0x36, | ||
35 | 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff, | ||
36 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, | ||
37 | 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, | ||
38 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, | ||
39 | 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, | ||
40 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1a, 0x1b, | ||
41 | 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, | ||
42 | 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, | ||
43 | 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33 | ||
44 | }; | ||
45 | |||
46 | int av_base64_decode(uint8_t * out, const char *in, int out_length) | ||
47 | { | ||
48 | int i, v; | ||
49 | uint8_t *dst = out; | ||
50 | |||
51 | v = 0; | ||
52 | for (i = 0; in[i] && in[i] != '='; i++) { | ||
53 | unsigned int index= in[i]-43; | ||
54 | if (index>=(sizeof(map2)/sizeof(map2[0])) || map2[index] == 0xff) | ||
55 | return -1; | ||
56 | v = (v << 6) + map2[index]; | ||
57 | if (i & 3) { | ||
58 | if (dst - out < out_length) { | ||
59 | *dst++ = v >> (6 - 2 * (i & 3)); | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | |||
64 | return dst - out; | ||
65 | } | ||
66 | |||
67 | /***************************************************************************** | ||
68 | * b64_encode: stolen from VLC's http.c | ||
69 | * simplified by michael | ||
70 | * fixed edge cases and made it work from data (vs. strings) by ryan. | ||
71 | *****************************************************************************/ | ||
72 | |||
73 | char *av_base64_encode(char * buf, int buf_len, const uint8_t * src, int len) | ||
74 | { | ||
75 | static const char b64[] = | ||
76 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
77 | char *ret, *dst; | ||
78 | unsigned i_bits = 0; | ||
79 | int i_shift = 0; | ||
80 | int bytes_remaining = len; | ||
81 | |||
82 | if (len >= UINT_MAX / 4 || | ||
83 | buf_len < len * 4 / 3 + 12) | ||
84 | return NULL; | ||
85 | ret = dst = buf; | ||
86 | while (bytes_remaining) { | ||
87 | i_bits = (i_bits << 8) + *src++; | ||
88 | bytes_remaining--; | ||
89 | i_shift += 8; | ||
90 | |||
91 | do { | ||
92 | *dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f]; | ||
93 | i_shift -= 6; | ||
94 | } while (i_shift > 6 || (bytes_remaining == 0 && i_shift > 0)); | ||
95 | } | ||
96 | while ((dst - ret) & 3) | ||
97 | *dst++ = '='; | ||
98 | *dst = '\0'; | ||
99 | |||
100 | return ret; | ||
101 | } | ||
102 | |||
103 | // #define TEST_BASE64 | ||
104 | |||
105 | #ifdef TEST_BASE64 | ||
106 | #include "avutil.h" | ||
107 | |||
108 | int b64test() | ||
109 | { | ||
110 | int numerr = 0; | ||
111 | int len; | ||
112 | int numtest = 1; | ||
113 | uint8_t decode[1000]; | ||
114 | struct test { | ||
115 | void *data; | ||
116 | int len; | ||
117 | const char *result; | ||
118 | } *t, tests[] = { | ||
119 | { | ||
120 | "", 0, ""}, { | ||
121 | "1", 1, "MQ=="}, { | ||
122 | "22", 2, "MjI="}, { | ||
123 | "333", 3, "MzMz"}, { | ||
124 | "4444", 4, "NDQ0NA=="}, { | ||
125 | "55555", 5, "NTU1NTU="}, { | ||
126 | "abc:def", 7, "YWJjOmRlZg=="}, { | ||
127 | NULL} | ||
128 | }; | ||
129 | for (t = tests; t->data; t++) { | ||
130 | char *str; | ||
131 | |||
132 | av_log(NULL, AV_LOG_ERROR, "Encoding %s...\n", (char *) t->data); | ||
133 | str = av_base64_encode(t->data, t->len); | ||
134 | if (str) { | ||
135 | av_log(NULL, AV_LOG_ERROR, "Encoded to %s...\n", str); | ||
136 | if (strcmp(str, t->result) != 0) { | ||
137 | av_log(NULL, AV_LOG_ERROR, "failed test %d: %s != %s\n", | ||
138 | numtest, str, t->result); | ||
139 | numerr++; | ||
140 | } | ||
141 | av_free(str); | ||
142 | } | ||
143 | |||
144 | av_log(NULL, AV_LOG_ERROR, "Done encoding, about to decode...\n"); | ||
145 | len = av_base64_decode(decode, t->result, sizeof(decode)); | ||
146 | if (len != t->len) { | ||
147 | av_log(NULL, AV_LOG_ERROR, "failed test %d: len %d != %d\n", | ||
148 | numtest, len, t->len); | ||
149 | numerr++; | ||
150 | } else if (memcmp(decode, t->data, t->len) != 0) { | ||
151 | av_log(NULL, AV_LOG_ERROR, "failed test %d: data\n", numtest); | ||
152 | numerr++; | ||
153 | } else { | ||
154 | av_log(NULL, AV_LOG_ERROR, "Decoded to %s\n", | ||
155 | (char *) t->data); | ||
156 | } | ||
157 | numtest++; | ||
158 | } | ||
159 | |||
160 | #undef srand | ||
161 | #undef rand | ||
162 | |||
163 | { | ||
164 | int test_count; | ||
165 | srand(123141); // time(NULL)); | ||
166 | for (test_count = 0; test_count < 100; test_count++) { | ||
167 | int size = rand() % 1024; | ||
168 | int ii; | ||
169 | uint8_t *data; | ||
170 | char *encoded_result; | ||
171 | |||
172 | av_log(NULL, AV_LOG_ERROR, "Test %d: Size %d bytes...", | ||
173 | test_count, size); | ||
174 | data = (uint8_t *) av_malloc(size); | ||
175 | for (ii = 0; ii < size; ii++) { | ||
176 | data[ii] = rand() % 255; | ||
177 | } | ||
178 | |||
179 | encoded_result = av_base64_encode(data, size); | ||
180 | if (encoded_result) { | ||
181 | int decode_buffer_size = size + 10; // try without 10 as well | ||
182 | uint8_t *decode_buffer = av_malloc(decode_buffer_size); | ||
183 | if (decode_buffer) { | ||
184 | int decoded_size = | ||
185 | av_base64_decode(decode_buffer, encoded_result, | ||
186 | decode_buffer_size); | ||
187 | |||
188 | if (decoded_size != size) { | ||
189 | av_log(NULL, AV_LOG_ERROR, | ||
190 | "Decoded/Encoded size mismatch (%d != %d)\n", | ||
191 | decoded_size, size); | ||
192 | } else { | ||
193 | if (memcmp(decode_buffer, data, decoded_size) == 0) { | ||
194 | av_log(NULL, AV_LOG_ERROR, "Passed!\n"); | ||
195 | } else { | ||
196 | av_log(NULL, AV_LOG_ERROR, | ||
197 | "Failed (Data differs)!\n"); | ||
198 | } | ||
199 | } | ||
200 | av_free(decode_buffer); | ||
201 | } | ||
202 | |||
203 | av_free(encoded_result); | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
208 | // these are invalid strings, that it currently decodes (which it probably shouldn't?) | ||
209 | { | ||
210 | uint8_t str[32]; | ||
211 | if (av_base64_decode(str, "M=M=", sizeof(str)) != -1) { | ||
212 | av_log(NULL, AV_LOG_ERROR, | ||
213 | "failed test %d: successful decode of `M=M='\n", | ||
214 | numtest++); | ||
215 | numerr++; | ||
216 | } | ||
217 | if (av_base64_decode(str, "MQ===", sizeof(str)) != -1) { | ||
218 | av_log(NULL, AV_LOG_ERROR, | ||
219 | "failed test %d: successful decode of `MQ==='\n", | ||
220 | numtest++); | ||
221 | numerr++; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | return numerr; | ||
226 | } | ||
227 | #endif | ||
228 | |||
diff --git a/src/plugins/ffmpeg/libavutil/base64.h b/src/plugins/ffmpeg/libavutil/base64.h deleted file mode 100644 index e95e4ea..0000000 --- a/src/plugins/ffmpeg/libavutil/base64.h +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | /* | ||
2 | * Base64.c | ||
3 | * Copyright (c) 2006 Ryan Martell. (rdm4@martellventures.com) | ||
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 FFMPEG_BASE64_H | ||
23 | #define FFMPEG_BASE64_H | ||
24 | |||
25 | #include <stdint.h> | ||
26 | |||
27 | /** | ||
28 | * decodes base64 | ||
29 | * param order as strncpy() | ||
30 | */ | ||
31 | int av_base64_decode(uint8_t * out, const char *in, int out_length); | ||
32 | |||
33 | /** | ||
34 | * encodes base64 | ||
35 | * @param src data, not a string | ||
36 | * @param buf output string | ||
37 | */ | ||
38 | char *av_base64_encode(char * buf, int buf_len, const uint8_t * src, int len); | ||
39 | |||
40 | #endif /* FFMPEG_BASE64_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/bswap.h b/src/plugins/ffmpeg/libavutil/bswap.h deleted file mode 100644 index 2f1e768..0000000 --- a/src/plugins/ffmpeg/libavutil/bswap.h +++ /dev/null | |||
@@ -1,132 +0,0 @@ | |||
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 bswap.h | ||
23 | * byte swapping routines | ||
24 | */ | ||
25 | |||
26 | #ifndef FFMPEG_BSWAP_H | ||
27 | #define FFMPEG_BSWAP_H | ||
28 | |||
29 | #include <stdint.h> | ||
30 | #include "config.h" | ||
31 | #include "common.h" | ||
32 | |||
33 | #ifdef HAVE_BYTESWAP_H | ||
34 | #include <byteswap.h> | ||
35 | #else | ||
36 | |||
37 | static av_always_inline av_const uint16_t bswap_16(uint16_t x) | ||
38 | { | ||
39 | #if defined(ARCH_X86) | ||
40 | asm("rorw $8, %0" : "+r"(x)); | ||
41 | #elif defined(ARCH_SH4) | ||
42 | asm("swap.b %0,%0" : "=r"(x) : "0"(x)); | ||
43 | #elif defined(HAVE_ARMV6) | ||
44 | asm("rev16 %0, %0" : "+r"(x)); | ||
45 | #else | ||
46 | x= (x>>8) | (x<<8); | ||
47 | #endif | ||
48 | return x; | ||
49 | } | ||
50 | |||
51 | static av_always_inline av_const uint32_t bswap_32(uint32_t x) | ||
52 | { | ||
53 | #if defined(ARCH_X86) | ||
54 | #ifdef HAVE_BSWAP | ||
55 | asm("bswap %0" : "+r" (x)); | ||
56 | #else | ||
57 | asm("rorw $8, %w0 \n\t" | ||
58 | "rorl $16, %0 \n\t" | ||
59 | "rorw $8, %w0" | ||
60 | : "+r"(x)); | ||
61 | #endif | ||
62 | #elif defined(ARCH_SH4) | ||
63 | asm("swap.b %0,%0\n" | ||
64 | "swap.w %0,%0\n" | ||
65 | "swap.b %0,%0\n" | ||
66 | : "=r"(x) : "0"(x)); | ||
67 | #elif defined(HAVE_ARMV6) | ||
68 | asm("rev %0, %0" : "+r"(x)); | ||
69 | #elif defined(ARCH_ARMV4L) | ||
70 | uint32_t t; | ||
71 | asm ("eor %1, %0, %0, ror #16 \n\t" | ||
72 | "bic %1, %1, #0xFF0000 \n\t" | ||
73 | "mov %0, %0, ror #8 \n\t" | ||
74 | "eor %0, %0, %1, lsr #8 \n\t" | ||
75 | : "+r"(x), "+r"(t)); | ||
76 | #elif defined(ARCH_BFIN) | ||
77 | unsigned tmp; | ||
78 | asm("%1 = %0 >> 8 (V); \n\t" | ||
79 | "%0 = %0 << 8 (V); \n\t" | ||
80 | "%0 = %0 | %1; \n\t" | ||
81 | "%0 = PACK(%0.L, %0.H); \n\t" | ||
82 | : "+d"(x), "=&d"(tmp)); | ||
83 | #else | ||
84 | x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); | ||
85 | x= (x>>16) | (x<<16); | ||
86 | #endif | ||
87 | return x; | ||
88 | } | ||
89 | |||
90 | static inline uint64_t av_const bswap_64(uint64_t x) | ||
91 | { | ||
92 | #if 0 | ||
93 | x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); | ||
94 | x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); | ||
95 | return (x>>32) | (x<<32); | ||
96 | #elif defined(ARCH_X86_64) | ||
97 | asm("bswap %0": "=r" (x) : "0" (x)); | ||
98 | return x; | ||
99 | #else | ||
100 | union { | ||
101 | uint64_t ll; | ||
102 | uint32_t l[2]; | ||
103 | } w, r; | ||
104 | w.ll = x; | ||
105 | r.l[0] = bswap_32 (w.l[1]); | ||
106 | r.l[1] = bswap_32 (w.l[0]); | ||
107 | return r.ll; | ||
108 | #endif | ||
109 | } | ||
110 | |||
111 | #endif /* !HAVE_BYTESWAP_H */ | ||
112 | |||
113 | // be2me ... BigEndian to MachineEndian | ||
114 | // le2me ... LittleEndian to MachineEndian | ||
115 | |||
116 | #ifdef WORDS_BIGENDIAN | ||
117 | #define be2me_16(x) (x) | ||
118 | #define be2me_32(x) (x) | ||
119 | #define be2me_64(x) (x) | ||
120 | #define le2me_16(x) bswap_16(x) | ||
121 | #define le2me_32(x) bswap_32(x) | ||
122 | #define le2me_64(x) bswap_64(x) | ||
123 | #else | ||
124 | #define be2me_16(x) bswap_16(x) | ||
125 | #define be2me_32(x) bswap_32(x) | ||
126 | #define be2me_64(x) bswap_64(x) | ||
127 | #define le2me_16(x) (x) | ||
128 | #define le2me_32(x) (x) | ||
129 | #define le2me_64(x) (x) | ||
130 | #endif | ||
131 | |||
132 | #endif /* FFMPEG_BSWAP_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/common.h b/src/plugins/ffmpeg/libavutil/common.h deleted file mode 100644 index 696b03e..0000000 --- a/src/plugins/ffmpeg/libavutil/common.h +++ /dev/null | |||
@@ -1,415 +0,0 @@ | |||
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 common.h | ||
23 | * common internal and external API header | ||
24 | */ | ||
25 | |||
26 | #ifndef FFMPEG_COMMON_H | ||
27 | #define FFMPEG_COMMON_H | ||
28 | |||
29 | #include <inttypes.h> | ||
30 | |||
31 | #ifdef HAVE_AV_CONFIG_H | ||
32 | /* only include the following when compiling package */ | ||
33 | # include "config.h" | ||
34 | |||
35 | # include <stdlib.h> | ||
36 | # include <stdio.h> | ||
37 | # include <string.h> | ||
38 | # include <ctype.h> | ||
39 | # include <limits.h> | ||
40 | # include <errno.h> | ||
41 | # include <math.h> | ||
42 | #endif /* HAVE_AV_CONFIG_H */ | ||
43 | |||
44 | #ifndef av_always_inline | ||
45 | #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) | ||
46 | # define av_always_inline __attribute__((always_inline)) inline | ||
47 | #else | ||
48 | # define av_always_inline inline | ||
49 | #endif | ||
50 | #endif | ||
51 | |||
52 | #ifndef av_noinline | ||
53 | #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) | ||
54 | # define av_noinline __attribute__((noinline)) | ||
55 | #else | ||
56 | # define av_noinline | ||
57 | #endif | ||
58 | #endif | ||
59 | |||
60 | #ifndef av_pure | ||
61 | #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) | ||
62 | # define av_pure __attribute__((pure)) | ||
63 | #else | ||
64 | # define av_pure | ||
65 | #endif | ||
66 | #endif | ||
67 | |||
68 | #ifndef av_const | ||
69 | #if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 5) | ||
70 | # define av_const __attribute__((const)) | ||
71 | #else | ||
72 | # define av_const | ||
73 | #endif | ||
74 | #endif | ||
75 | |||
76 | #ifndef av_cold | ||
77 | #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 2) | ||
78 | # define av_cold __attribute__((cold)) | ||
79 | #else | ||
80 | # define av_cold | ||
81 | #endif | ||
82 | #endif | ||
83 | |||
84 | #ifdef HAVE_AV_CONFIG_H | ||
85 | # include "internal.h" | ||
86 | #endif /* HAVE_AV_CONFIG_H */ | ||
87 | |||
88 | #ifndef attribute_deprecated | ||
89 | #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) | ||
90 | # define attribute_deprecated __attribute__((deprecated)) | ||
91 | #else | ||
92 | # define attribute_deprecated | ||
93 | #endif | ||
94 | #endif | ||
95 | |||
96 | #ifndef av_unused | ||
97 | #if defined(__GNUC__) | ||
98 | # define av_unused __attribute__((unused)) | ||
99 | #else | ||
100 | # define av_unused | ||
101 | #endif | ||
102 | #endif | ||
103 | |||
104 | #include "mem.h" | ||
105 | |||
106 | //rounded divison & shift | ||
107 | #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) | ||
108 | /* assume b>0 */ | ||
109 | #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) | ||
110 | #define FFABS(a) ((a) >= 0 ? (a) : (-(a))) | ||
111 | #define FFSIGN(a) ((a) > 0 ? 1 : -1) | ||
112 | |||
113 | #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) | ||
114 | #define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) | ||
115 | #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) | ||
116 | #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) | ||
117 | |||
118 | #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) | ||
119 | |||
120 | /* misc math functions */ | ||
121 | extern const uint8_t ff_log2_tab[256]; | ||
122 | |||
123 | static inline av_const int av_log2(unsigned int v) | ||
124 | { | ||
125 | int n = 0; | ||
126 | if (v & 0xffff0000) { | ||
127 | v >>= 16; | ||
128 | n += 16; | ||
129 | } | ||
130 | if (v & 0xff00) { | ||
131 | v >>= 8; | ||
132 | n += 8; | ||
133 | } | ||
134 | n += ff_log2_tab[v]; | ||
135 | |||
136 | return n; | ||
137 | } | ||
138 | |||
139 | static inline av_const int av_log2_16bit(unsigned int v) | ||
140 | { | ||
141 | int n = 0; | ||
142 | if (v & 0xff00) { | ||
143 | v >>= 8; | ||
144 | n += 8; | ||
145 | } | ||
146 | n += ff_log2_tab[v]; | ||
147 | |||
148 | return n; | ||
149 | } | ||
150 | |||
151 | /* median of 3 */ | ||
152 | static inline av_const int mid_pred(int a, int b, int c) | ||
153 | { | ||
154 | #ifdef HAVE_CMOV | ||
155 | int i=b; | ||
156 | asm volatile( | ||
157 | "cmp %2, %1 \n\t" | ||
158 | "cmovg %1, %0 \n\t" | ||
159 | "cmovg %2, %1 \n\t" | ||
160 | "cmp %3, %1 \n\t" | ||
161 | "cmovl %3, %1 \n\t" | ||
162 | "cmp %1, %0 \n\t" | ||
163 | "cmovg %1, %0 \n\t" | ||
164 | :"+&r"(i), "+&r"(a) | ||
165 | :"r"(b), "r"(c) | ||
166 | ); | ||
167 | return i; | ||
168 | #elif 0 | ||
169 | int t= (a-b)&((a-b)>>31); | ||
170 | a-=t; | ||
171 | b+=t; | ||
172 | b-= (b-c)&((b-c)>>31); | ||
173 | b+= (a-b)&((a-b)>>31); | ||
174 | |||
175 | return b; | ||
176 | #else | ||
177 | if(a>b){ | ||
178 | if(c>b){ | ||
179 | if(c>a) b=a; | ||
180 | else b=c; | ||
181 | } | ||
182 | }else{ | ||
183 | if(b>c){ | ||
184 | if(c>a) b=c; | ||
185 | else b=a; | ||
186 | } | ||
187 | } | ||
188 | return b; | ||
189 | #endif | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * clip a signed integer value into the amin-amax range | ||
194 | * @param a value to clip | ||
195 | * @param amin minimum value of the clip range | ||
196 | * @param amax maximum value of the clip range | ||
197 | * @return clipped value | ||
198 | */ | ||
199 | static inline av_const int av_clip(int a, int amin, int amax) | ||
200 | { | ||
201 | if (a < amin) return amin; | ||
202 | else if (a > amax) return amax; | ||
203 | else return a; | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * clip a signed integer value into the 0-255 range | ||
208 | * @param a value to clip | ||
209 | * @return clipped value | ||
210 | */ | ||
211 | static inline av_const uint8_t av_clip_uint8(int a) | ||
212 | { | ||
213 | if (a&(~255)) return (-a)>>31; | ||
214 | else return a; | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * clip a signed integer value into the -32768,32767 range | ||
219 | * @param a value to clip | ||
220 | * @return clipped value | ||
221 | */ | ||
222 | static inline av_const int16_t av_clip_int16(int a) | ||
223 | { | ||
224 | if ((a+32768) & ~65535) return (a>>31) ^ 32767; | ||
225 | else return a; | ||
226 | } | ||
227 | |||
228 | /** | ||
229 | * clip a float value into the amin-amax range | ||
230 | * @param a value to clip | ||
231 | * @param amin minimum value of the clip range | ||
232 | * @param amax maximum value of the clip range | ||
233 | * @return clipped value | ||
234 | */ | ||
235 | static inline av_const float av_clipf(float a, float amin, float amax) | ||
236 | { | ||
237 | if (a < amin) return amin; | ||
238 | else if (a > amax) return amax; | ||
239 | else return a; | ||
240 | } | ||
241 | |||
242 | /* math */ | ||
243 | int64_t av_const ff_gcd(int64_t a, int64_t b); | ||
244 | |||
245 | /** | ||
246 | * converts fourcc string to int | ||
247 | */ | ||
248 | static inline av_pure int ff_get_fourcc(const char *s){ | ||
249 | #ifdef HAVE_AV_CONFIG_H | ||
250 | assert( strlen(s)==4 ); | ||
251 | #endif | ||
252 | |||
253 | return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24); | ||
254 | } | ||
255 | |||
256 | #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) | ||
257 | #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) | ||
258 | |||
259 | /*! | ||
260 | * \def GET_UTF8(val, GET_BYTE, ERROR) | ||
261 | * converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form | ||
262 | * \param val is the output and should be of type uint32_t. It holds the converted | ||
263 | * UCS-4 character and should be a left value. | ||
264 | * \param GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be | ||
265 | * a function or a statement whose return value or evaluated value is of type | ||
266 | * uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range, | ||
267 | * and up to 7 times in the general case. | ||
268 | * \param ERROR action that should be taken when an invalid UTF-8 byte is returned | ||
269 | * from GET_BYTE. It should be a statement that jumps out of the macro, | ||
270 | * like exit(), goto, return, break, or continue. | ||
271 | */ | ||
272 | #define GET_UTF8(val, GET_BYTE, ERROR)\ | ||
273 | val= GET_BYTE;\ | ||
274 | {\ | ||
275 | int ones= 7 - av_log2(val ^ 255);\ | ||
276 | if(ones==1)\ | ||
277 | ERROR\ | ||
278 | val&= 127>>ones;\ | ||
279 | while(--ones > 0){\ | ||
280 | int tmp= GET_BYTE - 128;\ | ||
281 | if(tmp>>6)\ | ||
282 | ERROR\ | ||
283 | val= (val<<6) + tmp;\ | ||
284 | }\ | ||
285 | } | ||
286 | |||
287 | /*! | ||
288 | * \def PUT_UTF8(val, tmp, PUT_BYTE) | ||
289 | * converts a 32-bit unicode character to its UTF-8 encoded form (up to 4 bytes long). | ||
290 | * \param val is an input only argument and should be of type uint32_t. It holds | ||
291 | * a ucs4 encoded unicode character that is to be converted to UTF-8. If | ||
292 | * val is given as a function it's executed only once. | ||
293 | * \param tmp is a temporary variable and should be of type uint8_t. It | ||
294 | * represents an intermediate value during conversion that is to be | ||
295 | * outputted by PUT_BYTE. | ||
296 | * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. | ||
297 | * It could be a function or a statement, and uses tmp as the input byte. | ||
298 | * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be | ||
299 | * executed up to 4 times for values in the valid UTF-8 range and up to | ||
300 | * 7 times in the general case, depending on the length of the converted | ||
301 | * unicode character. | ||
302 | */ | ||
303 | #define PUT_UTF8(val, tmp, PUT_BYTE)\ | ||
304 | {\ | ||
305 | int bytes, shift;\ | ||
306 | uint32_t in = val;\ | ||
307 | if (in < 0x80) {\ | ||
308 | tmp = in;\ | ||
309 | PUT_BYTE\ | ||
310 | } else {\ | ||
311 | bytes = (av_log2(in) + 4) / 5;\ | ||
312 | shift = (bytes - 1) * 6;\ | ||
313 | tmp = (256 - (256 >> bytes)) | (in >> shift);\ | ||
314 | PUT_BYTE\ | ||
315 | while (shift >= 6) {\ | ||
316 | shift -= 6;\ | ||
317 | tmp = 0x80 | ((in >> shift) & 0x3f);\ | ||
318 | PUT_BYTE\ | ||
319 | }\ | ||
320 | }\ | ||
321 | } | ||
322 | |||
323 | #if defined(ARCH_X86) || defined(ARCH_POWERPC) || defined(ARCH_BFIN) | ||
324 | #define AV_READ_TIME read_time | ||
325 | #if defined(ARCH_X86_64) | ||
326 | static inline uint64_t read_time(void) | ||
327 | { | ||
328 | uint64_t a, d; | ||
329 | asm volatile("rdtsc\n\t" | ||
330 | : "=a" (a), "=d" (d)); | ||
331 | return (d << 32) | (a & 0xffffffff); | ||
332 | } | ||
333 | #elif defined(ARCH_X86_32) | ||
334 | static inline long long read_time(void) | ||
335 | { | ||
336 | long long l; | ||
337 | asm volatile("rdtsc\n\t" | ||
338 | : "=A" (l)); | ||
339 | return l; | ||
340 | } | ||
341 | #elif ARCH_BFIN | ||
342 | static inline uint64_t read_time(void) | ||
343 | { | ||
344 | union { | ||
345 | struct { | ||
346 | unsigned lo; | ||
347 | unsigned hi; | ||
348 | } p; | ||
349 | unsigned long long c; | ||
350 | } t; | ||
351 | asm volatile ("%0=cycles; %1=cycles2;" : "=d" (t.p.lo), "=d" (t.p.hi)); | ||
352 | return t.c; | ||
353 | } | ||
354 | #else //FIXME check ppc64 | ||
355 | static inline uint64_t read_time(void) | ||
356 | { | ||
357 | uint32_t tbu, tbl, temp; | ||
358 | |||
359 | /* from section 2.2.1 of the 32-bit PowerPC PEM */ | ||
360 | asm volatile( | ||
361 | "1:\n" | ||
362 | "mftbu %2\n" | ||
363 | "mftb %0\n" | ||
364 | "mftbu %1\n" | ||
365 | "cmpw %2,%1\n" | ||
366 | "bne 1b\n" | ||
367 | : "=r"(tbl), "=r"(tbu), "=r"(temp) | ||
368 | : | ||
369 | : "cc"); | ||
370 | |||
371 | return (((uint64_t)tbu)<<32) | (uint64_t)tbl; | ||
372 | } | ||
373 | #endif | ||
374 | #elif defined(HAVE_GETHRTIME) | ||
375 | #define AV_READ_TIME gethrtime | ||
376 | #endif | ||
377 | |||
378 | #ifdef AV_READ_TIME | ||
379 | #define START_TIMER \ | ||
380 | uint64_t tend;\ | ||
381 | uint64_t tstart= AV_READ_TIME();\ | ||
382 | |||
383 | #define STOP_TIMER(id) \ | ||
384 | tend= AV_READ_TIME();\ | ||
385 | {\ | ||
386 | static uint64_t tsum=0;\ | ||
387 | static int tcount=0;\ | ||
388 | static int tskip_count=0;\ | ||
389 | if(tcount<2 || tend - tstart < FFMAX(8*tsum/tcount, 2000)){\ | ||
390 | tsum+= tend - tstart;\ | ||
391 | tcount++;\ | ||
392 | }else\ | ||
393 | tskip_count++;\ | ||
394 | if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\ | ||
395 | av_log(NULL, AV_LOG_ERROR, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n",\ | ||
396 | tsum*10/tcount, id, tcount, tskip_count);\ | ||
397 | }\ | ||
398 | } | ||
399 | #else | ||
400 | #define START_TIMER | ||
401 | #define STOP_TIMER(id) {} | ||
402 | #endif | ||
403 | |||
404 | /** | ||
405 | * Returns NULL if CONFIG_SMALL is defined otherwise the argument | ||
406 | * without modifications, used to disable the definition of strings | ||
407 | * (for example AVCodec long_names). | ||
408 | */ | ||
409 | #ifdef CONFIG_SMALL | ||
410 | # define NULL_IF_CONFIG_SMALL(x) NULL | ||
411 | #else | ||
412 | # define NULL_IF_CONFIG_SMALL(x) x | ||
413 | #endif | ||
414 | |||
415 | #endif /* FFMPEG_COMMON_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/crc.c b/src/plugins/ffmpeg/libavutil/crc.c deleted file mode 100644 index 743a640..0000000 --- a/src/plugins/ffmpeg/libavutil/crc.c +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
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 | #include "common.h" | ||
22 | #include "crc.h" | ||
23 | |||
24 | #ifdef CONFIG_HARDCODED_TABLES | ||
25 | #include "crc_data.h" | ||
26 | #else | ||
27 | static struct { | ||
28 | uint8_t le; | ||
29 | uint8_t bits; | ||
30 | uint32_t poly; | ||
31 | } av_crc_table_params[AV_CRC_MAX] = { | ||
32 | [AV_CRC_8_ATM] = { 0, 8, 0x07 }, | ||
33 | [AV_CRC_16_ANSI] = { 0, 16, 0x8005 }, | ||
34 | [AV_CRC_16_CCITT] = { 0, 16, 0x1021 }, | ||
35 | [AV_CRC_32_IEEE] = { 0, 32, 0x04C11DB7 }, | ||
36 | [AV_CRC_32_IEEE_LE] = { 1, 32, 0xEDB88320 }, | ||
37 | }; | ||
38 | static AVCRC av_crc_table[AV_CRC_MAX][257]; | ||
39 | #endif | ||
40 | |||
41 | /** | ||
42 | * Inits a crc table. | ||
43 | * @param ctx must be an array of sizeof(AVCRC)*257 or sizeof(AVCRC)*1024 | ||
44 | * @param cts_size size of ctx in bytes | ||
45 | * @param le if 1, lowest bit represents coefficient for highest exponent | ||
46 | * of corresponding polynomial (both for poly and actual CRC). | ||
47 | * If 0, you must swap the crc parameter and the result of av_crc | ||
48 | * if you need the standard representation (can be simplified in | ||
49 | * most cases to e.g. bswap16): | ||
50 | * bswap_32(crc << (32-bits)) | ||
51 | * @param bits number of bits for the CRC | ||
52 | * @param poly generator polynomial without the x**bits coefficient, in the | ||
53 | * representation as specified by le | ||
54 | * @return <0 on failure | ||
55 | */ | ||
56 | int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){ | ||
57 | int i, j; | ||
58 | uint32_t c; | ||
59 | |||
60 | if (bits < 8 || bits > 32 || poly >= (1LL<<bits)) | ||
61 | return -1; | ||
62 | if (ctx_size != sizeof(AVCRC)*257 && ctx_size != sizeof(AVCRC)*1024) | ||
63 | return -1; | ||
64 | |||
65 | for (i = 0; i < 256; i++) { | ||
66 | if (le) { | ||
67 | for (c = i, j = 0; j < 8; j++) | ||
68 | c = (c>>1)^(poly & (-(c&1))); | ||
69 | ctx[i] = c; | ||
70 | } else { | ||
71 | for (c = i << 24, j = 0; j < 8; j++) | ||
72 | c = (c<<1) ^ ((poly<<(32-bits)) & (((int32_t)c)>>31) ); | ||
73 | ctx[i] = bswap_32(c); | ||
74 | } | ||
75 | } | ||
76 | ctx[256]=1; | ||
77 | #ifndef CONFIG_SMALL | ||
78 | if(ctx_size >= sizeof(AVCRC)*1024) | ||
79 | for (i = 0; i < 256; i++) | ||
80 | for(j=0; j<3; j++) | ||
81 | ctx[256*(j+1) + i]= (ctx[256*j + i]>>8) ^ ctx[ ctx[256*j + i]&0xFF ]; | ||
82 | #endif | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * Get an initialized standard CRC table. | ||
89 | * @param crc_id ID of a standard CRC | ||
90 | * @return a pointer to the CRC table or NULL on failure | ||
91 | */ | ||
92 | const AVCRC *av_crc_get_table(AVCRCId crc_id){ | ||
93 | #ifndef CONFIG_HARDCODED_TABLES | ||
94 | if (!av_crc_table[crc_id][sizeof(av_crc_table[crc_id])/sizeof(av_crc_table[crc_id][0])-1]) | ||
95 | if (av_crc_init(av_crc_table[crc_id], | ||
96 | av_crc_table_params[crc_id].le, | ||
97 | av_crc_table_params[crc_id].bits, | ||
98 | av_crc_table_params[crc_id].poly, | ||
99 | sizeof(av_crc_table[crc_id])) < 0) | ||
100 | return NULL; | ||
101 | #endif | ||
102 | return av_crc_table[crc_id]; | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * Calculate the CRC of a block | ||
107 | * @param crc CRC of previous blocks if any or initial value for CRC. | ||
108 | * @return CRC updated with the data from the given block | ||
109 | * | ||
110 | * @see av_crc_init() "le" parameter | ||
111 | */ | ||
112 | uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length){ | ||
113 | const uint8_t *end= buffer+length; | ||
114 | |||
115 | #ifndef CONFIG_SMALL | ||
116 | if(!ctx[256]) | ||
117 | while(buffer<end-3){ | ||
118 | crc ^= le2me_32(*(const uint32_t*)buffer); buffer+=4; | ||
119 | crc = ctx[3*256 + ( crc &0xFF)] | ||
120 | ^ctx[2*256 + ((crc>>8 )&0xFF)] | ||
121 | ^ctx[1*256 + ((crc>>16)&0xFF)] | ||
122 | ^ctx[0*256 + ((crc>>24) )]; | ||
123 | } | ||
124 | #endif | ||
125 | while(buffer<end) | ||
126 | crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); | ||
127 | |||
128 | return crc; | ||
129 | } | ||
130 | |||
131 | #ifdef TEST | ||
132 | #undef printf | ||
133 | int main(void){ | ||
134 | uint8_t buf[1999]; | ||
135 | int i; | ||
136 | int p[4][3]={{AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04}, | ||
137 | {AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0}, | ||
138 | {AV_CRC_16_ANSI , 0x8005, 0x1FBB }, | ||
139 | {AV_CRC_8_ATM , 0x07, 0xE3 },}; | ||
140 | const AVCRC *ctx; | ||
141 | |||
142 | for(i=0; i<sizeof(buf); i++) | ||
143 | buf[i]= i+i*i; | ||
144 | |||
145 | for(i=0; i<4; i++){ | ||
146 | ctx = av_crc_get_table(p[i][0]); | ||
147 | printf("crc %08X =%X\n", p[i][1], av_crc(ctx, 0, buf, sizeof(buf))); | ||
148 | } | ||
149 | return 0; | ||
150 | } | ||
151 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/crc.h b/src/plugins/ffmpeg/libavutil/crc.h deleted file mode 100644 index 5ebb2f5..0000000 --- a/src/plugins/ffmpeg/libavutil/crc.h +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
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 FFMPEG_CRC_H | ||
22 | #define FFMPEG_CRC_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | #include <stddef.h> | ||
26 | #include "common.h" | ||
27 | |||
28 | typedef uint32_t AVCRC; | ||
29 | |||
30 | typedef enum { | ||
31 | AV_CRC_8_ATM, | ||
32 | AV_CRC_16_ANSI, | ||
33 | AV_CRC_16_CCITT, | ||
34 | AV_CRC_32_IEEE, | ||
35 | AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */ | ||
36 | AV_CRC_MAX, /*< not part of public API! don't use outside lavu */ | ||
37 | }AVCRCId; | ||
38 | |||
39 | int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size); | ||
40 | const AVCRC *av_crc_get_table(AVCRCId crc_id); | ||
41 | uint32_t av_crc(const AVCRC *ctx, uint32_t start_crc, const uint8_t *buffer, size_t length) av_pure; | ||
42 | |||
43 | #endif /* FFMPEG_CRC_H */ | ||
44 | |||
diff --git a/src/plugins/ffmpeg/libavutil/crc_data.h b/src/plugins/ffmpeg/libavutil/crc_data.h deleted file mode 100644 index 857678d..0000000 --- a/src/plugins/ffmpeg/libavutil/crc_data.h +++ /dev/null | |||
@@ -1,213 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2008 Aurelien Jacobs <aurel@gnuage.org> | ||
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 FFMPEG_CRC_DATA_H | ||
22 | #define FFMPEG_CRC_DATA_H | ||
23 | |||
24 | #include "crc.h" | ||
25 | |||
26 | static const AVCRC av_crc_table[AV_CRC_MAX][257] = { | ||
27 | [AV_CRC_8_ATM] = { | ||
28 | 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, | ||
29 | 0x24, 0x23, 0x2A, 0x2D, 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, | ||
30 | 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, 0xE0, 0xE7, 0xEE, 0xE9, | ||
31 | 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD, | ||
32 | 0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, | ||
33 | 0xB4, 0xB3, 0xBA, 0xBD, 0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, | ||
34 | 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA, 0xB7, 0xB0, 0xB9, 0xBE, | ||
35 | 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A, | ||
36 | 0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, | ||
37 | 0x03, 0x04, 0x0D, 0x0A, 0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, | ||
38 | 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A, 0x89, 0x8E, 0x87, 0x80, | ||
39 | 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4, | ||
40 | 0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, | ||
41 | 0xDD, 0xDA, 0xD3, 0xD4, 0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, | ||
42 | 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44, 0x19, 0x1E, 0x17, 0x10, | ||
43 | 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34, | ||
44 | 0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, | ||
45 | 0x6A, 0x6D, 0x64, 0x63, 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, | ||
46 | 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, 0xAE, 0xA9, 0xA0, 0xA7, | ||
47 | 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83, | ||
48 | 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, | ||
49 | 0xFA, 0xFD, 0xF4, 0xF3, 0x01 | ||
50 | }, | ||
51 | [AV_CRC_16_ANSI] = { | ||
52 | 0x0000, 0x0580, 0x0F80, 0x0A00, 0x1B80, 0x1E00, 0x1400, 0x1180, | ||
53 | 0x3380, 0x3600, 0x3C00, 0x3980, 0x2800, 0x2D80, 0x2780, 0x2200, | ||
54 | 0x6380, 0x6600, 0x6C00, 0x6980, 0x7800, 0x7D80, 0x7780, 0x7200, | ||
55 | 0x5000, 0x5580, 0x5F80, 0x5A00, 0x4B80, 0x4E00, 0x4400, 0x4180, | ||
56 | 0xC380, 0xC600, 0xCC00, 0xC980, 0xD800, 0xDD80, 0xD780, 0xD200, | ||
57 | 0xF000, 0xF580, 0xFF80, 0xFA00, 0xEB80, 0xEE00, 0xE400, 0xE180, | ||
58 | 0xA000, 0xA580, 0xAF80, 0xAA00, 0xBB80, 0xBE00, 0xB400, 0xB180, | ||
59 | 0x9380, 0x9600, 0x9C00, 0x9980, 0x8800, 0x8D80, 0x8780, 0x8200, | ||
60 | 0x8381, 0x8601, 0x8C01, 0x8981, 0x9801, 0x9D81, 0x9781, 0x9201, | ||
61 | 0xB001, 0xB581, 0xBF81, 0xBA01, 0xAB81, 0xAE01, 0xA401, 0xA181, | ||
62 | 0xE001, 0xE581, 0xEF81, 0xEA01, 0xFB81, 0xFE01, 0xF401, 0xF181, | ||
63 | 0xD381, 0xD601, 0xDC01, 0xD981, 0xC801, 0xCD81, 0xC781, 0xC201, | ||
64 | 0x4001, 0x4581, 0x4F81, 0x4A01, 0x5B81, 0x5E01, 0x5401, 0x5181, | ||
65 | 0x7381, 0x7601, 0x7C01, 0x7981, 0x6801, 0x6D81, 0x6781, 0x6201, | ||
66 | 0x2381, 0x2601, 0x2C01, 0x2981, 0x3801, 0x3D81, 0x3781, 0x3201, | ||
67 | 0x1001, 0x1581, 0x1F81, 0x1A01, 0x0B81, 0x0E01, 0x0401, 0x0181, | ||
68 | 0x0383, 0x0603, 0x0C03, 0x0983, 0x1803, 0x1D83, 0x1783, 0x1203, | ||
69 | 0x3003, 0x3583, 0x3F83, 0x3A03, 0x2B83, 0x2E03, 0x2403, 0x2183, | ||
70 | 0x6003, 0x6583, 0x6F83, 0x6A03, 0x7B83, 0x7E03, 0x7403, 0x7183, | ||
71 | 0x5383, 0x5603, 0x5C03, 0x5983, 0x4803, 0x4D83, 0x4783, 0x4203, | ||
72 | 0xC003, 0xC583, 0xCF83, 0xCA03, 0xDB83, 0xDE03, 0xD403, 0xD183, | ||
73 | 0xF383, 0xF603, 0xFC03, 0xF983, 0xE803, 0xED83, 0xE783, 0xE203, | ||
74 | 0xA383, 0xA603, 0xAC03, 0xA983, 0xB803, 0xBD83, 0xB783, 0xB203, | ||
75 | 0x9003, 0x9583, 0x9F83, 0x9A03, 0x8B83, 0x8E03, 0x8403, 0x8183, | ||
76 | 0x8002, 0x8582, 0x8F82, 0x8A02, 0x9B82, 0x9E02, 0x9402, 0x9182, | ||
77 | 0xB382, 0xB602, 0xBC02, 0xB982, 0xA802, 0xAD82, 0xA782, 0xA202, | ||
78 | 0xE382, 0xE602, 0xEC02, 0xE982, 0xF802, 0xFD82, 0xF782, 0xF202, | ||
79 | 0xD002, 0xD582, 0xDF82, 0xDA02, 0xCB82, 0xCE02, 0xC402, 0xC182, | ||
80 | 0x4382, 0x4602, 0x4C02, 0x4982, 0x5802, 0x5D82, 0x5782, 0x5202, | ||
81 | 0x7002, 0x7582, 0x7F82, 0x7A02, 0x6B82, 0x6E02, 0x6402, 0x6182, | ||
82 | 0x2002, 0x2582, 0x2F82, 0x2A02, 0x3B82, 0x3E02, 0x3402, 0x3182, | ||
83 | 0x1382, 0x1602, 0x1C02, 0x1982, 0x0802, 0x0D82, 0x0782, 0x0202, | ||
84 | 0x0001 | ||
85 | }, | ||
86 | [AV_CRC_16_CCITT] = { | ||
87 | 0x0000, 0x2110, 0x4220, 0x6330, 0x8440, 0xA550, 0xC660, 0xE770, | ||
88 | 0x0881, 0x2991, 0x4AA1, 0x6BB1, 0x8CC1, 0xADD1, 0xCEE1, 0xEFF1, | ||
89 | 0x3112, 0x1002, 0x7332, 0x5222, 0xB552, 0x9442, 0xF772, 0xD662, | ||
90 | 0x3993, 0x1883, 0x7BB3, 0x5AA3, 0xBDD3, 0x9CC3, 0xFFF3, 0xDEE3, | ||
91 | 0x6224, 0x4334, 0x2004, 0x0114, 0xE664, 0xC774, 0xA444, 0x8554, | ||
92 | 0x6AA5, 0x4BB5, 0x2885, 0x0995, 0xEEE5, 0xCFF5, 0xACC5, 0x8DD5, | ||
93 | 0x5336, 0x7226, 0x1116, 0x3006, 0xD776, 0xF666, 0x9556, 0xB446, | ||
94 | 0x5BB7, 0x7AA7, 0x1997, 0x3887, 0xDFF7, 0xFEE7, 0x9DD7, 0xBCC7, | ||
95 | 0xC448, 0xE558, 0x8668, 0xA778, 0x4008, 0x6118, 0x0228, 0x2338, | ||
96 | 0xCCC9, 0xEDD9, 0x8EE9, 0xAFF9, 0x4889, 0x6999, 0x0AA9, 0x2BB9, | ||
97 | 0xF55A, 0xD44A, 0xB77A, 0x966A, 0x711A, 0x500A, 0x333A, 0x122A, | ||
98 | 0xFDDB, 0xDCCB, 0xBFFB, 0x9EEB, 0x799B, 0x588B, 0x3BBB, 0x1AAB, | ||
99 | 0xA66C, 0x877C, 0xE44C, 0xC55C, 0x222C, 0x033C, 0x600C, 0x411C, | ||
100 | 0xAEED, 0x8FFD, 0xECCD, 0xCDDD, 0x2AAD, 0x0BBD, 0x688D, 0x499D, | ||
101 | 0x977E, 0xB66E, 0xD55E, 0xF44E, 0x133E, 0x322E, 0x511E, 0x700E, | ||
102 | 0x9FFF, 0xBEEF, 0xDDDF, 0xFCCF, 0x1BBF, 0x3AAF, 0x599F, 0x788F, | ||
103 | 0x8891, 0xA981, 0xCAB1, 0xEBA1, 0x0CD1, 0x2DC1, 0x4EF1, 0x6FE1, | ||
104 | 0x8010, 0xA100, 0xC230, 0xE320, 0x0450, 0x2540, 0x4670, 0x6760, | ||
105 | 0xB983, 0x9893, 0xFBA3, 0xDAB3, 0x3DC3, 0x1CD3, 0x7FE3, 0x5EF3, | ||
106 | 0xB102, 0x9012, 0xF322, 0xD232, 0x3542, 0x1452, 0x7762, 0x5672, | ||
107 | 0xEAB5, 0xCBA5, 0xA895, 0x8985, 0x6EF5, 0x4FE5, 0x2CD5, 0x0DC5, | ||
108 | 0xE234, 0xC324, 0xA014, 0x8104, 0x6674, 0x4764, 0x2454, 0x0544, | ||
109 | 0xDBA7, 0xFAB7, 0x9987, 0xB897, 0x5FE7, 0x7EF7, 0x1DC7, 0x3CD7, | ||
110 | 0xD326, 0xF236, 0x9106, 0xB016, 0x5766, 0x7676, 0x1546, 0x3456, | ||
111 | 0x4CD9, 0x6DC9, 0x0EF9, 0x2FE9, 0xC899, 0xE989, 0x8AB9, 0xABA9, | ||
112 | 0x4458, 0x6548, 0x0678, 0x2768, 0xC018, 0xE108, 0x8238, 0xA328, | ||
113 | 0x7DCB, 0x5CDB, 0x3FEB, 0x1EFB, 0xF98B, 0xD89B, 0xBBAB, 0x9ABB, | ||
114 | 0x754A, 0x545A, 0x376A, 0x167A, 0xF10A, 0xD01A, 0xB32A, 0x923A, | ||
115 | 0x2EFD, 0x0FED, 0x6CDD, 0x4DCD, 0xAABD, 0x8BAD, 0xE89D, 0xC98D, | ||
116 | 0x267C, 0x076C, 0x645C, 0x454C, 0xA23C, 0x832C, 0xE01C, 0xC10C, | ||
117 | 0x1FEF, 0x3EFF, 0x5DCF, 0x7CDF, 0x9BAF, 0xBABF, 0xD98F, 0xF89F, | ||
118 | 0x176E, 0x367E, 0x554E, 0x745E, 0x932E, 0xB23E, 0xD10E, 0xF01E, | ||
119 | 0x0001 | ||
120 | }, | ||
121 | [AV_CRC_32_IEEE] = { | ||
122 | 0x00000000, 0xB71DC104, 0x6E3B8209, 0xD926430D, 0xDC760413, 0x6B6BC517, | ||
123 | 0xB24D861A, 0x0550471E, 0xB8ED0826, 0x0FF0C922, 0xD6D68A2F, 0x61CB4B2B, | ||
124 | 0x649B0C35, 0xD386CD31, 0x0AA08E3C, 0xBDBD4F38, 0x70DB114C, 0xC7C6D048, | ||
125 | 0x1EE09345, 0xA9FD5241, 0xACAD155F, 0x1BB0D45B, 0xC2969756, 0x758B5652, | ||
126 | 0xC836196A, 0x7F2BD86E, 0xA60D9B63, 0x11105A67, 0x14401D79, 0xA35DDC7D, | ||
127 | 0x7A7B9F70, 0xCD665E74, 0xE0B62398, 0x57ABE29C, 0x8E8DA191, 0x39906095, | ||
128 | 0x3CC0278B, 0x8BDDE68F, 0x52FBA582, 0xE5E66486, 0x585B2BBE, 0xEF46EABA, | ||
129 | 0x3660A9B7, 0x817D68B3, 0x842D2FAD, 0x3330EEA9, 0xEA16ADA4, 0x5D0B6CA0, | ||
130 | 0x906D32D4, 0x2770F3D0, 0xFE56B0DD, 0x494B71D9, 0x4C1B36C7, 0xFB06F7C3, | ||
131 | 0x2220B4CE, 0x953D75CA, 0x28803AF2, 0x9F9DFBF6, 0x46BBB8FB, 0xF1A679FF, | ||
132 | 0xF4F63EE1, 0x43EBFFE5, 0x9ACDBCE8, 0x2DD07DEC, 0x77708634, 0xC06D4730, | ||
133 | 0x194B043D, 0xAE56C539, 0xAB068227, 0x1C1B4323, 0xC53D002E, 0x7220C12A, | ||
134 | 0xCF9D8E12, 0x78804F16, 0xA1A60C1B, 0x16BBCD1F, 0x13EB8A01, 0xA4F64B05, | ||
135 | 0x7DD00808, 0xCACDC90C, 0x07AB9778, 0xB0B6567C, 0x69901571, 0xDE8DD475, | ||
136 | 0xDBDD936B, 0x6CC0526F, 0xB5E61162, 0x02FBD066, 0xBF469F5E, 0x085B5E5A, | ||
137 | 0xD17D1D57, 0x6660DC53, 0x63309B4D, 0xD42D5A49, 0x0D0B1944, 0xBA16D840, | ||
138 | 0x97C6A5AC, 0x20DB64A8, 0xF9FD27A5, 0x4EE0E6A1, 0x4BB0A1BF, 0xFCAD60BB, | ||
139 | 0x258B23B6, 0x9296E2B2, 0x2F2BAD8A, 0x98366C8E, 0x41102F83, 0xF60DEE87, | ||
140 | 0xF35DA999, 0x4440689D, 0x9D662B90, 0x2A7BEA94, 0xE71DB4E0, 0x500075E4, | ||
141 | 0x892636E9, 0x3E3BF7ED, 0x3B6BB0F3, 0x8C7671F7, 0x555032FA, 0xE24DF3FE, | ||
142 | 0x5FF0BCC6, 0xE8ED7DC2, 0x31CB3ECF, 0x86D6FFCB, 0x8386B8D5, 0x349B79D1, | ||
143 | 0xEDBD3ADC, 0x5AA0FBD8, 0xEEE00C69, 0x59FDCD6D, 0x80DB8E60, 0x37C64F64, | ||
144 | 0x3296087A, 0x858BC97E, 0x5CAD8A73, 0xEBB04B77, 0x560D044F, 0xE110C54B, | ||
145 | 0x38368646, 0x8F2B4742, 0x8A7B005C, 0x3D66C158, 0xE4408255, 0x535D4351, | ||
146 | 0x9E3B1D25, 0x2926DC21, 0xF0009F2C, 0x471D5E28, 0x424D1936, 0xF550D832, | ||
147 | 0x2C769B3F, 0x9B6B5A3B, 0x26D61503, 0x91CBD407, 0x48ED970A, 0xFFF0560E, | ||
148 | 0xFAA01110, 0x4DBDD014, 0x949B9319, 0x2386521D, 0x0E562FF1, 0xB94BEEF5, | ||
149 | 0x606DADF8, 0xD7706CFC, 0xD2202BE2, 0x653DEAE6, 0xBC1BA9EB, 0x0B0668EF, | ||
150 | 0xB6BB27D7, 0x01A6E6D3, 0xD880A5DE, 0x6F9D64DA, 0x6ACD23C4, 0xDDD0E2C0, | ||
151 | 0x04F6A1CD, 0xB3EB60C9, 0x7E8D3EBD, 0xC990FFB9, 0x10B6BCB4, 0xA7AB7DB0, | ||
152 | 0xA2FB3AAE, 0x15E6FBAA, 0xCCC0B8A7, 0x7BDD79A3, 0xC660369B, 0x717DF79F, | ||
153 | 0xA85BB492, 0x1F467596, 0x1A163288, 0xAD0BF38C, 0x742DB081, 0xC3307185, | ||
154 | 0x99908A5D, 0x2E8D4B59, 0xF7AB0854, 0x40B6C950, 0x45E68E4E, 0xF2FB4F4A, | ||
155 | 0x2BDD0C47, 0x9CC0CD43, 0x217D827B, 0x9660437F, 0x4F460072, 0xF85BC176, | ||
156 | 0xFD0B8668, 0x4A16476C, 0x93300461, 0x242DC565, 0xE94B9B11, 0x5E565A15, | ||
157 | 0x87701918, 0x306DD81C, 0x353D9F02, 0x82205E06, 0x5B061D0B, 0xEC1BDC0F, | ||
158 | 0x51A69337, 0xE6BB5233, 0x3F9D113E, 0x8880D03A, 0x8DD09724, 0x3ACD5620, | ||
159 | 0xE3EB152D, 0x54F6D429, 0x7926A9C5, 0xCE3B68C1, 0x171D2BCC, 0xA000EAC8, | ||
160 | 0xA550ADD6, 0x124D6CD2, 0xCB6B2FDF, 0x7C76EEDB, 0xC1CBA1E3, 0x76D660E7, | ||
161 | 0xAFF023EA, 0x18EDE2EE, 0x1DBDA5F0, 0xAAA064F4, 0x738627F9, 0xC49BE6FD, | ||
162 | 0x09FDB889, 0xBEE0798D, 0x67C63A80, 0xD0DBFB84, 0xD58BBC9A, 0x62967D9E, | ||
163 | 0xBBB03E93, 0x0CADFF97, 0xB110B0AF, 0x060D71AB, 0xDF2B32A6, 0x6836F3A2, | ||
164 | 0x6D66B4BC, 0xDA7B75B8, 0x035D36B5, 0xB440F7B1, 0x00000001 | ||
165 | }, | ||
166 | [AV_CRC_32_IEEE_LE] = { | ||
167 | 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, | ||
168 | 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, | ||
169 | 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, | ||
170 | 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, | ||
171 | 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, | ||
172 | 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, | ||
173 | 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, | ||
174 | 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, | ||
175 | 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, | ||
176 | 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, | ||
177 | 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, | ||
178 | 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, | ||
179 | 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, | ||
180 | 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, | ||
181 | 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, | ||
182 | 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, | ||
183 | 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, | ||
184 | 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, | ||
185 | 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, | ||
186 | 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, | ||
187 | 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, | ||
188 | 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, | ||
189 | 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, | ||
190 | 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, | ||
191 | 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, | ||
192 | 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, | ||
193 | 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, | ||
194 | 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, | ||
195 | 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, | ||
196 | 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, | ||
197 | 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, | ||
198 | 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, | ||
199 | 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, | ||
200 | 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, | ||
201 | 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, | ||
202 | 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, | ||
203 | 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, | ||
204 | 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, | ||
205 | 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, | ||
206 | 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, | ||
207 | 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, | ||
208 | 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, | ||
209 | 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D, 0x00000001 | ||
210 | }, | ||
211 | }; | ||
212 | |||
213 | #endif /* FFMPEG_CRC_DATA_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/des.c b/src/plugins/ffmpeg/libavutil/des.c deleted file mode 100644 index 43a14f6..0000000 --- a/src/plugins/ffmpeg/libavutil/des.c +++ /dev/null | |||
@@ -1,334 +0,0 @@ | |||
1 | /* | ||
2 | * DES encryption/decryption | ||
3 | * Copyright (c) 2007 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 | #include <inttypes.h> | ||
22 | #include "common.h" | ||
23 | #include "des.h" | ||
24 | |||
25 | #define T(a, b, c, d, e, f, g, h) 64-a,64-b,64-c,64-d,64-e,64-f,64-g,64-h | ||
26 | static const uint8_t IP_shuffle[] = { | ||
27 | T(58, 50, 42, 34, 26, 18, 10, 2), | ||
28 | T(60, 52, 44, 36, 28, 20, 12, 4), | ||
29 | T(62, 54, 46, 38, 30, 22, 14, 6), | ||
30 | T(64, 56, 48, 40, 32, 24, 16, 8), | ||
31 | T(57, 49, 41, 33, 25, 17, 9, 1), | ||
32 | T(59, 51, 43, 35, 27, 19, 11, 3), | ||
33 | T(61, 53, 45, 37, 29, 21, 13, 5), | ||
34 | T(63, 55, 47, 39, 31, 23, 15, 7) | ||
35 | }; | ||
36 | #undef T | ||
37 | |||
38 | #define T(a, b, c, d) 32-a,32-b,32-c,32-d | ||
39 | static const uint8_t P_shuffle[] = { | ||
40 | T(16, 7, 20, 21), | ||
41 | T(29, 12, 28, 17), | ||
42 | T( 1, 15, 23, 26), | ||
43 | T( 5, 18, 31, 10), | ||
44 | T( 2, 8, 24, 14), | ||
45 | T(32, 27, 3, 9), | ||
46 | T(19, 13, 30, 6), | ||
47 | T(22, 11, 4, 25) | ||
48 | }; | ||
49 | #undef T | ||
50 | |||
51 | #define T(a, b, c, d, e, f, g) 64-a,64-b,64-c,64-d,64-e,64-f,64-g | ||
52 | static const uint8_t PC1_shuffle[] = { | ||
53 | T(57, 49, 41, 33, 25, 17, 9), | ||
54 | T( 1, 58, 50, 42, 34, 26, 18), | ||
55 | T(10, 2, 59, 51, 43, 35, 27), | ||
56 | T(19, 11, 3, 60, 52, 44, 36), | ||
57 | T(63, 55, 47, 39, 31, 23, 15), | ||
58 | T( 7, 62, 54, 46, 38, 30, 22), | ||
59 | T(14, 6, 61, 53, 45, 37, 29), | ||
60 | T(21, 13, 5, 28, 20, 12, 4) | ||
61 | }; | ||
62 | #undef T | ||
63 | |||
64 | #define T(a, b, c, d, e, f) 56-a,56-b,56-c,56-d,56-e,56-f | ||
65 | static const uint8_t PC2_shuffle[] = { | ||
66 | T(14, 17, 11, 24, 1, 5), | ||
67 | T( 3, 28, 15, 6, 21, 10), | ||
68 | T(23, 19, 12, 4, 26, 8), | ||
69 | T(16, 7, 27, 20, 13, 2), | ||
70 | T(41, 52, 31, 37, 47, 55), | ||
71 | T(30, 40, 51, 45, 33, 48), | ||
72 | T(44, 49, 39, 56, 34, 53), | ||
73 | T(46, 42, 50, 36, 29, 32) | ||
74 | }; | ||
75 | #undef T | ||
76 | |||
77 | #ifdef CONFIG_SMALL | ||
78 | static const uint8_t S_boxes[8][32] = { | ||
79 | { | ||
80 | 0x0e, 0xf4, 0x7d, 0x41, 0xe2, 0x2f, 0xdb, 0x18, 0xa3, 0x6a, 0xc6, 0xbc, 0x95, 0x59, 0x30, 0x87, | ||
81 | 0xf4, 0xc1, 0x8e, 0x28, 0x4d, 0x96, 0x12, 0x7b, 0x5f, 0xbc, 0x39, 0xe7, 0xa3, 0x0a, 0x65, 0xd0, | ||
82 | }, { | ||
83 | 0x3f, 0xd1, 0x48, 0x7e, 0xf6, 0x2b, 0x83, 0xe4, 0xc9, 0x07, 0x12, 0xad, 0x6c, 0x90, 0xb5, 0x5a, | ||
84 | 0xd0, 0x8e, 0xa7, 0x1b, 0x3a, 0xf4, 0x4d, 0x21, 0xb5, 0x68, 0x7c, 0xc6, 0x09, 0x53, 0xe2, 0x9f, | ||
85 | }, { | ||
86 | 0xda, 0x70, 0x09, 0x9e, 0x36, 0x43, 0x6f, 0xa5, 0x21, 0x8d, 0x5c, 0xe7, 0xcb, 0xb4, 0xf2, 0x18, | ||
87 | 0x1d, 0xa6, 0xd4, 0x09, 0x68, 0x9f, 0x83, 0x70, 0x4b, 0xf1, 0xe2, 0x3c, 0xb5, 0x5a, 0x2e, 0xc7, | ||
88 | }, { | ||
89 | 0xd7, 0x8d, 0xbe, 0x53, 0x60, 0xf6, 0x09, 0x3a, 0x41, 0x72, 0x28, 0xc5, 0x1b, 0xac, 0xe4, 0x9f, | ||
90 | 0x3a, 0xf6, 0x09, 0x60, 0xac, 0x1b, 0xd7, 0x8d, 0x9f, 0x41, 0x53, 0xbe, 0xc5, 0x72, 0x28, 0xe4, | ||
91 | }, { | ||
92 | 0xe2, 0xbc, 0x24, 0xc1, 0x47, 0x7a, 0xdb, 0x16, 0x58, 0x05, 0xf3, 0xaf, 0x3d, 0x90, 0x8e, 0x69, | ||
93 | 0xb4, 0x82, 0xc1, 0x7b, 0x1a, 0xed, 0x27, 0xd8, 0x6f, 0xf9, 0x0c, 0x95, 0xa6, 0x43, 0x50, 0x3e, | ||
94 | }, { | ||
95 | 0xac, 0xf1, 0x4a, 0x2f, 0x79, 0xc2, 0x96, 0x58, 0x60, 0x1d, 0xd3, 0xe4, 0x0e, 0xb7, 0x35, 0x8b, | ||
96 | 0x49, 0x3e, 0x2f, 0xc5, 0x92, 0x58, 0xfc, 0xa3, 0xb7, 0xe0, 0x14, 0x7a, 0x61, 0x0d, 0x8b, 0xd6, | ||
97 | }, { | ||
98 | 0xd4, 0x0b, 0xb2, 0x7e, 0x4f, 0x90, 0x18, 0xad, 0xe3, 0x3c, 0x59, 0xc7, 0x25, 0xfa, 0x86, 0x61, | ||
99 | 0x61, 0xb4, 0xdb, 0x8d, 0x1c, 0x43, 0xa7, 0x7e, 0x9a, 0x5f, 0x06, 0xf8, 0xe0, 0x25, 0x39, 0xc2, | ||
100 | }, { | ||
101 | 0x1d, 0xf2, 0xd8, 0x84, 0xa6, 0x3f, 0x7b, 0x41, 0xca, 0x59, 0x63, 0xbe, 0x05, 0xe0, 0x9c, 0x27, | ||
102 | 0x27, 0x1b, 0xe4, 0x71, 0x49, 0xac, 0x8e, 0xd2, 0xf0, 0xc6, 0x9a, 0x0d, 0x3f, 0x53, 0x65, 0xb8, | ||
103 | } | ||
104 | }; | ||
105 | #else | ||
106 | /** | ||
107 | * This table contains the results of applying both the S-box and P-shuffle. | ||
108 | * It can be regenerated by compiling this file with -DCONFIG_SMALL -DTEST -DGENTABLES | ||
109 | */ | ||
110 | static const uint32_t S_boxes_P_shuffle[8][64] = { | ||
111 | { | ||
112 | 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000, | ||
113 | 0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002, | ||
114 | 0x00000202, 0x00800200, 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202, | ||
115 | 0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, 0x00008202, 0x00800000, | ||
116 | 0x00008000, 0x00808202, 0x00000002, 0x00808000, 0x00808200, 0x00800000, 0x00800000, 0x00000200, | ||
117 | 0x00808002, 0x00008000, 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202, | ||
118 | 0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, 0x00008202, 0x00808200, | ||
119 | 0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002, | ||
120 | }, | ||
121 | { | ||
122 | 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010, | ||
123 | 0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010, | ||
124 | 0x00084000, 0x00080010, 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000, | ||
125 | 0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, 0x40080000, 0x00004010, | ||
126 | 0x00000000, 0x00084010, 0x40080010, 0x00080000, 0x40004010, 0x40080000, 0x40084000, 0x00004000, | ||
127 | 0x40080000, 0x40004000, 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000, | ||
128 | 0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, 0x40000010, 0x00080010, | ||
129 | 0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000, | ||
130 | }, | ||
131 | { | ||
132 | 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100, | ||
133 | 0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104, | ||
134 | 0x04000000, 0x00000004, 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104, | ||
135 | 0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, 0x00000100, 0x04000000, | ||
136 | 0x04010100, 0x04000000, 0x00010004, 0x00000104, 0x00010000, 0x04010100, 0x04000100, 0x00000000, | ||
137 | 0x00000100, 0x00010004, 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004, | ||
138 | 0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, 0x00010100, 0x04000004, | ||
139 | 0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100, | ||
140 | }, | ||
141 | { | ||
142 | 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000, | ||
143 | 0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000, | ||
144 | 0x80000000, 0x00001000, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040, | ||
145 | 0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, 0x80401040, 0x80000040, | ||
146 | 0x00400040, 0x80400000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00000000, 0x00401000, | ||
147 | 0x00001040, 0x00400040, 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040, | ||
148 | 0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, 0x00401040, 0x80400040, | ||
149 | 0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040, | ||
150 | }, | ||
151 | { | ||
152 | 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000, | ||
153 | 0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000, | ||
154 | 0x01000000, 0x20040000, 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080, | ||
155 | 0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, 0x21000000, 0x00040080, | ||
156 | 0x00040000, 0x21000080, 0x00000080, 0x01000000, 0x20000000, 0x01040000, 0x21000080, 0x20040080, | ||
157 | 0x01000080, 0x20000000, 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000, | ||
158 | 0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, 0x20040000, 0x21000000, | ||
159 | 0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080, | ||
160 | }, | ||
161 | { | ||
162 | 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000, | ||
163 | 0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008, | ||
164 | 0x00000000, 0x00200008, 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008, | ||
165 | 0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, 0x10202000, 0x10000000, | ||
166 | 0x10002000, 0x00000008, 0x10200008, 0x00202000, 0x10202008, 0x00200000, 0x00002008, 0x10000008, | ||
167 | 0x00200000, 0x10002000, 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000, | ||
168 | 0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, 0x10200000, 0x00202008, | ||
169 | 0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008, | ||
170 | }, | ||
171 | { | ||
172 | 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400, | ||
173 | 0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401, | ||
174 | 0x02000400, 0x00100401, 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001, | ||
175 | 0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, 0x02000000, 0x00100400, | ||
176 | 0x02000000, 0x00100400, 0x00100000, 0x02000401, 0x02000401, 0x02100001, 0x02100001, 0x00000001, | ||
177 | 0x00100001, 0x02000000, 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400, | ||
178 | 0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, 0x00000001, 0x02100401, | ||
179 | 0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001, | ||
180 | }, | ||
181 | { | ||
182 | 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000, | ||
183 | 0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020, | ||
184 | 0x08020000, 0x08000020, 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800, | ||
185 | 0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, 0x00020820, 0x00020000, | ||
186 | 0x00020820, 0x00020000, 0x08020800, 0x00000800, 0x00000020, 0x08020020, 0x00000800, 0x00020820, | ||
187 | 0x08000800, 0x00000020, 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820, | ||
188 | 0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, 0x08000820, 0x00000000, | ||
189 | 0x08020820, 0x00020800, 0x00020800, 0x00000820, 0x00000820, 0x00020020, 0x08000000, 0x08020800, | ||
190 | }, | ||
191 | }; | ||
192 | #endif | ||
193 | |||
194 | static uint64_t shuffle(uint64_t in, const uint8_t *shuffle, int shuffle_len) { | ||
195 | int i; | ||
196 | uint64_t res = 0; | ||
197 | for (i = 0; i < shuffle_len; i++) | ||
198 | res += res + ((in >> *shuffle++) & 1); | ||
199 | return res; | ||
200 | } | ||
201 | |||
202 | static uint64_t shuffle_inv(uint64_t in, const uint8_t *shuffle, int shuffle_len) { | ||
203 | int i; | ||
204 | uint64_t res = 0; | ||
205 | shuffle += shuffle_len - 1; | ||
206 | for (i = 0; i < shuffle_len; i++) { | ||
207 | res |= (in & 1) << *shuffle--; | ||
208 | in >>= 1; | ||
209 | } | ||
210 | return res; | ||
211 | } | ||
212 | |||
213 | static uint32_t f_func(uint32_t r, uint64_t k) { | ||
214 | int i; | ||
215 | uint32_t out = 0; | ||
216 | // rotate to get first part of E-shuffle in the lowest 6 bits | ||
217 | r = (r << 1) | (r >> 31); | ||
218 | // apply S-boxes, those compress the data again from 8 * 6 to 8 * 4 bits | ||
219 | for (i = 7; i >= 0; i--) { | ||
220 | uint8_t tmp = (r ^ k) & 0x3f; | ||
221 | #ifdef CONFIG_SMALL | ||
222 | uint8_t v = S_boxes[i][tmp >> 1]; | ||
223 | if (tmp & 1) v >>= 4; | ||
224 | out = (out >> 4) | (v << 28); | ||
225 | #else | ||
226 | out |= S_boxes_P_shuffle[i][tmp]; | ||
227 | #endif | ||
228 | // get next 6 bits of E-shuffle and round key k into the lowest bits | ||
229 | r = (r >> 4) | (r << 28); | ||
230 | k >>= 6; | ||
231 | } | ||
232 | #ifdef CONFIG_SMALL | ||
233 | out = shuffle(out, P_shuffle, sizeof(P_shuffle)); | ||
234 | #endif | ||
235 | return out; | ||
236 | } | ||
237 | |||
238 | /** | ||
239 | * \brief rotate the two halves of the expanded 56 bit key each 1 bit left | ||
240 | * | ||
241 | * Note: the specification calls this "shift", so I kept it although | ||
242 | * it is confusing. | ||
243 | */ | ||
244 | static uint64_t key_shift_left(uint64_t CDn) { | ||
245 | uint64_t carries = (CDn >> 27) & 0x10000001; | ||
246 | CDn <<= 1; | ||
247 | CDn &= ~0x10000001; | ||
248 | CDn |= carries; | ||
249 | return CDn; | ||
250 | } | ||
251 | |||
252 | uint64_t ff_des_encdec(uint64_t in, uint64_t key, int decrypt) { | ||
253 | int i; | ||
254 | uint64_t K[16]; | ||
255 | // discard parity bits from key and shuffle it into C and D parts | ||
256 | uint64_t CDn = shuffle(key, PC1_shuffle, sizeof(PC1_shuffle)); | ||
257 | // generate round keys | ||
258 | for (i = 0; i < 16; i++) { | ||
259 | CDn = key_shift_left(CDn); | ||
260 | if (i > 1 && i != 8 && i != 15) | ||
261 | CDn = key_shift_left(CDn); | ||
262 | K[i] = shuffle(CDn, PC2_shuffle, sizeof(PC2_shuffle)); | ||
263 | } | ||
264 | // used to apply round keys in reverse order for decryption | ||
265 | decrypt = decrypt ? 15 : 0; | ||
266 | // shuffle irrelevant to security but to ease hardware implementations | ||
267 | in = shuffle(in, IP_shuffle, sizeof(IP_shuffle)); | ||
268 | for (i = 0; i < 16; i++) { | ||
269 | uint32_t f_res; | ||
270 | f_res = f_func(in, K[decrypt ^ i]); | ||
271 | in = (in << 32) | (in >> 32); | ||
272 | in ^= f_res; | ||
273 | } | ||
274 | in = (in << 32) | (in >> 32); | ||
275 | // reverse shuffle used to ease hardware implementations | ||
276 | in = shuffle_inv(in, IP_shuffle, sizeof(IP_shuffle)); | ||
277 | return in; | ||
278 | } | ||
279 | |||
280 | #ifdef TEST | ||
281 | #undef printf | ||
282 | #undef rand | ||
283 | #undef srand | ||
284 | #include <stdlib.h> | ||
285 | #include <stdio.h> | ||
286 | #include <sys/time.h> | ||
287 | static uint64_t rand64(void) { | ||
288 | uint64_t r = rand(); | ||
289 | r = (r << 32) | rand(); | ||
290 | return r; | ||
291 | } | ||
292 | |||
293 | int main(void) { | ||
294 | int i, j; | ||
295 | struct timeval tv; | ||
296 | uint64_t key; | ||
297 | uint64_t data; | ||
298 | uint64_t ct; | ||
299 | gettimeofday(&tv, NULL); | ||
300 | srand(tv.tv_sec * 1000 * 1000 + tv.tv_usec); | ||
301 | key = 0x123456789abcdef0ULL; | ||
302 | data = 0xfedcba9876543210ULL; | ||
303 | if (ff_des_encdec(data, key, 0) != 0x4ab65b3d4b061518ULL) { | ||
304 | printf("Test 1 failed\n"); | ||
305 | return 1; | ||
306 | } | ||
307 | for (i = 0; i < 1000000; i++) { | ||
308 | key = rand64(); | ||
309 | data = rand64(); | ||
310 | ct = ff_des_encdec(data, key, 0); | ||
311 | if (ff_des_encdec(ct, key, 1) != data) { | ||
312 | printf("Test 2 failed\n"); | ||
313 | return 1; | ||
314 | } | ||
315 | } | ||
316 | #ifdef GENTABLES | ||
317 | printf("static const uint32_t S_boxes_P_shuffle[8][64] = {\n"); | ||
318 | for (i = 0; i < 8; i++) { | ||
319 | printf(" {"); | ||
320 | for (j = 0; j < 64; j++) { | ||
321 | uint32_t v = S_boxes[i][j >> 1]; | ||
322 | v = j & 1 ? v >> 4 : v & 0xf; | ||
323 | v <<= 28 - 4 * i; | ||
324 | v = shuffle(v, P_shuffle, sizeof(P_shuffle)); | ||
325 | printf((j & 7) == 0 ? "\n " : " "); | ||
326 | printf("0x%08X,", v); | ||
327 | } | ||
328 | printf("\n },\n"); | ||
329 | } | ||
330 | printf("};\n"); | ||
331 | #endif | ||
332 | return 0; | ||
333 | } | ||
334 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/des.h b/src/plugins/ffmpeg/libavutil/des.h deleted file mode 100644 index 40d8aa1..0000000 --- a/src/plugins/ffmpeg/libavutil/des.h +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | /* | ||
2 | * DES encryption/decryption | ||
3 | * Copyright (c) 2007 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 FFMPEG_DES_H | ||
23 | #define FFMPEG_DES_H | ||
24 | |||
25 | #include <stdint.h> | ||
26 | #include "common.h" | ||
27 | |||
28 | /** | ||
29 | * \brief en- or decrypt an 64-bit block of data with DES | ||
30 | * \param in data to process. | ||
31 | * \param key key to use for en-/decryption. | ||
32 | * \param decrypt if 0 encrypt, else decrypt. | ||
33 | * \return processed data | ||
34 | * | ||
35 | * If your input data is in 8-bit blocks treat it as big-endian | ||
36 | * (use e.g. AV_RB64 and AV_WB64). | ||
37 | */ | ||
38 | uint64_t ff_des_encdec(uint64_t in, uint64_t key, int decrypt) av_const; | ||
39 | |||
40 | #endif /* FFMPEG_DES_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/fifo.c b/src/plugins/ffmpeg/libavutil/fifo.c deleted file mode 100644 index ed56f6c..0000000 --- a/src/plugins/ffmpeg/libavutil/fifo.c +++ /dev/null | |||
@@ -1,119 +0,0 @@ | |||
1 | /* | ||
2 | * A very simple circular buffer FIFO implementation | ||
3 | * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | ||
4 | * Copyright (c) 2006 Roman Shaposhnik | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | #include "common.h" | ||
23 | #include "fifo.h" | ||
24 | |||
25 | int av_fifo_init(AVFifoBuffer *f, unsigned int size) | ||
26 | { | ||
27 | size= FFMAX(size, size+1); | ||
28 | f->wptr = f->rptr = | ||
29 | f->buffer = av_malloc(size); | ||
30 | f->end = f->buffer + size; | ||
31 | if (!f->buffer) | ||
32 | return -1; | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | void av_fifo_free(AVFifoBuffer *f) | ||
37 | { | ||
38 | av_free(f->buffer); | ||
39 | } | ||
40 | |||
41 | int av_fifo_size(AVFifoBuffer *f) | ||
42 | { | ||
43 | int size = f->wptr - f->rptr; | ||
44 | if (size < 0) | ||
45 | size += f->end - f->buffer; | ||
46 | return size; | ||
47 | } | ||
48 | |||
49 | int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size) | ||
50 | { | ||
51 | return av_fifo_generic_read(f, buf_size, NULL, buf); | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * Resizes a FIFO. | ||
56 | */ | ||
57 | void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) { | ||
58 | unsigned int old_size= f->end - f->buffer; | ||
59 | |||
60 | if(old_size <= new_size){ | ||
61 | int len= av_fifo_size(f); | ||
62 | AVFifoBuffer f2; | ||
63 | |||
64 | av_fifo_init(&f2, new_size); | ||
65 | av_fifo_read(f, f2.buffer, len); | ||
66 | f2.wptr += len; | ||
67 | av_free(f->buffer); | ||
68 | *f= f2; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size) | ||
73 | { | ||
74 | av_fifo_generic_write(f, buf, size, NULL); | ||
75 | } | ||
76 | |||
77 | int av_fifo_generic_write(AVFifoBuffer *f, const void *src, int size, int (*func)(const void*, void*, int)) | ||
78 | { | ||
79 | int total = size; | ||
80 | do { | ||
81 | int len = FFMIN(f->end - f->wptr, size); | ||
82 | if(func) { | ||
83 | if(func(src, f->wptr, len) <= 0) | ||
84 | break; | ||
85 | } else { | ||
86 | memcpy(f->wptr, src, len); | ||
87 | src = (const uint8_t*)src + len; | ||
88 | } | ||
89 | f->wptr += len; | ||
90 | if (f->wptr >= f->end) | ||
91 | f->wptr = f->buffer; | ||
92 | size -= len; | ||
93 | } while (size > 0); | ||
94 | return total - size; | ||
95 | } | ||
96 | |||
97 | |||
98 | int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest) | ||
99 | { | ||
100 | do { | ||
101 | int len = FFMIN(f->end - f->rptr, buf_size); | ||
102 | if(func) func(dest, f->rptr, len); | ||
103 | else{ | ||
104 | memcpy(dest, f->rptr, len); | ||
105 | dest = (uint8_t*)dest + len; | ||
106 | } | ||
107 | av_fifo_drain(f, len); | ||
108 | buf_size -= len; | ||
109 | } while (buf_size > 0); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | /** discard data from the fifo */ | ||
114 | void av_fifo_drain(AVFifoBuffer *f, int size) | ||
115 | { | ||
116 | f->rptr += size; | ||
117 | if (f->rptr >= f->end) | ||
118 | f->rptr -= f->end - f->buffer; | ||
119 | } | ||
diff --git a/src/plugins/ffmpeg/libavutil/fifo.h b/src/plugins/ffmpeg/libavutil/fifo.h deleted file mode 100644 index 3e20d72..0000000 --- a/src/plugins/ffmpeg/libavutil/fifo.h +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
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 | /** | ||
20 | * @file fifo.h | ||
21 | * A very simple circular buffer FIFO implementation. | ||
22 | */ | ||
23 | |||
24 | #ifndef FFMPEG_FIFO_H | ||
25 | #define FFMPEG_FIFO_H | ||
26 | |||
27 | #include <stdint.h> | ||
28 | #include "common.h" | ||
29 | |||
30 | typedef struct AVFifoBuffer { | ||
31 | uint8_t *buffer; | ||
32 | uint8_t *rptr, *wptr, *end; | ||
33 | } AVFifoBuffer; | ||
34 | |||
35 | /** | ||
36 | * Initializes an AVFifoBuffer. | ||
37 | * @param *f AVFifoBuffer to initialize | ||
38 | * @param size of FIFO | ||
39 | * @return <0 for failure >=0 otherwise | ||
40 | */ | ||
41 | int av_fifo_init(AVFifoBuffer *f, unsigned int size); | ||
42 | |||
43 | /** | ||
44 | * Frees an AVFifoBuffer. | ||
45 | * @param *f AVFifoBuffer to free | ||
46 | */ | ||
47 | void av_fifo_free(AVFifoBuffer *f); | ||
48 | |||
49 | /** | ||
50 | * Returns the amount of data in bytes in the AVFifoBuffer, that is the | ||
51 | * amount of data you can read from it. | ||
52 | * @param *f AVFifoBuffer to read from | ||
53 | * @return size | ||
54 | */ | ||
55 | int av_fifo_size(AVFifoBuffer *f); | ||
56 | |||
57 | /** | ||
58 | * Reads data from an AVFifoBuffer. | ||
59 | * @param *f AVFifoBuffer to read from | ||
60 | * @param *buf data destination | ||
61 | * @param buf_size number of bytes to read | ||
62 | */ | ||
63 | int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size); | ||
64 | |||
65 | /** | ||
66 | * Feeds data from an AVFifoBuffer to a user supplied callback. | ||
67 | * @param *f AVFifoBuffer to read from | ||
68 | * @param buf_size number of bytes to read | ||
69 | * @param *func generic read function | ||
70 | * @param *dest data destination | ||
71 | */ | ||
72 | int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest); | ||
73 | |||
74 | /** | ||
75 | * Writes data into an AVFifoBuffer. | ||
76 | * @param *f AVFifoBuffer to write to | ||
77 | * @param *buf data source | ||
78 | * @param size data size | ||
79 | */ | ||
80 | attribute_deprecated void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size); | ||
81 | |||
82 | /** | ||
83 | * Feeds data from a user supplied callback to an AVFifoBuffer. | ||
84 | * @param *f AVFifoBuffer to write to | ||
85 | * @param *src data source | ||
86 | * @param size number of bytes to write | ||
87 | * @param *func generic write function. First parameter is src, | ||
88 | * second is dest_buf, third is dest_buf_size. | ||
89 | * func must return the number of bytes written to dest_buf, or <= 0 to | ||
90 | * indicate no more data available to write. | ||
91 | * If func is NULL, src is interpreted as a simple byte array for source data. | ||
92 | * @return the number of bytes written to the fifo. | ||
93 | */ | ||
94 | int av_fifo_generic_write(AVFifoBuffer *f, const void *src, int size, int (*func)(const void*, void*, int)); | ||
95 | |||
96 | /** | ||
97 | * Resizes an AVFifoBuffer. | ||
98 | * @param *f AVFifoBuffer to resize | ||
99 | * @param size new AVFifoBuffer size in bytes | ||
100 | */ | ||
101 | void av_fifo_realloc(AVFifoBuffer *f, unsigned int size); | ||
102 | |||
103 | /** | ||
104 | * Reads and discards the specified amount of data from an AVFifoBuffer. | ||
105 | * @param *f AVFifoBuffer to read from | ||
106 | * @param size amount of data to read in bytes | ||
107 | */ | ||
108 | void av_fifo_drain(AVFifoBuffer *f, int size); | ||
109 | |||
110 | static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs) | ||
111 | { | ||
112 | uint8_t *ptr = f->rptr + offs; | ||
113 | if (ptr >= f->end) | ||
114 | ptr -= f->end - f->buffer; | ||
115 | return *ptr; | ||
116 | } | ||
117 | #endif /* FFMPEG_FIFO_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/integer.c b/src/plugins/ffmpeg/libavutil/integer.c deleted file mode 100644 index 0787b19..0000000 --- a/src/plugins/ffmpeg/libavutil/integer.c +++ /dev/null | |||
@@ -1,197 +0,0 @@ | |||
1 | /* | ||
2 | * arbitrary precision integers | ||
3 | * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> | ||
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 integer.c | ||
24 | * arbitrary precision integers. | ||
25 | * @author Michael Niedermayer <michaelni@gmx.at> | ||
26 | */ | ||
27 | |||
28 | #include "common.h" | ||
29 | #include "integer.h" | ||
30 | |||
31 | AVInteger av_add_i(AVInteger a, AVInteger b){ | ||
32 | int i, carry=0; | ||
33 | |||
34 | for(i=0; i<AV_INTEGER_SIZE; i++){ | ||
35 | carry= (carry>>16) + a.v[i] + b.v[i]; | ||
36 | a.v[i]= carry; | ||
37 | } | ||
38 | return a; | ||
39 | } | ||
40 | |||
41 | AVInteger av_sub_i(AVInteger a, AVInteger b){ | ||
42 | int i, carry=0; | ||
43 | |||
44 | for(i=0; i<AV_INTEGER_SIZE; i++){ | ||
45 | carry= (carry>>16) + a.v[i] - b.v[i]; | ||
46 | a.v[i]= carry; | ||
47 | } | ||
48 | return a; | ||
49 | } | ||
50 | |||
51 | int av_log2_i(AVInteger a){ | ||
52 | int i; | ||
53 | |||
54 | for(i=AV_INTEGER_SIZE-1; i>=0; i--){ | ||
55 | if(a.v[i]) | ||
56 | return av_log2_16bit(a.v[i]) + 16*i; | ||
57 | } | ||
58 | return -1; | ||
59 | } | ||
60 | |||
61 | AVInteger av_mul_i(AVInteger a, AVInteger b){ | ||
62 | AVInteger out; | ||
63 | int i, j; | ||
64 | int na= (av_log2_i(a)+16) >> 4; | ||
65 | int nb= (av_log2_i(b)+16) >> 4; | ||
66 | |||
67 | memset(&out, 0, sizeof(out)); | ||
68 | |||
69 | for(i=0; i<na; i++){ | ||
70 | unsigned int carry=0; | ||
71 | |||
72 | if(a.v[i]) | ||
73 | for(j=i; j<AV_INTEGER_SIZE && j-i<=nb; j++){ | ||
74 | carry= (carry>>16) + out.v[j] + a.v[i]*b.v[j-i]; | ||
75 | out.v[j]= carry; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | return out; | ||
80 | } | ||
81 | |||
82 | int av_cmp_i(AVInteger a, AVInteger b){ | ||
83 | int i; | ||
84 | int v= (int16_t)a.v[AV_INTEGER_SIZE-1] - (int16_t)b.v[AV_INTEGER_SIZE-1]; | ||
85 | if(v) return (v>>16)|1; | ||
86 | |||
87 | for(i=AV_INTEGER_SIZE-2; i>=0; i--){ | ||
88 | int v= a.v[i] - b.v[i]; | ||
89 | if(v) return (v>>16)|1; | ||
90 | } | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | AVInteger av_shr_i(AVInteger a, int s){ | ||
95 | AVInteger out; | ||
96 | int i; | ||
97 | |||
98 | for(i=0; i<AV_INTEGER_SIZE; i++){ | ||
99 | unsigned int index= i + (s>>4); | ||
100 | unsigned int v=0; | ||
101 | if(index+1<AV_INTEGER_SIZE) v = a.v[index+1]<<16; | ||
102 | if(index <AV_INTEGER_SIZE) v+= a.v[index ]; | ||
103 | out.v[i]= v >> (s&15); | ||
104 | } | ||
105 | return out; | ||
106 | } | ||
107 | |||
108 | AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b){ | ||
109 | int i= av_log2_i(a) - av_log2_i(b); | ||
110 | AVInteger quot_temp; | ||
111 | if(!quot) quot = "_temp; | ||
112 | |||
113 | assert((int16_t)a[AV_INTEGER_SIZE-1] >= 0 && (int16_t)b[AV_INTEGER_SIZE-1] >= 0); | ||
114 | assert(av_log2(b)>=0); | ||
115 | |||
116 | if(i > 0) | ||
117 | b= av_shr_i(b, -i); | ||
118 | |||
119 | memset(quot, 0, sizeof(AVInteger)); | ||
120 | |||
121 | while(i-- >= 0){ | ||
122 | *quot= av_shr_i(*quot, -1); | ||
123 | if(av_cmp_i(a, b) >= 0){ | ||
124 | a= av_sub_i(a, b); | ||
125 | quot->v[0] += 1; | ||
126 | } | ||
127 | b= av_shr_i(b, 1); | ||
128 | } | ||
129 | return a; | ||
130 | } | ||
131 | |||
132 | AVInteger av_div_i(AVInteger a, AVInteger b){ | ||
133 | AVInteger quot; | ||
134 | av_mod_i(", a, b); | ||
135 | return quot; | ||
136 | } | ||
137 | |||
138 | AVInteger av_int2i(int64_t a){ | ||
139 | AVInteger out; | ||
140 | int i; | ||
141 | |||
142 | for(i=0; i<AV_INTEGER_SIZE; i++){ | ||
143 | out.v[i]= a; | ||
144 | a>>=16; | ||
145 | } | ||
146 | return out; | ||
147 | } | ||
148 | |||
149 | int64_t av_i2int(AVInteger a){ | ||
150 | int i; | ||
151 | int64_t out=(int8_t)a.v[AV_INTEGER_SIZE-1]; | ||
152 | |||
153 | for(i= AV_INTEGER_SIZE-2; i>=0; i--){ | ||
154 | out = (out<<16) + a.v[i]; | ||
155 | } | ||
156 | return out; | ||
157 | } | ||
158 | |||
159 | #ifdef TEST | ||
160 | #undef NDEBUG | ||
161 | #include <assert.h> | ||
162 | |||
163 | const uint8_t ff_log2_tab[256]={ | ||
164 | 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, | ||
165 | 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, | ||
166 | 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, | ||
167 | 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, | ||
168 | 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, | ||
169 | 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, | ||
170 | 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, | ||
171 | 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 | ||
172 | }; | ||
173 | |||
174 | int main(void){ | ||
175 | int64_t a,b; | ||
176 | |||
177 | for(a=7; a<256*256*256; a+=13215){ | ||
178 | for(b=3; b<256*256*256; b+=27118){ | ||
179 | AVInteger ai= av_int2i(a); | ||
180 | AVInteger bi= av_int2i(b); | ||
181 | |||
182 | assert(av_i2int(ai) == a); | ||
183 | assert(av_i2int(bi) == b); | ||
184 | assert(av_i2int(av_add_i(ai,bi)) == a+b); | ||
185 | assert(av_i2int(av_sub_i(ai,bi)) == a-b); | ||
186 | assert(av_i2int(av_mul_i(ai,bi)) == a*b); | ||
187 | assert(av_i2int(av_shr_i(ai, 9)) == a>>9); | ||
188 | assert(av_i2int(av_shr_i(ai,-9)) == a<<9); | ||
189 | assert(av_i2int(av_shr_i(ai, 17)) == a>>17); | ||
190 | assert(av_i2int(av_shr_i(ai,-17)) == a<<17); | ||
191 | assert(av_log2_i(ai) == av_log2(a)); | ||
192 | assert(av_i2int(av_div_i(ai,bi)) == a/b); | ||
193 | } | ||
194 | } | ||
195 | return 0; | ||
196 | } | ||
197 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/integer.h b/src/plugins/ffmpeg/libavutil/integer.h deleted file mode 100644 index b38d5ca..0000000 --- a/src/plugins/ffmpeg/libavutil/integer.h +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* | ||
2 | * arbitrary precision integers | ||
3 | * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> | ||
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 integer.h | ||
24 | * arbitrary precision integers | ||
25 | * @author Michael Niedermayer <michaelni@gmx.at> | ||
26 | */ | ||
27 | |||
28 | #ifndef FFMPEG_INTEGER_H | ||
29 | #define FFMPEG_INTEGER_H | ||
30 | |||
31 | #include <stdint.h> | ||
32 | #include "common.h" | ||
33 | |||
34 | #define AV_INTEGER_SIZE 8 | ||
35 | |||
36 | typedef struct AVInteger{ | ||
37 | uint16_t v[AV_INTEGER_SIZE]; | ||
38 | } AVInteger; | ||
39 | |||
40 | AVInteger av_add_i(AVInteger a, AVInteger b) av_const; | ||
41 | AVInteger av_sub_i(AVInteger a, AVInteger b) av_const; | ||
42 | |||
43 | /** | ||
44 | * returns the rounded down value of the logarithm of base 2 of the given AVInteger. | ||
45 | * this is simply the index of the most significant bit which is 1. Or 0 of all bits are 0 | ||
46 | */ | ||
47 | int av_log2_i(AVInteger a) av_const; | ||
48 | AVInteger av_mul_i(AVInteger a, AVInteger b) av_const; | ||
49 | |||
50 | /** | ||
51 | * returns 0 if a==b, 1 if a>b and -1 if a<b. | ||
52 | */ | ||
53 | int av_cmp_i(AVInteger a, AVInteger b) av_const; | ||
54 | |||
55 | /** | ||
56 | * bitwise shift. | ||
57 | * @param s the number of bits by which the value should be shifted right, may be negative for shifting left | ||
58 | */ | ||
59 | AVInteger av_shr_i(AVInteger a, int s) av_const; | ||
60 | |||
61 | /** | ||
62 | * returns a % b. | ||
63 | * @param quot a/b will be stored here | ||
64 | */ | ||
65 | AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b); | ||
66 | |||
67 | /** | ||
68 | * returns a/b. | ||
69 | */ | ||
70 | AVInteger av_div_i(AVInteger a, AVInteger b) av_const; | ||
71 | |||
72 | /** | ||
73 | * converts the given int64_t to an AVInteger. | ||
74 | */ | ||
75 | AVInteger av_int2i(int64_t a) av_const; | ||
76 | |||
77 | /** | ||
78 | * converts the given AVInteger to an int64_t. | ||
79 | * if the AVInteger is too large to fit into an int64_t, | ||
80 | * then only the least significant 64bit will be used | ||
81 | */ | ||
82 | int64_t av_i2int(AVInteger a) av_const; | ||
83 | |||
84 | #endif /* FFMPEG_INTEGER_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/internal.h b/src/plugins/ffmpeg/libavutil/internal.h deleted file mode 100644 index 35f4d5c..0000000 --- a/src/plugins/ffmpeg/libavutil/internal.h +++ /dev/null | |||
@@ -1,305 +0,0 @@ | |||
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 internal.h | ||
23 | * common internal api header. | ||
24 | */ | ||
25 | |||
26 | #ifndef FFMPEG_INTERNAL_H | ||
27 | #define FFMPEG_INTERNAL_H | ||
28 | |||
29 | #if !defined(DEBUG) && !defined(NDEBUG) | ||
30 | # define NDEBUG | ||
31 | #endif | ||
32 | |||
33 | #include <stdint.h> | ||
34 | #include <stddef.h> | ||
35 | #include <assert.h> | ||
36 | |||
37 | #ifndef attribute_align_arg | ||
38 | #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1) | ||
39 | # define attribute_align_arg __attribute__((force_align_arg_pointer)) | ||
40 | #else | ||
41 | # define attribute_align_arg | ||
42 | #endif | ||
43 | #endif | ||
44 | |||
45 | #ifndef attribute_used | ||
46 | #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) | ||
47 | # define attribute_used __attribute__((used)) | ||
48 | #else | ||
49 | # define attribute_used | ||
50 | #endif | ||
51 | #endif | ||
52 | |||
53 | #ifdef HAVE_ALTIVEC | ||
54 | #ifdef HAVE_ALTIVEC_VECTOR_BRACES | ||
55 | #define AVV(x...) {x} | ||
56 | #else | ||
57 | #define AVV(x...) (x) | ||
58 | #endif | ||
59 | #endif | ||
60 | |||
61 | #ifndef M_PI | ||
62 | #define M_PI 3.14159265358979323846 | ||
63 | #endif | ||
64 | |||
65 | #ifndef INT16_MIN | ||
66 | #define INT16_MIN (-0x7fff-1) | ||
67 | #endif | ||
68 | |||
69 | #ifndef INT16_MAX | ||
70 | #define INT16_MAX 0x7fff | ||
71 | #endif | ||
72 | |||
73 | #ifndef INT32_MIN | ||
74 | #define INT32_MIN (-0x7fffffff-1) | ||
75 | #endif | ||
76 | |||
77 | #ifndef INT32_MAX | ||
78 | #define INT32_MAX 0x7fffffff | ||
79 | #endif | ||
80 | |||
81 | #ifndef UINT32_MAX | ||
82 | #define UINT32_MAX 0xffffffff | ||
83 | #endif | ||
84 | |||
85 | #ifndef INT64_MIN | ||
86 | #define INT64_MIN (-0x7fffffffffffffffLL-1) | ||
87 | #endif | ||
88 | |||
89 | #ifndef INT64_MAX | ||
90 | #define INT64_MAX INT64_C(9223372036854775807) | ||
91 | #endif | ||
92 | |||
93 | #ifndef UINT64_MAX | ||
94 | #define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) | ||
95 | #endif | ||
96 | |||
97 | #ifndef INT_BIT | ||
98 | # if INT_MAX != 2147483647 | ||
99 | # define INT_BIT 64 | ||
100 | # else | ||
101 | # define INT_BIT 32 | ||
102 | # endif | ||
103 | #endif | ||
104 | |||
105 | #if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC) | ||
106 | # define PIC | ||
107 | #endif | ||
108 | |||
109 | #include "config.h" | ||
110 | #include "intreadwrite.h" | ||
111 | #include "bswap.h" | ||
112 | |||
113 | #ifndef offsetof | ||
114 | # define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F)) | ||
115 | #endif | ||
116 | |||
117 | #ifdef USE_FASTMEMCPY | ||
118 | # include "libvo/fastmemcpy.h" | ||
119 | # define memcpy(a,b,c) fast_memcpy(a,b,c) | ||
120 | #endif | ||
121 | |||
122 | // Use rip-relative addressing if compiling PIC code on x86-64. | ||
123 | #if defined(ARCH_X86_64) && defined(PIC) | ||
124 | # define LOCAL_MANGLE(a) #a "(%%rip)" | ||
125 | #else | ||
126 | # define LOCAL_MANGLE(a) #a | ||
127 | #endif | ||
128 | |||
129 | #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) | ||
130 | |||
131 | /* debug stuff */ | ||
132 | |||
133 | /* dprintf macros */ | ||
134 | #ifdef DEBUG | ||
135 | # define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) | ||
136 | #else | ||
137 | # define dprintf(pctx, ...) | ||
138 | #endif | ||
139 | |||
140 | #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) | ||
141 | |||
142 | /* math */ | ||
143 | |||
144 | extern const uint32_t ff_inverse[256]; | ||
145 | |||
146 | #if defined(ARCH_X86) | ||
147 | # define FASTDIV(a,b) \ | ||
148 | ({\ | ||
149 | int ret,dmy;\ | ||
150 | asm volatile(\ | ||
151 | "mull %3"\ | ||
152 | :"=d"(ret),"=a"(dmy)\ | ||
153 | :"1"(a),"g"(ff_inverse[b])\ | ||
154 | );\ | ||
155 | ret;\ | ||
156 | }) | ||
157 | #elif defined(HAVE_ARMV6) | ||
158 | static inline av_const int FASTDIV(int a, int b) | ||
159 | { | ||
160 | int r; | ||
161 | asm volatile("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(ff_inverse[b])); | ||
162 | return r; | ||
163 | } | ||
164 | #elif defined(ARCH_ARMV4L) | ||
165 | # define FASTDIV(a,b) \ | ||
166 | ({\ | ||
167 | int ret,dmy;\ | ||
168 | asm volatile(\ | ||
169 | "umull %1, %0, %2, %3"\ | ||
170 | :"=&r"(ret),"=&r"(dmy)\ | ||
171 | :"r"(a),"r"(ff_inverse[b])\ | ||
172 | );\ | ||
173 | ret;\ | ||
174 | }) | ||
175 | #elif defined(CONFIG_FASTDIV) | ||
176 | # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*ff_inverse[b])>>32)) | ||
177 | #else | ||
178 | # define FASTDIV(a,b) ((a)/(b)) | ||
179 | #endif | ||
180 | |||
181 | extern const uint8_t ff_sqrt_tab[256]; | ||
182 | |||
183 | static inline int av_log2_16bit(unsigned int v); | ||
184 | |||
185 | static inline av_const unsigned int ff_sqrt(unsigned int a) | ||
186 | { | ||
187 | unsigned int b; | ||
188 | |||
189 | if(a<255) return (ff_sqrt_tab[a+1]-1)>>4; | ||
190 | else if(a<(1<<12)) b= ff_sqrt_tab[a>>4 ]>>2; | ||
191 | #ifndef CONFIG_SMALL | ||
192 | else if(a<(1<<14)) b= ff_sqrt_tab[a>>6 ]>>1; | ||
193 | else if(a<(1<<16)) b= ff_sqrt_tab[a>>8 ] ; | ||
194 | #endif | ||
195 | else{ | ||
196 | int s= av_log2_16bit(a>>16)>>1; | ||
197 | unsigned int c= a>>(s+2); | ||
198 | b= ff_sqrt_tab[c>>(s+8)]; | ||
199 | b= FASTDIV(c,b) + (b<<s); | ||
200 | } | ||
201 | |||
202 | return b - (a<b*b); | ||
203 | } | ||
204 | |||
205 | #if defined(ARCH_X86) | ||
206 | #define MASK_ABS(mask, level)\ | ||
207 | asm volatile(\ | ||
208 | "cltd \n\t"\ | ||
209 | "xorl %1, %0 \n\t"\ | ||
210 | "subl %1, %0 \n\t"\ | ||
211 | : "+a" (level), "=&d" (mask)\ | ||
212 | ); | ||
213 | #else | ||
214 | #define MASK_ABS(mask, level)\ | ||
215 | mask= level>>31;\ | ||
216 | level= (level^mask)-mask; | ||
217 | #endif | ||
218 | |||
219 | #ifdef HAVE_CMOV | ||
220 | #define COPY3_IF_LT(x,y,a,b,c,d)\ | ||
221 | asm volatile (\ | ||
222 | "cmpl %0, %3 \n\t"\ | ||
223 | "cmovl %3, %0 \n\t"\ | ||
224 | "cmovl %4, %1 \n\t"\ | ||
225 | "cmovl %5, %2 \n\t"\ | ||
226 | : "+&r" (x), "+&r" (a), "+r" (c)\ | ||
227 | : "r" (y), "r" (b), "r" (d)\ | ||
228 | ); | ||
229 | #else | ||
230 | #define COPY3_IF_LT(x,y,a,b,c,d)\ | ||
231 | if((y)<(x)){\ | ||
232 | (x)=(y);\ | ||
233 | (a)=(b);\ | ||
234 | (c)=(d);\ | ||
235 | } | ||
236 | #endif | ||
237 | |||
238 | /* avoid usage of various functions */ | ||
239 | #undef malloc | ||
240 | #define malloc please_use_av_malloc | ||
241 | #undef free | ||
242 | #define free please_use_av_free | ||
243 | #undef realloc | ||
244 | #define realloc please_use_av_realloc | ||
245 | #undef time | ||
246 | #define time time_is_forbidden_due_to_security_issues | ||
247 | #undef rand | ||
248 | #define rand rand_is_forbidden_due_to_state_trashing_use_av_random | ||
249 | #undef srand | ||
250 | #define srand srand_is_forbidden_due_to_state_trashing_use_av_init_random | ||
251 | #undef random | ||
252 | #define random random_is_forbidden_due_to_state_trashing_use_av_random | ||
253 | #undef sprintf | ||
254 | #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf | ||
255 | #undef strcat | ||
256 | #define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat | ||
257 | #undef exit | ||
258 | #define exit exit_is_forbidden | ||
259 | #if !(defined(LIBAVFORMAT_BUILD) || defined(FFMPEG_FRAMEHOOK_H)) | ||
260 | #undef printf | ||
261 | #define printf please_use_av_log | ||
262 | #undef fprintf | ||
263 | #define fprintf please_use_av_log | ||
264 | #undef puts | ||
265 | #define puts please_use_av_log | ||
266 | #undef perror | ||
267 | #define perror please_use_av_log_instead_of_perror | ||
268 | #endif | ||
269 | |||
270 | #define CHECKED_ALLOCZ(p, size)\ | ||
271 | {\ | ||
272 | p= av_mallocz(size);\ | ||
273 | if(p==NULL && (size)!=0){\ | ||
274 | av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ | ||
275 | goto fail;\ | ||
276 | }\ | ||
277 | } | ||
278 | |||
279 | #ifndef HAVE_LLRINT | ||
280 | #define llrint(x) ((long long) rint(x)) | ||
281 | #endif /* HAVE_LLRINT */ | ||
282 | |||
283 | #ifndef HAVE_LRINT | ||
284 | #define lrint(x) ((long int) rint(x)) | ||
285 | #endif /* HAVE_LRINT */ | ||
286 | |||
287 | #ifndef HAVE_LRINTF | ||
288 | #define lrintf(x) ((long int) rint(x)) | ||
289 | #endif /* HAVE_LRINTF */ | ||
290 | |||
291 | #ifndef HAVE_ROUND | ||
292 | static av_always_inline av_const double round(double x) | ||
293 | { | ||
294 | return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); | ||
295 | } | ||
296 | #endif /* HAVE_ROUND */ | ||
297 | |||
298 | #ifndef HAVE_ROUNDF | ||
299 | static av_always_inline av_const float roundf(float x) | ||
300 | { | ||
301 | return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); | ||
302 | } | ||
303 | #endif /* HAVE_ROUNDF */ | ||
304 | |||
305 | #endif /* FFMPEG_INTERNAL_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/intfloat_readwrite.c b/src/plugins/ffmpeg/libavutil/intfloat_readwrite.c deleted file mode 100644 index 261cf76..0000000 --- a/src/plugins/ffmpeg/libavutil/intfloat_readwrite.c +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | /* | ||
2 | * portable IEEE float/double read/write functions | ||
3 | * | ||
4 | * Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at> | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | /** | ||
24 | * @file intfloat_readwrite.c | ||
25 | * Portable IEEE float/double read/write functions. | ||
26 | */ | ||
27 | |||
28 | #include "common.h" | ||
29 | #include "intfloat_readwrite.h" | ||
30 | |||
31 | double av_int2dbl(int64_t v){ | ||
32 | if(v+v > 0xFFEULL<<52) | ||
33 | return 0.0/0.0; | ||
34 | return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075); | ||
35 | } | ||
36 | |||
37 | float av_int2flt(int32_t v){ | ||
38 | if(v+v > 0xFF000000U) | ||
39 | return 0.0/0.0; | ||
40 | return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150); | ||
41 | } | ||
42 | |||
43 | double av_ext2dbl(const AVExtFloat ext){ | ||
44 | uint64_t m = 0; | ||
45 | int e, i; | ||
46 | |||
47 | for (i = 0; i < 8; i++) | ||
48 | m = (m<<8) + ext.mantissa[i]; | ||
49 | e = (((int)ext.exponent[0]&0x7f)<<8) | ext.exponent[1]; | ||
50 | if (e == 0x7fff && m) | ||
51 | return 0.0/0.0; | ||
52 | e -= 16383 + 63; /* In IEEE 80 bits, the whole (i.e. 1.xxxx) | ||
53 | * mantissa bit is written as opposed to the | ||
54 | * single and double precision formats */ | ||
55 | if (ext.exponent[0]&0x80) | ||
56 | m= -m; | ||
57 | return ldexp(m, e); | ||
58 | } | ||
59 | |||
60 | int64_t av_dbl2int(double d){ | ||
61 | int e; | ||
62 | if ( !d) return 0; | ||
63 | else if(d-d) return 0x7FF0000000000000LL + ((int64_t)(d<0)<<63) + (d!=d); | ||
64 | d= frexp(d, &e); | ||
65 | return (int64_t)(d<0)<<63 | (e+1022LL)<<52 | (int64_t)((fabs(d)-0.5)*(1LL<<53)); | ||
66 | } | ||
67 | |||
68 | int32_t av_flt2int(float d){ | ||
69 | int e; | ||
70 | if ( !d) return 0; | ||
71 | else if(d-d) return 0x7F800000 + ((d<0)<<31) + (d!=d); | ||
72 | d= frexp(d, &e); | ||
73 | return (d<0)<<31 | (e+126)<<23 | (int64_t)((fabs(d)-0.5)*(1<<24)); | ||
74 | } | ||
75 | |||
76 | AVExtFloat av_dbl2ext(double d){ | ||
77 | struct AVExtFloat ext= {{0}}; | ||
78 | int e, i; double f; uint64_t m; | ||
79 | |||
80 | f = fabs(frexp(d, &e)); | ||
81 | if (f >= 0.5 && f < 1) { | ||
82 | e += 16382; | ||
83 | ext.exponent[0] = e>>8; | ||
84 | ext.exponent[1] = e; | ||
85 | m = (uint64_t)ldexp(f, 64); | ||
86 | for (i=0; i < 8; i++) | ||
87 | ext.mantissa[i] = m>>(56-(i<<3)); | ||
88 | } else if (f != 0.0) { | ||
89 | ext.exponent[0] = 0x7f; ext.exponent[1] = 0xff; | ||
90 | if (f != 1/0.0) | ||
91 | ext.mantissa[0] = ~0; | ||
92 | } | ||
93 | if (d < 0) | ||
94 | ext.exponent[0] |= 0x80; | ||
95 | return ext; | ||
96 | } | ||
97 | |||
diff --git a/src/plugins/ffmpeg/libavutil/intfloat_readwrite.h b/src/plugins/ffmpeg/libavutil/intfloat_readwrite.h deleted file mode 100644 index 4b3f9b7..0000000 --- a/src/plugins/ffmpeg/libavutil/intfloat_readwrite.h +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
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 FFMPEG_INTFLOAT_READWRITE_H | ||
22 | #define FFMPEG_INTFLOAT_READWRITE_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | #include "common.h" | ||
26 | |||
27 | /* IEEE 80 bits extended float */ | ||
28 | typedef struct AVExtFloat { | ||
29 | uint8_t exponent[2]; | ||
30 | uint8_t mantissa[8]; | ||
31 | } AVExtFloat; | ||
32 | |||
33 | double av_int2dbl(int64_t v) av_const; | ||
34 | float av_int2flt(int32_t v) av_const; | ||
35 | double av_ext2dbl(const AVExtFloat ext) av_const; | ||
36 | int64_t av_dbl2int(double d) av_const; | ||
37 | int32_t av_flt2int(float d) av_const; | ||
38 | AVExtFloat av_dbl2ext(double d) av_const; | ||
39 | |||
40 | #endif /* FFMPEG_INTFLOAT_READWRITE_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/intreadwrite.h b/src/plugins/ffmpeg/libavutil/intreadwrite.h deleted file mode 100644 index 72ad5b3..0000000 --- a/src/plugins/ffmpeg/libavutil/intreadwrite.h +++ /dev/null | |||
@@ -1,192 +0,0 @@ | |||
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 FFMPEG_INTREADWRITE_H | ||
20 | #define FFMPEG_INTREADWRITE_H | ||
21 | |||
22 | #include <stdint.h> | ||
23 | #include "config.h" | ||
24 | #include "bswap.h" | ||
25 | |||
26 | #ifdef __GNUC__ | ||
27 | |||
28 | struct unaligned_64 { uint64_t l; } __attribute__((packed)); | ||
29 | struct unaligned_32 { uint32_t l; } __attribute__((packed)); | ||
30 | struct unaligned_16 { uint16_t l; } __attribute__((packed)); | ||
31 | |||
32 | #define AV_RN16(a) (((const struct unaligned_16 *) (a))->l) | ||
33 | #define AV_RN32(a) (((const struct unaligned_32 *) (a))->l) | ||
34 | #define AV_RN64(a) (((const struct unaligned_64 *) (a))->l) | ||
35 | |||
36 | #define AV_WN16(a, b) (((struct unaligned_16 *) (a))->l) = (b) | ||
37 | #define AV_WN32(a, b) (((struct unaligned_32 *) (a))->l) = (b) | ||
38 | #define AV_WN64(a, b) (((struct unaligned_64 *) (a))->l) = (b) | ||
39 | |||
40 | #elif defined(__DECC) | ||
41 | |||
42 | #define AV_RN16(a) (*((const __unaligned uint16_t*)(a))) | ||
43 | #define AV_RN32(a) (*((const __unaligned uint32_t*)(a))) | ||
44 | #define AV_RN64(a) (*((const __unaligned uint64_t*)(a))) | ||
45 | |||
46 | #define AV_WN16(a, b) *((__unaligned uint16_t*)(a)) = (b) | ||
47 | #define AV_WN32(a, b) *((__unaligned uint32_t*)(a)) = (b) | ||
48 | #define AV_WN64(a, b) *((__unaligned uint64_t*)(a)) = (b) | ||
49 | |||
50 | #else | ||
51 | |||
52 | #define AV_RN16(a) (*((const uint16_t*)(a))) | ||
53 | #define AV_RN32(a) (*((const uint32_t*)(a))) | ||
54 | #define AV_RN64(a) (*((const uint64_t*)(a))) | ||
55 | |||
56 | #define AV_WN16(a, b) *((uint16_t*)(a)) = (b) | ||
57 | #define AV_WN32(a, b) *((uint32_t*)(a)) = (b) | ||
58 | #define AV_WN64(a, b) *((uint64_t*)(a)) = (b) | ||
59 | |||
60 | #endif /* !__GNUC__ */ | ||
61 | |||
62 | /* endian macros */ | ||
63 | #define AV_RB8(x) (((const uint8_t*)(x))[0]) | ||
64 | #define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) | ||
65 | |||
66 | #define AV_RL8(x) AV_RB8(x) | ||
67 | #define AV_WL8(p, d) AV_WB8(p, d) | ||
68 | |||
69 | #ifdef HAVE_FAST_UNALIGNED | ||
70 | # ifdef WORDS_BIGENDIAN | ||
71 | # define AV_RB16(x) AV_RN16(x) | ||
72 | # define AV_WB16(p, d) AV_WN16(p, d) | ||
73 | |||
74 | # define AV_RL16(x) bswap_16(AV_RN16(x)) | ||
75 | # define AV_WL16(p, d) AV_WN16(p, bswap_16(d)) | ||
76 | |||
77 | # define AV_RB32(x) AV_RN32(x) | ||
78 | # define AV_WB32(p, d) AV_WN32(p, d) | ||
79 | |||
80 | # define AV_RL32(x) bswap_32(AV_RN32(x)) | ||
81 | # define AV_WL32(p, d) AV_WN32(p, bswap_32(d)) | ||
82 | |||
83 | # define AV_RB64(x) AV_RN64(x) | ||
84 | # define AV_WB64(p, d) AV_WN64(p, d) | ||
85 | |||
86 | # define AV_RL64(x) bswap_64(AV_RN64(x)) | ||
87 | # define AV_WL64(p, d) AV_WN64(p, bswap_64(d)) | ||
88 | # else /* WORDS_BIGENDIAN */ | ||
89 | # define AV_RB16(x) bswap_16(AV_RN16(x)) | ||
90 | # define AV_WB16(p, d) AV_WN16(p, bswap_16(d)) | ||
91 | |||
92 | # define AV_RL16(x) AV_RN16(x) | ||
93 | # define AV_WL16(p, d) AV_WN16(p, d) | ||
94 | |||
95 | # define AV_RB32(x) bswap_32(AV_RN32(x)) | ||
96 | # define AV_WB32(p, d) AV_WN32(p, bswap_32(d)) | ||
97 | |||
98 | # define AV_RL32(x) AV_RN32(x) | ||
99 | # define AV_WL32(p, d) AV_WN32(p, d) | ||
100 | |||
101 | # define AV_RB64(x) bswap_64(AV_RN64(x)) | ||
102 | # define AV_WB64(p, d) AV_WN64(p, bswap_64(d)) | ||
103 | |||
104 | # define AV_RL64(x) AV_RN64(x) | ||
105 | # define AV_WL64(p, d) AV_WN64(p, d) | ||
106 | # endif | ||
107 | #else /* HAVE_FAST_UNALIGNED */ | ||
108 | #define AV_RB16(x) ((((const uint8_t*)(x))[0] << 8) | ((const uint8_t*)(x))[1]) | ||
109 | #define AV_WB16(p, d) do { \ | ||
110 | ((uint8_t*)(p))[1] = (d); \ | ||
111 | ((uint8_t*)(p))[0] = (d)>>8; } while(0) | ||
112 | |||
113 | #define AV_RL16(x) ((((const uint8_t*)(x))[1] << 8) | \ | ||
114 | ((const uint8_t*)(x))[0]) | ||
115 | #define AV_WL16(p, d) do { \ | ||
116 | ((uint8_t*)(p))[0] = (d); \ | ||
117 | ((uint8_t*)(p))[1] = (d)>>8; } while(0) | ||
118 | |||
119 | #define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ | ||
120 | (((const uint8_t*)(x))[1] << 16) | \ | ||
121 | (((const uint8_t*)(x))[2] << 8) | \ | ||
122 | ((const uint8_t*)(x))[3]) | ||
123 | #define AV_WB32(p, d) do { \ | ||
124 | ((uint8_t*)(p))[3] = (d); \ | ||
125 | ((uint8_t*)(p))[2] = (d)>>8; \ | ||
126 | ((uint8_t*)(p))[1] = (d)>>16; \ | ||
127 | ((uint8_t*)(p))[0] = (d)>>24; } while(0) | ||
128 | |||
129 | #define AV_RL32(x) ((((const uint8_t*)(x))[3] << 24) | \ | ||
130 | (((const uint8_t*)(x))[2] << 16) | \ | ||
131 | (((const uint8_t*)(x))[1] << 8) | \ | ||
132 | ((const uint8_t*)(x))[0]) | ||
133 | #define AV_WL32(p, d) do { \ | ||
134 | ((uint8_t*)(p))[0] = (d); \ | ||
135 | ((uint8_t*)(p))[1] = (d)>>8; \ | ||
136 | ((uint8_t*)(p))[2] = (d)>>16; \ | ||
137 | ((uint8_t*)(p))[3] = (d)>>24; } while(0) | ||
138 | |||
139 | #define AV_RB64(x) (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ | ||
140 | ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ | ||
141 | ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ | ||
142 | ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ | ||
143 | ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ | ||
144 | ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ | ||
145 | ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ | ||
146 | (uint64_t)((const uint8_t*)(x))[7]) | ||
147 | #define AV_WB64(p, d) do { \ | ||
148 | ((uint8_t*)(p))[7] = (d); \ | ||
149 | ((uint8_t*)(p))[6] = (d)>>8; \ | ||
150 | ((uint8_t*)(p))[5] = (d)>>16; \ | ||
151 | ((uint8_t*)(p))[4] = (d)>>24; \ | ||
152 | ((uint8_t*)(p))[3] = (d)>>32; \ | ||
153 | ((uint8_t*)(p))[2] = (d)>>40; \ | ||
154 | ((uint8_t*)(p))[1] = (d)>>48; \ | ||
155 | ((uint8_t*)(p))[0] = (d)>>56; } while(0) | ||
156 | |||
157 | #define AV_RL64(x) (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ | ||
158 | ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ | ||
159 | ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ | ||
160 | ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ | ||
161 | ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ | ||
162 | ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ | ||
163 | ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ | ||
164 | (uint64_t)((const uint8_t*)(x))[0]) | ||
165 | #define AV_WL64(p, d) do { \ | ||
166 | ((uint8_t*)(p))[0] = (d); \ | ||
167 | ((uint8_t*)(p))[1] = (d)>>8; \ | ||
168 | ((uint8_t*)(p))[2] = (d)>>16; \ | ||
169 | ((uint8_t*)(p))[3] = (d)>>24; \ | ||
170 | ((uint8_t*)(p))[4] = (d)>>32; \ | ||
171 | ((uint8_t*)(p))[5] = (d)>>40; \ | ||
172 | ((uint8_t*)(p))[6] = (d)>>48; \ | ||
173 | ((uint8_t*)(p))[7] = (d)>>56; } while(0) | ||
174 | #endif /* HAVE_FAST_UNALIGNED */ | ||
175 | |||
176 | #define AV_RB24(x) ((((const uint8_t*)(x))[0] << 16) | \ | ||
177 | (((const uint8_t*)(x))[1] << 8) | \ | ||
178 | ((const uint8_t*)(x))[2]) | ||
179 | #define AV_WB24(p, d) do { \ | ||
180 | ((uint8_t*)(p))[2] = (d); \ | ||
181 | ((uint8_t*)(p))[1] = (d)>>8; \ | ||
182 | ((uint8_t*)(p))[0] = (d)>>16; } while(0) | ||
183 | |||
184 | #define AV_RL24(x) ((((const uint8_t*)(x))[2] << 16) | \ | ||
185 | (((const uint8_t*)(x))[1] << 8) | \ | ||
186 | ((const uint8_t*)(x))[0]) | ||
187 | #define AV_WL24(p, d) do { \ | ||
188 | ((uint8_t*)(p))[0] = (d); \ | ||
189 | ((uint8_t*)(p))[1] = (d)>>8; \ | ||
190 | ((uint8_t*)(p))[2] = (d)>>16; } while(0) | ||
191 | |||
192 | #endif /* FFMPEG_INTREADWRITE_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/lls.c b/src/plugins/ffmpeg/libavutil/lls.c deleted file mode 100644 index b9d2d81..0000000 --- a/src/plugins/ffmpeg/libavutil/lls.c +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
1 | /* | ||
2 | * linear least squares model | ||
3 | * | ||
4 | * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | /** | ||
24 | * @file lls.c | ||
25 | * linear least squares model | ||
26 | */ | ||
27 | |||
28 | #include <math.h> | ||
29 | #include <string.h> | ||
30 | |||
31 | #include "lls.h" | ||
32 | |||
33 | #ifdef TEST | ||
34 | #define av_log(a,b,...) printf(__VA_ARGS__) | ||
35 | #endif | ||
36 | |||
37 | void av_init_lls(LLSModel *m, int indep_count){ | ||
38 | memset(m, 0, sizeof(LLSModel)); | ||
39 | |||
40 | m->indep_count= indep_count; | ||
41 | } | ||
42 | |||
43 | void av_update_lls(LLSModel *m, double *var, double decay){ | ||
44 | int i,j; | ||
45 | |||
46 | for(i=0; i<=m->indep_count; i++){ | ||
47 | for(j=i; j<=m->indep_count; j++){ | ||
48 | m->covariance[i][j] *= decay; | ||
49 | m->covariance[i][j] += var[i]*var[j]; | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | |||
54 | void av_solve_lls(LLSModel *m, double threshold, int min_order){ | ||
55 | int i,j,k; | ||
56 | double (*factor)[MAX_VARS+1]= (void*)&m->covariance[1][0]; | ||
57 | double (*covar )[MAX_VARS+1]= (void*)&m->covariance[1][1]; | ||
58 | double *covar_y = m->covariance[0]; | ||
59 | int count= m->indep_count; | ||
60 | |||
61 | for(i=0; i<count; i++){ | ||
62 | for(j=i; j<count; j++){ | ||
63 | double sum= covar[i][j]; | ||
64 | |||
65 | for(k=i-1; k>=0; k--) | ||
66 | sum -= factor[i][k]*factor[j][k]; | ||
67 | |||
68 | if(i==j){ | ||
69 | if(sum < threshold) | ||
70 | sum= 1.0; | ||
71 | factor[i][i]= sqrt(sum); | ||
72 | }else | ||
73 | factor[j][i]= sum / factor[i][i]; | ||
74 | } | ||
75 | } | ||
76 | for(i=0; i<count; i++){ | ||
77 | double sum= covar_y[i+1]; | ||
78 | for(k=i-1; k>=0; k--) | ||
79 | sum -= factor[i][k]*m->coeff[0][k]; | ||
80 | m->coeff[0][i]= sum / factor[i][i]; | ||
81 | } | ||
82 | |||
83 | for(j=count-1; j>=min_order; j--){ | ||
84 | for(i=j; i>=0; i--){ | ||
85 | double sum= m->coeff[0][i]; | ||
86 | for(k=i+1; k<=j; k++) | ||
87 | sum -= factor[k][i]*m->coeff[j][k]; | ||
88 | m->coeff[j][i]= sum / factor[i][i]; | ||
89 | } | ||
90 | |||
91 | m->variance[j]= covar_y[0]; | ||
92 | for(i=0; i<=j; i++){ | ||
93 | double sum= m->coeff[j][i]*covar[i][i] - 2*covar_y[i+1]; | ||
94 | for(k=0; k<i; k++) | ||
95 | sum += 2*m->coeff[j][k]*covar[k][i]; | ||
96 | m->variance[j] += m->coeff[j][i]*sum; | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | |||
101 | double av_evaluate_lls(LLSModel *m, double *param, int order){ | ||
102 | int i; | ||
103 | double out= 0; | ||
104 | |||
105 | for(i=0; i<=order; i++) | ||
106 | out+= param[i]*m->coeff[order][i]; | ||
107 | |||
108 | return out; | ||
109 | } | ||
110 | |||
111 | #ifdef TEST | ||
112 | |||
113 | #include <stdlib.h> | ||
114 | #include <stdio.h> | ||
115 | |||
116 | int main(void){ | ||
117 | LLSModel m; | ||
118 | int i, order; | ||
119 | |||
120 | av_init_lls(&m, 3); | ||
121 | |||
122 | for(i=0; i<100; i++){ | ||
123 | double var[4]; | ||
124 | double eval; | ||
125 | #if 0 | ||
126 | var[1] = rand() / (double)RAND_MAX; | ||
127 | var[2] = rand() / (double)RAND_MAX; | ||
128 | var[3] = rand() / (double)RAND_MAX; | ||
129 | |||
130 | var[2]= var[1] + var[3]/2; | ||
131 | |||
132 | var[0] = var[1] + var[2] + var[3] + var[1]*var[2]/100; | ||
133 | #else | ||
134 | var[0] = (rand() / (double)RAND_MAX - 0.5)*2; | ||
135 | var[1] = var[0] + rand() / (double)RAND_MAX - 0.5; | ||
136 | var[2] = var[1] + rand() / (double)RAND_MAX - 0.5; | ||
137 | var[3] = var[2] + rand() / (double)RAND_MAX - 0.5; | ||
138 | #endif | ||
139 | av_update_lls(&m, var, 0.99); | ||
140 | av_solve_lls(&m, 0.001, 0); | ||
141 | for(order=0; order<3; order++){ | ||
142 | eval= av_evaluate_lls(&m, var+1, order); | ||
143 | av_log(NULL, AV_LOG_DEBUG, "real:%f order:%d pred:%f var:%f coeffs:%f %f %f\n", | ||
144 | var[0], order, eval, sqrt(m.variance[order] / (i+1)), | ||
145 | m.coeff[order][0], m.coeff[order][1], m.coeff[order][2]); | ||
146 | } | ||
147 | } | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/lls.h b/src/plugins/ffmpeg/libavutil/lls.h deleted file mode 100644 index 90b2332..0000000 --- a/src/plugins/ffmpeg/libavutil/lls.h +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* | ||
2 | * linear least squares model | ||
3 | * | ||
4 | * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | #ifndef FFMPEG_LLS_H | ||
24 | #define FFMPEG_LLS_H | ||
25 | |||
26 | #define MAX_VARS 32 | ||
27 | |||
28 | //FIXME avoid direct access to LLSModel from outside | ||
29 | |||
30 | /** | ||
31 | * Linear least squares model. | ||
32 | */ | ||
33 | typedef struct LLSModel{ | ||
34 | double covariance[MAX_VARS+1][MAX_VARS+1]; | ||
35 | double coeff[MAX_VARS][MAX_VARS]; | ||
36 | double variance[MAX_VARS]; | ||
37 | int indep_count; | ||
38 | }LLSModel; | ||
39 | |||
40 | void av_init_lls(LLSModel *m, int indep_count); | ||
41 | void av_update_lls(LLSModel *m, double *param, double decay); | ||
42 | void av_solve_lls(LLSModel *m, double threshold, int min_order); | ||
43 | double av_evaluate_lls(LLSModel *m, double *param, int order); | ||
44 | |||
45 | #endif /* FFMPEG_LLS_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/log.c b/src/plugins/ffmpeg/libavutil/log.c deleted file mode 100644 index aadcf90..0000000 --- a/src/plugins/ffmpeg/libavutil/log.c +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
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 log.c | ||
24 | * log. | ||
25 | */ | ||
26 | |||
27 | #include "avutil.h" | ||
28 | |||
29 | int av_log_level = AV_LOG_INFO; | ||
30 | |||
31 | void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) | ||
32 | { | ||
33 | static int print_prefix=1; | ||
34 | AVClass* avc= ptr ? *(AVClass**)ptr : NULL; | ||
35 | if(level>av_log_level) | ||
36 | return; | ||
37 | #undef fprintf | ||
38 | if(print_prefix && avc) { | ||
39 | fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), ptr); | ||
40 | } | ||
41 | #define fprintf please_use_av_log | ||
42 | |||
43 | print_prefix= strstr(fmt, "\n") != NULL; | ||
44 | |||
45 | vfprintf(stderr, fmt, vl); | ||
46 | } | ||
47 | |||
48 | static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; | ||
49 | |||
50 | void av_log(void* avcl, int level, const char *fmt, ...) | ||
51 | { | ||
52 | va_list vl; | ||
53 | va_start(vl, fmt); | ||
54 | av_vlog(avcl, level, fmt, vl); | ||
55 | va_end(vl); | ||
56 | } | ||
57 | |||
58 | void av_vlog(void* avcl, int level, const char *fmt, va_list vl) | ||
59 | { | ||
60 | av_log_callback(avcl, level, fmt, vl); | ||
61 | } | ||
62 | |||
63 | int av_log_get_level(void) | ||
64 | { | ||
65 | return av_log_level; | ||
66 | } | ||
67 | |||
68 | void av_log_set_level(int level) | ||
69 | { | ||
70 | av_log_level = level; | ||
71 | } | ||
72 | |||
73 | void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)) | ||
74 | { | ||
75 | av_log_callback = callback; | ||
76 | } | ||
diff --git a/src/plugins/ffmpeg/libavutil/log.h b/src/plugins/ffmpeg/libavutil/log.h deleted file mode 100644 index e0ff1f6..0000000 --- a/src/plugins/ffmpeg/libavutil/log.h +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
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 FFMPEG_LOG_H | ||
22 | #define FFMPEG_LOG_H | ||
23 | |||
24 | #include <stdarg.h> | ||
25 | |||
26 | /** | ||
27 | * Describes the class of an AVClass context structure, that is an | ||
28 | * arbitrary struct of which the first field is a pointer to an | ||
29 | * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). | ||
30 | */ | ||
31 | typedef struct AVCLASS AVClass; | ||
32 | struct AVCLASS { | ||
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 \p 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 | /* av_log API */ | ||
54 | |||
55 | #if LIBAVUTIL_VERSION_INT < (50<<16) | ||
56 | #define AV_LOG_QUIET -1 | ||
57 | #define AV_LOG_FATAL 0 | ||
58 | #define AV_LOG_ERROR 0 | ||
59 | #define AV_LOG_WARNING 1 | ||
60 | #define AV_LOG_INFO 1 | ||
61 | #define AV_LOG_VERBOSE 1 | ||
62 | #define AV_LOG_DEBUG 2 | ||
63 | #else | ||
64 | #define AV_LOG_QUIET -8 | ||
65 | |||
66 | /** | ||
67 | * something went really wrong and we will crash now | ||
68 | */ | ||
69 | #define AV_LOG_PANIC 0 | ||
70 | |||
71 | /** | ||
72 | * something went wrong and recovery is not possible | ||
73 | * like no header in a format which depends on it or a combination | ||
74 | * of parameters which are not allowed | ||
75 | */ | ||
76 | #define AV_LOG_FATAL 8 | ||
77 | |||
78 | /** | ||
79 | * something went wrong and cannot losslessly be recovered | ||
80 | * but not all future data is affected | ||
81 | */ | ||
82 | #define AV_LOG_ERROR 16 | ||
83 | |||
84 | /** | ||
85 | * something somehow does not look correct / something which may or may not | ||
86 | * lead to some problems like use of -vstrict -2 | ||
87 | */ | ||
88 | #define AV_LOG_WARNING 24 | ||
89 | |||
90 | #define AV_LOG_INFO 32 | ||
91 | #define AV_LOG_VERBOSE 40 | ||
92 | |||
93 | /** | ||
94 | * stuff which is only useful for libav* developers | ||
95 | */ | ||
96 | #define AV_LOG_DEBUG 48 | ||
97 | #endif | ||
98 | |||
99 | #if LIBAVUTIL_VERSION_INT < (50<<16) | ||
100 | extern int av_log_level; | ||
101 | #endif | ||
102 | |||
103 | /** | ||
104 | * Send the specified message to the log if the level is less than or equal to | ||
105 | * the current av_log_level. By default, all logging messages are sent to | ||
106 | * stderr. This behavior can be altered by setting a different av_vlog callback | ||
107 | * function. | ||
108 | * | ||
109 | * @param avcl A pointer to an arbitrary struct of which the first field is a | ||
110 | * pointer to an AVClass struct. | ||
111 | * @param level The importance level of the message, lower values signifying | ||
112 | * higher importance. | ||
113 | * @param fmt The format string (printf-compatible) that specifies how | ||
114 | * subsequent arguments are converted to output. | ||
115 | * @see av_vlog | ||
116 | */ | ||
117 | #ifdef __GNUC__ | ||
118 | void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); | ||
119 | #else | ||
120 | void av_log(void*, int level, const char *fmt, ...); | ||
121 | #endif | ||
122 | |||
123 | void av_vlog(void*, int level, const char *fmt, va_list); | ||
124 | int av_log_get_level(void); | ||
125 | void av_log_set_level(int); | ||
126 | void av_log_set_callback(void (*)(void*, int, const char*, va_list)); | ||
127 | void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); | ||
128 | |||
129 | #endif /* FFMPEG_LOG_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/lzo.c b/src/plugins/ffmpeg/libavutil/lzo.c deleted file mode 100644 index 35247b1..0000000 --- a/src/plugins/ffmpeg/libavutil/lzo.c +++ /dev/null | |||
@@ -1,274 +0,0 @@ | |||
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 | #include "common.h" | ||
22 | //! avoid e.g. MPlayers fast_memcpy, it slows things down here | ||
23 | #undef memcpy | ||
24 | #include <string.h> | ||
25 | #include "lzo.h" | ||
26 | |||
27 | //! define if we may write up to 12 bytes beyond the output buffer | ||
28 | #define OUTBUF_PADDED 1 | ||
29 | //! define if we may read up to 8 bytes beyond the input buffer | ||
30 | #define INBUF_PADDED 1 | ||
31 | typedef struct LZOContext { | ||
32 | const uint8_t *in, *in_end; | ||
33 | uint8_t *out_start, *out, *out_end; | ||
34 | int error; | ||
35 | } LZOContext; | ||
36 | |||
37 | /** | ||
38 | * \brief read one byte from input buffer, avoiding overrun | ||
39 | * \return byte read | ||
40 | */ | ||
41 | static inline int get_byte(LZOContext *c) { | ||
42 | if (c->in < c->in_end) | ||
43 | return *c->in++; | ||
44 | c->error |= LZO_INPUT_DEPLETED; | ||
45 | return 1; | ||
46 | } | ||
47 | |||
48 | #ifdef INBUF_PADDED | ||
49 | #define GETB(c) (*(c).in++) | ||
50 | #else | ||
51 | #define GETB(c) get_byte(&(c)) | ||
52 | #endif | ||
53 | |||
54 | /** | ||
55 | * \brief decode a length value in the coding used by lzo | ||
56 | * \param x previous byte value | ||
57 | * \param mask bits used from x | ||
58 | * \return decoded length value | ||
59 | */ | ||
60 | static inline int get_len(LZOContext *c, int x, int mask) { | ||
61 | int cnt = x & mask; | ||
62 | if (!cnt) { | ||
63 | while (!(x = get_byte(c))) cnt += 255; | ||
64 | cnt += mask + x; | ||
65 | } | ||
66 | return cnt; | ||
67 | } | ||
68 | |||
69 | //#define UNALIGNED_LOADSTORE | ||
70 | #define BUILTIN_MEMCPY | ||
71 | #ifdef UNALIGNED_LOADSTORE | ||
72 | #define COPY2(d, s) *(uint16_t *)(d) = *(uint16_t *)(s); | ||
73 | #define COPY4(d, s) *(uint32_t *)(d) = *(uint32_t *)(s); | ||
74 | #elif defined(BUILTIN_MEMCPY) | ||
75 | #define COPY2(d, s) memcpy(d, s, 2); | ||
76 | #define COPY4(d, s) memcpy(d, s, 4); | ||
77 | #else | ||
78 | #define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; | ||
79 | #define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3]; | ||
80 | #endif | ||
81 | |||
82 | /** | ||
83 | * \brief copy bytes from input to output buffer with checking | ||
84 | * \param cnt number of bytes to copy, must be >= 0 | ||
85 | */ | ||
86 | static inline void copy(LZOContext *c, int cnt) { | ||
87 | register const uint8_t *src = c->in; | ||
88 | register uint8_t *dst = c->out; | ||
89 | if (cnt > c->in_end - src) { | ||
90 | cnt = FFMAX(c->in_end - src, 0); | ||
91 | c->error |= LZO_INPUT_DEPLETED; | ||
92 | } | ||
93 | if (cnt > c->out_end - dst) { | ||
94 | cnt = FFMAX(c->out_end - dst, 0); | ||
95 | c->error |= LZO_OUTPUT_FULL; | ||
96 | } | ||
97 | #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) | ||
98 | COPY4(dst, src); | ||
99 | src += 4; | ||
100 | dst += 4; | ||
101 | cnt -= 4; | ||
102 | if (cnt > 0) | ||
103 | #endif | ||
104 | memcpy(dst, src, cnt); | ||
105 | c->in = src + cnt; | ||
106 | c->out = dst + cnt; | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * \brief copy previously decoded bytes to current position | ||
111 | * \param back how many bytes back we start | ||
112 | * \param cnt number of bytes to copy, must be >= 0 | ||
113 | * | ||
114 | * cnt > back is valid, this will copy the bytes we just copied, | ||
115 | * thus creating a repeating pattern with a period length of back. | ||
116 | */ | ||
117 | static inline void copy_backptr(LZOContext *c, int back, int cnt) { | ||
118 | register const uint8_t *src = &c->out[-back]; | ||
119 | register uint8_t *dst = c->out; | ||
120 | if (src < c->out_start || src > dst) { | ||
121 | c->error |= LZO_INVALID_BACKPTR; | ||
122 | return; | ||
123 | } | ||
124 | if (cnt > c->out_end - dst) { | ||
125 | cnt = FFMAX(c->out_end - dst, 0); | ||
126 | c->error |= LZO_OUTPUT_FULL; | ||
127 | } | ||
128 | if (back == 1) { | ||
129 | memset(dst, *src, cnt); | ||
130 | dst += cnt; | ||
131 | } else { | ||
132 | #ifdef OUTBUF_PADDED | ||
133 | COPY2(dst, src); | ||
134 | COPY2(dst + 2, src + 2); | ||
135 | src += 4; | ||
136 | dst += 4; | ||
137 | cnt -= 4; | ||
138 | if (cnt > 0) { | ||
139 | COPY2(dst, src); | ||
140 | COPY2(dst + 2, src + 2); | ||
141 | COPY2(dst + 4, src + 4); | ||
142 | COPY2(dst + 6, src + 6); | ||
143 | src += 8; | ||
144 | dst += 8; | ||
145 | cnt -= 8; | ||
146 | } | ||
147 | #endif | ||
148 | if (cnt > 0) { | ||
149 | int blocklen = back; | ||
150 | while (cnt > blocklen) { | ||
151 | memcpy(dst, src, blocklen); | ||
152 | dst += blocklen; | ||
153 | cnt -= blocklen; | ||
154 | blocklen <<= 1; | ||
155 | } | ||
156 | memcpy(dst, src, cnt); | ||
157 | } | ||
158 | dst += cnt; | ||
159 | } | ||
160 | c->out = dst; | ||
161 | } | ||
162 | |||
163 | /** | ||
164 | * \brief decode LZO 1x compressed data | ||
165 | * \param out output buffer | ||
166 | * \param outlen size of output buffer, number of bytes left are returned here | ||
167 | * \param in input buffer | ||
168 | * \param inlen size of input buffer, number of bytes left are returned here | ||
169 | * \return 0 on success, otherwise error flags, see lzo.h | ||
170 | * | ||
171 | * make sure all buffers are appropriately padded, in must provide | ||
172 | * LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes | ||
173 | */ | ||
174 | int 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 |= LZO_ERROR; | ||
188 | } | ||
189 | if (c.in > c.in_end) | ||
190 | c.error |= 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 |= 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 | int main(int argc, char *argv[]) { | ||
243 | FILE *in = fopen(argv[1], "rb"); | ||
244 | uint8_t *orig = av_malloc(MAXSZ + 16); | ||
245 | uint8_t *comp = av_malloc(2*MAXSZ + 16); | ||
246 | uint8_t *decomp = av_malloc(MAXSZ + 16); | ||
247 | size_t s = fread(orig, 1, MAXSZ, in); | ||
248 | lzo_uint clen = 0; | ||
249 | long tmp[LZO1X_MEM_COMPRESS]; | ||
250 | int inlen, outlen; | ||
251 | int i; | ||
252 | av_log_level = AV_LOG_DEBUG; | ||
253 | lzo1x_999_compress(orig, s, comp, &clen, tmp); | ||
254 | for (i = 0; i < 300; i++) { | ||
255 | START_TIMER | ||
256 | inlen = clen; outlen = MAXSZ; | ||
257 | #ifdef LIBLZO | ||
258 | if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL)) | ||
259 | #elif defined(LIBLZO_UNSAFE) | ||
260 | if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL)) | ||
261 | #else | ||
262 | if (lzo1x_decode(decomp, &outlen, comp, &inlen)) | ||
263 | #endif | ||
264 | av_log(NULL, AV_LOG_ERROR, "decompression error\n"); | ||
265 | STOP_TIMER("lzod") | ||
266 | } | ||
267 | if (memcmp(orig, decomp, s)) | ||
268 | av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n"); | ||
269 | else | ||
270 | av_log(NULL, AV_LOG_ERROR, "decompression ok\n"); | ||
271 | fclose (in); | ||
272 | return 0; | ||
273 | } | ||
274 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/lzo.h b/src/plugins/ffmpeg/libavutil/lzo.h deleted file mode 100644 index e7795f7..0000000 --- a/src/plugins/ffmpeg/libavutil/lzo.h +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
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 FFMPEG_LZO_H | ||
23 | #define FFMPEG_LZO_H | ||
24 | |||
25 | #define LZO_INPUT_DEPLETED 1 | ||
26 | #define LZO_OUTPUT_FULL 2 | ||
27 | #define LZO_INVALID_BACKPTR 4 | ||
28 | #define LZO_ERROR 8 | ||
29 | |||
30 | #define LZO_INPUT_PADDING 8 | ||
31 | #define LZO_OUTPUT_PADDING 12 | ||
32 | |||
33 | int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); | ||
34 | |||
35 | #endif /* FFMPEG_LZO_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/mathematics.c b/src/plugins/ffmpeg/libavutil/mathematics.c deleted file mode 100644 index ef93ba4..0000000 --- a/src/plugins/ffmpeg/libavutil/mathematics.c +++ /dev/null | |||
@@ -1,145 +0,0 @@ | |||
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 mathematics.c | ||
23 | * Miscellaneous math routines and tables. | ||
24 | */ | ||
25 | |||
26 | #include "common.h" | ||
27 | #include "mathematics.h" | ||
28 | |||
29 | const uint8_t ff_sqrt_tab[256]={ | ||
30 | 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, | ||
31 | 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, | ||
32 | 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, | ||
33 | 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, | ||
34 | 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, | ||
35 | 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, | ||
36 | 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, | ||
37 | 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 | ||
38 | }; | ||
39 | |||
40 | const uint8_t ff_log2_tab[256]={ | ||
41 | 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, | ||
42 | 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, | ||
43 | 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, | ||
44 | 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, | ||
45 | 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, | ||
46 | 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, | ||
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 | }; | ||
50 | |||
51 | int64_t ff_gcd(int64_t a, int64_t b){ | ||
52 | if(b) return ff_gcd(b, a%b); | ||
53 | else return a; | ||
54 | } | ||
55 | |||
56 | int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){ | ||
57 | int64_t r=0; | ||
58 | assert(c > 0); | ||
59 | assert(b >=0); | ||
60 | assert(rnd >=0 && rnd<=5 && rnd!=4); | ||
61 | |||
62 | if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1)); | ||
63 | |||
64 | if(rnd==AV_ROUND_NEAR_INF) r= c/2; | ||
65 | else if(rnd&1) r= c-1; | ||
66 | |||
67 | if(b<=INT_MAX && c<=INT_MAX){ | ||
68 | if(a<=INT_MAX) | ||
69 | return (a * b + r)/c; | ||
70 | else | ||
71 | return a/c*b + (a%c*b + r)/c; | ||
72 | }else{ | ||
73 | #if 1 | ||
74 | uint64_t a0= a&0xFFFFFFFF; | ||
75 | uint64_t a1= a>>32; | ||
76 | uint64_t b0= b&0xFFFFFFFF; | ||
77 | uint64_t b1= b>>32; | ||
78 | uint64_t t1= a0*b1 + a1*b0; | ||
79 | uint64_t t1a= t1<<32; | ||
80 | int i; | ||
81 | |||
82 | a0 = a0*b0 + t1a; | ||
83 | a1 = a1*b1 + (t1>>32) + (a0<t1a); | ||
84 | a0 += r; | ||
85 | a1 += a0<r; | ||
86 | |||
87 | for(i=63; i>=0; i--){ | ||
88 | // int o= a1 & 0x8000000000000000ULL; | ||
89 | a1+= a1 + ((a0>>i)&1); | ||
90 | t1+=t1; | ||
91 | if(/*o || */c <= a1){ | ||
92 | a1 -= c; | ||
93 | t1++; | ||
94 | } | ||
95 | } | ||
96 | return t1; | ||
97 | } | ||
98 | #else | ||
99 | AVInteger ai; | ||
100 | ai= av_mul_i(av_int2i(a), av_int2i(b)); | ||
101 | ai= av_add_i(ai, av_int2i(r)); | ||
102 | |||
103 | return av_i2int(av_div_i(ai, av_int2i(c))); | ||
104 | } | ||
105 | #endif | ||
106 | } | ||
107 | |||
108 | int64_t av_rescale(int64_t a, int64_t b, int64_t c){ | ||
109 | return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); | ||
110 | } | ||
111 | |||
112 | int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){ | ||
113 | int64_t b= bq.num * (int64_t)cq.den; | ||
114 | int64_t c= cq.num * (int64_t)bq.den; | ||
115 | return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); | ||
116 | } | ||
117 | |||
118 | #ifdef TEST | ||
119 | #include "integer.h" | ||
120 | #undef printf | ||
121 | int main(void){ | ||
122 | int64_t a,b,c,d,e; | ||
123 | |||
124 | for(a=7; a<(1LL<<62); a+=a/3+1){ | ||
125 | for(b=3; b<(1LL<<62); b+=b/4+1){ | ||
126 | for(c=9; c<(1LL<<62); c+=(c*2)/5+3){ | ||
127 | int64_t r= c/2; | ||
128 | AVInteger ai; | ||
129 | ai= av_mul_i(av_int2i(a), av_int2i(b)); | ||
130 | ai= av_add_i(ai, av_int2i(r)); | ||
131 | |||
132 | d= av_i2int(av_div_i(ai, av_int2i(c))); | ||
133 | |||
134 | e= av_rescale(a,b,c); | ||
135 | |||
136 | if((double)a * (double)b / (double)c > (1LL<<63)) | ||
137 | continue; | ||
138 | |||
139 | if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | return 0; | ||
144 | } | ||
145 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/mathematics.h b/src/plugins/ffmpeg/libavutil/mathematics.h deleted file mode 100644 index a9dfe7e..0000000 --- a/src/plugins/ffmpeg/libavutil/mathematics.h +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
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 FFMPEG_MATHEMATICS_H | ||
22 | #define FFMPEG_MATHEMATICS_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | #include "rational.h" | ||
26 | |||
27 | enum AVRounding { | ||
28 | AV_ROUND_ZERO = 0, ///< round toward zero | ||
29 | AV_ROUND_INF = 1, ///< round away from zero | ||
30 | AV_ROUND_DOWN = 2, ///< round toward -infinity | ||
31 | AV_ROUND_UP = 3, ///< round toward +infinity | ||
32 | AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero | ||
33 | }; | ||
34 | |||
35 | /** | ||
36 | * rescale a 64bit integer with rounding to nearest. | ||
37 | * a simple a*b/c isn't possible as it can overflow | ||
38 | */ | ||
39 | int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; | ||
40 | |||
41 | /** | ||
42 | * rescale a 64bit integer with specified rounding. | ||
43 | * a simple a*b/c isn't possible as it can overflow | ||
44 | */ | ||
45 | int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const; | ||
46 | |||
47 | /** | ||
48 | * rescale a 64bit integer by 2 rational numbers. | ||
49 | */ | ||
50 | int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; | ||
51 | |||
52 | #endif /* FFMPEG_MATHEMATICS_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/md5.c b/src/plugins/ffmpeg/libavutil/md5.c deleted file mode 100644 index ee39de1..0000000 --- a/src/plugins/ffmpeg/libavutil/md5.c +++ /dev/null | |||
@@ -1,182 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006 Michael Niedermayer (michaelni@gmx.at) | ||
3 | * Copyright (C) 2003-2005 by Christopher R. Hertel (crh@ubiqx.mn.org) | ||
4 | * | ||
5 | * References: | ||
6 | * IETF RFC 1321: The MD5 Message-Digest Algorithm | ||
7 | * Ron Rivest. IETF, April, 1992 | ||
8 | * | ||
9 | * based on http://ubiqx.org/libcifs/source/Auth/MD5.c | ||
10 | * from Christopher R. Hertel (crh@ubiqx.mn.org) | ||
11 | * Simplified, cleaned and IMO redundant comments removed by michael. | ||
12 | * | ||
13 | * If you use gcc, then version 4.1 or later and -fomit-frame-pointer is | ||
14 | * strongly recommended. | ||
15 | * | ||
16 | * This file is part of FFmpeg. | ||
17 | * | ||
18 | * FFmpeg is free software; you can redistribute it and/or | ||
19 | * modify it under the terms of the GNU Lesser General Public | ||
20 | * License as published by the Free Software Foundation; either | ||
21 | * version 2.1 of the License, or (at your option) any later version. | ||
22 | * | ||
23 | * FFmpeg is distributed in the hope that it will be useful, | ||
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
26 | * Lesser General Public License for more details. | ||
27 | * | ||
28 | * You should have received a copy of the GNU Lesser General Public | ||
29 | * License along with FFmpeg; if not, write to the Free Software | ||
30 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
31 | */ | ||
32 | |||
33 | #include "common.h" | ||
34 | #include <string.h> | ||
35 | #include "md5.h" | ||
36 | |||
37 | typedef struct AVMD5{ | ||
38 | uint64_t len; | ||
39 | uint8_t block[64]; | ||
40 | uint32_t ABCD[4]; | ||
41 | } AVMD5; | ||
42 | |||
43 | const int av_md5_size= sizeof(AVMD5); | ||
44 | |||
45 | static const uint8_t S[4][4] = { | ||
46 | { 7, 12, 17, 22 }, /* Round 1 */ | ||
47 | { 5, 9, 14, 20 }, /* Round 2 */ | ||
48 | { 4, 11, 16, 23 }, /* Round 3 */ | ||
49 | { 6, 10, 15, 21 } /* Round 4 */ | ||
50 | }; | ||
51 | |||
52 | static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32) | ||
53 | 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, /* Round 1 */ | ||
54 | 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, | ||
55 | 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, | ||
56 | 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, | ||
57 | |||
58 | 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, /* Round 2 */ | ||
59 | 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, | ||
60 | 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, | ||
61 | 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, | ||
62 | |||
63 | 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, /* Round 3 */ | ||
64 | 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, | ||
65 | 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, | ||
66 | 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, | ||
67 | |||
68 | 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, /* Round 4 */ | ||
69 | 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, | ||
70 | 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, | ||
71 | 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, | ||
72 | }; | ||
73 | |||
74 | #define CORE(i, a, b, c, d) \ | ||
75 | t = S[i>>4][i&3];\ | ||
76 | a += T[i];\ | ||
77 | \ | ||
78 | if(i<32){\ | ||
79 | if(i<16) a += (d ^ (b&(c^d))) + X[ i &15 ];\ | ||
80 | else a += (c ^ (d&(c^b))) + X[ (1+5*i)&15 ];\ | ||
81 | }else{\ | ||
82 | if(i<48) a += (b^c^d) + X[ (5+3*i)&15 ];\ | ||
83 | else a += (c^(b|~d)) + X[ ( 7*i)&15 ];\ | ||
84 | }\ | ||
85 | a = b + (( a << t ) | ( a >> (32 - t) )); | ||
86 | |||
87 | static void body(uint32_t ABCD[4], uint32_t X[16]){ | ||
88 | |||
89 | int t; | ||
90 | int i av_unused; | ||
91 | unsigned int a= ABCD[3]; | ||
92 | unsigned int b= ABCD[2]; | ||
93 | unsigned int c= ABCD[1]; | ||
94 | unsigned int d= ABCD[0]; | ||
95 | |||
96 | #ifdef WORDS_BIGENDIAN | ||
97 | for(i=0; i<16; i++) | ||
98 | X[i]= bswap_32(X[i]); | ||
99 | #endif | ||
100 | |||
101 | #ifdef CONFIG_SMALL | ||
102 | for( i = 0; i < 64; i++ ){ | ||
103 | CORE(i,a,b,c,d) | ||
104 | t=d; d=c; c=b; b=a; a=t; | ||
105 | } | ||
106 | #else | ||
107 | #define CORE2(i) CORE(i,a,b,c,d) CORE((i+1),d,a,b,c) CORE((i+2),c,d,a,b) CORE((i+3),b,c,d,a) | ||
108 | #define CORE4(i) CORE2(i) CORE2((i+4)) CORE2((i+8)) CORE2((i+12)) | ||
109 | CORE4(0) CORE4(16) CORE4(32) CORE4(48) | ||
110 | #endif | ||
111 | |||
112 | ABCD[0] += d; | ||
113 | ABCD[1] += c; | ||
114 | ABCD[2] += b; | ||
115 | ABCD[3] += a; | ||
116 | } | ||
117 | |||
118 | void av_md5_init(AVMD5 *ctx){ | ||
119 | ctx->len = 0; | ||
120 | |||
121 | ctx->ABCD[0] = 0x10325476; | ||
122 | ctx->ABCD[1] = 0x98badcfe; | ||
123 | ctx->ABCD[2] = 0xefcdab89; | ||
124 | ctx->ABCD[3] = 0x67452301; | ||
125 | } | ||
126 | |||
127 | void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len){ | ||
128 | int i, j; | ||
129 | |||
130 | j= ctx->len & 63; | ||
131 | ctx->len += len; | ||
132 | |||
133 | for( i = 0; i < len; i++ ){ | ||
134 | ctx->block[j++] = src[i]; | ||
135 | if( 64 == j ){ | ||
136 | body(ctx->ABCD, (uint32_t*) ctx->block); | ||
137 | j = 0; | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | |||
142 | void av_md5_final(AVMD5 *ctx, uint8_t *dst){ | ||
143 | int i; | ||
144 | uint64_t finalcount= le2me_64(ctx->len<<3); | ||
145 | |||
146 | av_md5_update(ctx, "\200", 1); | ||
147 | while((ctx->len & 63)<56) | ||
148 | av_md5_update(ctx, "", 1); | ||
149 | |||
150 | av_md5_update(ctx, (uint8_t*)&finalcount, 8); | ||
151 | |||
152 | for(i=0; i<4; i++) | ||
153 | ((uint32_t*)dst)[i]= le2me_32(ctx->ABCD[3-i]); | ||
154 | } | ||
155 | |||
156 | void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len){ | ||
157 | AVMD5 ctx[1]; | ||
158 | |||
159 | av_md5_init(ctx); | ||
160 | av_md5_update(ctx, src, len); | ||
161 | av_md5_final(ctx, dst); | ||
162 | } | ||
163 | |||
164 | #ifdef TEST | ||
165 | #include <stdio.h> | ||
166 | #undef printf | ||
167 | int main(void){ | ||
168 | uint64_t md5val; | ||
169 | int i; | ||
170 | uint8_t in[1000]; | ||
171 | |||
172 | for(i=0; i<1000; i++) in[i]= i*i; | ||
173 | av_md5_sum( (uint8_t*)&md5val, in, 1000); printf("%"PRId64"\n", md5val); | ||
174 | av_md5_sum( (uint8_t*)&md5val, in, 63); printf("%"PRId64"\n", md5val); | ||
175 | av_md5_sum( (uint8_t*)&md5val, in, 64); printf("%"PRId64"\n", md5val); | ||
176 | av_md5_sum( (uint8_t*)&md5val, in, 65); printf("%"PRId64"\n", md5val); | ||
177 | for(i=0; i<1000; i++) in[i]= i % 127; | ||
178 | av_md5_sum( (uint8_t*)&md5val, in, 999); printf("%"PRId64"\n", md5val); | ||
179 | |||
180 | return 0; | ||
181 | } | ||
182 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/md5.h b/src/plugins/ffmpeg/libavutil/md5.h deleted file mode 100644 index 7d63df0..0000000 --- a/src/plugins/ffmpeg/libavutil/md5.h +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
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 FFMPEG_MD5_H | ||
22 | #define FFMPEG_MD5_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | |||
26 | extern const int av_md5_size; | ||
27 | |||
28 | struct AVMD5; | ||
29 | |||
30 | void av_md5_init(struct AVMD5 *ctx); | ||
31 | void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); | ||
32 | void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); | ||
33 | void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len); | ||
34 | |||
35 | #endif /* FFMPEG_MD5_H */ | ||
36 | |||
diff --git a/src/plugins/ffmpeg/libavutil/mem.c b/src/plugins/ffmpeg/libavutil/mem.c deleted file mode 100644 index 960074c..0000000 --- a/src/plugins/ffmpeg/libavutil/mem.c +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
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 mem.c | ||
24 | * default memory allocator for libavutil. | ||
25 | */ | ||
26 | |||
27 | #include "common.h" | ||
28 | |||
29 | /* here we can use OS dependent allocation functions */ | ||
30 | #undef malloc | ||
31 | #undef free | ||
32 | #undef realloc | ||
33 | |||
34 | #ifdef HAVE_MALLOC_H | ||
35 | #include <malloc.h> | ||
36 | #endif | ||
37 | |||
38 | /* you can redefine av_malloc and av_free in your project to use your | ||
39 | memory allocator. You do not need to suppress this file because the | ||
40 | linker will do it automatically */ | ||
41 | |||
42 | void *av_malloc(unsigned int size) | ||
43 | { | ||
44 | void *ptr; | ||
45 | #ifdef CONFIG_MEMALIGN_HACK | ||
46 | long diff; | ||
47 | #endif | ||
48 | |||
49 | /* let's disallow possible ambiguous cases */ | ||
50 | if(size > (INT_MAX-16) ) | ||
51 | return NULL; | ||
52 | |||
53 | #ifdef CONFIG_MEMALIGN_HACK | ||
54 | ptr = malloc(size+16); | ||
55 | if(!ptr) | ||
56 | return ptr; | ||
57 | diff= ((-(long)ptr - 1)&15) + 1; | ||
58 | ptr = (char*)ptr + diff; | ||
59 | ((char*)ptr)[-1]= diff; | ||
60 | #elif defined (HAVE_MEMALIGN) | ||
61 | ptr = memalign(16,size); | ||
62 | /* Why 64? | ||
63 | Indeed, we should align it: | ||
64 | on 4 for 386 | ||
65 | on 16 for 486 | ||
66 | on 32 for 586, PPro - k6-III | ||
67 | on 64 for K7 (maybe for P3 too). | ||
68 | Because L1 and L2 caches are aligned on those values. | ||
69 | But I don't want to code such logic here! | ||
70 | */ | ||
71 | /* Why 16? | ||
72 | Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs | ||
73 | it will just trigger an exception and the unaligned load will be done in the | ||
74 | exception handler or it will just segfault (SSE2 on P4) | ||
75 | Why not larger? Because I did not see a difference in benchmarks ... | ||
76 | */ | ||
77 | /* benchmarks with p3 | ||
78 | memalign(64)+1 3071,3051,3032 | ||
79 | memalign(64)+2 3051,3032,3041 | ||
80 | memalign(64)+4 2911,2896,2915 | ||
81 | memalign(64)+8 2545,2554,2550 | ||
82 | memalign(64)+16 2543,2572,2563 | ||
83 | memalign(64)+32 2546,2545,2571 | ||
84 | memalign(64)+64 2570,2533,2558 | ||
85 | |||
86 | btw, malloc seems to do 8 byte alignment by default here | ||
87 | */ | ||
88 | #else | ||
89 | ptr = malloc(size); | ||
90 | #endif | ||
91 | return ptr; | ||
92 | } | ||
93 | |||
94 | void *av_realloc(void *ptr, unsigned int size) | ||
95 | { | ||
96 | #ifdef CONFIG_MEMALIGN_HACK | ||
97 | int diff; | ||
98 | #endif | ||
99 | |||
100 | /* let's disallow possible ambiguous cases */ | ||
101 | if(size > (INT_MAX-16) ) | ||
102 | return NULL; | ||
103 | |||
104 | #ifdef CONFIG_MEMALIGN_HACK | ||
105 | //FIXME this isn't aligned correctly, though it probably isn't needed | ||
106 | if(!ptr) return av_malloc(size); | ||
107 | diff= ((char*)ptr)[-1]; | ||
108 | return (char*)realloc((char*)ptr - diff, size + diff) + diff; | ||
109 | #else | ||
110 | return realloc(ptr, size); | ||
111 | #endif | ||
112 | } | ||
113 | |||
114 | void av_free(void *ptr) | ||
115 | { | ||
116 | /* XXX: this test should not be needed on most libcs */ | ||
117 | if (ptr) | ||
118 | #ifdef CONFIG_MEMALIGN_HACK | ||
119 | free((char*)ptr - ((char*)ptr)[-1]); | ||
120 | #else | ||
121 | free(ptr); | ||
122 | #endif | ||
123 | } | ||
124 | |||
125 | void av_freep(void *arg) | ||
126 | { | ||
127 | void **ptr= (void**)arg; | ||
128 | av_free(*ptr); | ||
129 | *ptr = NULL; | ||
130 | } | ||
131 | |||
132 | void *av_mallocz(unsigned int size) | ||
133 | { | ||
134 | void *ptr = av_malloc(size); | ||
135 | if (ptr) | ||
136 | memset(ptr, 0, size); | ||
137 | return ptr; | ||
138 | } | ||
139 | |||
140 | char *av_strdup(const char *s) | ||
141 | { | ||
142 | char *ptr= NULL; | ||
143 | if(s){ | ||
144 | int len = strlen(s) + 1; | ||
145 | ptr = av_malloc(len); | ||
146 | if (ptr) | ||
147 | memcpy(ptr, s, len); | ||
148 | } | ||
149 | return ptr; | ||
150 | } | ||
151 | |||
diff --git a/src/plugins/ffmpeg/libavutil/mem.h b/src/plugins/ffmpeg/libavutil/mem.h deleted file mode 100644 index 84d647d..0000000 --- a/src/plugins/ffmpeg/libavutil/mem.h +++ /dev/null | |||
@@ -1,119 +0,0 @@ | |||
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 mem.h | ||
23 | * Memory handling functions. | ||
24 | */ | ||
25 | |||
26 | #ifndef FFMPEG_MEM_H | ||
27 | #define FFMPEG_MEM_H | ||
28 | |||
29 | #ifdef __ICC | ||
30 | #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) | ||
31 | #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v | ||
32 | #elif defined(__GNUC__) | ||
33 | #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) | ||
34 | #define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n))) | ||
35 | #elif defined(_MSC_VER) | ||
36 | #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v | ||
37 | #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v | ||
38 | #elif defined(HAVE_INLINE_ASM) | ||
39 | #error The asm code needs alignment, but we do not know how to do it for this compiler. | ||
40 | #else | ||
41 | #define DECLARE_ALIGNED(n,t,v) t v | ||
42 | #define DECLARE_ASM_CONST(n,t,v) static const t v | ||
43 | #endif | ||
44 | |||
45 | #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) | ||
46 | #define av_malloc_attrib __attribute__((__malloc__)) | ||
47 | #else | ||
48 | #define av_malloc_attrib | ||
49 | #endif | ||
50 | |||
51 | #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 2) | ||
52 | #define av_alloc_size(n) __attribute__((alloc_size(n))) | ||
53 | #else | ||
54 | #define av_alloc_size(n) | ||
55 | #endif | ||
56 | |||
57 | /** | ||
58 | * Allocate a block of \p size bytes with alignment suitable for all | ||
59 | * memory accesses (including vectors if available on the CPU). | ||
60 | * @param size Size in bytes for the memory block to be allocated. | ||
61 | * @return Pointer to the allocated block, NULL if it cannot allocate | ||
62 | * it. | ||
63 | * @see av_mallocz() | ||
64 | */ | ||
65 | void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
66 | |||
67 | /** | ||
68 | * Allocate or reallocate a block of memory. | ||
69 | * If \p ptr is NULL and \p size > 0, allocate a new block. If \p | ||
70 | * size is zero, free the memory block pointed by \p ptr. | ||
71 | * @param size Size in bytes for the memory block to be allocated or | ||
72 | * reallocated. | ||
73 | * @param ptr Pointer to a memory block already allocated with | ||
74 | * av_malloc(z)() or av_realloc() or NULL. | ||
75 | * @return Pointer to a newly reallocated block or NULL if it cannot | ||
76 | * reallocate or the function is used to free the memory block. | ||
77 | * @see av_fast_realloc() | ||
78 | */ | ||
79 | void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); | ||
80 | |||
81 | /** | ||
82 | * Free a memory block which has been allocated with av_malloc(z)() or | ||
83 | * av_realloc(). | ||
84 | * @param ptr Pointer to the memory block which should be freed. | ||
85 | * @note ptr = NULL is explicitly allowed. | ||
86 | * @note It is recommended that you use av_freep() instead. | ||
87 | * @see av_freep() | ||
88 | */ | ||
89 | void av_free(void *ptr); | ||
90 | |||
91 | /** | ||
92 | * Allocate a block of \p size bytes with alignment suitable for all | ||
93 | * memory accesses (including vectors if available on the CPU) and | ||
94 | * set to zeroes all the bytes of the block. | ||
95 | * @param size Size in bytes for the memory block to be allocated. | ||
96 | * @return Pointer to the allocated block, NULL if it cannot allocate | ||
97 | * it. | ||
98 | * @see av_malloc() | ||
99 | */ | ||
100 | void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
101 | |||
102 | /** | ||
103 | * Duplicate the string \p s. | ||
104 | * @param s String to be duplicated. | ||
105 | * @return Pointer to a newly allocated string containing a | ||
106 | * copy of \p s or NULL if it cannot be allocated. | ||
107 | */ | ||
108 | char *av_strdup(const char *s) av_malloc_attrib; | ||
109 | |||
110 | /** | ||
111 | * Free a memory block which has been allocated with av_malloc(z)() or | ||
112 | * av_realloc() and set to NULL the pointer to it. | ||
113 | * @param ptr Pointer to the pointer to the memory block which should | ||
114 | * be freed. | ||
115 | * @see av_free() | ||
116 | */ | ||
117 | void av_freep(void *ptr); | ||
118 | |||
119 | #endif /* FFMPEG_MEM_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/random.c b/src/plugins/ffmpeg/libavutil/random.c deleted file mode 100644 index c3e71e6..0000000 --- a/src/plugins/ffmpeg/libavutil/random.c +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /* | ||
2 | * Mersenne Twister Random Algorithm | ||
3 | * Copyright (c) 2006 Ryan Martell. | ||
4 | * Based on A C-program for MT19937, with initialization improved 2002/1/26. Coded by | ||
5 | * Takuji Nishimura and Makoto Matsumoto. | ||
6 | * | ||
7 | * This file is part of FFmpeg. | ||
8 | * | ||
9 | * FFmpeg is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Lesser General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2.1 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * FFmpeg is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with FFmpeg; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | */ | ||
23 | |||
24 | |||
25 | /** | ||
26 | see http://en.wikipedia.org/wiki/Mersenne_twister for an explanation of this algorithm. | ||
27 | */ | ||
28 | #include <stdio.h> | ||
29 | #include "random.h" | ||
30 | |||
31 | //#define DEBUG | ||
32 | |||
33 | #ifdef DEBUG | ||
34 | #include "common.h" | ||
35 | #include "log.h" | ||
36 | #endif | ||
37 | |||
38 | |||
39 | /* Period parameters */ | ||
40 | #define M 397 | ||
41 | #define A 0x9908b0df /* constant vector a */ | ||
42 | #define UPPER_MASK 0x80000000 /* most significant w-r bits */ | ||
43 | #define LOWER_MASK 0x7fffffff /* least significant r bits */ | ||
44 | |||
45 | /** initializes mt[AV_RANDOM_N] with a seed */ | ||
46 | void av_init_random(unsigned int seed, AVRandomState *state) | ||
47 | { | ||
48 | int index; | ||
49 | |||
50 | /* | ||
51 | This differs from the wikipedia article. Source is from the Makoto | ||
52 | Makoto Matsumoto and Takuji Nishimura code, with the following comment: | ||
53 | */ | ||
54 | /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ | ||
55 | /* In the previous versions, MSBs of the seed affect */ | ||
56 | /* only MSBs of the array mt[]. */ | ||
57 | state->mt[0] = seed & 0xffffffff; | ||
58 | for (index = 1; index < AV_RANDOM_N; index++) { | ||
59 | unsigned int prev= state->mt[index - 1]; | ||
60 | state->mt[index] = (1812433253UL * (prev ^ (prev>>30)) + index) & 0xffffffff; | ||
61 | } | ||
62 | state->index= index; // will cause it to generate untempered numbers the first iteration | ||
63 | } | ||
64 | |||
65 | /** generate AV_RANDOM_N words at one time (which will then be tempered later) (av_random calls this; you shouldn't) */ | ||
66 | void av_random_generate_untempered_numbers(AVRandomState *state) | ||
67 | { | ||
68 | int kk; | ||
69 | unsigned int y; | ||
70 | |||
71 | for (kk = 0; kk < AV_RANDOM_N - M; kk++) { | ||
72 | y = (state->mt[kk] & UPPER_MASK) | (state->mt[kk + 1] & LOWER_MASK); | ||
73 | state->mt[kk] = state->mt[kk + M] ^ (y >> 1) ^ ((y&1)*A); | ||
74 | } | ||
75 | for (; kk < AV_RANDOM_N - 1; kk++) { | ||
76 | y = (state->mt[kk] & UPPER_MASK) | (state->mt[kk + 1] & LOWER_MASK); | ||
77 | state->mt[kk] = state->mt[kk + (M - AV_RANDOM_N)] ^ (y >> 1) ^ ((y&1)*A); | ||
78 | } | ||
79 | y = (state->mt[AV_RANDOM_N - 1] & UPPER_MASK) | (state->mt[0] & LOWER_MASK); | ||
80 | state->mt[AV_RANDOM_N - 1] = state->mt[M - 1] ^ (y >> 1) ^ ((y&1)*A); | ||
81 | state->index = 0; | ||
82 | } | ||
83 | |||
84 | #ifdef DEBUG | ||
85 | void av_benchmark_random(void) | ||
86 | { | ||
87 | int x=0; | ||
88 | int i, j; | ||
89 | AVRandomState state; | ||
90 | |||
91 | av_init_random(0xdeadbeef, &state); | ||
92 | for (j = 0; j < 100; j++) { | ||
93 | START_TIMER; | ||
94 | x+= av_random(&state); | ||
95 | STOP_TIMER("first call to av_random"); | ||
96 | for (i = 1; i < AV_RANDOM_N; i++) { | ||
97 | START_TIMER; | ||
98 | x+= av_random(&state); | ||
99 | STOP_TIMER("AV_RANDOM_N calls of av_random"); | ||
100 | } | ||
101 | } | ||
102 | av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x); | ||
103 | } | ||
104 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/random.h b/src/plugins/ffmpeg/libavutil/random.h deleted file mode 100644 index 4d00d7e..0000000 --- a/src/plugins/ffmpeg/libavutil/random.h +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | /* | ||
2 | * Mersenne Twister Random Algorithm | ||
3 | * Copyright (c) 2006 Ryan Martell. | ||
4 | * Based on A C-program for MT19937, with initialization improved 2002/1/26. Coded by | ||
5 | * Takuji Nishimura and Makoto Matsumoto. | ||
6 | * | ||
7 | * This file is part of FFmpeg. | ||
8 | * | ||
9 | * FFmpeg is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Lesser General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2.1 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * FFmpeg is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with FFmpeg; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | */ | ||
23 | |||
24 | #ifndef FFMPEG_RANDOM_H | ||
25 | #define FFMPEG_RANDOM_H | ||
26 | |||
27 | #define AV_RANDOM_N 624 | ||
28 | |||
29 | typedef struct { | ||
30 | unsigned int mt[AV_RANDOM_N]; ///< the array for the state vector | ||
31 | int index; ///< current untempered value we use as the base. | ||
32 | } AVRandomState; | ||
33 | |||
34 | |||
35 | void av_init_random(unsigned int seed, AVRandomState *state); ///< to be inlined, the struct must be visible, so it doesn't make sense to try and keep it opaque with malloc/free like calls | ||
36 | void av_random_generate_untempered_numbers(AVRandomState *state); ///< Regenerate the untempered numbers (must be done every 624 iterations, or it will loop) | ||
37 | |||
38 | /** generates a random number on [0,0xffffffff]-interval */ | ||
39 | static inline unsigned int av_random(AVRandomState *state) | ||
40 | { | ||
41 | unsigned int y; | ||
42 | |||
43 | // regenerate the untempered numbers if we should... | ||
44 | if (state->index >= AV_RANDOM_N) | ||
45 | av_random_generate_untempered_numbers(state); | ||
46 | |||
47 | // grab one... | ||
48 | y = state->mt[state->index++]; | ||
49 | |||
50 | /* Now temper (Mersenne Twister coefficients) The coefficients for MT19937 are.. */ | ||
51 | y ^= (y >> 11); | ||
52 | y ^= (y << 7) & 0x9d2c5680; | ||
53 | y ^= (y << 15) & 0xefc60000; | ||
54 | y ^= (y >> 18); | ||
55 | |||
56 | return y; | ||
57 | } | ||
58 | |||
59 | /** return random in range [0-1] as double */ | ||
60 | static inline double av_random_real1(AVRandomState *state) | ||
61 | { | ||
62 | /* divided by 2^32-1 */ | ||
63 | return av_random(state) * (1.0 / 4294967296.0); | ||
64 | } | ||
65 | |||
66 | // only available if DEBUG is defined in the .c file | ||
67 | void av_benchmark_random(void); | ||
68 | |||
69 | #endif /* FFMPEG_RANDOM_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/rational.c b/src/plugins/ffmpeg/libavutil/rational.c deleted file mode 100644 index 96a4c54..0000000 --- a/src/plugins/ffmpeg/libavutil/rational.c +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | * Rational numbers | ||
3 | * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> | ||
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 rational.c | ||
24 | * Rational numbers | ||
25 | * @author Michael Niedermayer <michaelni@gmx.at> | ||
26 | */ | ||
27 | |||
28 | //#include <math.h> | ||
29 | #include <limits.h> | ||
30 | |||
31 | #include "common.h" | ||
32 | #include "mathematics.h" | ||
33 | #include "rational.h" | ||
34 | |||
35 | int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){ | ||
36 | AVRational a0={0,1}, a1={1,0}; | ||
37 | int sign= (nom<0) ^ (den<0); | ||
38 | int64_t gcd= ff_gcd(FFABS(nom), FFABS(den)); | ||
39 | |||
40 | if(gcd){ | ||
41 | nom = FFABS(nom)/gcd; | ||
42 | den = FFABS(den)/gcd; | ||
43 | } | ||
44 | if(nom<=max && den<=max){ | ||
45 | a1= (AVRational){nom, den}; | ||
46 | den=0; | ||
47 | } | ||
48 | |||
49 | while(den){ | ||
50 | uint64_t x = nom / den; | ||
51 | int64_t next_den= nom - den*x; | ||
52 | int64_t a2n= x*a1.num + a0.num; | ||
53 | int64_t a2d= x*a1.den + a0.den; | ||
54 | |||
55 | if(a2n > max || a2d > max){ | ||
56 | if(a1.num) x= (max - a0.num) / a1.num; | ||
57 | if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den); | ||
58 | |||
59 | if (den*(2*x*a1.den + a0.den) > nom*a1.den) | ||
60 | a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den}; | ||
61 | break; | ||
62 | } | ||
63 | |||
64 | a0= a1; | ||
65 | a1= (AVRational){a2n, a2d}; | ||
66 | nom= den; | ||
67 | den= next_den; | ||
68 | } | ||
69 | assert(ff_gcd(a1.num, a1.den) <= 1U); | ||
70 | |||
71 | *dst_nom = sign ? -a1.num : a1.num; | ||
72 | *dst_den = a1.den; | ||
73 | |||
74 | return den==0; | ||
75 | } | ||
76 | |||
77 | AVRational av_mul_q(AVRational b, AVRational c){ | ||
78 | av_reduce(&b.num, &b.den, b.num * (int64_t)c.num, b.den * (int64_t)c.den, INT_MAX); | ||
79 | return b; | ||
80 | } | ||
81 | |||
82 | AVRational av_div_q(AVRational b, AVRational c){ | ||
83 | return av_mul_q(b, (AVRational){c.den, c.num}); | ||
84 | } | ||
85 | |||
86 | AVRational av_add_q(AVRational b, AVRational c){ | ||
87 | av_reduce(&b.num, &b.den, b.num * (int64_t)c.den + c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX); | ||
88 | return b; | ||
89 | } | ||
90 | |||
91 | AVRational av_sub_q(AVRational b, AVRational c){ | ||
92 | return av_add_q(b, (AVRational){-c.num, c.den}); | ||
93 | } | ||
94 | |||
95 | AVRational av_d2q(double d, int max){ | ||
96 | AVRational a; | ||
97 | #define LOG2 0.69314718055994530941723212145817656807550013436025 | ||
98 | int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0); | ||
99 | int64_t den= 1LL << (61 - exponent); | ||
100 | av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); | ||
101 | |||
102 | return a; | ||
103 | } | ||
diff --git a/src/plugins/ffmpeg/libavutil/rational.h b/src/plugins/ffmpeg/libavutil/rational.h deleted file mode 100644 index 2f0017c..0000000 --- a/src/plugins/ffmpeg/libavutil/rational.h +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | /* | ||
2 | * Rational numbers | ||
3 | * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> | ||
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 rational.h | ||
24 | * Rational numbers. | ||
25 | * @author Michael Niedermayer <michaelni@gmx.at> | ||
26 | */ | ||
27 | |||
28 | #ifndef FFMPEG_RATIONAL_H | ||
29 | #define FFMPEG_RATIONAL_H | ||
30 | |||
31 | #include <stdint.h> | ||
32 | #include "common.h" | ||
33 | |||
34 | /** | ||
35 | * Rational number num/den. | ||
36 | */ | ||
37 | typedef struct AVRational{ | ||
38 | int num; ///< numerator | ||
39 | int den; ///< denominator | ||
40 | } AVRational; | ||
41 | |||
42 | /** | ||
43 | * Compare two rationals. | ||
44 | * @param a first rational | ||
45 | * @param b second rational | ||
46 | * @return 0 if a==b, 1 if a>b and -1 if a<b. | ||
47 | */ | ||
48 | static inline int av_cmp_q(AVRational a, AVRational b){ | ||
49 | const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den; | ||
50 | |||
51 | if(tmp) return (tmp>>63)|1; | ||
52 | else return 0; | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * Rational to double conversion. | ||
57 | * @param a rational to convert | ||
58 | * @return (double) a | ||
59 | */ | ||
60 | static inline double av_q2d(AVRational a){ | ||
61 | return a.num / (double) a.den; | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * Reduce a fraction. | ||
66 | * This is useful for framerate calculations. | ||
67 | * @param dst_nom destination numerator | ||
68 | * @param dst_den destination denominator | ||
69 | * @param nom source numerator | ||
70 | * @param den source denominator | ||
71 | * @param max the maximum allowed for dst_nom & dst_den | ||
72 | * @return 1 if exact, 0 otherwise | ||
73 | */ | ||
74 | int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max); | ||
75 | |||
76 | /** | ||
77 | * Multiplies two rationals. | ||
78 | * @param b first rational. | ||
79 | * @param c second rational. | ||
80 | * @return b*c. | ||
81 | */ | ||
82 | AVRational av_mul_q(AVRational b, AVRational c) av_const; | ||
83 | |||
84 | /** | ||
85 | * Divides one rational by another. | ||
86 | * @param b first rational. | ||
87 | * @param c second rational. | ||
88 | * @return b/c. | ||
89 | */ | ||
90 | AVRational av_div_q(AVRational b, AVRational c) av_const; | ||
91 | |||
92 | /** | ||
93 | * Adds two rationals. | ||
94 | * @param b first rational. | ||
95 | * @param c second rational. | ||
96 | * @return b+c. | ||
97 | */ | ||
98 | AVRational av_add_q(AVRational b, AVRational c) av_const; | ||
99 | |||
100 | /** | ||
101 | * Subtracts one rational from another. | ||
102 | * @param b first rational. | ||
103 | * @param c second rational. | ||
104 | * @return b-c. | ||
105 | */ | ||
106 | AVRational av_sub_q(AVRational b, AVRational c) av_const; | ||
107 | |||
108 | /** | ||
109 | * Converts a double precision floating point number to a rational. | ||
110 | * @param d double to convert | ||
111 | * @param max the maximum allowed numerator and denominator | ||
112 | * @return (AVRational) d. | ||
113 | */ | ||
114 | AVRational av_d2q(double d, int max) av_const; | ||
115 | |||
116 | #endif /* FFMPEG_RATIONAL_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/rc4.c b/src/plugins/ffmpeg/libavutil/rc4.c deleted file mode 100644 index 0cf71a4..0000000 --- a/src/plugins/ffmpeg/libavutil/rc4.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /* | ||
2 | * RC4 encryption/decryption/pseudo-random number generator | ||
3 | * Copyright (c) 2007 Reimar Doeffinger | ||
4 | * | ||
5 | * loosely based on LibTomCrypt by Tom St Denis | ||
6 | * | ||
7 | * This file is part of FFmpeg. | ||
8 | * | ||
9 | * FFmpeg is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Lesser General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2.1 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * FFmpeg is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with FFmpeg; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | */ | ||
23 | #include "common.h" | ||
24 | #include "rc4.h" | ||
25 | |||
26 | void ff_rc4_enc(const uint8_t *key, int keylen, uint8_t *data, int datalen) { | ||
27 | int i, j; | ||
28 | uint8_t x, y; | ||
29 | uint8_t state[256]; | ||
30 | for (i = 0; i < 256; i++) | ||
31 | state[i] = i; | ||
32 | y = 0; | ||
33 | // j is i % keylen | ||
34 | for (j = 0, i = 0; i < 256; i++, j++) { | ||
35 | if (j == keylen) j = 0; | ||
36 | y += state[i] + key[j]; | ||
37 | FFSWAP(uint8_t, state[i], state[y]); | ||
38 | } | ||
39 | // state initialized, now do the real encryption | ||
40 | x = 1; y = state[1]; | ||
41 | while (datalen-- > 0) { | ||
42 | uint8_t sum = state[x] + state[y]; | ||
43 | FFSWAP(uint8_t, state[x], state[y]); | ||
44 | *data++ ^= state[sum]; | ||
45 | x++; | ||
46 | y += state[x]; | ||
47 | } | ||
48 | } | ||
diff --git a/src/plugins/ffmpeg/libavutil/rc4.h b/src/plugins/ffmpeg/libavutil/rc4.h deleted file mode 100644 index 882fa23..0000000 --- a/src/plugins/ffmpeg/libavutil/rc4.h +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | /* | ||
2 | * RC4 encryption/decryption/pseudo-random number generator | ||
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 FFMPEG_RC4_H | ||
22 | #define FFMPEG_RC4_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | |||
26 | void ff_rc4_enc(const uint8_t *key, int keylen, uint8_t *data, int datalen); | ||
27 | |||
28 | #endif /* FFMPEG_RC4_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/sha1.c b/src/plugins/ffmpeg/libavutil/sha1.c deleted file mode 100644 index 61ad38d..0000000 --- a/src/plugins/ffmpeg/libavutil/sha1.c +++ /dev/null | |||
@@ -1,180 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * based on public domain SHA-1 code by Steve Reid <steve@edmweb.com> | ||
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 "common.h" | ||
23 | #include "bswap.h" | ||
24 | #include "sha1.h" | ||
25 | |||
26 | typedef struct AVSHA1 { | ||
27 | uint64_t count; | ||
28 | uint8_t buffer[64]; | ||
29 | uint32_t state[5]; | ||
30 | } AVSHA1; | ||
31 | |||
32 | const int av_sha1_size = sizeof(AVSHA1); | ||
33 | |||
34 | #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) | ||
35 | |||
36 | /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ | ||
37 | #define blk0(i) (block[i] = be2me_32(((const uint32_t*)buffer)[i])) | ||
38 | #define blk(i) (block[i] = rol(block[i-3]^block[i-8]^block[i-14]^block[i-16],1)) | ||
39 | |||
40 | #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y) +blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); | ||
41 | #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y) +blk (i)+0x5A827999+rol(v,5);w=rol(w,30); | ||
42 | #define R2(v,w,x,y,z,i) z+=( w^x ^y) +blk (i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); | ||
43 | #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk (i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); | ||
44 | #define R4(v,w,x,y,z,i) z+=( w^x ^y) +blk (i)+0xCA62C1D6+rol(v,5);w=rol(w,30); | ||
45 | |||
46 | /* Hash a single 512-bit block. This is the core of the algorithm. */ | ||
47 | |||
48 | static void transform(uint32_t state[5], const uint8_t buffer[64]){ | ||
49 | uint32_t block[80]; | ||
50 | unsigned int i, a, b, c, d, e; | ||
51 | |||
52 | a = state[0]; | ||
53 | b = state[1]; | ||
54 | c = state[2]; | ||
55 | d = state[3]; | ||
56 | e = state[4]; | ||
57 | #ifdef CONFIG_SMALL | ||
58 | for(i=0; i<80; i++){ | ||
59 | int t; | ||
60 | if(i<16) t= be2me_32(((uint32_t*)buffer)[i]); | ||
61 | else t= rol(block[i-3]^block[i-8]^block[i-14]^block[i-16],1); | ||
62 | block[i]= t; | ||
63 | t+= e+rol(a,5); | ||
64 | if(i<40){ | ||
65 | if(i<20) t+= ((b&(c^d))^d) +0x5A827999; | ||
66 | else t+= ( b^c ^d) +0x6ED9EBA1; | ||
67 | }else{ | ||
68 | if(i<60) t+= (((b|c)&d)|(b&c))+0x8F1BBCDC; | ||
69 | else t+= ( b^c ^d) +0xCA62C1D6; | ||
70 | } | ||
71 | e= d; | ||
72 | d= c; | ||
73 | c= rol(b,30); | ||
74 | b= a; | ||
75 | a= t; | ||
76 | } | ||
77 | #else | ||
78 | for(i=0; i<15; i+=5){ | ||
79 | R0(a,b,c,d,e,0+i); R0(e,a,b,c,d,1+i); R0(d,e,a,b,c,2+i); R0(c,d,e,a,b,3+i); R0(b,c,d,e,a,4+i); | ||
80 | } | ||
81 | R0(a,b,c,d,e,15); R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); | ||
82 | for(i=20; i<40; i+=5){ | ||
83 | R2(a,b,c,d,e,0+i); R2(e,a,b,c,d,1+i); R2(d,e,a,b,c,2+i); R2(c,d,e,a,b,3+i); R2(b,c,d,e,a,4+i); | ||
84 | } | ||
85 | for(; i<60; i+=5){ | ||
86 | R3(a,b,c,d,e,0+i); R3(e,a,b,c,d,1+i); R3(d,e,a,b,c,2+i); R3(c,d,e,a,b,3+i); R3(b,c,d,e,a,4+i); | ||
87 | } | ||
88 | for(; i<80; i+=5){ | ||
89 | R4(a,b,c,d,e,0+i); R4(e,a,b,c,d,1+i); R4(d,e,a,b,c,2+i); R4(c,d,e,a,b,3+i); R4(b,c,d,e,a,4+i); | ||
90 | } | ||
91 | #endif | ||
92 | state[0] += a; | ||
93 | state[1] += b; | ||
94 | state[2] += c; | ||
95 | state[3] += d; | ||
96 | state[4] += e; | ||
97 | } | ||
98 | |||
99 | void av_sha1_init(AVSHA1* ctx){ | ||
100 | ctx->state[0] = 0x67452301; | ||
101 | ctx->state[1] = 0xEFCDAB89; | ||
102 | ctx->state[2] = 0x98BADCFE; | ||
103 | ctx->state[3] = 0x10325476; | ||
104 | ctx->state[4] = 0xC3D2E1F0; | ||
105 | ctx->count = 0; | ||
106 | } | ||
107 | |||
108 | void av_sha1_update(AVSHA1* ctx, const uint8_t* data, unsigned int len){ | ||
109 | unsigned int i, j; | ||
110 | |||
111 | j = ctx->count & 63; | ||
112 | ctx->count += len; | ||
113 | #ifdef CONFIG_SMALL | ||
114 | for( i = 0; i < len; i++ ){ | ||
115 | ctx->buffer[ j++ ] = data[i]; | ||
116 | if( 64 == j ){ | ||
117 | transform(ctx->state, ctx->buffer); | ||
118 | j = 0; | ||
119 | } | ||
120 | } | ||
121 | #else | ||
122 | if ((j + len) > 63) { | ||
123 | memcpy(&ctx->buffer[j], data, (i = 64-j)); | ||
124 | transform(ctx->state, ctx->buffer); | ||
125 | for ( ; i + 63 < len; i += 64) { | ||
126 | transform(ctx->state, &data[i]); | ||
127 | } | ||
128 | j=0; | ||
129 | } | ||
130 | else i = 0; | ||
131 | memcpy(&ctx->buffer[j], &data[i], len - i); | ||
132 | #endif | ||
133 | } | ||
134 | |||
135 | void av_sha1_final(AVSHA1* ctx, uint8_t digest[20]){ | ||
136 | int i; | ||
137 | uint64_t finalcount= be2me_64(ctx->count<<3); | ||
138 | |||
139 | av_sha1_update(ctx, "\200", 1); | ||
140 | while ((ctx->count & 63) != 56) { | ||
141 | av_sha1_update(ctx, "", 1); | ||
142 | } | ||
143 | av_sha1_update(ctx, (uint8_t *)&finalcount, 8); /* Should cause a transform() */ | ||
144 | for(i=0; i<5; i++) | ||
145 | ((uint32_t*)digest)[i]= be2me_32(ctx->state[i]); | ||
146 | } | ||
147 | |||
148 | // use the following to test | ||
149 | // gcc -DTEST -DHAVE_AV_CONFIG_H -I.. sha1.c -O2 -W -Wall -o sha1 && time ./sha1 | ||
150 | #ifdef TEST | ||
151 | #include <stdio.h> | ||
152 | #undef printf | ||
153 | |||
154 | int main(void){ | ||
155 | int i, k; | ||
156 | AVSHA1 ctx; | ||
157 | unsigned char digest[20]; | ||
158 | |||
159 | for(k=0; k<3; k++){ | ||
160 | av_sha1_init(&ctx); | ||
161 | if(k==0) | ||
162 | av_sha1_update(&ctx, "abc", 3); | ||
163 | else if(k==1) | ||
164 | av_sha1_update(&ctx, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56); | ||
165 | else | ||
166 | for(i=0; i<1000*1000; i++) | ||
167 | av_sha1_update(&ctx, "a", 1); | ||
168 | av_sha1_final(&ctx, digest); | ||
169 | for (i = 0; i < 20; i++) | ||
170 | printf("%02X", digest[i]); | ||
171 | putchar('\n'); | ||
172 | } | ||
173 | //Test Vectors (from FIPS PUB 180-1) | ||
174 | printf("A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\n" | ||
175 | "84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1\n" | ||
176 | "34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F\n"); | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/sha1.h b/src/plugins/ffmpeg/libavutil/sha1.h deleted file mode 100644 index fc5bf08..0000000 --- a/src/plugins/ffmpeg/libavutil/sha1.h +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 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 FFMPEG_SHA1_H | ||
22 | #define FFMPEG_SHA1_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | |||
26 | extern const int av_sha1_size; | ||
27 | |||
28 | struct AVSHA1; | ||
29 | |||
30 | void av_sha1_init(struct AVSHA1* context); | ||
31 | void av_sha1_update(struct AVSHA1* context, const uint8_t* data, unsigned int len); | ||
32 | void av_sha1_final(struct AVSHA1* context, uint8_t digest[20]); | ||
33 | |||
34 | #endif /* FFMPEG_SHA1_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/softfloat.c b/src/plugins/ffmpeg/libavutil/softfloat.c deleted file mode 100644 index a5757c2..0000000 --- a/src/plugins/ffmpeg/libavutil/softfloat.c +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
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 | #include <inttypes.h> | ||
22 | #include <stdio.h> | ||
23 | #include <assert.h> | ||
24 | #include "softfloat.h" | ||
25 | #include "common.h" | ||
26 | #include "log.h" | ||
27 | |||
28 | #undef printf | ||
29 | |||
30 | int main(void){ | ||
31 | SoftFloat one= av_int2sf(1, 0); | ||
32 | SoftFloat sf1, sf2; | ||
33 | double d1, d2; | ||
34 | int i, j; | ||
35 | av_log_level = AV_LOG_DEBUG; | ||
36 | |||
37 | d1= 1; | ||
38 | for(i= 0; i<10; i++){ | ||
39 | d1= 1/(d1+1); | ||
40 | } | ||
41 | printf("test1 double=%d\n", (int)(d1 * (1<<24))); | ||
42 | |||
43 | sf1= one; | ||
44 | for(i= 0; i<10; i++){ | ||
45 | sf1= av_div_sf(one, av_normalize_sf(av_add_sf(one, sf1))); | ||
46 | } | ||
47 | printf("test1 sf =%d\n", av_sf2int(sf1, 24)); | ||
48 | |||
49 | |||
50 | for(i= 0; i<100; i++){ | ||
51 | START_TIMER | ||
52 | d1= i; | ||
53 | d2= i/100.0; | ||
54 | for(j= 0; j<1000; j++){ | ||
55 | d1= (d1+1)*d2; | ||
56 | } | ||
57 | STOP_TIMER("float add mul") | ||
58 | } | ||
59 | printf("test2 double=%d\n", (int)(d1 * (1<<24))); | ||
60 | |||
61 | for(i= 0; i<100; i++){ | ||
62 | START_TIMER | ||
63 | sf1= av_int2sf(i, 0); | ||
64 | sf2= av_div_sf(av_int2sf(i, 2), av_int2sf(200, 3)); | ||
65 | for(j= 0; j<1000; j++){ | ||
66 | sf1= av_mul_sf(av_add_sf(sf1, one),sf2); | ||
67 | } | ||
68 | STOP_TIMER("softfloat add mul") | ||
69 | } | ||
70 | printf("test2 sf =%d (%d %d)\n", av_sf2int(sf1, 24), sf1.exp, sf1.mant); | ||
71 | return 0; | ||
72 | } | ||
diff --git a/src/plugins/ffmpeg/libavutil/softfloat.h b/src/plugins/ffmpeg/libavutil/softfloat.h deleted file mode 100644 index 78648f3..0000000 --- a/src/plugins/ffmpeg/libavutil/softfloat.h +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
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 FFMPEG_SOFTFLOAT_H | ||
22 | #define FFMPEG_SOFTFLOAT_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | #include "common.h" | ||
26 | |||
27 | #define MIN_EXP -126 | ||
28 | #define MAX_EXP 126 | ||
29 | #define ONE_BITS 29 | ||
30 | |||
31 | typedef struct SoftFloat{ | ||
32 | int32_t exp; | ||
33 | int32_t mant; | ||
34 | }SoftFloat; | ||
35 | |||
36 | static av_const SoftFloat av_normalize_sf(SoftFloat a){ | ||
37 | if(a.mant){ | ||
38 | #if 1 | ||
39 | while((a.mant + 0x20000000U)<0x40000000U){ | ||
40 | a.mant += a.mant; | ||
41 | a.exp -= 1; | ||
42 | } | ||
43 | #else | ||
44 | int s=ONE_BITS + 1 - av_log2(a.mant ^ (a.mant<<1)); | ||
45 | a.exp -= s; | ||
46 | a.mant <<= s; | ||
47 | #endif | ||
48 | if(a.exp < MIN_EXP){ | ||
49 | a.exp = MIN_EXP; | ||
50 | a.mant= 0; | ||
51 | } | ||
52 | }else{ | ||
53 | a.exp= MIN_EXP; | ||
54 | } | ||
55 | return a; | ||
56 | } | ||
57 | |||
58 | static inline av_const SoftFloat av_normalize1_sf(SoftFloat a){ | ||
59 | #if 1 | ||
60 | if(a.mant + 0x40000000 < 0){ | ||
61 | a.exp++; | ||
62 | a.mant>>=1; | ||
63 | } | ||
64 | return a; | ||
65 | #elif 1 | ||
66 | int t= a.mant + 0x40000000 < 0; | ||
67 | return (SoftFloat){a.exp+t, a.mant>>t}; | ||
68 | #else | ||
69 | int t= (a.mant + 0x40000000U)>>31; | ||
70 | return (SoftFloat){a.exp+t, a.mant>>t}; | ||
71 | #endif | ||
72 | } | ||
73 | |||
74 | /** | ||
75 | * | ||
76 | * @return will not be more denormalized then a+b, so if either input is | ||
77 | * normalized then the output wont be worse then the other input | ||
78 | * if both are normalized then the output will be normalized | ||
79 | */ | ||
80 | static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){ | ||
81 | a.exp += b.exp; | ||
82 | a.mant = (a.mant * (int64_t)b.mant) >> ONE_BITS; | ||
83 | return av_normalize1_sf(a); | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * | ||
88 | * b has to be normalized and not zero | ||
89 | * @return will not be more denormalized then a | ||
90 | */ | ||
91 | static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){ | ||
92 | a.exp -= b.exp+1; | ||
93 | a.mant = ((int64_t)a.mant<<(ONE_BITS+1)) / b.mant; | ||
94 | return av_normalize1_sf(a); | ||
95 | } | ||
96 | |||
97 | static inline av_const int av_cmp_sf(SoftFloat a, SoftFloat b){ | ||
98 | int t= a.exp - b.exp; | ||
99 | if(t<0) return (a.mant >> (-t)) - b.mant ; | ||
100 | else return a.mant - (b.mant >> t); | ||
101 | } | ||
102 | |||
103 | static inline av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b){ | ||
104 | int t= a.exp - b.exp; | ||
105 | if(t<0) return av_normalize1_sf((SoftFloat){b.exp, b.mant + (a.mant >> (-t))}); | ||
106 | else return av_normalize1_sf((SoftFloat){a.exp, a.mant + (b.mant >> t )}); | ||
107 | } | ||
108 | |||
109 | static inline av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b){ | ||
110 | return av_add_sf(a, (SoftFloat){b.exp, -b.mant}); | ||
111 | } | ||
112 | |||
113 | //FIXME sqrt, log, exp, pow, sin, cos | ||
114 | |||
115 | static inline av_const SoftFloat av_int2sf(int v, int frac_bits){ | ||
116 | return av_normalize_sf((SoftFloat){ONE_BITS-frac_bits, v}); | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * | ||
121 | * rounding is to -inf | ||
122 | */ | ||
123 | static inline av_const int av_sf2int(SoftFloat v, int frac_bits){ | ||
124 | v.exp += frac_bits - ONE_BITS; | ||
125 | if(v.exp >= 0) return v.mant << v.exp ; | ||
126 | else return v.mant >>(-v.exp); | ||
127 | } | ||
128 | |||
129 | #endif /* FFMPEG_SOFTFLOAT_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/string.c b/src/plugins/ffmpeg/libavutil/string.c deleted file mode 100644 index 8ee2a6b..0000000 --- a/src/plugins/ffmpeg/libavutil/string.c +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | ||
3 | * Copyright (c) 2007 Mans Rullgard | ||
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 <stdarg.h> | ||
23 | #include <stdio.h> | ||
24 | #include <string.h> | ||
25 | #include <ctype.h> | ||
26 | #include "avstring.h" | ||
27 | |||
28 | int av_strstart(const char *str, const char *pfx, const char **ptr) | ||
29 | { | ||
30 | while (*pfx && *pfx == *str) { | ||
31 | pfx++; | ||
32 | str++; | ||
33 | } | ||
34 | if (!*pfx && ptr) | ||
35 | *ptr = str; | ||
36 | return !*pfx; | ||
37 | } | ||
38 | |||
39 | int av_stristart(const char *str, const char *pfx, const char **ptr) | ||
40 | { | ||
41 | while (*pfx && toupper((unsigned)*pfx) == toupper((unsigned)*str)) { | ||
42 | pfx++; | ||
43 | str++; | ||
44 | } | ||
45 | if (!*pfx && ptr) | ||
46 | *ptr = str; | ||
47 | return !*pfx; | ||
48 | } | ||
49 | |||
50 | size_t av_strlcpy(char *dst, const char *src, size_t size) | ||
51 | { | ||
52 | size_t len = 0; | ||
53 | while (++len < size && *src) | ||
54 | *dst++ = *src++; | ||
55 | if (len <= size) | ||
56 | *dst = 0; | ||
57 | return len + strlen(src) - 1; | ||
58 | } | ||
59 | |||
60 | size_t av_strlcat(char *dst, const char *src, size_t size) | ||
61 | { | ||
62 | size_t len = strlen(dst); | ||
63 | if (size <= len + 1) | ||
64 | return len + strlen(src); | ||
65 | return len + av_strlcpy(dst + len, src, size - len); | ||
66 | } | ||
67 | |||
68 | size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) | ||
69 | { | ||
70 | int len = strlen(dst); | ||
71 | va_list vl; | ||
72 | |||
73 | va_start(vl, fmt); | ||
74 | len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl); | ||
75 | va_end(vl); | ||
76 | |||
77 | return len; | ||
78 | } | ||
diff --git a/src/plugins/ffmpeg/libavutil/tree.c b/src/plugins/ffmpeg/libavutil/tree.c deleted file mode 100644 index cb442ff..0000000 --- a/src/plugins/ffmpeg/libavutil/tree.c +++ /dev/null | |||
@@ -1,203 +0,0 @@ | |||
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 | #include "common.h" | ||
22 | #include "log.h" | ||
23 | #include "tree.h" | ||
24 | |||
25 | typedef struct AVTreeNode{ | ||
26 | struct AVTreeNode *child[2]; | ||
27 | void *elem; | ||
28 | int state; | ||
29 | }AVTreeNode; | ||
30 | |||
31 | const int av_tree_node_size = sizeof(AVTreeNode); | ||
32 | |||
33 | void *av_tree_find(const AVTreeNode *t, void *key, int (*cmp)(void *key, const void *b), void *next[2]){ | ||
34 | if(t){ | ||
35 | unsigned int v= cmp(key, t->elem); | ||
36 | if(v){ | ||
37 | if(next) next[v>>31]= t->elem; | ||
38 | return av_tree_find(t->child[(v>>31)^1], key, cmp, next); | ||
39 | }else{ | ||
40 | if(next){ | ||
41 | av_tree_find(t->child[0], key, cmp, next); | ||
42 | av_tree_find(t->child[1], key, cmp, next); | ||
43 | } | ||
44 | return t->elem; | ||
45 | } | ||
46 | } | ||
47 | return NULL; | ||
48 | } | ||
49 | |||
50 | void *av_tree_insert(AVTreeNode **tp, void *key, int (*cmp)(void *key, const void *b), AVTreeNode **next){ | ||
51 | AVTreeNode *t= *tp; | ||
52 | if(t){ | ||
53 | unsigned int v= cmp(t->elem, key); | ||
54 | void *ret; | ||
55 | if(!v){ | ||
56 | if(*next) | ||
57 | return t->elem; | ||
58 | else if(t->child[0]||t->child[1]){ | ||
59 | int i= !t->child[0]; | ||
60 | void *next_elem[2]; | ||
61 | av_tree_find(t->child[i], key, cmp, next_elem); | ||
62 | key= t->elem= next_elem[i]; | ||
63 | v= -i; | ||
64 | }else{ | ||
65 | *next= t; | ||
66 | *tp=NULL; | ||
67 | return NULL; | ||
68 | } | ||
69 | } | ||
70 | ret= av_tree_insert(&t->child[v>>31], key, cmp, next); | ||
71 | if(!ret){ | ||
72 | int i= (v>>31) ^ !!*next; | ||
73 | AVTreeNode **child= &t->child[i]; | ||
74 | t->state += 2*i - 1; | ||
75 | |||
76 | if(!(t->state&1)){ | ||
77 | if(t->state){ | ||
78 | /* The following code is equivalent to | ||
79 | if((*child)->state*2 == -t->state) | ||
80 | rotate(child, i^1); | ||
81 | rotate(tp, i); | ||
82 | |||
83 | with rotate(): | ||
84 | static void rotate(AVTreeNode **tp, int i){ | ||
85 | AVTreeNode *t= *tp; | ||
86 | |||
87 | *tp= t->child[i]; | ||
88 | t->child[i]= t->child[i]->child[i^1]; | ||
89 | (*tp)->child[i^1]= t; | ||
90 | i= 4*t->state + 2*(*tp)->state + 12; | ||
91 | t ->state= ((0x614586 >> i) & 3)-1; | ||
92 | (*tp)->state= ((*tp)->state>>1) + ((0x400EEA >> i) & 3)-1; | ||
93 | } | ||
94 | but such a rotate function is both bigger and slower | ||
95 | */ | ||
96 | if((*child)->state*2 == -t->state){ | ||
97 | *tp= (*child)->child[i^1]; | ||
98 | (*child)->child[i^1]= (*tp)->child[i]; | ||
99 | (*tp)->child[i]= *child; | ||
100 | *child= (*tp)->child[i^1]; | ||
101 | (*tp)->child[i^1]= t; | ||
102 | |||
103 | (*tp)->child[0]->state= -((*tp)->state>0); | ||
104 | (*tp)->child[1]->state= (*tp)->state<0 ; | ||
105 | (*tp)->state=0; | ||
106 | }else{ | ||
107 | *tp= *child; | ||
108 | *child= (*child)->child[i^1]; | ||
109 | (*tp)->child[i^1]= t; | ||
110 | if((*tp)->state) t->state = 0; | ||
111 | else t->state>>= 1; | ||
112 | (*tp)->state= -t->state; | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | if(!(*tp)->state ^ !!*next) | ||
117 | return key; | ||
118 | } | ||
119 | return ret; | ||
120 | }else{ | ||
121 | *tp= *next; *next= NULL; | ||
122 | (*tp)->elem= key; | ||
123 | return NULL; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | void av_tree_destroy(AVTreeNode *t){ | ||
128 | av_tree_destroy(t->child[0]); | ||
129 | av_tree_destroy(t->child[1]); | ||
130 | av_free(t); | ||
131 | } | ||
132 | |||
133 | #if 0 | ||
134 | void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*f)(void *opaque, void *elem)){ | ||
135 | int v= f(opaque, t->elem); | ||
136 | if(v>=0) av_tree_enumerate(t->child[0], opaque, f); | ||
137 | if(v<=0) av_tree_enumerate(t->child[1], opaque, f); | ||
138 | } | ||
139 | #endif | ||
140 | |||
141 | #ifdef TEST | ||
142 | #undef random | ||
143 | static int check(AVTreeNode *t){ | ||
144 | if(t){ | ||
145 | int left= check(t->child[0]); | ||
146 | int right= check(t->child[1]); | ||
147 | |||
148 | if(left>999 || right>999) | ||
149 | return 1000; | ||
150 | if(right - left != t->state) | ||
151 | return 1000; | ||
152 | if(t->state>1 || t->state<-1) | ||
153 | return 1000; | ||
154 | return FFMAX(left, right)+1; | ||
155 | } | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static void print(AVTreeNode *t, int depth){ | ||
160 | int i; | ||
161 | for(i=0; i<depth*4; i++) av_log(NULL, AV_LOG_ERROR, " "); | ||
162 | if(t){ | ||
163 | av_log(NULL, AV_LOG_ERROR, "Node %p %2d %4d\n", t, t->state, t->elem); | ||
164 | print(t->child[0], depth+1); | ||
165 | print(t->child[1], depth+1); | ||
166 | }else | ||
167 | av_log(NULL, AV_LOG_ERROR, "NULL\n"); | ||
168 | } | ||
169 | |||
170 | int cmp(const void *a, const void *b){ | ||
171 | return a-b; | ||
172 | } | ||
173 | |||
174 | int main(void){ | ||
175 | int i,k; | ||
176 | AVTreeNode *root= NULL, *node=NULL; | ||
177 | |||
178 | for(i=0; i<10000; i++){ | ||
179 | int j= (random()%86294); | ||
180 | if(check(root) > 999){ | ||
181 | av_log(NULL, AV_LOG_ERROR, "FATAL error %d\n", i); | ||
182 | print(root, 0); | ||
183 | return -1; | ||
184 | } | ||
185 | av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", j); | ||
186 | if(!node) | ||
187 | node= av_mallocz(av_tree_node_size); | ||
188 | av_tree_insert(&root, (void*)(j+1), cmp, &node); | ||
189 | |||
190 | j= (random()%86294); | ||
191 | k= av_tree_find(root, (void*)(j+1), cmp, NULL); | ||
192 | if(k){ | ||
193 | AVTreeNode *node2=NULL; | ||
194 | av_log(NULL, AV_LOG_ERROR, "removing %4d\n", j); | ||
195 | av_tree_insert(&root, (void*)(j+1), cmp, &node2); | ||
196 | k= av_tree_find(root, (void*)(j+1), cmp, NULL); | ||
197 | if(k) | ||
198 | av_log(NULL, AV_LOG_ERROR, "removial failure %d\n", i); | ||
199 | } | ||
200 | } | ||
201 | return 0; | ||
202 | } | ||
203 | #endif | ||
diff --git a/src/plugins/ffmpeg/libavutil/tree.h b/src/plugins/ffmpeg/libavutil/tree.h deleted file mode 100644 index 111ea81..0000000 --- a/src/plugins/ffmpeg/libavutil/tree.h +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
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 tree.h | ||
23 | * A tree container. | ||
24 | * Insertion, Removial, Finding equal, largest which is smaller than and | ||
25 | * smallest which is larger than all have O(log n) worst case time. | ||
26 | * @author Michael Niedermayer <michaelni@gmx.at> | ||
27 | */ | ||
28 | |||
29 | #ifndef FFMPEG_TREE_H | ||
30 | #define FFMPEG_TREE_H | ||
31 | |||
32 | struct AVTreeNode; | ||
33 | extern const int av_tree_node_size; | ||
34 | |||
35 | /** | ||
36 | * Finds an element. | ||
37 | * @param root a pointer to the root node of the tree | ||
38 | * @param next If next is not NULL then next[0] will contain the previous | ||
39 | * element and next[1] the next element if either does not exist | ||
40 | * then the corresponding entry in next is unchanged. | ||
41 | * @return An element with cmp(key, elem)==0 or NULL if no such element exists in | ||
42 | * the tree. | ||
43 | */ | ||
44 | void *av_tree_find(const struct AVTreeNode *root, void *key, int (*cmp)(void *key, const void *b), void *next[2]); | ||
45 | |||
46 | /** | ||
47 | * Inserts or removes an element. | ||
48 | * If *next is NULL then the element supplied will be removed, if no such | ||
49 | * element exists behavior is undefined. | ||
50 | * If *next is not NULL then the element supplied will be inserted, unless | ||
51 | * it already exists in the tree. | ||
52 | * @param rootp A pointer to a pointer to the root node of the tree. Note that | ||
53 | * the root node can change during insertions, this is required | ||
54 | * to keep the tree balanced. | ||
55 | * @param next Used to allocate and free AVTreeNodes. For insertion the user | ||
56 | * must set it to an allocated and zeroed object of at least | ||
57 | * av_tree_node_size bytes size. av_tree_insert() will set it to | ||
58 | * NULL if it has been consumed. | ||
59 | * For deleting elements *next is set to NULL by the user and | ||
60 | * av_tree_node_size() will set it to the AVTreeNode which was | ||
61 | * used for the removed element. | ||
62 | * This allows the use of flat arrays, which have | ||
63 | * lower overhead compared to many malloced elements. | ||
64 | * You might want to define a function like: | ||
65 | * void *tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b), AVTreeNode **next){ | ||
66 | * if(!*next) *next= av_mallocz(av_tree_node_size); | ||
67 | * return av_tree_insert(rootp, key, cmp, next); | ||
68 | * } | ||
69 | * void *tree_remove(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b, AVTreeNode **next)){ | ||
70 | * if(*next) av_freep(next); | ||
71 | * return av_tree_insert(rootp, key, cmp, next); | ||
72 | * } | ||
73 | * | ||
74 | * @return If no insertion happened, the found element. | ||
75 | * If an insertion or removial happened, then either key or NULL will be returned. | ||
76 | * Which one it is depends on the tree state and the implementation. You | ||
77 | * should make no assumptions that it's one or the other in the code. | ||
78 | */ | ||
79 | void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b), struct AVTreeNode **next); | ||
80 | void av_tree_destroy(struct AVTreeNode *t); | ||
81 | |||
82 | #endif /* FFMPEG_TREE_H */ | ||
diff --git a/src/plugins/ffmpeg/libavutil/x86_cpu.h b/src/plugins/ffmpeg/libavutil/x86_cpu.h deleted file mode 100644 index a60b0b5..0000000 --- a/src/plugins/ffmpeg/libavutil/x86_cpu.h +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
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 FFMPEG_X86CPU_H | ||
22 | #define FFMPEG_X86CPU_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | #include "config.h" | ||
26 | |||
27 | #ifdef ARCH_X86_64 | ||
28 | # define REG_a "rax" | ||
29 | # define REG_b "rbx" | ||
30 | # define REG_c "rcx" | ||
31 | # define REG_d "rdx" | ||
32 | # define REG_D "rdi" | ||
33 | # define REG_S "rsi" | ||
34 | # define PTR_SIZE "8" | ||
35 | typedef int64_t x86_reg; | ||
36 | |||
37 | # define REG_SP "rsp" | ||
38 | # define REG_BP "rbp" | ||
39 | # define REGBP rbp | ||
40 | # define REGa rax | ||
41 | # define REGb rbx | ||
42 | # define REGc rcx | ||
43 | # define REGd rdx | ||
44 | # define REGSP rsp | ||
45 | |||
46 | #else | ||
47 | |||
48 | # define REG_a "eax" | ||
49 | # define REG_b "ebx" | ||
50 | # define REG_c "ecx" | ||
51 | # define REG_d "edx" | ||
52 | # define REG_D "edi" | ||
53 | # define REG_S "esi" | ||
54 | # define PTR_SIZE "4" | ||
55 | typedef int32_t x86_reg; | ||
56 | |||
57 | # define REG_SP "esp" | ||
58 | # define REG_BP "ebp" | ||
59 | # define REGBP ebp | ||
60 | # define REGa eax | ||
61 | # define REGb ebx | ||
62 | # define REGc ecx | ||
63 | # define REGd edx | ||
64 | # define REGSP esp | ||
65 | #endif | ||
66 | |||
67 | #if defined(ARCH_X86_64) || (defined(ARCH_X86_32) && defined(HAVE_EBX_AVAILABLE) && defined(HAVE_EBP_AVAILABLE)) | ||
68 | # define HAVE_7REGS 1 | ||
69 | #endif | ||
70 | |||
71 | #if defined(ARCH_X86_64) || (defined(ARCH_X86_32) && (defined(HAVE_EBX_AVAILABLE) || defined(HAVE_EBP_AVAILABLE))) | ||
72 | # define HAVE_6REGS 1 | ||
73 | #endif | ||
74 | |||
75 | #if defined(ARCH_X86_64) && defined(PIC) | ||
76 | # define BROKEN_RELOCATIONS 1 | ||
77 | #endif | ||
78 | |||
79 | #endif /* FFMPEG_X86CPU_H */ | ||