... | ... |
@@ -24,27 +24,29 @@ |
24 | 24 |
* different IIR filters implementation |
25 | 25 |
*/ |
26 | 26 |
|
27 |
-#include "iirfilter.h" |
|
28 | 27 |
#include <math.h> |
28 |
+ |
|
29 | 29 |
#include "libavutil/attributes.h" |
30 | 30 |
#include "libavutil/common.h" |
31 | 31 |
|
32 |
+#include "iirfilter.h" |
|
33 |
+ |
|
32 | 34 |
/** |
33 | 35 |
* IIR filter global parameters |
34 | 36 |
*/ |
35 |
-typedef struct FFIIRFilterCoeffs{ |
|
37 |
+typedef struct FFIIRFilterCoeffs { |
|
36 | 38 |
int order; |
37 | 39 |
float gain; |
38 | 40 |
int *cx; |
39 | 41 |
float *cy; |
40 |
-}FFIIRFilterCoeffs; |
|
42 |
+} FFIIRFilterCoeffs; |
|
41 | 43 |
|
42 | 44 |
/** |
43 | 45 |
* IIR filter state |
44 | 46 |
*/ |
45 |
-typedef struct FFIIRFilterState{ |
|
47 |
+typedef struct FFIIRFilterState { |
|
46 | 48 |
float x[1]; |
47 |
-}FFIIRFilterState; |
|
49 |
+} FFIIRFilterState; |
|
48 | 50 |
|
49 | 51 |
/// maximum supported filter order |
50 | 52 |
#define MAXORDER 30 |
... | ... |
@@ -61,51 +63,50 @@ static av_cold int butterworth_init_coeffs(void *avc, |
61 | 61 |
|
62 | 62 |
if (filt_mode != FF_FILTER_MODE_LOWPASS) { |
63 | 63 |
av_log(avc, AV_LOG_ERROR, "Butterworth filter currently only supports " |
64 |
- "low-pass filter mode\n"); |
|
64 |
+ "low-pass filter mode\n"); |
|
65 | 65 |
return -1; |
66 | 66 |
} |
67 | 67 |
if (order & 1) { |
68 | 68 |
av_log(avc, AV_LOG_ERROR, "Butterworth filter currently only supports " |
69 |
- "even filter orders\n"); |
|
69 |
+ "even filter orders\n"); |
|
70 | 70 |
return -1; |
71 | 71 |
} |
72 | 72 |
|
73 | 73 |
wa = 2 * tan(M_PI * 0.5 * cutoff_ratio); |
74 | 74 |
|
75 | 75 |
c->cx[0] = 1; |
76 |
- for(i = 1; i < (order >> 1) + 1; i++) |
|
76 |
+ for (i = 1; i < (order >> 1) + 1; i++) |
|
77 | 77 |
c->cx[i] = c->cx[i - 1] * (order - i + 1LL) / i; |
78 | 78 |
|
79 | 79 |
p[0][0] = 1.0; |
80 | 80 |
p[0][1] = 0.0; |
81 |
- for(i = 1; i <= order; i++) |
|
81 |
+ for (i = 1; i <= order; i++) |
|
82 | 82 |
p[i][0] = p[i][1] = 0.0; |
83 |
- for(i = 0; i < order; i++){ |
|
83 |
+ for (i = 0; i < order; i++) { |
|
84 | 84 |
double zp[2]; |
85 | 85 |
double th = (i + (order >> 1) + 0.5) * M_PI / order; |
86 | 86 |
double a_re, a_im, c_re, c_im; |
87 | 87 |
zp[0] = cos(th) * wa; |
88 | 88 |
zp[1] = sin(th) * wa; |
89 |
- a_re = zp[0] + 2.0; |
|
90 |
- c_re = zp[0] - 2.0; |
|
91 |
- a_im = |
|
92 |
- c_im = zp[1]; |
|
89 |
+ a_re = zp[0] + 2.0; |
|
90 |
+ c_re = zp[0] - 2.0; |
|
91 |
+ a_im = |
|
92 |
+ c_im = zp[1]; |
|
93 | 93 |
zp[0] = (a_re * c_re + a_im * c_im) / (c_re * c_re + c_im * c_im); |
94 | 94 |
zp[1] = (a_im * c_re - a_re * c_im) / (c_re * c_re + c_im * c_im); |
95 | 95 |
|
96 |
- for(j = order; j >= 1; j--) |
|
97 |
- { |
|
98 |
- a_re = p[j][0]; |
|
99 |
- a_im = p[j][1]; |
|
100 |
- p[j][0] = a_re*zp[0] - a_im*zp[1] + p[j-1][0]; |
|
101 |
- p[j][1] = a_re*zp[1] + a_im*zp[0] + p[j-1][1]; |
|
96 |
+ for (j = order; j >= 1; j--) { |
|
97 |
+ a_re = p[j][0]; |
|
98 |
+ a_im = p[j][1]; |
|
99 |
+ p[j][0] = a_re * zp[0] - a_im * zp[1] + p[j - 1][0]; |
|
100 |
+ p[j][1] = a_re * zp[1] + a_im * zp[0] + p[j - 1][1]; |
|
102 | 101 |
} |
103 |
- a_re = p[0][0]*zp[0] - p[0][1]*zp[1]; |
|
104 |
- p[0][1] = p[0][0]*zp[1] + p[0][1]*zp[0]; |
|
102 |
+ a_re = p[0][0] * zp[0] - p[0][1] * zp[1]; |
|
103 |
+ p[0][1] = p[0][0] * zp[1] + p[0][1] * zp[0]; |
|
105 | 104 |
p[0][0] = a_re; |
106 | 105 |
} |
107 | 106 |
c->gain = p[order][0]; |
108 |
- for(i = 0; i < order; i++){ |
|
107 |
+ for (i = 0; i < order; i++) { |
|
109 | 108 |
c->gain += p[i][0]; |
110 | 109 |
c->cy[i] = (-p[i][0] * p[order][0] + -p[i][1] * p[order][1]) / |
111 | 110 |
(p[order][0] * p[order][0] + p[order][1] * p[order][1]); |
... | ... |
@@ -125,7 +126,7 @@ static av_cold int biquad_init_coeffs(void *avc, struct FFIIRFilterCoeffs *c, |
125 | 125 |
if (filt_mode != FF_FILTER_MODE_HIGHPASS && |
126 | 126 |
filt_mode != FF_FILTER_MODE_LOWPASS) { |
127 | 127 |
av_log(avc, AV_LOG_ERROR, "Biquad filter currently only supports " |
128 |
- "high-pass and low-pass filter modes\n"); |
|
128 |
+ "high-pass and low-pass filter modes\n"); |
|
129 | 129 |
return -1; |
130 | 130 |
} |
131 | 131 |
if (order != 2) { |
... | ... |
@@ -158,11 +159,11 @@ static av_cold int biquad_init_coeffs(void *avc, struct FFIIRFilterCoeffs *c, |
158 | 158 |
return 0; |
159 | 159 |
} |
160 | 160 |
|
161 |
-av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc, |
|
162 |
- enum IIRFilterType filt_type, |
|
163 |
- enum IIRFilterMode filt_mode, |
|
164 |
- int order, float cutoff_ratio, |
|
165 |
- float stopband, float ripple) |
|
161 |
+av_cold struct FFIIRFilterCoeffs *ff_iir_filter_init_coeffs(void *avc, |
|
162 |
+ enum IIRFilterType filt_type, |
|
163 |
+ enum IIRFilterMode filt_mode, |
|
164 |
+ int order, float cutoff_ratio, |
|
165 |
+ float stopband, float ripple) |
|
166 | 166 |
{ |
167 | 167 |
FFIIRFilterCoeffs *c; |
168 | 168 |
int ret = 0; |
... | ... |
@@ -170,12 +171,12 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc, |
170 | 170 |
if (order <= 0 || order > MAXORDER || cutoff_ratio >= 1.0) |
171 | 171 |
return NULL; |
172 | 172 |
|
173 |
- FF_ALLOCZ_OR_GOTO(avc, c, sizeof(FFIIRFilterCoeffs), |
|
174 |
- init_fail); |
|
175 |
- FF_ALLOC_OR_GOTO (avc, c->cx, sizeof(c->cx[0]) * ((order >> 1) + 1), |
|
176 |
- init_fail); |
|
177 |
- FF_ALLOC_OR_GOTO (avc, c->cy, sizeof(c->cy[0]) * order, |
|
173 |
+ FF_ALLOCZ_OR_GOTO(avc, c, sizeof(FFIIRFilterCoeffs), |
|
178 | 174 |
init_fail); |
175 |
+ FF_ALLOC_OR_GOTO(avc, c->cx, sizeof(c->cx[0]) * ((order >> 1) + 1), |
|
176 |
+ init_fail); |
|
177 |
+ FF_ALLOC_OR_GOTO(avc, c->cy, sizeof(c->cy[0]) * order, |
|
178 |
+ init_fail); |
|
179 | 179 |
c->order = order; |
180 | 180 |
|
181 | 181 |
switch (filt_type) { |
... | ... |
@@ -200,9 +201,9 @@ init_fail: |
200 | 200 |
return NULL; |
201 | 201 |
} |
202 | 202 |
|
203 |
-av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order) |
|
203 |
+av_cold struct FFIIRFilterState *ff_iir_filter_init_state(int order) |
|
204 | 204 |
{ |
205 |
- FFIIRFilterState* s = av_mallocz(sizeof(FFIIRFilterState) + sizeof(s->x[0]) * (order - 1)); |
|
205 |
+ FFIIRFilterState *s = av_mallocz(sizeof(FFIIRFilterState) + sizeof(s->x[0]) * (order - 1)); |
|
206 | 206 |
return s; |
207 | 207 |
} |
208 | 208 |
|
... | ... |
@@ -210,17 +211,19 @@ av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order) |
210 | 210 |
|
211 | 211 |
#define CONV_FLT(dest, source) dest = source; |
212 | 212 |
|
213 |
-#define FILTER_BW_O4_1(i0, i1, i2, i3, fmt) \ |
|
214 |
- in = *src0 * c->gain \ |
|
215 |
- + c->cy[0]*s->x[i0] + c->cy[1]*s->x[i1] \ |
|
216 |
- + c->cy[2]*s->x[i2] + c->cy[3]*s->x[i3]; \ |
|
217 |
- res = (s->x[i0] + in )*1 \ |
|
218 |
- + (s->x[i1] + s->x[i3])*4 \ |
|
219 |
- + s->x[i2] *6; \ |
|
220 |
- CONV_##fmt(*dst0, res) \ |
|
221 |
- s->x[i0] = in; \ |
|
222 |
- src0 += sstep; \ |
|
223 |
- dst0 += dstep; |
|
213 |
+#define FILTER_BW_O4_1(i0, i1, i2, i3, fmt) \ |
|
214 |
+ in = *src0 * c->gain + \ |
|
215 |
+ c->cy[0] * s->x[i0] + \ |
|
216 |
+ c->cy[1] * s->x[i1] + \ |
|
217 |
+ c->cy[2] * s->x[i2] + \ |
|
218 |
+ c->cy[3] * s->x[i3]; \ |
|
219 |
+ res = (s->x[i0] + in) * 1 + \ |
|
220 |
+ (s->x[i1] + s->x[i3]) * 4 + \ |
|
221 |
+ s->x[i2] * 6; \ |
|
222 |
+ CONV_ ## fmt(*dst0, res) \ |
|
223 |
+ s->x[i0] = in; \ |
|
224 |
+ src0 += sstep; \ |
|
225 |
+ dst0 += dstep; |
|
224 | 226 |
|
225 | 227 |
#define FILTER_BW_O4(type, fmt) { \ |
226 | 228 |
int i; \ |
... | ... |
@@ -243,17 +246,17 @@ av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order) |
243 | 243 |
int j; \ |
244 | 244 |
float in, res; \ |
245 | 245 |
in = *src0 * c->gain; \ |
246 |
- for(j = 0; j < c->order; j++) \ |
|
246 |
+ for (j = 0; j < c->order; j++) \ |
|
247 | 247 |
in += c->cy[j] * s->x[j]; \ |
248 | 248 |
res = s->x[0] + in + s->x[c->order >> 1] * c->cx[c->order >> 1]; \ |
249 |
- for(j = 1; j < c->order >> 1; j++) \ |
|
249 |
+ for (j = 1; j < c->order >> 1; j++) \ |
|
250 | 250 |
res += (s->x[j] + s->x[c->order - j]) * c->cx[j]; \ |
251 |
- for(j = 0; j < c->order - 1; j++) \ |
|
251 |
+ for (j = 0; j < c->order - 1; j++) \ |
|
252 | 252 |
s->x[j] = s->x[j + 1]; \ |
253 |
- CONV_##fmt(*dst0, res) \ |
|
253 |
+ CONV_ ## fmt(*dst0, res) \ |
|
254 | 254 |
s->x[c->order - 1] = in; \ |
255 |
- src0 += sstep; \ |
|
256 |
- dst0 += dstep; \ |
|
255 |
+ src0 += sstep; \ |
|
256 |
+ dst0 += dstep; \ |
|
257 | 257 |
} \ |
258 | 258 |
} |
259 | 259 |
|
... | ... |
@@ -265,11 +268,11 @@ av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order) |
265 | 265 |
float in = *src0 * c->gain + \ |
266 | 266 |
s->x[0] * c->cy[0] + \ |
267 | 267 |
s->x[1] * c->cy[1]; \ |
268 |
- CONV_##fmt(*dst0, s->x[0] + in + s->x[1] * c->cx[1]) \ |
|
268 |
+ CONV_ ## fmt(*dst0, s->x[0] + in + s->x[1] * c->cx[1]) \ |
|
269 | 269 |
s->x[0] = s->x[1]; \ |
270 | 270 |
s->x[1] = in; \ |
271 |
- src0 += sstep; \ |
|
272 |
- dst0 += dstep; \ |
|
271 |
+ src0 += sstep; \ |
|
272 |
+ dst0 += dstep; \ |
|
273 | 273 |
} \ |
274 | 274 |
} |
275 | 275 |
|
... | ... |
@@ -306,7 +309,7 @@ av_cold void ff_iir_filter_free_state(struct FFIIRFilterState *state) |
306 | 306 |
|
307 | 307 |
av_cold void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs) |
308 | 308 |
{ |
309 |
- if(coeffs){ |
|
309 |
+ if (coeffs) { |
|
310 | 310 |
av_free(coeffs->cx); |
311 | 311 |
av_free(coeffs->cy); |
312 | 312 |
} |
... | ... |
@@ -331,9 +334,8 @@ int main(void) |
331 | 331 |
cutoff_coeff, 0.0, 0.0); |
332 | 332 |
fstate = ff_iir_filter_init_state(FILT_ORDER); |
333 | 333 |
|
334 |
- for (i = 0; i < SIZE; i++) { |
|
335 |
- x[i] = lrint(0.75 * INT16_MAX * sin(0.5*M_PI*i*i/SIZE)); |
|
336 |
- } |
|
334 |
+ for (i = 0; i < SIZE; i++) |
|
335 |
+ x[i] = lrint(0.75 * INT16_MAX * sin(0.5 * M_PI * i * i / SIZE)); |
|
337 | 336 |
|
338 | 337 |
ff_iir_filter(fcoeffs, fstate, SIZE, x, 1, y, 1); |
339 | 338 |
|
... | ... |
@@ -55,7 +55,7 @@ av_cold void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, |
55 | 55 |
/* cast to avoid compiler warning */ |
56 | 56 |
ff_init_range_encoder(c, (uint8_t *)buf, buf_size); |
57 | 57 |
|
58 |
- c->low = AV_RB16(c->bytestream); |
|
58 |
+ c->low = AV_RB16(c->bytestream); |
|
59 | 59 |
c->bytestream += 2; |
60 | 60 |
} |
61 | 61 |
|
... | ... |
@@ -21,9 +21,9 @@ |
21 | 21 |
*/ |
22 | 22 |
|
23 | 23 |
#include "common.h" |
24 |
-#include "aes.h" |
|
25 | 24 |
#include "intreadwrite.h" |
26 | 25 |
#include "timer.h" |
26 |
+#include "aes.h" |
|
27 | 27 |
|
28 | 28 |
typedef union { |
29 | 29 |
uint64_t u64[2]; |
... | ... |
@@ -46,7 +46,7 @@ struct AVAES *av_aes_alloc(void) |
46 | 46 |
} |
47 | 47 |
|
48 | 48 |
static const uint8_t rcon[10] = { |
49 |
- 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 |
|
49 |
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 |
|
50 | 50 |
}; |
51 | 51 |
|
52 | 52 |
static uint8_t sbox[256]; |
... | ... |
@@ -109,7 +109,8 @@ static void subshift(av_aes_block s0[2], int s, const uint8_t *box) |
109 | 109 |
s3[0].u8[ 5] = box[s3[1].u8[ 1]]; |
110 | 110 |
} |
111 | 111 |
|
112 |
-static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){ |
|
112 |
+static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d) |
|
113 |
+{ |
|
113 | 114 |
#if CONFIG_SMALL |
114 | 115 |
return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24); |
115 | 116 |
#else |
... | ... |
@@ -117,12 +118,13 @@ static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){ |
117 | 117 |
#endif |
118 | 118 |
} |
119 | 119 |
|
120 |
-static inline void mix(av_aes_block state[2], uint32_t multbl[][256], int s1, int s3){ |
|
120 |
+static inline void mix(av_aes_block state[2], uint32_t multbl[][256], int s1, int s3) |
|
121 |
+{ |
|
121 | 122 |
uint8_t (*src)[4] = state[1].u8x4; |
122 |
- state[0].u32[0] = mix_core(multbl, src[0][0], src[s1 ][1], src[2][2], src[s3 ][3]); |
|
123 |
- state[0].u32[1] = mix_core(multbl, src[1][0], src[s3-1][1], src[3][2], src[s1-1][3]); |
|
124 |
- state[0].u32[2] = mix_core(multbl, src[2][0], src[s3 ][1], src[0][2], src[s1 ][3]); |
|
125 |
- state[0].u32[3] = mix_core(multbl, src[3][0], src[s1-1][1], src[1][2], src[s3-1][3]); |
|
123 |
+ state[0].u32[0] = mix_core(multbl, src[0][0], src[s1 ][1], src[2][2], src[s3 ][3]); |
|
124 |
+ state[0].u32[1] = mix_core(multbl, src[1][0], src[s3 - 1][1], src[3][2], src[s1 - 1][3]); |
|
125 |
+ state[0].u32[2] = mix_core(multbl, src[2][0], src[s3 ][1], src[0][2], src[s1 ][3]); |
|
126 |
+ state[0].u32[3] = mix_core(multbl, src[3][0], src[s1 - 1][1], src[1][2], src[s3 - 1][3]); |
|
126 | 127 |
} |
127 | 128 |
|
128 | 129 |
static inline void crypt(AVAES *a, int s, const uint8_t *sbox, |
... | ... |
@@ -178,7 +180,7 @@ static void init_multbl2(uint32_t tbl[][256], const int c[4], |
178 | 178 |
l = alog8[x + log8[c[1]]]; |
179 | 179 |
m = alog8[x + log8[c[2]]]; |
180 | 180 |
n = alog8[x + log8[c[3]]]; |
181 |
- tbl[0][i] = AV_NE(MKBETAG(k,l,m,n), MKTAG(k,l,m,n)); |
|
181 |
+ tbl[0][i] = AV_NE(MKBETAG(k, l, m, n), MKTAG(k, l, m, n)); |
|
182 | 182 |
#if !CONFIG_SMALL |
183 | 183 |
tbl[1][i] = ROT(tbl[0][i], 8); |
184 | 184 |
tbl[2][i] = ROT(tbl[0][i], 16); |
... | ... |
@@ -198,7 +200,7 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) |
198 | 198 |
uint8_t log8[256]; |
199 | 199 |
uint8_t alog8[512]; |
200 | 200 |
|
201 |
- if (!enc_multbl[FF_ARRAY_ELEMS(enc_multbl)-1][FF_ARRAY_ELEMS(enc_multbl[0])-1]) { |
|
201 |
+ if (!enc_multbl[FF_ARRAY_ELEMS(enc_multbl) - 1][FF_ARRAY_ELEMS(enc_multbl[0]) - 1]) { |
|
202 | 202 |
j = 1; |
203 | 203 |
for (i = 0; i < 255; i++) { |
204 | 204 |
alog8[i] = alog8[i + 255] = j; |
... | ... |
@@ -212,7 +214,7 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) |
212 | 212 |
j ^= (j << 1) ^ (j << 2) ^ (j << 3) ^ (j << 4); |
213 | 213 |
j = (j ^ (j >> 8) ^ 99) & 255; |
214 | 214 |
inv_sbox[j] = i; |
215 |
- sbox[i] = j; |
|
215 |
+ sbox[i] = j; |
|
216 | 216 |
} |
217 | 217 |
init_multbl2(dec_multbl, (const int[4]) { 0xe, 0x9, 0xd, 0xb }, |
218 | 218 |
log8, alog8, inv_sbox); |
... | ... |
@@ -254,9 +256,8 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) |
254 | 254 |
a->round_key[i] = tmp[0]; |
255 | 255 |
} |
256 | 256 |
} else { |
257 |
- for (i = 0; i < (rounds + 1) >> 1; i++) { |
|
258 |
- FFSWAP(av_aes_block, a->round_key[i], a->round_key[rounds-i]); |
|
259 |
- } |
|
257 |
+ for (i = 0; i < (rounds + 1) >> 1; i++) |
|
258 |
+ FFSWAP(av_aes_block, a->round_key[i], a->round_key[rounds - i]); |
|
260 | 259 |
} |
261 | 260 |
|
262 | 261 |
return 0; |
... | ... |
@@ -264,6 +265,7 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) |
264 | 264 |
|
265 | 265 |
#ifdef TEST |
266 | 266 |
#include <string.h> |
267 |
+ |
|
267 | 268 |
#include "lfg.h" |
268 | 269 |
#include "log.h" |
269 | 270 |
|
... | ... |
@@ -276,12 +278,12 @@ int main(int argc, char **argv) |
276 | 276 |
{ 0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, |
277 | 277 |
0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59 } |
278 | 278 |
}; |
279 |
- uint8_t pt[16], rpt[2][16]= { |
|
279 |
+ uint8_t pt[16], rpt[2][16] = { |
|
280 | 280 |
{ 0x6a, 0x84, 0x86, 0x7c, 0xd7, 0x7e, 0x12, 0xad, |
281 | 281 |
0x07, 0xea, 0x1b, 0xe8, 0x95, 0xc5, 0x3f, 0xa3 }, |
282 | 282 |
{ 0 } |
283 | 283 |
}; |
284 |
- uint8_t rct[2][16]= { |
|
284 |
+ uint8_t rct[2][16] = { |
|
285 | 285 |
{ 0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, |
286 | 286 |
0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf }, |
287 | 287 |
{ 0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, |
... | ... |
@@ -313,9 +315,8 @@ int main(int argc, char **argv) |
313 | 313 |
av_lfg_init(&prng, 1); |
314 | 314 |
|
315 | 315 |
for (i = 0; i < 10000; i++) { |
316 |
- for (j = 0; j < 16; j++) { |
|
316 |
+ for (j = 0; j < 16; j++) |
|
317 | 317 |
pt[j] = av_lfg_get(&prng); |
318 |
- } |
|
319 | 318 |
{ |
320 | 319 |
START_TIMER; |
321 | 320 |
av_aes_crypt(&ae, temp, pt, 1, NULL, 0); |
... | ... |
@@ -19,8 +19,9 @@ |
19 | 19 |
*/ |
20 | 20 |
|
21 | 21 |
#include "config.h" |
22 |
-#include "common.h" |
|
22 |
+ |
|
23 | 23 |
#include "bswap.h" |
24 |
+#include "common.h" |
|
24 | 25 |
#include "crc.h" |
25 | 26 |
|
26 | 27 |
#if CONFIG_HARDCODED_TABLES |
... | ... |
@@ -287,7 +288,7 @@ int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size) |
287 | 287 |
if (ctx_size >= sizeof(AVCRC) * 1024) |
288 | 288 |
for (i = 0; i < 256; i++) |
289 | 289 |
for (j = 0; j < 3; j++) |
290 |
- ctx[256 *(j + 1) + i] = |
|
290 |
+ ctx[256 * (j + 1) + i] = |
|
291 | 291 |
(ctx[256 * j + i] >> 8) ^ ctx[ctx[256 * j + i] & 0xFF]; |
292 | 292 |
#endif |
293 | 293 |
|
... | ... |
@@ -338,11 +339,12 @@ int main(void) |
338 | 338 |
{ |
339 | 339 |
uint8_t buf[1999]; |
340 | 340 |
int i; |
341 |
- int p[5][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 }, |
|
342 |
- { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 }, |
|
343 |
- { AV_CRC_16_ANSI_LE, 0xA001 , 0xBFD8 }, |
|
344 |
- { AV_CRC_16_ANSI , 0x8005 , 0x1FBB }, |
|
345 |
- { AV_CRC_8_ATM , 0x07 , 0xE3 } |
|
341 |
+ int p[5][3] = { |
|
342 |
+ { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 }, |
|
343 |
+ { AV_CRC_32_IEEE, 0x04C11DB7, 0xC0F5BAE0 }, |
|
344 |
+ { AV_CRC_16_ANSI_LE, 0xA001, 0xBFD8 }, |
|
345 |
+ { AV_CRC_16_ANSI, 0x8005, 0x1FBB }, |
|
346 |
+ { AV_CRC_8_ATM, 0x07, 0xE3 } |
|
346 | 347 |
}; |
347 | 348 |
const AVCRC *ctx; |
348 | 349 |
|
... | ... |
@@ -34,7 +34,7 @@ struct AVDES { |
34 | 34 |
}; |
35 | 35 |
#endif |
36 | 36 |
|
37 |
-#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 |
|
37 |
+#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 |
|
38 | 38 |
static const uint8_t IP_shuffle[] = { |
39 | 39 |
T(58, 50, 42, 34, 26, 18, 10, 2), |
40 | 40 |
T(60, 52, 44, 36, 28, 20, 12, 4), |
... | ... |
@@ -48,7 +48,7 @@ static const uint8_t IP_shuffle[] = { |
48 | 48 |
#undef T |
49 | 49 |
|
50 | 50 |
#if CONFIG_SMALL || defined(GENTABLES) |
51 |
-#define T(a, b, c, d) 32-a,32-b,32-c,32-d |
|
51 |
+#define T(a, b, c, d) 32 - a, 32 - b, 32 - c, 32 - d |
|
52 | 52 |
static const uint8_t P_shuffle[] = { |
53 | 53 |
T(16, 7, 20, 21), |
54 | 54 |
T(29, 12, 28, 17), |
... | ... |
@@ -62,7 +62,7 @@ static const uint8_t P_shuffle[] = { |
62 | 62 |
#undef T |
63 | 63 |
#endif |
64 | 64 |
|
65 |
-#define T(a, b, c, d, e, f, g) 64-a,64-b,64-c,64-d,64-e,64-f,64-g |
|
65 |
+#define T(a, b, c, d, e, f, g) 64 - a, 64 - b, 64 - c, 64 - d, 64 - e, 64 - f, 64 - g |
|
66 | 66 |
static const uint8_t PC1_shuffle[] = { |
67 | 67 |
T(57, 49, 41, 33, 25, 17, 9), |
68 | 68 |
T( 1, 58, 50, 42, 34, 26, 18), |
... | ... |
@@ -75,7 +75,7 @@ static const uint8_t PC1_shuffle[] = { |
75 | 75 |
}; |
76 | 76 |
#undef T |
77 | 77 |
|
78 |
-#define T(a, b, c, d, e, f) 56-a,56-b,56-c,56-d,56-e,56-f |
|
78 |
+#define T(a, b, c, d, e, f) 56 - a, 56 - b, 56 - c, 56 - d, 56 - e, 56 - f |
|
79 | 79 |
static const uint8_t PC2_shuffle[] = { |
80 | 80 |
T(14, 17, 11, 24, 1, 5), |
81 | 81 |
T( 3, 28, 15, 6, 21, 10), |
... | ... |
@@ -90,30 +90,22 @@ static const uint8_t PC2_shuffle[] = { |
90 | 90 |
|
91 | 91 |
#if CONFIG_SMALL |
92 | 92 |
static const uint8_t S_boxes[8][32] = { |
93 |
- { |
|
94 |
- 0x0e, 0xf4, 0x7d, 0x41, 0xe2, 0x2f, 0xdb, 0x18, 0xa3, 0x6a, 0xc6, 0xbc, 0x95, 0x59, 0x30, 0x87, |
|
95 |
- 0xf4, 0xc1, 0x8e, 0x28, 0x4d, 0x96, 0x12, 0x7b, 0x5f, 0xbc, 0x39, 0xe7, 0xa3, 0x0a, 0x65, 0xd0, |
|
96 |
- }, { |
|
97 |
- 0x3f, 0xd1, 0x48, 0x7e, 0xf6, 0x2b, 0x83, 0xe4, 0xc9, 0x07, 0x12, 0xad, 0x6c, 0x90, 0xb5, 0x5a, |
|
98 |
- 0xd0, 0x8e, 0xa7, 0x1b, 0x3a, 0xf4, 0x4d, 0x21, 0xb5, 0x68, 0x7c, 0xc6, 0x09, 0x53, 0xe2, 0x9f, |
|
99 |
- }, { |
|
100 |
- 0xda, 0x70, 0x09, 0x9e, 0x36, 0x43, 0x6f, 0xa5, 0x21, 0x8d, 0x5c, 0xe7, 0xcb, 0xb4, 0xf2, 0x18, |
|
101 |
- 0x1d, 0xa6, 0xd4, 0x09, 0x68, 0x9f, 0x83, 0x70, 0x4b, 0xf1, 0xe2, 0x3c, 0xb5, 0x5a, 0x2e, 0xc7, |
|
102 |
- }, { |
|
103 |
- 0xd7, 0x8d, 0xbe, 0x53, 0x60, 0xf6, 0x09, 0x3a, 0x41, 0x72, 0x28, 0xc5, 0x1b, 0xac, 0xe4, 0x9f, |
|
104 |
- 0x3a, 0xf6, 0x09, 0x60, 0xac, 0x1b, 0xd7, 0x8d, 0x9f, 0x41, 0x53, 0xbe, 0xc5, 0x72, 0x28, 0xe4, |
|
105 |
- }, { |
|
106 |
- 0xe2, 0xbc, 0x24, 0xc1, 0x47, 0x7a, 0xdb, 0x16, 0x58, 0x05, 0xf3, 0xaf, 0x3d, 0x90, 0x8e, 0x69, |
|
107 |
- 0xb4, 0x82, 0xc1, 0x7b, 0x1a, 0xed, 0x27, 0xd8, 0x6f, 0xf9, 0x0c, 0x95, 0xa6, 0x43, 0x50, 0x3e, |
|
108 |
- }, { |
|
109 |
- 0xac, 0xf1, 0x4a, 0x2f, 0x79, 0xc2, 0x96, 0x58, 0x60, 0x1d, 0xd3, 0xe4, 0x0e, 0xb7, 0x35, 0x8b, |
|
110 |
- 0x49, 0x3e, 0x2f, 0xc5, 0x92, 0x58, 0xfc, 0xa3, 0xb7, 0xe0, 0x14, 0x7a, 0x61, 0x0d, 0x8b, 0xd6, |
|
111 |
- }, { |
|
112 |
- 0xd4, 0x0b, 0xb2, 0x7e, 0x4f, 0x90, 0x18, 0xad, 0xe3, 0x3c, 0x59, 0xc7, 0x25, 0xfa, 0x86, 0x61, |
|
113 |
- 0x61, 0xb4, 0xdb, 0x8d, 0x1c, 0x43, 0xa7, 0x7e, 0x9a, 0x5f, 0x06, 0xf8, 0xe0, 0x25, 0x39, 0xc2, |
|
114 |
- }, { |
|
115 |
- 0x1d, 0xf2, 0xd8, 0x84, 0xa6, 0x3f, 0x7b, 0x41, 0xca, 0x59, 0x63, 0xbe, 0x05, 0xe0, 0x9c, 0x27, |
|
116 |
- 0x27, 0x1b, 0xe4, 0x71, 0x49, 0xac, 0x8e, 0xd2, 0xf0, 0xc6, 0x9a, 0x0d, 0x3f, 0x53, 0x65, 0xb8, |
|
93 |
+ { 0x0e, 0xf4, 0x7d, 0x41, 0xe2, 0x2f, 0xdb, 0x18, 0xa3, 0x6a, 0xc6, 0xbc, 0x95, 0x59, 0x30, 0x87, |
|
94 |
+ 0xf4, 0xc1, 0x8e, 0x28, 0x4d, 0x96, 0x12, 0x7b, 0x5f, 0xbc, 0x39, 0xe7, 0xa3, 0x0a, 0x65, 0xd0, }, |
|
95 |
+ { 0x3f, 0xd1, 0x48, 0x7e, 0xf6, 0x2b, 0x83, 0xe4, 0xc9, 0x07, 0x12, 0xad, 0x6c, 0x90, 0xb5, 0x5a, |
|
96 |
+ 0xd0, 0x8e, 0xa7, 0x1b, 0x3a, 0xf4, 0x4d, 0x21, 0xb5, 0x68, 0x7c, 0xc6, 0x09, 0x53, 0xe2, 0x9f, }, |
|
97 |
+ { 0xda, 0x70, 0x09, 0x9e, 0x36, 0x43, 0x6f, 0xa5, 0x21, 0x8d, 0x5c, 0xe7, 0xcb, 0xb4, 0xf2, 0x18, |
|
98 |
+ 0x1d, 0xa6, 0xd4, 0x09, 0x68, 0x9f, 0x83, 0x70, 0x4b, 0xf1, 0xe2, 0x3c, 0xb5, 0x5a, 0x2e, 0xc7, }, |
|
99 |
+ { 0xd7, 0x8d, 0xbe, 0x53, 0x60, 0xf6, 0x09, 0x3a, 0x41, 0x72, 0x28, 0xc5, 0x1b, 0xac, 0xe4, 0x9f, |
|
100 |
+ 0x3a, 0xf6, 0x09, 0x60, 0xac, 0x1b, 0xd7, 0x8d, 0x9f, 0x41, 0x53, 0xbe, 0xc5, 0x72, 0x28, 0xe4, }, |
|
101 |
+ { 0xe2, 0xbc, 0x24, 0xc1, 0x47, 0x7a, 0xdb, 0x16, 0x58, 0x05, 0xf3, 0xaf, 0x3d, 0x90, 0x8e, 0x69, |
|
102 |
+ 0xb4, 0x82, 0xc1, 0x7b, 0x1a, 0xed, 0x27, 0xd8, 0x6f, 0xf9, 0x0c, 0x95, 0xa6, 0x43, 0x50, 0x3e, }, |
|
103 |
+ { 0xac, 0xf1, 0x4a, 0x2f, 0x79, 0xc2, 0x96, 0x58, 0x60, 0x1d, 0xd3, 0xe4, 0x0e, 0xb7, 0x35, 0x8b, |
|
104 |
+ 0x49, 0x3e, 0x2f, 0xc5, 0x92, 0x58, 0xfc, 0xa3, 0xb7, 0xe0, 0x14, 0x7a, 0x61, 0x0d, 0x8b, 0xd6, }, |
|
105 |
+ { 0xd4, 0x0b, 0xb2, 0x7e, 0x4f, 0x90, 0x18, 0xad, 0xe3, 0x3c, 0x59, 0xc7, 0x25, 0xfa, 0x86, 0x61, |
|
106 |
+ 0x61, 0xb4, 0xdb, 0x8d, 0x1c, 0x43, 0xa7, 0x7e, 0x9a, 0x5f, 0x06, 0xf8, 0xe0, 0x25, 0x39, 0xc2, }, |
|
107 |
+ { 0x1d, 0xf2, 0xd8, 0x84, 0xa6, 0x3f, 0x7b, 0x41, 0xca, 0x59, 0x63, 0xbe, 0x05, 0xe0, 0x9c, 0x27, |
|
108 |
+ 0x27, 0x1b, 0xe4, 0x71, 0x49, 0xac, 0x8e, 0xd2, 0xf0, 0xc6, 0x9a, 0x0d, 0x3f, 0x53, 0x65, 0xb8, |
|
117 | 109 |
} |
118 | 110 |
}; |
119 | 111 |
#else |
... | ... |
@@ -122,90 +114,75 @@ static const uint8_t S_boxes[8][32] = { |
122 | 122 |
* It can be regenerated by compiling this file with -DCONFIG_SMALL -DTEST -DGENTABLES |
123 | 123 |
*/ |
124 | 124 |
static const uint32_t S_boxes_P_shuffle[8][64] = { |
125 |
- { |
|
126 |
- 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000, |
|
127 |
- 0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002, |
|
128 |
- 0x00000202, 0x00800200, 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202, |
|
129 |
- 0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, 0x00008202, 0x00800000, |
|
130 |
- 0x00008000, 0x00808202, 0x00000002, 0x00808000, 0x00808200, 0x00800000, 0x00800000, 0x00000200, |
|
131 |
- 0x00808002, 0x00008000, 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202, |
|
132 |
- 0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, 0x00008202, 0x00808200, |
|
133 |
- 0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002, |
|
134 |
- }, |
|
135 |
- { |
|
136 |
- 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010, |
|
137 |
- 0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010, |
|
138 |
- 0x00084000, 0x00080010, 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000, |
|
139 |
- 0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, 0x40080000, 0x00004010, |
|
140 |
- 0x00000000, 0x00084010, 0x40080010, 0x00080000, 0x40004010, 0x40080000, 0x40084000, 0x00004000, |
|
141 |
- 0x40080000, 0x40004000, 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000, |
|
142 |
- 0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, 0x40000010, 0x00080010, |
|
143 |
- 0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000, |
|
144 |
- }, |
|
145 |
- { |
|
146 |
- 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100, |
|
147 |
- 0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104, |
|
148 |
- 0x04000000, 0x00000004, 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104, |
|
149 |
- 0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, 0x00000100, 0x04000000, |
|
150 |
- 0x04010100, 0x04000000, 0x00010004, 0x00000104, 0x00010000, 0x04010100, 0x04000100, 0x00000000, |
|
151 |
- 0x00000100, 0x00010004, 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004, |
|
152 |
- 0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, 0x00010100, 0x04000004, |
|
153 |
- 0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100, |
|
154 |
- }, |
|
155 |
- { |
|
156 |
- 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000, |
|
157 |
- 0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000, |
|
158 |
- 0x80000000, 0x00001000, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040, |
|
159 |
- 0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, 0x80401040, 0x80000040, |
|
160 |
- 0x00400040, 0x80400000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00000000, 0x00401000, |
|
161 |
- 0x00001040, 0x00400040, 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040, |
|
162 |
- 0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, 0x00401040, 0x80400040, |
|
163 |
- 0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040, |
|
164 |
- }, |
|
165 |
- { |
|
166 |
- 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000, |
|
167 |
- 0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000, |
|
168 |
- 0x01000000, 0x20040000, 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080, |
|
169 |
- 0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, 0x21000000, 0x00040080, |
|
170 |
- 0x00040000, 0x21000080, 0x00000080, 0x01000000, 0x20000000, 0x01040000, 0x21000080, 0x20040080, |
|
171 |
- 0x01000080, 0x20000000, 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000, |
|
172 |
- 0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, 0x20040000, 0x21000000, |
|
173 |
- 0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080, |
|
174 |
- }, |
|
175 |
- { |
|
176 |
- 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000, |
|
177 |
- 0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008, |
|
178 |
- 0x00000000, 0x00200008, 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008, |
|
179 |
- 0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, 0x10202000, 0x10000000, |
|
180 |
- 0x10002000, 0x00000008, 0x10200008, 0x00202000, 0x10202008, 0x00200000, 0x00002008, 0x10000008, |
|
181 |
- 0x00200000, 0x10002000, 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000, |
|
182 |
- 0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, 0x10200000, 0x00202008, |
|
183 |
- 0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008, |
|
184 |
- }, |
|
185 |
- { |
|
186 |
- 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400, |
|
187 |
- 0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401, |
|
188 |
- 0x02000400, 0x00100401, 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001, |
|
189 |
- 0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, 0x02000000, 0x00100400, |
|
190 |
- 0x02000000, 0x00100400, 0x00100000, 0x02000401, 0x02000401, 0x02100001, 0x02100001, 0x00000001, |
|
191 |
- 0x00100001, 0x02000000, 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400, |
|
192 |
- 0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, 0x00000001, 0x02100401, |
|
193 |
- 0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001, |
|
194 |
- }, |
|
195 |
- { |
|
196 |
- 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000, |
|
197 |
- 0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020, |
|
198 |
- 0x08020000, 0x08000020, 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800, |
|
199 |
- 0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, 0x00020820, 0x00020000, |
|
200 |
- 0x00020820, 0x00020000, 0x08020800, 0x00000800, 0x00000020, 0x08020020, 0x00000800, 0x00020820, |
|
201 |
- 0x08000800, 0x00000020, 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820, |
|
202 |
- 0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, 0x08000820, 0x00000000, |
|
203 |
- 0x08020820, 0x00020800, 0x00020800, 0x00000820, 0x00000820, 0x00020020, 0x08000000, 0x08020800, |
|
204 |
- }, |
|
125 |
+ { 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000, |
|
126 |
+ 0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002, |
|
127 |
+ 0x00000202, 0x00800200, 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202, |
|
128 |
+ 0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, 0x00008202, 0x00800000, |
|
129 |
+ 0x00008000, 0x00808202, 0x00000002, 0x00808000, 0x00808200, 0x00800000, 0x00800000, 0x00000200, |
|
130 |
+ 0x00808002, 0x00008000, 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202, |
|
131 |
+ 0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, 0x00008202, 0x00808200, |
|
132 |
+ 0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002, }, |
|
133 |
+ { 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010, |
|
134 |
+ 0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010, |
|
135 |
+ 0x00084000, 0x00080010, 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000, |
|
136 |
+ 0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, 0x40080000, 0x00004010, |
|
137 |
+ 0x00000000, 0x00084010, 0x40080010, 0x00080000, 0x40004010, 0x40080000, 0x40084000, 0x00004000, |
|
138 |
+ 0x40080000, 0x40004000, 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000, |
|
139 |
+ 0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, 0x40000010, 0x00080010, |
|
140 |
+ 0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000, }, |
|
141 |
+ { 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100, |
|
142 |
+ 0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104, |
|
143 |
+ 0x04000000, 0x00000004, 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104, |
|
144 |
+ 0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, 0x00000100, 0x04000000, |
|
145 |
+ 0x04010100, 0x04000000, 0x00010004, 0x00000104, 0x00010000, 0x04010100, 0x04000100, 0x00000000, |
|
146 |
+ 0x00000100, 0x00010004, 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004, |
|
147 |
+ 0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, 0x00010100, 0x04000004, |
|
148 |
+ 0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100, }, |
|
149 |
+ { 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000, |
|
150 |
+ 0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000, |
|
151 |
+ 0x80000000, 0x00001000, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040, |
|
152 |
+ 0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, 0x80401040, 0x80000040, |
|
153 |
+ 0x00400040, 0x80400000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00000000, 0x00401000, |
|
154 |
+ 0x00001040, 0x00400040, 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040, |
|
155 |
+ 0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, 0x00401040, 0x80400040, |
|
156 |
+ 0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040, }, |
|
157 |
+ { 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000, |
|
158 |
+ 0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000, |
|
159 |
+ 0x01000000, 0x20040000, 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080, |
|
160 |
+ 0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, 0x21000000, 0x00040080, |
|
161 |
+ 0x00040000, 0x21000080, 0x00000080, 0x01000000, 0x20000000, 0x01040000, 0x21000080, 0x20040080, |
|
162 |
+ 0x01000080, 0x20000000, 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000, |
|
163 |
+ 0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, 0x20040000, 0x21000000, |
|
164 |
+ 0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080, }, |
|
165 |
+ { 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000, |
|
166 |
+ 0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008, |
|
167 |
+ 0x00000000, 0x00200008, 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008, |
|
168 |
+ 0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, 0x10202000, 0x10000000, |
|
169 |
+ 0x10002000, 0x00000008, 0x10200008, 0x00202000, 0x10202008, 0x00200000, 0x00002008, 0x10000008, |
|
170 |
+ 0x00200000, 0x10002000, 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000, |
|
171 |
+ 0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, 0x10200000, 0x00202008, |
|
172 |
+ 0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008, }, |
|
173 |
+ { 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400, |
|
174 |
+ 0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401, |
|
175 |
+ 0x02000400, 0x00100401, 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001, |
|
176 |
+ 0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, 0x02000000, 0x00100400, |
|
177 |
+ 0x02000000, 0x00100400, 0x00100000, 0x02000401, 0x02000401, 0x02100001, 0x02100001, 0x00000001, |
|
178 |
+ 0x00100001, 0x02000000, 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400, |
|
179 |
+ 0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, 0x00000001, 0x02100401, |
|
180 |
+ 0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001, }, |
|
181 |
+ { 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000, |
|
182 |
+ 0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020, |
|
183 |
+ 0x08020000, 0x08000020, 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800, |
|
184 |
+ 0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, 0x00020820, 0x00020000, |
|
185 |
+ 0x00020820, 0x00020000, 0x08020800, 0x00000800, 0x00000020, 0x08020020, 0x00000800, 0x00020820, |
|
186 |
+ 0x08000800, 0x00000020, 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820, |
|
187 |
+ 0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, 0x08000820, 0x00000000, |
|
188 |
+ 0x08020820, 0x00020800, 0x00020800, 0x00000820, 0x00000820, 0x00020020, 0x08000000, 0x08020800, }, |
|
205 | 189 |
}; |
206 | 190 |
#endif |
207 | 191 |
|
208 |
-static uint64_t shuffle(uint64_t in, const uint8_t *shuffle, int shuffle_len) { |
|
192 |
+static uint64_t shuffle(uint64_t in, const uint8_t *shuffle, int shuffle_len) |
|
193 |
+{ |
|
209 | 194 |
int i; |
210 | 195 |
uint64_t res = 0; |
211 | 196 |
for (i = 0; i < shuffle_len; i++) |
... | ... |
@@ -213,7 +190,8 @@ static uint64_t shuffle(uint64_t in, const uint8_t *shuffle, int shuffle_len) { |
213 | 213 |
return res; |
214 | 214 |
} |
215 | 215 |
|
216 |
-static uint64_t shuffle_inv(uint64_t in, const uint8_t *shuffle, int shuffle_len) { |
|
216 |
+static uint64_t shuffle_inv(uint64_t in, const uint8_t *shuffle, int shuffle_len) |
|
217 |
+{ |
|
217 | 218 |
int i; |
218 | 219 |
uint64_t res = 0; |
219 | 220 |
shuffle += shuffle_len - 1; |
... | ... |
@@ -224,7 +202,8 @@ static uint64_t shuffle_inv(uint64_t in, const uint8_t *shuffle, int shuffle_len |
224 | 224 |
return res; |
225 | 225 |
} |
226 | 226 |
|
227 |
-static uint32_t f_func(uint32_t r, uint64_t k) { |
|
227 |
+static uint32_t f_func(uint32_t r, uint64_t k) |
|
228 |
+{ |
|
228 | 229 |
int i; |
229 | 230 |
uint32_t out = 0; |
230 | 231 |
// rotate to get first part of E-shuffle in the lowest 6 bits |
... | ... |
@@ -234,13 +213,14 @@ static uint32_t f_func(uint32_t r, uint64_t k) { |
234 | 234 |
uint8_t tmp = (r ^ k) & 0x3f; |
235 | 235 |
#if CONFIG_SMALL |
236 | 236 |
uint8_t v = S_boxes[i][tmp >> 1]; |
237 |
- if (tmp & 1) v >>= 4; |
|
237 |
+ if (tmp & 1) |
|
238 |
+ v >>= 4; |
|
238 | 239 |
out = (out >> 4) | (v << 28); |
239 | 240 |
#else |
240 | 241 |
out |= S_boxes_P_shuffle[i][tmp]; |
241 | 242 |
#endif |
242 | 243 |
// get next 6 bits of E-shuffle and round key k into the lowest bits |
243 |
- r = (r >> 4) | (r << 28); |
|
244 |
+ r = (r >> 4) | (r << 28); |
|
244 | 245 |
k >>= 6; |
245 | 246 |
} |
246 | 247 |
#if CONFIG_SMALL |
... | ... |
@@ -255,15 +235,17 @@ static uint32_t f_func(uint32_t r, uint64_t k) { |
255 | 255 |
* Note: the specification calls this "shift", so I kept it although |
256 | 256 |
* it is confusing. |
257 | 257 |
*/ |
258 |
-static uint64_t key_shift_left(uint64_t CDn) { |
|
258 |
+static uint64_t key_shift_left(uint64_t CDn) |
|
259 |
+{ |
|
259 | 260 |
uint64_t carries = (CDn >> 27) & 0x10000001; |
260 | 261 |
CDn <<= 1; |
261 |
- CDn &= ~0x10000001; |
|
262 |
- CDn |= carries; |
|
262 |
+ CDn &= ~0x10000001; |
|
263 |
+ CDn |= carries; |
|
263 | 264 |
return CDn; |
264 | 265 |
} |
265 | 266 |
|
266 |
-static void gen_roundkeys(uint64_t K[16], uint64_t key) { |
|
267 |
+static void gen_roundkeys(uint64_t K[16], uint64_t key) |
|
268 |
+{ |
|
267 | 269 |
int i; |
268 | 270 |
// discard parity bits from key and shuffle it into C and D parts |
269 | 271 |
uint64_t CDn = shuffle(key, PC1_shuffle, sizeof(PC1_shuffle)); |
... | ... |
@@ -276,7 +258,8 @@ static void gen_roundkeys(uint64_t K[16], uint64_t key) { |
276 | 276 |
} |
277 | 277 |
} |
278 | 278 |
|
279 |
-static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) { |
|
279 |
+static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) |
|
280 |
+{ |
|
280 | 281 |
int i; |
281 | 282 |
// used to apply round keys in reverse order for decryption |
282 | 283 |
decrypt = decrypt ? 15 : 0; |
... | ... |
@@ -285,8 +268,8 @@ static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) { |
285 | 285 |
for (i = 0; i < 16; i++) { |
286 | 286 |
uint32_t f_res; |
287 | 287 |
f_res = f_func(in, K[decrypt ^ i]); |
288 |
- in = (in << 32) | (in >> 32); |
|
289 |
- in ^= f_res; |
|
288 |
+ in = (in << 32) | (in >> 32); |
|
289 |
+ in ^= f_res; |
|
290 | 290 |
} |
291 | 291 |
in = (in << 32) | (in >> 32); |
292 | 292 |
// reverse shuffle used to ease hardware implementations |
... | ... |
@@ -299,7 +282,8 @@ AVDES *av_des_alloc(void) |
299 | 299 |
return av_mallocz(sizeof(struct AVDES)); |
300 | 300 |
} |
301 | 301 |
|
302 |
-int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) { |
|
302 |
+int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) |
|
303 |
+{ |
|
303 | 304 |
if (key_bits != 64 && key_bits != 192) |
304 | 305 |
return -1; |
305 | 306 |
d->triple_des = key_bits > 64; |
... | ... |
@@ -311,7 +295,9 @@ int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) { |
311 | 311 |
return 0; |
312 | 312 |
} |
313 | 313 |
|
314 |
-static void av_des_crypt_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt, int mac) { |
|
314 |
+static void av_des_crypt_mac(AVDES *d, uint8_t *dst, const uint8_t *src, |
|
315 |
+ int count, uint8_t *iv, int decrypt, int mac) |
|
316 |
+{ |
|
315 | 317 |
uint64_t iv_val = iv ? AV_RB64(iv) : 0; |
316 | 318 |
while (count-- > 0) { |
317 | 319 |
uint64_t dst_val; |
... | ... |
@@ -323,7 +309,7 @@ static void av_des_crypt_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int cou |
323 | 323 |
src_val = des_encdec(src_val, d->round_keys[1], 0); |
324 | 324 |
} |
325 | 325 |
dst_val = des_encdec(src_val, d->round_keys[0], 1) ^ iv_val; |
326 |
- iv_val = iv ? tmp : 0; |
|
326 |
+ iv_val = iv ? tmp : 0; |
|
327 | 327 |
} else { |
328 | 328 |
dst_val = des_encdec(src_val ^ iv_val, d->round_keys[0], 0); |
329 | 329 |
if (d->triple_des) { |
... | ... |
@@ -341,12 +327,15 @@ static void av_des_crypt_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int cou |
341 | 341 |
AV_WB64(iv, iv_val); |
342 | 342 |
} |
343 | 343 |
|
344 |
-void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt) { |
|
344 |
+void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, |
|
345 |
+ int count, uint8_t *iv, int decrypt) |
|
346 |
+{ |
|
345 | 347 |
av_des_crypt_mac(d, dst, src, count, iv, decrypt, 0); |
346 | 348 |
} |
347 | 349 |
|
348 |
-void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count) { |
|
349 |
- av_des_crypt_mac(d, dst, src, count, (uint8_t[8]){0}, 0, 1); |
|
350 |
+void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count) |
|
351 |
+{ |
|
352 |
+ av_des_crypt_mac(d, dst, src, count, (uint8_t[8]) { 0 }, 0, 1); |
|
350 | 353 |
} |
351 | 354 |
|
352 | 355 |
#ifdef TEST |
... | ... |
@@ -355,15 +344,16 @@ void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count) { |
355 | 355 |
|
356 | 356 |
#include "time.h" |
357 | 357 |
|
358 |
-static uint64_t rand64(void) { |
|
358 |
+static uint64_t rand64(void) |
|
359 |
+{ |
|
359 | 360 |
uint64_t r = rand(); |
360 | 361 |
r = (r << 32) | rand(); |
361 | 362 |
return r; |
362 | 363 |
} |
363 | 364 |
|
364 |
-static const uint8_t test_key[] = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0}; |
|
365 |
-static const DECLARE_ALIGNED(8, uint8_t, plain)[] = {0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}; |
|
366 |
-static const DECLARE_ALIGNED(8, uint8_t, crypt)[] = {0x4a, 0xb6, 0x5b, 0x3d, 0x4b, 0x06, 0x15, 0x18}; |
|
365 |
+static const uint8_t test_key[] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 }; |
|
366 |
+static const DECLARE_ALIGNED(8, uint8_t, plain)[] = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }; |
|
367 |
+static const DECLARE_ALIGNED(8, uint8_t, crypt)[] = { 0x4a, 0xb6, 0x5b, 0x3d, 0x4b, 0x06, 0x15, 0x18 }; |
|
367 | 368 |
static DECLARE_ALIGNED(8, uint8_t, tmp)[8]; |
368 | 369 |
static DECLARE_ALIGNED(8, uint8_t, large_buffer)[10002][8]; |
369 | 370 |
static const uint8_t cbc_key[] = { |
... | ... |
@@ -372,7 +362,8 @@ static const uint8_t cbc_key[] = { |
372 | 372 |
0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23 |
373 | 373 |
}; |
374 | 374 |
|
375 |
-static int run_test(int cbc, int decrypt) { |
|
375 |
+static int run_test(int cbc, int decrypt) |
|
376 |
+{ |
|
376 | 377 |
AVDES d; |
377 | 378 |
int delay = cbc && !decrypt ? 2 : 1; |
378 | 379 |
uint64_t res; |
... | ... |
@@ -395,7 +386,8 @@ static int run_test(int cbc, int decrypt) { |
395 | 395 |
} |
396 | 396 |
} |
397 | 397 |
|
398 |
-int main(void) { |
|
398 |
+int main(void) |
|
399 |
+{ |
|
399 | 400 |
AVDES d; |
400 | 401 |
int i; |
401 | 402 |
uint64_t key[3]; |
... | ... |
@@ -404,7 +396,7 @@ int main(void) { |
404 | 404 |
uint64_t roundkeys[16]; |
405 | 405 |
srand(av_gettime()); |
406 | 406 |
key[0] = AV_RB64(test_key); |
407 |
- data = AV_RB64(plain); |
|
407 |
+ data = AV_RB64(plain); |
|
408 | 408 |
gen_roundkeys(roundkeys, key[0]); |
409 | 409 |
if (des_encdec(data, roundkeys, 0) != AV_RB64(crypt)) { |
410 | 410 |
printf("Test 1 failed\n"); |
... | ... |
@@ -421,8 +413,10 @@ int main(void) { |
421 | 421 |
return 1; |
422 | 422 |
} |
423 | 423 |
for (i = 0; i < 1000; i++) { |
424 |
- key[0] = rand64(); key[1] = rand64(); key[2] = rand64(); |
|
425 |
- data = rand64(); |
|
424 |
+ key[0] = rand64(); |
|
425 |
+ key[1] = rand64(); |
|
426 |
+ key[2] = rand64(); |
|
427 |
+ data = rand64(); |
|
426 | 428 |
av_des_init(&d, key, 192, 0); |
427 | 429 |
av_des_crypt(&d, &ct, &data, 1, NULL, 0); |
428 | 430 |
av_des_init(&d, key, 192, 1); |
... | ... |
@@ -439,9 +433,9 @@ int main(void) { |
439 | 439 |
printf(" {"); |
440 | 440 |
for (j = 0; j < 64; j++) { |
441 | 441 |
uint32_t v = S_boxes[i][j >> 1]; |
442 |
- v = j & 1 ? v >> 4 : v & 0xf; |
|
442 |
+ v = j & 1 ? v >> 4 : v & 0xf; |
|
443 | 443 |
v <<= 28 - 4 * i; |
444 |
- v = shuffle(v, P_shuffle, sizeof(P_shuffle)); |
|
444 |
+ v = shuffle(v, P_shuffle, sizeof(P_shuffle)); |
|
445 | 445 |
printf((j & 7) == 0 ? "\n " : " "); |
446 | 446 |
printf("0x%08X,", v); |
447 | 447 |
} |
... | ... |
@@ -141,7 +141,7 @@ int main(void) |
141 | 141 |
LOCAL_ALIGNED(32, double, var, [4]); |
142 | 142 |
double eval; |
143 | 143 |
|
144 |
- var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2; |
|
144 |
+ var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2; |
|
145 | 145 |
var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5; |
146 | 146 |
var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5; |
147 | 147 |
var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5; |
... | ... |
@@ -31,12 +31,13 @@ |
31 | 31 |
*/ |
32 | 32 |
|
33 | 33 |
#include <stdint.h> |
34 |
+ |
|
34 | 35 |
#include "bswap.h" |
35 | 36 |
#include "intreadwrite.h" |
36 |
-#include "md5.h" |
|
37 | 37 |
#include "mem.h" |
38 |
+#include "md5.h" |
|
38 | 39 |
|
39 |
-typedef struct AVMD5{ |
|
40 |
+typedef struct AVMD5 { |
|
40 | 41 |
uint64_t len; |
41 | 42 |
uint8_t block[64]; |
42 | 43 |
uint32_t ABCD[4]; |
... | ... |
@@ -76,16 +77,21 @@ static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32) |
76 | 76 |
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, |
77 | 77 |
}; |
78 | 78 |
|
79 |
-#define CORE(i, a, b, c, d) do { \ |
|
80 |
- t = S[i >> 4][i & 3]; \ |
|
79 |
+#define CORE(i, a, b, c, d) \ |
|
80 |
+ do { \ |
|
81 |
+ t = S[i >> 4][i & 3]; \ |
|
81 | 82 |
a += T[i]; \ |
82 | 83 |
\ |
83 | 84 |
if (i < 32) { \ |
84 |
- if (i < 16) a += (d ^ (b & (c ^ d))) + X[ i & 15]; \ |
|
85 |
- else a += (c ^ (d & (c ^ b))) + X[(1 + 5*i) & 15]; \ |
|
85 |
+ if (i < 16) \ |
|
86 |
+ a += (d ^ (b & (c ^ d))) + X[i & 15]; \ |
|
87 |
+ else \ |
|
88 |
+ a += (c ^ (d & (c ^ b))) + X[(1 + 5 * i) & 15]; \ |
|
86 | 89 |
} else { \ |
87 |
- if (i < 48) a += (b ^ c ^ d) + X[(5 + 3*i) & 15]; \ |
|
88 |
- else a += (c ^ (b | ~d)) + X[( 7*i) & 15]; \ |
|
90 |
+ if (i < 48) \ |
|
91 |
+ a += (b ^ c ^ d) + X[(5 + 3 * i) & 15]; \ |
|
92 |
+ else \ |
|
93 |
+ a += (c ^ (b | ~d)) + X[(7 * i) & 15]; \ |
|
89 | 94 |
} \ |
90 | 95 |
a = b + (a << t | a >> (32 - t)); \ |
91 | 96 |
} while (0) |
... | ... |
@@ -115,10 +121,13 @@ static void body(uint32_t ABCD[4], uint32_t X[16]) |
115 | 115 |
} |
116 | 116 |
#else |
117 | 117 |
#define CORE2(i) \ |
118 |
- CORE( i, a,b,c,d); CORE((i+1),d,a,b,c); \ |
|
119 |
- CORE((i+2),c,d,a,b); CORE((i+3),b,c,d,a) |
|
120 |
-#define CORE4(i) CORE2(i); CORE2((i+4)); CORE2((i+8)); CORE2((i+12)) |
|
121 |
- CORE4(0); CORE4(16); CORE4(32); CORE4(48); |
|
118 |
+ CORE(i, a, b, c, d); CORE((i + 1), d, a, b, c); \ |
|
119 |
+ CORE((i + 2), c, d, a, b); CORE((i + 3), b, c, d, a) |
|
120 |
+#define CORE4(i) CORE2(i); CORE2((i + 4)); CORE2((i + 8)); CORE2((i + 12)) |
|
121 |
+ CORE4(0); |
|
122 |
+ CORE4(16); |
|
123 |
+ CORE4(32); |
|
124 |
+ CORE4(48); |
|
122 | 125 |
#endif |
123 | 126 |
|
124 | 127 |
ABCD[0] += d; |
... | ... |
@@ -141,7 +150,7 @@ void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len) |
141 | 141 |
{ |
142 | 142 |
int i, j; |
143 | 143 |
|
144 |
- j = ctx->len & 63; |
|
144 |
+ j = ctx->len & 63; |
|
145 | 145 |
ctx->len += len; |
146 | 146 |
|
147 | 147 |
for (i = 0; i < len; i++) { |
... | ... |
@@ -162,10 +171,10 @@ void av_md5_final(AVMD5 *ctx, uint8_t *dst) |
162 | 162 |
while ((ctx->len & 63) != 56) |
163 | 163 |
av_md5_update(ctx, "", 1); |
164 | 164 |
|
165 |
- av_md5_update(ctx, (uint8_t *)&finalcount, 8); |
|
165 |
+ av_md5_update(ctx, (uint8_t *) &finalcount, 8); |
|
166 | 166 |
|
167 | 167 |
for (i = 0; i < 4; i++) |
168 |
- AV_WL32(dst + 4*i, ctx->ABCD[3 - i]); |
|
168 |
+ AV_WL32(dst + 4 * i, ctx->ABCD[3 - i]); |
|
169 | 169 |
} |
170 | 170 |
|
171 | 171 |
void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len) |
... | ... |
@@ -188,20 +197,26 @@ static void print_md5(uint8_t *md5) |
188 | 188 |
printf("\n"); |
189 | 189 |
} |
190 | 190 |
|
191 |
-int main(void){ |
|
191 |
+int main(void) |
|
192 |
+{ |
|
192 | 193 |
uint8_t md5val[16]; |
193 | 194 |
int i; |
194 | 195 |
uint8_t in[1000]; |
195 | 196 |
|
196 | 197 |
for (i = 0; i < 1000; i++) |
197 | 198 |
in[i] = i * i; |
198 |
- av_md5_sum(md5val, in, 1000); print_md5(md5val); |
|
199 |
- av_md5_sum(md5val, in, 63); print_md5(md5val); |
|
200 |
- av_md5_sum(md5val, in, 64); print_md5(md5val); |
|
201 |
- av_md5_sum(md5val, in, 65); print_md5(md5val); |
|
199 |
+ av_md5_sum(md5val, in, 1000); |
|
200 |
+ print_md5(md5val); |
|
201 |
+ av_md5_sum(md5val, in, 63); |
|
202 |
+ print_md5(md5val); |
|
203 |
+ av_md5_sum(md5val, in, 64); |
|
204 |
+ print_md5(md5val); |
|
205 |
+ av_md5_sum(md5val, in, 65); |
|
206 |
+ print_md5(md5val); |
|
202 | 207 |
for (i = 0; i < 1000; i++) |
203 | 208 |
in[i] = i % 127; |
204 |
- av_md5_sum(md5val, in, 999); print_md5(md5val); |
|
209 |
+ av_md5_sum(md5val, in, 999); |
|
210 |
+ print_md5(md5val); |
|
205 | 211 |
|
206 | 212 |
return 0; |
207 | 213 |
} |
... | ... |
@@ -25,18 +25,18 @@ |
25 | 25 |
* @author Michael Niedermayer <michaelni@gmx.at> |
26 | 26 |
*/ |
27 | 27 |
|
28 |
-#include "avutil.h" |
|
29 | 28 |
#include "avstring.h" |
29 |
+#include "avutil.h" |
|
30 | 30 |
#include "common.h" |
31 |
-#include "opt.h" |
|
32 |
-#include "eval.h" |
|
33 | 31 |
#include "dict.h" |
32 |
+#include "eval.h" |
|
34 | 33 |
#include "log.h" |
35 | 34 |
#include "mathematics.h" |
35 |
+#include "opt.h" |
|
36 | 36 |
|
37 | 37 |
const AVOption *av_opt_next(const void *obj, const AVOption *last) |
38 | 38 |
{ |
39 |
- AVClass *class = *(AVClass**)obj; |
|
39 |
+ AVClass *class = *(AVClass **)obj; |
|
40 | 40 |
if (!last && class->option && class->option[0].name) |
41 | 41 |
return class->option; |
42 | 42 |
if (last && last[1].name) |
... | ... |
@@ -47,14 +47,25 @@ const AVOption *av_opt_next(const void *obj, const AVOption *last) |
47 | 47 |
static int read_number(const AVOption *o, const void *dst, double *num, int *den, int64_t *intnum) |
48 | 48 |
{ |
49 | 49 |
switch (o->type) { |
50 |
- case AV_OPT_TYPE_FLAGS: *intnum = *(unsigned int*)dst;return 0; |
|
51 |
- case AV_OPT_TYPE_INT: *intnum = *(int *)dst;return 0; |
|
52 |
- case AV_OPT_TYPE_INT64: *intnum = *(int64_t *)dst;return 0; |
|
53 |
- case AV_OPT_TYPE_FLOAT: *num = *(float *)dst;return 0; |
|
54 |
- case AV_OPT_TYPE_DOUBLE: *num = *(double *)dst;return 0; |
|
55 |
- case AV_OPT_TYPE_RATIONAL: *intnum = ((AVRational*)dst)->num; |
|
56 |
- *den = ((AVRational*)dst)->den; |
|
57 |
- return 0; |
|
50 |
+ case AV_OPT_TYPE_FLAGS: |
|
51 |
+ *intnum = *(unsigned int *)dst; |
|
52 |
+ return 0; |
|
53 |
+ case AV_OPT_TYPE_INT: |
|
54 |
+ *intnum = *(int *)dst; |
|
55 |
+ return 0; |
|
56 |
+ case AV_OPT_TYPE_INT64: |
|
57 |
+ *intnum = *(int64_t *)dst; |
|
58 |
+ return 0; |
|
59 |
+ case AV_OPT_TYPE_FLOAT: |
|
60 |
+ *num = *(float *)dst; |
|
61 |
+ return 0; |
|
62 |
+ case AV_OPT_TYPE_DOUBLE: |
|
63 |
+ *num = *(double *)dst; |
|
64 |
+ return 0; |
|
65 |
+ case AV_OPT_TYPE_RATIONAL: |
|
66 |
+ *intnum = ((AVRational *)dst)->num; |
|
67 |
+ *den = ((AVRational *)dst)->den; |
|
68 |
+ return 0; |
|
58 | 69 |
} |
59 | 70 |
return AVERROR(EINVAL); |
60 | 71 |
} |
... | ... |
@@ -64,19 +75,29 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int |
64 | 64 |
if (o->type != AV_OPT_TYPE_FLAGS && |
65 | 65 |
(o->max * den < num * intnum || o->min * den > num * intnum)) { |
66 | 66 |
av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range\n", |
67 |
- num*intnum/den, o->name); |
|
67 |
+ num * intnum / den, o->name); |
|
68 | 68 |
return AVERROR(ERANGE); |
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
switch (o->type) { |
72 | 72 |
case AV_OPT_TYPE_FLAGS: |
73 |
- case AV_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break; |
|
74 |
- case AV_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break; |
|
75 |
- case AV_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break; |
|
76 |
- case AV_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break; |
|
73 |
+ case AV_OPT_TYPE_INT: |
|
74 |
+ *(int *)dst = llrint(num / den) * intnum; |
|
75 |
+ break; |
|
76 |
+ case AV_OPT_TYPE_INT64: |
|
77 |
+ *(int64_t *)dst = llrint(num / den) * intnum; |
|
78 |
+ break; |
|
79 |
+ case AV_OPT_TYPE_FLOAT: |
|
80 |
+ *(float *)dst = num * intnum / den; |
|
81 |
+ break; |
|
82 |
+ case AV_OPT_TYPE_DOUBLE: |
|
83 |
+ *(double *)dst = num * intnum / den; |
|
84 |
+ break; |
|
77 | 85 |
case AV_OPT_TYPE_RATIONAL: |
78 |
- if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den}; |
|
79 |
- else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24); |
|
86 |
+ if ((int) num == num) |
|
87 |
+ *(AVRational *)dst = (AVRational) { num *intnum, den }; |
|
88 |
+ else |
|
89 |
+ *(AVRational *)dst = av_d2q(num * intnum / den, 1 << 24); |
|
80 | 90 |
break; |
81 | 91 |
default: |
82 | 92 |
return AVERROR(EINVAL); |
... | ... |
@@ -91,17 +112,21 @@ static const double const_values[] = { |
91 | 91 |
0 |
92 | 92 |
}; |
93 | 93 |
|
94 |
-static const char * const const_names[] = { |
|
94 |
+static const char *const const_names[] = { |
|
95 | 95 |
"PI", |
96 | 96 |
"E", |
97 | 97 |
"QP2LAMBDA", |
98 | 98 |
0 |
99 | 99 |
}; |
100 | 100 |
|
101 |
-static int hexchar2int(char c) { |
|
102 |
- if (c >= '0' && c <= '9') return c - '0'; |
|
103 |
- if (c >= 'a' && c <= 'f') return c - 'a' + 10; |
|
104 |
- if (c >= 'A' && c <= 'F') return c - 'A' + 10; |
|
101 |
+static int hexchar2int(char c) |
|
102 |
+{ |
|
103 |
+ if (c >= '0' && c <= '9') |
|
104 |
+ return c - '0'; |
|
105 |
+ if (c >= 'a' && c <= 'f') |
|
106 |
+ return c - 'a' + 10; |
|
107 |
+ if (c >= 'A' && c <= 'F') |
|
108 |
+ return c - 'A' + 10; |
|
105 | 109 |
return -1; |
106 | 110 |
} |
107 | 111 |
|
... | ... |
@@ -130,7 +155,7 @@ static int set_string_binary(void *obj, const AVOption *o, const char *val, uint |
130 | 130 |
} |
131 | 131 |
*ptr++ = (a << 4) | b; |
132 | 132 |
} |
133 |
- *dst = bin; |
|
133 |
+ *dst = bin; |
|
134 | 134 |
*lendst = len; |
135 | 135 |
|
136 | 136 |
return 0; |
... | ... |
@@ -146,8 +171,9 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d |
146 | 146 |
#define DEFAULT_NUMVAL(opt) ((opt->type == AV_OPT_TYPE_INT64 || \ |
147 | 147 |
opt->type == AV_OPT_TYPE_CONST || \ |
148 | 148 |
opt->type == AV_OPT_TYPE_FLAGS || \ |
149 |
- opt->type == AV_OPT_TYPE_INT) ? \ |
|
150 |
- opt->default_val.i64 : opt->default_val.dbl) |
|
149 |
+ opt->type == AV_OPT_TYPE_INT) \ |
|
150 |
+ ? opt->default_val.i64 \ |
|
151 |
+ : opt->default_val.dbl) |
|
151 | 152 |
|
152 | 153 |
static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst) |
153 | 154 |
{ |
... | ... |
@@ -175,11 +201,16 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con |
175 | 175 |
const AVOption *o_named = av_opt_find(target_obj, buf, o->unit, 0, 0); |
176 | 176 |
if (o_named && o_named->type == AV_OPT_TYPE_CONST) |
177 | 177 |
d = DEFAULT_NUMVAL(o_named); |
178 |
- else if (!strcmp(buf, "default")) d = DEFAULT_NUMVAL(o); |
|
179 |
- else if (!strcmp(buf, "max" )) d = o->max; |
|
180 |
- else if (!strcmp(buf, "min" )) d = o->min; |
|
181 |
- else if (!strcmp(buf, "none" )) d = 0; |
|
182 |
- else if (!strcmp(buf, "all" )) d = ~0; |
|
178 |
+ else if (!strcmp(buf, "default")) |
|
179 |
+ d = DEFAULT_NUMVAL(o); |
|
180 |
+ else if (!strcmp(buf, "max")) |
|
181 |
+ d = o->max; |
|
182 |
+ else if (!strcmp(buf, "min")) |
|
183 |
+ d = o->min; |
|
184 |
+ else if (!strcmp(buf, "none")) |
|
185 |
+ d = 0; |
|
186 |
+ else if (!strcmp(buf, "all")) |
|
187 |
+ d = ~0; |
|
183 | 188 |
else { |
184 | 189 |
int res = av_expr_parse_and_eval(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj); |
185 | 190 |
if (res < 0) { |
... | ... |
@@ -190,12 +221,16 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con |
190 | 190 |
} |
191 | 191 |
if (o->type == AV_OPT_TYPE_FLAGS) { |
192 | 192 |
read_number(o, dst, NULL, NULL, &intnum); |
193 |
- if (cmd == '+') d = intnum | (int64_t)d; |
|
194 |
- else if (cmd == '-') d = intnum &~(int64_t)d; |
|
193 |
+ if (cmd == '+') |
|
194 |
+ d = intnum | (int64_t)d; |
|
195 |
+ else if (cmd == '-') |
|
196 |
+ d = intnum & ~(int64_t)d; |
|
195 | 197 |
} else { |
196 | 198 |
read_number(o, dst, &num, &den, &intnum); |
197 |
- if (cmd == '+') d = notfirst*num*intnum/den + d; |
|
198 |
- else if (cmd == '-') d = notfirst*num*intnum/den - d; |
|
199 |
+ if (cmd == '+') |
|
200 |
+ d = notfirst * num * intnum / den + d; |
|
201 |
+ else if (cmd == '-') |
|
202 |
+ d = notfirst * num * intnum / den - d; |
|
199 | 203 |
} |
200 | 204 |
|
201 | 205 |
if ((ret = write_number(obj, o, dst, d, 1, 1)) < 0) |
... | ... |
@@ -218,29 +253,33 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) |
218 | 218 |
if (!val || o->flags & AV_OPT_FLAG_READONLY) |
219 | 219 |
return AVERROR(EINVAL); |
220 | 220 |
|
221 |
- dst = ((uint8_t*)target_obj) + o->offset; |
|
221 |
+ dst = ((uint8_t *)target_obj) + o->offset; |
|
222 | 222 |
switch (o->type) { |
223 |
- case AV_OPT_TYPE_STRING: return set_string(obj, o, val, dst); |
|
224 |
- case AV_OPT_TYPE_BINARY: return set_string_binary(obj, o, val, dst); |
|
223 |
+ case AV_OPT_TYPE_STRING: |
|
224 |
+ return set_string(obj, o, val, dst); |
|
225 |
+ case AV_OPT_TYPE_BINARY: |
|
226 |
+ return set_string_binary(obj, o, val, dst); |
|
225 | 227 |
case AV_OPT_TYPE_FLAGS: |
226 | 228 |
case AV_OPT_TYPE_INT: |
227 | 229 |
case AV_OPT_TYPE_INT64: |
228 | 230 |
case AV_OPT_TYPE_FLOAT: |
229 | 231 |
case AV_OPT_TYPE_DOUBLE: |
230 |
- case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, target_obj, o, val, dst); |
|
232 |
+ case AV_OPT_TYPE_RATIONAL: |
|
233 |
+ return set_string_number(obj, target_obj, o, val, dst); |
|
231 | 234 |
} |
232 | 235 |
|
233 | 236 |
av_log(obj, AV_LOG_ERROR, "Invalid option type.\n"); |
234 | 237 |
return AVERROR(EINVAL); |
235 | 238 |
} |
236 | 239 |
|
237 |
-#define OPT_EVAL_NUMBER(name, opttype, vartype)\ |
|
238 |
- int av_opt_eval_ ## name(void *obj, const AVOption *o, const char *val, vartype *name ## _out)\ |
|
239 |
- {\ |
|
240 |
- if (!o || o->type != opttype || o->flags & AV_OPT_FLAG_READONLY)\ |
|
241 |
- return AVERROR(EINVAL);\ |
|
242 |
- return set_string_number(obj, obj, o, val, name ## _out);\ |
|
243 |
- } |
|
240 |
+#define OPT_EVAL_NUMBER(name, opttype, vartype) \ |
|
241 |
+int av_opt_eval_ ## name(void *obj, const AVOption *o, \ |
|
242 |
+ const char *val, vartype *name ## _out) \ |
|
243 |
+{ \ |
|
244 |
+ if (!o || o->type != opttype || o->flags & AV_OPT_FLAG_READONLY) \ |
|
245 |
+ return AVERROR(EINVAL); \ |
|
246 |
+ return set_string_number(obj, obj, o, val, name ## _out); \ |
|
247 |
+} |
|
244 | 248 |
|
245 | 249 |
OPT_EVAL_NUMBER(flags, AV_OPT_TYPE_FLAGS, int) |
246 | 250 |
OPT_EVAL_NUMBER(int, AV_OPT_TYPE_INT, int) |
... | ... |
@@ -250,7 +289,7 @@ OPT_EVAL_NUMBER(double, AV_OPT_TYPE_DOUBLE, double) |
250 | 250 |
OPT_EVAL_NUMBER(q, AV_OPT_TYPE_RATIONAL, AVRational) |
251 | 251 |
|
252 | 252 |
static int set_number(void *obj, const char *name, double num, int den, int64_t intnum, |
253 |
- int search_flags) |
|
253 |
+ int search_flags) |
|
254 | 254 |
{ |
255 | 255 |
void *dst, *target_obj; |
256 | 256 |
const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); |
... | ... |
@@ -261,7 +300,7 @@ static int set_number(void *obj, const char *name, double num, int den, int64_t |
261 | 261 |
if (o->flags & AV_OPT_FLAG_READONLY) |
262 | 262 |
return AVERROR(EINVAL); |
263 | 263 |
|
264 |
- dst = ((uint8_t*)target_obj) + o->offset; |
|
264 |
+ dst = ((uint8_t *)target_obj) + o->offset; |
|
265 | 265 |
return write_number(obj, o, dst, num, den, intnum); |
266 | 266 |
} |
267 | 267 |
|
... | ... |
@@ -298,18 +337,19 @@ int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int |
298 | 298 |
if (!ptr) |
299 | 299 |
return AVERROR(ENOMEM); |
300 | 300 |
|
301 |
- dst = (uint8_t **)(((uint8_t *)target_obj) + o->offset); |
|
301 |
+ dst = (uint8_t **)(((uint8_t *)target_obj) + o->offset); |
|
302 | 302 |
lendst = (int *)(dst + 1); |
303 | 303 |
|
304 | 304 |
av_free(*dst); |
305 |
- *dst = ptr; |
|
305 |
+ *dst = ptr; |
|
306 | 306 |
*lendst = len; |
307 | 307 |
memcpy(ptr, val, len); |
308 | 308 |
|
309 | 309 |
return 0; |
310 | 310 |
} |
311 | 311 |
|
312 |
-int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags) |
|
312 |
+int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, |
|
313 |
+ int search_flags) |
|
313 | 314 |
{ |
314 | 315 |
void *target_obj; |
315 | 316 |
AVDictionary **dst; |
... | ... |
@@ -337,31 +377,44 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) |
337 | 337 |
if (!o || !target_obj) |
338 | 338 |
return AVERROR_OPTION_NOT_FOUND; |
339 | 339 |
|
340 |
- dst = (uint8_t*)target_obj + o->offset; |
|
340 |
+ dst = (uint8_t *)target_obj + o->offset; |
|
341 | 341 |
|
342 | 342 |
buf[0] = 0; |
343 | 343 |
switch (o->type) { |
344 |
- case AV_OPT_TYPE_FLAGS: ret = snprintf(buf, sizeof(buf), "0x%08X", *(int *)dst);break; |
|
345 |
- case AV_OPT_TYPE_INT: ret = snprintf(buf, sizeof(buf), "%d" , *(int *)dst);break; |
|
346 |
- case AV_OPT_TYPE_INT64: ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break; |
|
347 |
- case AV_OPT_TYPE_FLOAT: ret = snprintf(buf, sizeof(buf), "%f" , *(float *)dst);break; |
|
348 |
- case AV_OPT_TYPE_DOUBLE: ret = snprintf(buf, sizeof(buf), "%f" , *(double *)dst);break; |
|
349 |
- case AV_OPT_TYPE_RATIONAL: ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break; |
|
344 |
+ case AV_OPT_TYPE_FLAGS: |
|
345 |
+ ret = snprintf(buf, sizeof(buf), "0x%08X", *(int *)dst); |
|
346 |
+ break; |
|
347 |
+ case AV_OPT_TYPE_INT: |
|
348 |
+ ret = snprintf(buf, sizeof(buf), "%d", *(int *)dst); |
|
349 |
+ break; |
|
350 |
+ case AV_OPT_TYPE_INT64: |
|
351 |
+ ret = snprintf(buf, sizeof(buf), "%" PRId64, *(int64_t *)dst); |
|
352 |
+ break; |
|
353 |
+ case AV_OPT_TYPE_FLOAT: |
|
354 |
+ ret = snprintf(buf, sizeof(buf), "%f", *(float *)dst); |
|
355 |
+ break; |
|
356 |
+ case AV_OPT_TYPE_DOUBLE: |
|
357 |
+ ret = snprintf(buf, sizeof(buf), "%f", *(double *)dst); |
|
358 |
+ break; |
|
359 |
+ case AV_OPT_TYPE_RATIONAL: |
|
360 |
+ ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational *)dst)->num, |
|
361 |
+ ((AVRational *)dst)->den); |
|
362 |
+ break; |
|
350 | 363 |
case AV_OPT_TYPE_STRING: |
351 |
- if (*(uint8_t**)dst) |
|
352 |
- *out_val = av_strdup(*(uint8_t**)dst); |
|
364 |
+ if (*(uint8_t **)dst) |
|
365 |
+ *out_val = av_strdup(*(uint8_t **)dst); |
|
353 | 366 |
else |
354 | 367 |
*out_val = av_strdup(""); |
355 | 368 |
return *out_val ? 0 : AVERROR(ENOMEM); |
356 | 369 |
case AV_OPT_TYPE_BINARY: |
357 |
- len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *)); |
|
358 |
- if ((uint64_t)len*2 + 1 > INT_MAX) |
|
370 |
+ len = *(int *)(((uint8_t *)dst) + sizeof(uint8_t *)); |
|
371 |
+ if ((uint64_t)len * 2 + 1 > INT_MAX) |
|
359 | 372 |
return AVERROR(EINVAL); |
360 |
- if (!(*out_val = av_malloc(len*2 + 1))) |
|
373 |
+ if (!(*out_val = av_malloc(len * 2 + 1))) |
|
361 | 374 |
return AVERROR(ENOMEM); |
362 |
- bin = *(uint8_t**)dst; |
|
375 |
+ bin = *(uint8_t **)dst; |
|
363 | 376 |
for (i = 0; i < len; i++) |
364 |
- snprintf(*out_val + i*2, 3, "%02X", bin[i]); |
|
377 |
+ snprintf(*out_val + i * 2, 3, "%02X", bin[i]); |
|
365 | 378 |
return 0; |
366 | 379 |
default: |
367 | 380 |
return AVERROR(EINVAL); |
... | ... |
@@ -381,52 +434,53 @@ static int get_number(void *obj, const char *name, double *num, int *den, int64_ |
381 | 381 |
if (!o || !target_obj) |
382 | 382 |
goto error; |
383 | 383 |
|
384 |
- dst = ((uint8_t*)target_obj) + o->offset; |
|
384 |
+ dst = ((uint8_t *)target_obj) + o->offset; |
|
385 | 385 |
|
386 | 386 |
return read_number(o, dst, num, den, intnum); |
387 | 387 |
|
388 | 388 |
error: |
389 |
- *den=*intnum=0; |
|
389 |
+ *den = |
|
390 |
+ *intnum = 0; |
|
390 | 391 |
return -1; |
391 | 392 |
} |
392 | 393 |
|
393 | 394 |
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val) |
394 | 395 |
{ |
395 | 396 |
int64_t intnum = 1; |
396 |
- double num = 1; |
|
397 |
- int ret, den = 1; |
|
397 |
+ double num = 1; |
|
398 |
+ int ret, den = 1; |
|
398 | 399 |
|
399 | 400 |
if ((ret = get_number(obj, name, &num, &den, &intnum, search_flags)) < 0) |
400 | 401 |
return ret; |
401 |
- *out_val = num*intnum/den; |
|
402 |
+ *out_val = num * intnum / den; |
|
402 | 403 |
return 0; |
403 | 404 |
} |
404 | 405 |
|
405 | 406 |
int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val) |
406 | 407 |
{ |
407 | 408 |
int64_t intnum = 1; |
408 |
- double num = 1; |
|
409 |
- int ret, den = 1; |
|
409 |
+ double num = 1; |
|
410 |
+ int ret, den = 1; |
|
410 | 411 |
|
411 | 412 |
if ((ret = get_number(obj, name, &num, &den, &intnum, search_flags)) < 0) |
412 | 413 |
return ret; |
413 |
- *out_val = num*intnum/den; |
|
414 |
+ *out_val = num * intnum / den; |
|
414 | 415 |
return 0; |
415 | 416 |
} |
416 | 417 |
|
417 | 418 |
int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_val) |
418 | 419 |
{ |
419 | 420 |
int64_t intnum = 1; |
420 |
- double num = 1; |
|
421 |
- int ret, den = 1; |
|
421 |
+ double num = 1; |
|
422 |
+ int ret, den = 1; |
|
422 | 423 |
|
423 | 424 |
if ((ret = get_number(obj, name, &num, &den, &intnum, search_flags)) < 0) |
424 | 425 |
return ret; |
425 | 426 |
|
426 | 427 |
if (num == 1.0 && (int)intnum == intnum) |
427 |
- *out_val = (AVRational){intnum, den}; |
|
428 |
+ *out_val = (AVRational) { intnum, den }; |
|
428 | 429 |
else |
429 |
- *out_val = av_d2q(num*intnum/den, 1<<24); |
|
430 |
+ *out_val = av_d2q(num * intnum / den, 1 << 24); |
|
430 | 431 |
return 0; |
431 | 432 |
} |
432 | 433 |
|
... | ... |
@@ -463,7 +517,7 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name) |
463 | 463 |
static void opt_list(void *obj, void *av_log_obj, const char *unit, |
464 | 464 |
int req_flags, int rej_flags) |
465 | 465 |
{ |
466 |
- const AVOption *opt=NULL; |
|
466 |
+ const AVOption *opt = NULL; |
|
467 | 467 |
|
468 | 468 |
while ((opt = av_opt_next(obj, opt))) { |
469 | 469 |
if (!(opt->flags & req_flags) || (opt->flags & rej_flags)) |
... | ... |
@@ -473,11 +527,11 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, |
473 | 473 |
* Don't print anything but CONST's on level two. |
474 | 474 |
* Only print items from the requested unit. |
475 | 475 |
*/ |
476 |
- if (!unit && opt->type==AV_OPT_TYPE_CONST) |
|
476 |
+ if (!unit && opt->type == AV_OPT_TYPE_CONST) |
|
477 | 477 |
continue; |
478 |
- else if (unit && opt->type!=AV_OPT_TYPE_CONST) |
|
478 |
+ else if (unit && opt->type != AV_OPT_TYPE_CONST) |
|
479 | 479 |
continue; |
480 |
- else if (unit && opt->type==AV_OPT_TYPE_CONST && strcmp(unit, opt->unit)) |
|
480 |
+ else if (unit && opt->type == AV_OPT_TYPE_CONST && strcmp(unit, opt->unit)) |
|
481 | 481 |
continue; |
482 | 482 |
else if (unit && opt->type == AV_OPT_TYPE_CONST) |
483 | 483 |
av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name); |
... | ... |
@@ -485,39 +539,39 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, |
485 | 485 |
av_log(av_log_obj, AV_LOG_INFO, "-%-17s ", opt->name); |
486 | 486 |
|
487 | 487 |
switch (opt->type) { |
488 |
- case AV_OPT_TYPE_FLAGS: |
|
489 |
- av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<flags>"); |
|
490 |
- break; |
|
491 |
- case AV_OPT_TYPE_INT: |
|
492 |
- av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<int>"); |
|
493 |
- break; |
|
494 |
- case AV_OPT_TYPE_INT64: |
|
495 |
- av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<int64>"); |
|
496 |
- break; |
|
497 |
- case AV_OPT_TYPE_DOUBLE: |
|
498 |
- av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<double>"); |
|
499 |
- break; |
|
500 |
- case AV_OPT_TYPE_FLOAT: |
|
501 |
- av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<float>"); |
|
502 |
- break; |
|
503 |
- case AV_OPT_TYPE_STRING: |
|
504 |
- av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<string>"); |
|
505 |
- break; |
|
506 |
- case AV_OPT_TYPE_RATIONAL: |
|
507 |
- av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<rational>"); |
|
508 |
- break; |
|
509 |
- case AV_OPT_TYPE_BINARY: |
|
510 |
- av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<binary>"); |
|
511 |
- break; |
|
512 |
- case AV_OPT_TYPE_CONST: |
|
513 |
- default: |
|
514 |
- av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); |
|
515 |
- break; |
|
488 |
+ case AV_OPT_TYPE_FLAGS: |
|
489 |
+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<flags>"); |
|
490 |
+ break; |
|
491 |
+ case AV_OPT_TYPE_INT: |
|
492 |
+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<int>"); |
|
493 |
+ break; |
|
494 |
+ case AV_OPT_TYPE_INT64: |
|
495 |
+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<int64>"); |
|
496 |
+ break; |
|
497 |
+ case AV_OPT_TYPE_DOUBLE: |
|
498 |
+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<double>"); |
|
499 |
+ break; |
|
500 |
+ case AV_OPT_TYPE_FLOAT: |
|
501 |
+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<float>"); |
|
502 |
+ break; |
|
503 |
+ case AV_OPT_TYPE_STRING: |
|
504 |
+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<string>"); |
|
505 |
+ break; |
|
506 |
+ case AV_OPT_TYPE_RATIONAL: |
|
507 |
+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<rational>"); |
|
508 |
+ break; |
|
509 |
+ case AV_OPT_TYPE_BINARY: |
|
510 |
+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<binary>"); |
|
511 |
+ break; |
|
512 |
+ case AV_OPT_TYPE_CONST: |
|
513 |
+ default: |
|
514 |
+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); |
|
515 |
+ break; |
|
516 | 516 |
} |
517 | 517 |
av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.'); |
518 | 518 |
av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.'); |
519 |
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM ) ? 'V' : '.'); |
|
520 |
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM ) ? 'A' : '.'); |
|
519 |
+ av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM) ? 'V' : '.'); |
|
520 |
+ av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM) ? 'A' : '.'); |
|
521 | 521 |
av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.'); |
522 | 522 |
av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_EXPORT) ? 'X' : '.'); |
523 | 523 |
av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_READONLY) ? 'R' : '.'); |
... | ... |
@@ -525,9 +579,8 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, |
525 | 525 |
if (opt->help) |
526 | 526 |
av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help); |
527 | 527 |
av_log(av_log_obj, AV_LOG_INFO, "\n"); |
528 |
- if (opt->unit && opt->type != AV_OPT_TYPE_CONST) { |
|
528 |
+ if (opt->unit && opt->type != AV_OPT_TYPE_CONST) |
|
529 | 529 |
opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags); |
530 |
- } |
|
531 | 530 |
} |
532 | 531 |
} |
533 | 532 |
|
... | ... |
@@ -536,7 +589,7 @@ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags) |
536 | 536 |
if (!obj) |
537 | 537 |
return -1; |
538 | 538 |
|
539 |
- av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name); |
|
539 |
+ av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass **)obj)->class_name); |
|
540 | 540 |
|
541 | 541 |
opt_list(obj, av_log_obj, NULL, req_flags, rej_flags); |
542 | 542 |
|
... | ... |
@@ -551,36 +604,39 @@ void av_opt_set_defaults(void *s) |
551 | 551 |
continue; |
552 | 552 |
|
553 | 553 |
switch (opt->type) { |
554 |
- case AV_OPT_TYPE_CONST: |
|
555 |
- /* Nothing to be done here */ |
|
556 |
- break; |
|
557 |
- case AV_OPT_TYPE_FLAGS: |
|
558 |
- case AV_OPT_TYPE_INT: |
|
559 |
- case AV_OPT_TYPE_INT64: |
|
560 |
- av_opt_set_int(s, opt->name, opt->default_val.i64, 0); |
|
554 |
+ case AV_OPT_TYPE_CONST: |
|
555 |
+ /* Nothing to be done here */ |
|
561 | 556 |
break; |
562 |
- case AV_OPT_TYPE_DOUBLE: |
|
563 |
- case AV_OPT_TYPE_FLOAT: { |
|
564 |
- double val; |
|
565 |
- val = opt->default_val.dbl; |
|
566 |
- av_opt_set_double(s, opt->name, val, 0); |
|
567 |
- } |
|
557 |
+ case AV_OPT_TYPE_FLAGS: |
|
558 |
+ case AV_OPT_TYPE_INT: |
|
559 |
+ case AV_OPT_TYPE_INT64: |
|
560 |
+ av_opt_set_int(s, opt->name, opt->default_val.i64, 0); |
|
568 | 561 |
break; |
569 |
- case AV_OPT_TYPE_RATIONAL: { |
|
570 |
- AVRational val; |
|
571 |
- val = av_d2q(opt->default_val.dbl, INT_MAX); |
|
572 |
- av_opt_set_q(s, opt->name, val, 0); |
|
573 |
- } |
|
562 |
+ case AV_OPT_TYPE_DOUBLE: |
|
563 |
+ case AV_OPT_TYPE_FLOAT: |
|
564 |
+ { |
|
565 |
+ double val; |
|
566 |
+ val = opt->default_val.dbl; |
|
567 |
+ av_opt_set_double(s, opt->name, val, 0); |
|
568 |
+ } |
|
569 |
+ break; |
|
570 |
+ case AV_OPT_TYPE_RATIONAL: |
|
571 |
+ { |
|
572 |
+ AVRational val; |
|
573 |
+ val = av_d2q(opt->default_val.dbl, INT_MAX); |
|
574 |
+ av_opt_set_q(s, opt->name, val, 0); |
|
575 |
+ } |
|
576 |
+ break; |
|
577 |
+ case AV_OPT_TYPE_STRING: |
|
578 |
+ av_opt_set(s, opt->name, opt->default_val.str, 0); |
|
574 | 579 |
break; |
575 |
- case AV_OPT_TYPE_STRING: |
|
576 |
- av_opt_set(s, opt->name, opt->default_val.str, 0); |
|
577 |
- break; |
|
578 |
- case AV_OPT_TYPE_BINARY: |
|
579 |
- case AV_OPT_TYPE_DICT: |
|
580 |
- /* Cannot set defaults for these types */ |
|
580 |
+ case AV_OPT_TYPE_BINARY: |
|
581 |
+ case AV_OPT_TYPE_DICT: |
|
582 |
+ /* Cannot set defaults for these types */ |
|
581 | 583 |
break; |
582 |
- default: |
|
583 |
- av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name); |
|
584 |
+ default: |
|
585 |
+ av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", |
|
586 |
+ opt->type, opt->name); |
|
584 | 587 |
} |
585 | 588 |
} |
586 | 589 |
} |
... | ... |
@@ -706,7 +762,7 @@ const AVOption *av_opt_find(void *obj, const char *name, const char *unit, |
706 | 706 |
const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, |
707 | 707 |
int opt_flags, int search_flags, void **target_obj) |
708 | 708 |
{ |
709 |
- const AVClass *c = *(AVClass**)obj; |
|
709 |
+ const AVClass *c = *(AVClass **)obj; |
|
710 | 710 |
const AVOption *o = NULL; |
711 | 711 |
|
712 | 712 |
if (!c) |
... | ... |
@@ -729,7 +785,7 @@ const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, |
729 | 729 |
while (o = av_opt_next(obj, o)) { |
730 | 730 |
if (!strcmp(o->name, name) && (o->flags & opt_flags) == opt_flags && |
731 | 731 |
((!unit && o->type != AV_OPT_TYPE_CONST) || |
732 |
- (unit && o->unit && !strcmp(o->unit, unit)))) { |
|
732 |
+ (unit && o->unit && !strcmp(o->unit, unit)))) { |
|
733 | 733 |
if (target_obj) { |
734 | 734 |
if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ)) |
735 | 735 |
*target_obj = obj; |
... | ... |
@@ -744,7 +800,7 @@ const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, |
744 | 744 |
|
745 | 745 |
void *av_opt_child_next(void *obj, void *prev) |
746 | 746 |
{ |
747 |
- const AVClass *c = *(AVClass**)obj; |
|
747 |
+ const AVClass *c = *(AVClass **)obj; |
|
748 | 748 |
if (c->child_next) |
749 | 749 |
return c->child_next(obj, prev); |
750 | 750 |
return NULL; |
... | ... |
@@ -759,15 +815,22 @@ const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *pre |
759 | 759 |
|
760 | 760 |
static int opt_size(enum AVOptionType type) |
761 | 761 |
{ |
762 |
- switch(type) { |
|
762 |
+ switch (type) { |
|
763 | 763 |
case AV_OPT_TYPE_INT: |
764 |
- case AV_OPT_TYPE_FLAGS: return sizeof(int); |
|
765 |
- case AV_OPT_TYPE_INT64: return sizeof(int64_t); |
|
766 |
- case AV_OPT_TYPE_DOUBLE: return sizeof(double); |
|
767 |
- case AV_OPT_TYPE_FLOAT: return sizeof(float); |
|
768 |
- case AV_OPT_TYPE_STRING: return sizeof(uint8_t*); |
|
769 |
- case AV_OPT_TYPE_RATIONAL: return sizeof(AVRational); |
|
770 |
- case AV_OPT_TYPE_BINARY: return sizeof(uint8_t*) + sizeof(int); |
|
764 |
+ case AV_OPT_TYPE_FLAGS: |
|
765 |
+ return sizeof(int); |
|
766 |
+ case AV_OPT_TYPE_INT64: |
|
767 |
+ return sizeof(int64_t); |
|
768 |
+ case AV_OPT_TYPE_DOUBLE: |
|
769 |
+ return sizeof(double); |
|
770 |
+ case AV_OPT_TYPE_FLOAT: |
|
771 |
+ return sizeof(float); |
|
772 |
+ case AV_OPT_TYPE_STRING: |
|
773 |
+ return sizeof(uint8_t *); |
|
774 |
+ case AV_OPT_TYPE_RATIONAL: |
|
775 |
+ return sizeof(AVRational); |
|
776 |
+ case AV_OPT_TYPE_BINARY: |
|
777 |
+ return sizeof(uint8_t *) + sizeof(int); |
|
771 | 778 |
} |
772 | 779 |
return AVERROR(EINVAL); |
773 | 780 |
} |
... | ... |
@@ -781,22 +844,22 @@ int av_opt_copy(void *dst, const void *src) |
781 | 781 |
if (!src) |
782 | 782 |
return AVERROR(EINVAL); |
783 | 783 |
|
784 |
- c = *(AVClass**)src; |
|
785 |
- if (!c || c != *(AVClass**)dst) |
|
784 |
+ c = *(AVClass **)src; |
|
785 |
+ if (!c || c != *(AVClass **)dst) |
|
786 | 786 |
return AVERROR(EINVAL); |
787 | 787 |
|
788 | 788 |
while ((o = av_opt_next(src, o))) { |
789 |
- void *field_dst = ((uint8_t*)dst) + o->offset; |
|
790 |
- void *field_src = ((uint8_t*)src) + o->offset; |
|
791 |
- uint8_t **field_dst8 = (uint8_t**)field_dst; |
|
792 |
- uint8_t **field_src8 = (uint8_t**)field_src; |
|
789 |
+ void *field_dst = (uint8_t *)dst + o->offset; |
|
790 |
+ void *field_src = (uint8_t *)src + o->offset; |
|
791 |
+ uint8_t **field_dst8 = (uint8_t **)field_dst; |
|
792 |
+ uint8_t **field_src8 = (uint8_t **)field_src; |
|
793 | 793 |
|
794 | 794 |
if (o->type == AV_OPT_TYPE_STRING) { |
795 | 795 |
set_string(dst, o, *field_src8, field_dst8); |
796 | 796 |
if (*field_src8 && !*field_dst8) |
797 | 797 |
ret = AVERROR(ENOMEM); |
798 | 798 |
} else if (o->type == AV_OPT_TYPE_BINARY) { |
799 |
- int len = *(int*)(field_src8 + 1); |
|
799 |
+ int len = *(int *)(field_src8 + 1); |
|
800 | 800 |
if (*field_dst8 != *field_src8) |
801 | 801 |
av_freep(field_dst8); |
802 | 802 |
if (len) { |
... | ... |
@@ -809,7 +872,7 @@ int av_opt_copy(void *dst, const void *src) |
809 | 809 |
} else { |
810 | 810 |
*field_dst8 = NULL; |
811 | 811 |
} |
812 |
- *(int*)(field_dst8 + 1) = len; |
|
812 |
+ *(int *)(field_dst8 + 1) = len; |
|
813 | 813 |
} else if (o->type == AV_OPT_TYPE_CONST) { |
814 | 814 |
// do nothing |
815 | 815 |
} else { |
... | ... |
@@ -825,8 +888,7 @@ int av_opt_copy(void *dst, const void *src) |
825 | 825 |
|
826 | 826 |
#ifdef TEST |
827 | 827 |
|
828 |
-typedef struct TestContext |
|
829 |
-{ |
|
828 |
+typedef struct TestContext { |
|
830 | 829 |
const AVClass *class; |
831 | 830 |
int num; |
832 | 831 |
int toggle; |
... | ... |
@@ -841,16 +903,16 @@ typedef struct TestContext |
841 | 841 |
#define TEST_FLAG_LAME 02 |
842 | 842 |
#define TEST_FLAG_MU 04 |
843 | 843 |
|
844 |
-static const AVOption test_options[]= { |
|
845 |
-{"num", "set num", OFFSET(num), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 100 }, |
|
846 |
-{"toggle", "set toggle", OFFSET(toggle), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1 }, |
|
847 |
-{"rational", "set rational", OFFSET(rational), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10 }, |
|
848 |
-{"string", "set string", OFFSET(string), AV_OPT_TYPE_STRING, {0}, CHAR_MIN, CHAR_MAX }, |
|
849 |
-{"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, INT_MAX, 0, "flags" }, |
|
850 |
-{"cool", "set cool flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_COOL}, INT_MIN, INT_MAX, 0, "flags" }, |
|
851 |
-{"lame", "set lame flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" }, |
|
852 |
-{"mu", "set mu flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" }, |
|
853 |
-{NULL}, |
|
844 |
+static const AVOption test_options[] = { |
|
845 |
+ { "num", "set num", OFFSET(num), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100 }, |
|
846 |
+ { "toggle", "set toggle", OFFSET(toggle), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1 }, |
|
847 |
+ { "rational", "set rational", OFFSET(rational), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, 10 }, |
|
848 |
+ { "string", "set string", OFFSET(string), AV_OPT_TYPE_STRING, { 0 }, CHAR_MIN, CHAR_MAX }, |
|
849 |
+ { "flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, INT_MAX, 0, "flags"}, |
|
850 |
+ { "cool", "set cool flag ", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_COOL }, INT_MIN, INT_MAX, 0, "flags"}, |
|
851 |
+ { "lame", "set lame flag ", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_LAME }, INT_MIN, INT_MAX, 0, "flags"}, |
|
852 |
+ { "mu", "set mu flag ", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_MU }, INT_MIN, INT_MAX, 0, "flags"}, |
|
853 |
+ { NULL }, |
|
854 | 854 |
}; |
855 | 855 |
|
856 | 856 |
static const char *test_get_name(void *ctx) |