aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-21 16:40:10 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-21 16:50:06 +0100
commit5f587b1daf90a8c0bf4f2eb5c13b4022252ec498 (patch)
tree35a70d34f85854c68facfbdfffefc962ca66f1e5
parent32c044cbc64034a9688e3711efe5251998d767b1 (diff)
parent3b08d9d932eef09403074d5af31e10d8011e840b (diff)
downloadffmpeg-5f587b1daf90a8c0bf4f2eb5c13b4022252ec498.tar.gz
Merge commit '3b08d9d932eef09403074d5af31e10d8011e840b'
* commit '3b08d9d932eef09403074d5af31e10d8011e840b': testprogs: K&R formatting cosmetics Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r--libavcodec/iirfilter.c122
-rw-r--r--libavcodec/rangecoder.c2
-rw-r--r--libavutil/aes.c39
-rw-r--r--libavutil/crc.c19
-rw-r--r--libavutil/des.c273
-rw-r--r--libavutil/lls.c2
-rw-r--r--libavutil/md5.c57
-rw-r--r--libavutil/opt.c349
8 files changed, 474 insertions, 389 deletions
diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c
index cb5871cb29..474f52fde7 100644
--- a/libavcodec/iirfilter.c
+++ b/libavcodec/iirfilter.c
@@ -24,27 +24,29 @@
* different IIR filters implementation
*/
-#include "iirfilter.h"
#include <math.h>
+
#include "libavutil/attributes.h"
#include "libavutil/common.h"
+#include "iirfilter.h"
+
/**
* IIR filter global parameters
*/
-typedef struct FFIIRFilterCoeffs{
+typedef struct FFIIRFilterCoeffs {
int order;
float gain;
int *cx;
float *cy;
-}FFIIRFilterCoeffs;
+} FFIIRFilterCoeffs;
/**
* IIR filter state
*/
-typedef struct FFIIRFilterState{
+typedef struct FFIIRFilterState {
float x[1];
-}FFIIRFilterState;
+} FFIIRFilterState;
/// maximum supported filter order
#define MAXORDER 30
@@ -61,51 +63,50 @@ static av_cold int butterworth_init_coeffs(void *avc,
if (filt_mode != FF_FILTER_MODE_LOWPASS) {
av_log(avc, AV_LOG_ERROR, "Butterworth filter currently only supports "
- "low-pass filter mode\n");
+ "low-pass filter mode\n");
return -1;
}
if (order & 1) {
av_log(avc, AV_LOG_ERROR, "Butterworth filter currently only supports "
- "even filter orders\n");
+ "even filter orders\n");
return -1;
}
wa = 2 * tan(M_PI * 0.5 * cutoff_ratio);
c->cx[0] = 1;
- for(i = 1; i < (order >> 1) + 1; i++)
+ for (i = 1; i < (order >> 1) + 1; i++)
c->cx[i] = c->cx[i - 1] * (order - i + 1LL) / i;
p[0][0] = 1.0;
p[0][1] = 0.0;
- for(i = 1; i <= order; i++)
+ for (i = 1; i <= order; i++)
p[i][0] = p[i][1] = 0.0;
- for(i = 0; i < order; i++){
+ for (i = 0; i < order; i++) {
double zp[2];
double th = (i + (order >> 1) + 0.5) * M_PI / order;
double a_re, a_im, c_re, c_im;
zp[0] = cos(th) * wa;
zp[1] = sin(th) * wa;
- a_re = zp[0] + 2.0;
- c_re = zp[0] - 2.0;
- a_im =
- c_im = zp[1];
+ a_re = zp[0] + 2.0;
+ c_re = zp[0] - 2.0;
+ a_im =
+ c_im = zp[1];
zp[0] = (a_re * c_re + a_im * c_im) / (c_re * c_re + c_im * c_im);
zp[1] = (a_im * c_re - a_re * c_im) / (c_re * c_re + c_im * c_im);
- for(j = order; j >= 1; j--)
- {
- a_re = p[j][0];
- a_im = p[j][1];
- p[j][0] = a_re*zp[0] - a_im*zp[1] + p[j-1][0];
- p[j][1] = a_re*zp[1] + a_im*zp[0] + p[j-1][1];
+ for (j = order; j >= 1; j--) {
+ a_re = p[j][0];
+ a_im = p[j][1];
+ p[j][0] = a_re * zp[0] - a_im * zp[1] + p[j - 1][0];
+ p[j][1] = a_re * zp[1] + a_im * zp[0] + p[j - 1][1];
}
- a_re = p[0][0]*zp[0] - p[0][1]*zp[1];
- p[0][1] = p[0][0]*zp[1] + p[0][1]*zp[0];
+ a_re = p[0][0] * zp[0] - p[0][1] * zp[1];
+ p[0][1] = p[0][0] * zp[1] + p[0][1] * zp[0];
p[0][0] = a_re;
}
c->gain = p[order][0];
- for(i = 0; i < order; i++){
+ for (i = 0; i < order; i++) {
c->gain += p[i][0];
c->cy[i] = (-p[i][0] * p[order][0] + -p[i][1] * p[order][1]) /
(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,
if (filt_mode != FF_FILTER_MODE_HIGHPASS &&
filt_mode != FF_FILTER_MODE_LOWPASS) {
av_log(avc, AV_LOG_ERROR, "Biquad filter currently only supports "
- "high-pass and low-pass filter modes\n");
+ "high-pass and low-pass filter modes\n");
return -1;
}
if (order != 2) {
@@ -158,11 +159,11 @@ static av_cold int biquad_init_coeffs(void *avc, struct FFIIRFilterCoeffs *c,
return 0;
}
-av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
- enum IIRFilterType filt_type,
- enum IIRFilterMode filt_mode,
- int order, float cutoff_ratio,
- float stopband, float ripple)
+av_cold struct FFIIRFilterCoeffs *ff_iir_filter_init_coeffs(void *avc,
+ enum IIRFilterType filt_type,
+ enum IIRFilterMode filt_mode,
+ int order, float cutoff_ratio,
+ float stopband, float ripple)
{
FFIIRFilterCoeffs *c;
int ret = 0;
@@ -170,12 +171,12 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
if (order <= 0 || order > MAXORDER || cutoff_ratio >= 1.0)
return NULL;
- FF_ALLOCZ_OR_GOTO(avc, c, sizeof(FFIIRFilterCoeffs),
- init_fail);
- FF_ALLOC_OR_GOTO (avc, c->cx, sizeof(c->cx[0]) * ((order >> 1) + 1),
- init_fail);
- FF_ALLOC_OR_GOTO (avc, c->cy, sizeof(c->cy[0]) * order,
+ FF_ALLOCZ_OR_GOTO(avc, c, sizeof(FFIIRFilterCoeffs),
init_fail);
+ FF_ALLOC_OR_GOTO(avc, c->cx, sizeof(c->cx[0]) * ((order >> 1) + 1),
+ init_fail);
+ FF_ALLOC_OR_GOTO(avc, c->cy, sizeof(c->cy[0]) * order,
+ init_fail);
c->order = order;
switch (filt_type) {
@@ -200,9 +201,9 @@ init_fail:
return NULL;
}
-av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order)
+av_cold struct FFIIRFilterState *ff_iir_filter_init_state(int order)
{
- FFIIRFilterState* s = av_mallocz(sizeof(FFIIRFilterState) + sizeof(s->x[0]) * (order - 1));
+ FFIIRFilterState *s = av_mallocz(sizeof(FFIIRFilterState) + sizeof(s->x[0]) * (order - 1));
return s;
}
@@ -210,17 +211,19 @@ av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order)
#define CONV_FLT(dest, source) dest = source;
-#define FILTER_BW_O4_1(i0, i1, i2, i3, fmt) \
- in = *src0 * c->gain \
- + c->cy[0]*s->x[i0] + c->cy[1]*s->x[i1] \
- + c->cy[2]*s->x[i2] + c->cy[3]*s->x[i3]; \
- res = (s->x[i0] + in )*1 \
- + (s->x[i1] + s->x[i3])*4 \
- + s->x[i2] *6; \
- CONV_##fmt(*dst0, res) \
- s->x[i0] = in; \
- src0 += sstep; \
- dst0 += dstep;
+#define FILTER_BW_O4_1(i0, i1, i2, i3, fmt) \
+ in = *src0 * c->gain + \
+ c->cy[0] * s->x[i0] + \
+ c->cy[1] * s->x[i1] + \
+ c->cy[2] * s->x[i2] + \
+ c->cy[3] * s->x[i3]; \
+ res = (s->x[i0] + in) * 1 + \
+ (s->x[i1] + s->x[i3]) * 4 + \
+ s->x[i2] * 6; \
+ CONV_ ## fmt(*dst0, res) \
+ s->x[i0] = in; \
+ src0 += sstep; \
+ dst0 += dstep;
#define FILTER_BW_O4(type, fmt) { \
int i; \
@@ -243,17 +246,17 @@ av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order)
int j; \
float in, res; \
in = *src0 * c->gain; \
- for(j = 0; j < c->order; j++) \
+ for (j = 0; j < c->order; j++) \
in += c->cy[j] * s->x[j]; \
res = s->x[0] + in + s->x[c->order >> 1] * c->cx[c->order >> 1]; \
- for(j = 1; j < c->order >> 1; j++) \
+ for (j = 1; j < c->order >> 1; j++) \
res += (s->x[j] + s->x[c->order - j]) * c->cx[j]; \
- for(j = 0; j < c->order - 1; j++) \
+ for (j = 0; j < c->order - 1; j++) \
s->x[j] = s->x[j + 1]; \
- CONV_##fmt(*dst0, res) \
+ CONV_ ## fmt(*dst0, res) \
s->x[c->order - 1] = in; \
- src0 += sstep; \
- dst0 += dstep; \
+ src0 += sstep; \
+ dst0 += dstep; \
} \
}
@@ -265,11 +268,11 @@ av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order)
float in = *src0 * c->gain + \
s->x[0] * c->cy[0] + \
s->x[1] * c->cy[1]; \
- CONV_##fmt(*dst0, s->x[0] + in + s->x[1] * c->cx[1]) \
+ CONV_ ## fmt(*dst0, s->x[0] + in + s->x[1] * c->cx[1]) \
s->x[0] = s->x[1]; \
s->x[1] = in; \
- src0 += sstep; \
- dst0 += dstep; \
+ src0 += sstep; \
+ dst0 += dstep; \
} \
}
@@ -307,7 +310,7 @@ av_cold void ff_iir_filter_free_statep(struct FFIIRFilterState **state)
av_cold void ff_iir_filter_free_coeffsp(struct FFIIRFilterCoeffs **coeffsp)
{
struct FFIIRFilterCoeffs *coeffs = *coeffsp;
- if(coeffs){
+ if (coeffs) {
av_freep(&coeffs->cx);
av_freep(&coeffs->cy);
}
@@ -339,9 +342,8 @@ int main(void)
cutoff_coeff, 0.0, 0.0);
fstate = ff_iir_filter_init_state(FILT_ORDER);
- for (i = 0; i < SIZE; i++) {
- x[i] = lrint(0.75 * INT16_MAX * sin(0.5*M_PI*i*i/SIZE));
- }
+ for (i = 0; i < SIZE; i++)
+ x[i] = lrint(0.75 * INT16_MAX * sin(0.5 * M_PI * i * i / SIZE));
ff_iir_filter(fcoeffs, fstate, SIZE, x, 1, y, 1);
diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c
index b81a6d09fc..31bbaa5881 100644
--- a/libavcodec/rangecoder.c
+++ b/libavcodec/rangecoder.c
@@ -56,7 +56,7 @@ av_cold void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf,
/* cast to avoid compiler warning */
ff_init_range_encoder(c, (uint8_t *)buf, buf_size);
- c->low = AV_RB16(c->bytestream);
+ c->low = AV_RB16(c->bytestream);
c->bytestream += 2;
}
diff --git a/libavutil/aes.c b/libavutil/aes.c
index 9096f03ae3..15dc602de2 100644
--- a/libavutil/aes.c
+++ b/libavutil/aes.c
@@ -25,6 +25,7 @@
#include "aes_internal.h"
#include "intreadwrite.h"
#include "timer.h"
+#include "aes.h"
const int av_aes_size= sizeof(AVAES);
@@ -34,7 +35,7 @@ struct AVAES *av_aes_alloc(void)
}
static const uint8_t rcon[10] = {
- 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36
};
static uint8_t sbox[256];
@@ -97,7 +98,8 @@ static void subshift(av_aes_block s0[2], int s, const uint8_t *box)
s3[0].u8[ 5] = box[s3[1].u8[ 1]];
}
-static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){
+static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d)
+{
#if CONFIG_SMALL
return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24);
#else
@@ -105,12 +107,13 @@ static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){
#endif
}
-static inline void mix(av_aes_block state[2], uint32_t multbl[][256], int s1, int s3){
+static inline void mix(av_aes_block state[2], uint32_t multbl[][256], int s1, int s3)
+{
uint8_t (*src)[4] = state[1].u8x4;
- state[0].u32[0] = mix_core(multbl, src[0][0], src[s1 ][1], src[2][2], src[s3 ][3]);
- state[0].u32[1] = mix_core(multbl, src[1][0], src[s3-1][1], src[3][2], src[s1-1][3]);
- state[0].u32[2] = mix_core(multbl, src[2][0], src[s3 ][1], src[0][2], src[s1 ][3]);
- state[0].u32[3] = mix_core(multbl, src[3][0], src[s1-1][1], src[1][2], src[s3-1][3]);
+ state[0].u32[0] = mix_core(multbl, src[0][0], src[s1 ][1], src[2][2], src[s3 ][3]);
+ state[0].u32[1] = mix_core(multbl, src[1][0], src[s3 - 1][1], src[3][2], src[s1 - 1][3]);
+ state[0].u32[2] = mix_core(multbl, src[2][0], src[s3 ][1], src[0][2], src[s1 ][3]);
+ state[0].u32[3] = mix_core(multbl, src[3][0], src[s1 - 1][1], src[1][2], src[s3 - 1][3]);
}
static inline void aes_crypt(AVAES *a, int s, const uint8_t *sbox,
@@ -179,7 +182,7 @@ static void init_multbl2(uint32_t tbl[][256], const int c[4],
l = alog8[x + log8[c[1]]];
m = alog8[x + log8[c[2]]];
n = alog8[x + log8[c[3]]];
- tbl[0][i] = AV_NE(MKBETAG(k,l,m,n), MKTAG(k,l,m,n));
+ tbl[0][i] = AV_NE(MKBETAG(k, l, m, n), MKTAG(k, l, m, n));
#if !CONFIG_SMALL
tbl[1][i] = ROT(tbl[0][i], 8);
tbl[2][i] = ROT(tbl[0][i], 16);
@@ -201,7 +204,7 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
a->crypt = decrypt ? aes_decrypt : aes_encrypt;
- if (!enc_multbl[FF_ARRAY_ELEMS(enc_multbl)-1][FF_ARRAY_ELEMS(enc_multbl[0])-1]) {
+ if (!enc_multbl[FF_ARRAY_ELEMS(enc_multbl) - 1][FF_ARRAY_ELEMS(enc_multbl[0]) - 1]) {
j = 1;
for (i = 0; i < 255; i++) {
alog8[i] = alog8[i + 255] = j;
@@ -215,7 +218,7 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
j ^= (j << 1) ^ (j << 2) ^ (j << 3) ^ (j << 4);
j = (j ^ (j >> 8) ^ 99) & 255;
inv_sbox[j] = i;
- sbox[i] = j;
+ sbox[i] = j;
}
init_multbl2(dec_multbl, (const int[4]) { 0xe, 0x9, 0xd, 0xb },
log8, alog8, inv_sbox);
@@ -257,9 +260,8 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
a->round_key[i] = tmp[0];
}
} else {
- for (i = 0; i < (rounds + 1) >> 1; i++) {
- FFSWAP(av_aes_block, a->round_key[i], a->round_key[rounds-i]);
- }
+ for (i = 0; i < (rounds + 1) >> 1; i++)
+ FFSWAP(av_aes_block, a->round_key[i], a->round_key[rounds - i]);
}
return 0;
@@ -268,6 +270,7 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
#ifdef TEST
// LCOV_EXCL_START
#include <string.h>
+
#include "lfg.h"
#include "log.h"
@@ -280,12 +283,12 @@ int main(int argc, char **argv)
{ 0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3,
0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59 }
};
- uint8_t pt[32], rpt[2][16]= {
+ uint8_t pt[32], rpt[2][16] = {
{ 0x6a, 0x84, 0x86, 0x7c, 0xd7, 0x7e, 0x12, 0xad,
0x07, 0xea, 0x1b, 0xe8, 0x95, 0xc5, 0x3f, 0xa3 },
{ 0 }
};
- uint8_t rct[2][16]= {
+ uint8_t rct[2][16] = {
{ 0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7,
0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf },
{ 0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0,
@@ -318,12 +321,10 @@ int main(int argc, char **argv)
av_lfg_init(&prng, 1);
for (i = 0; i < 10000; i++) {
- for (j = 0; j < 32; j++) {
+ for (j = 0; j < 32; j++)
pt[j] = av_lfg_get(&prng);
- }
- for (j = 0; j < 16; j++) {
+ for (j = 0; j < 16; j++)
iv[0][j] = iv[1][j] = av_lfg_get(&prng);
- }
{
START_TIMER;
av_aes_crypt(&ae, temp, pt, 2, iv[0], 0);
diff --git a/libavutil/crc.c b/libavutil/crc.c
index 5a1ddf092b..8d9cb326bc 100644
--- a/libavutil/crc.c
+++ b/libavutil/crc.c
@@ -19,8 +19,9 @@
*/
#include "config.h"
-#include "common.h"
+
#include "bswap.h"
+#include "common.h"
#include "crc.h"
#if CONFIG_HARDCODED_TABLES
@@ -332,7 +333,7 @@ int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size)
if (ctx_size >= sizeof(AVCRC) * 1024)
for (i = 0; i < 256; i++)
for (j = 0; j < 3; j++)
- ctx[256 *(j + 1) + i] =
+ ctx[256 * (j + 1) + i] =
(ctx[256 * j + i] >> 8) ^ ctx[ctx[256 * j + i] & 0xFF];
#endif
@@ -383,13 +384,13 @@ int main(void)
{
uint8_t buf[1999];
int i;
- unsigned
- p[6][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 },
- { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 },
- { AV_CRC_24_IEEE , 0x864CFB , 0xB704CE },
- { AV_CRC_16_ANSI_LE, 0xA001 , 0xBFD8 },
- { AV_CRC_16_ANSI , 0x8005 , 0x1FBB },
- { AV_CRC_8_ATM , 0x07 , 0xE3 }
+ unsigned p[6][3] = {
+ { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 },
+ { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 },
+ { AV_CRC_24_IEEE , 0x864CFB , 0xB704CE },
+ { AV_CRC_16_ANSI_LE, 0xA001 , 0xBFD8 },
+ { AV_CRC_16_ANSI , 0x8005 , 0x1FBB },
+ { AV_CRC_8_ATM , 0x07 , 0xE3 }
};
const AVCRC *ctx;
diff --git a/libavutil/des.c b/libavutil/des.c
index ec2c399590..25f3b6f517 100644
--- a/libavutil/des.c
+++ b/libavutil/des.c
@@ -27,7 +27,7 @@
#include "mem.h"
#include "des.h"
-#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
+#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
static const uint8_t IP_shuffle[] = {
T(58, 50, 42, 34, 26, 18, 10, 2),
T(60, 52, 44, 36, 28, 20, 12, 4),
@@ -41,7 +41,7 @@ static const uint8_t IP_shuffle[] = {
#undef T
#if CONFIG_SMALL || defined(GENTABLES)
-#define T(a, b, c, d) 32-a,32-b,32-c,32-d
+#define T(a, b, c, d) 32 - a, 32 - b, 32 - c, 32 - d
static const uint8_t P_shuffle[] = {
T(16, 7, 20, 21),
T(29, 12, 28, 17),
@@ -55,7 +55,7 @@ static const uint8_t P_shuffle[] = {
#undef T
#endif
-#define T(a, b, c, d, e, f, g) 64-a,64-b,64-c,64-d,64-e,64-f,64-g
+#define T(a, b, c, d, e, f, g) 64 - a, 64 - b, 64 - c, 64 - d, 64 - e, 64 - f, 64 - g
static const uint8_t PC1_shuffle[] = {
T(57, 49, 41, 33, 25, 17, 9),
T( 1, 58, 50, 42, 34, 26, 18),
@@ -68,7 +68,7 @@ static const uint8_t PC1_shuffle[] = {
};
#undef T
-#define T(a, b, c, d, e, f) 56-a,56-b,56-c,56-d,56-e,56-f
+#define T(a, b, c, d, e, f) 56 - a, 56 - b, 56 - c, 56 - d, 56 - e, 56 - f
static const uint8_t PC2_shuffle[] = {
T(14, 17, 11, 24, 1, 5),
T( 3, 28, 15, 6, 21, 10),
@@ -83,30 +83,22 @@ static const uint8_t PC2_shuffle[] = {
#if CONFIG_SMALL
static const uint8_t S_boxes[8][32] = {
- {
- 0x0e, 0xf4, 0x7d, 0x41, 0xe2, 0x2f, 0xdb, 0x18, 0xa3, 0x6a, 0xc6, 0xbc, 0x95, 0x59, 0x30, 0x87,
- 0xf4, 0xc1, 0x8e, 0x28, 0x4d, 0x96, 0x12, 0x7b, 0x5f, 0xbc, 0x39, 0xe7, 0xa3, 0x0a, 0x65, 0xd0,
- }, {
- 0x3f, 0xd1, 0x48, 0x7e, 0xf6, 0x2b, 0x83, 0xe4, 0xc9, 0x07, 0x12, 0xad, 0x6c, 0x90, 0xb5, 0x5a,
- 0xd0, 0x8e, 0xa7, 0x1b, 0x3a, 0xf4, 0x4d, 0x21, 0xb5, 0x68, 0x7c, 0xc6, 0x09, 0x53, 0xe2, 0x9f,
- }, {
- 0xda, 0x70, 0x09, 0x9e, 0x36, 0x43, 0x6f, 0xa5, 0x21, 0x8d, 0x5c, 0xe7, 0xcb, 0xb4, 0xf2, 0x18,
- 0x1d, 0xa6, 0xd4, 0x09, 0x68, 0x9f, 0x83, 0x70, 0x4b, 0xf1, 0xe2, 0x3c, 0xb5, 0x5a, 0x2e, 0xc7,
- }, {
- 0xd7, 0x8d, 0xbe, 0x53, 0x60, 0xf6, 0x09, 0x3a, 0x41, 0x72, 0x28, 0xc5, 0x1b, 0xac, 0xe4, 0x9f,
- 0x3a, 0xf6, 0x09, 0x60, 0xac, 0x1b, 0xd7, 0x8d, 0x9f, 0x41, 0x53, 0xbe, 0xc5, 0x72, 0x28, 0xe4,
- }, {
- 0xe2, 0xbc, 0x24, 0xc1, 0x47, 0x7a, 0xdb, 0x16, 0x58, 0x05, 0xf3, 0xaf, 0x3d, 0x90, 0x8e, 0x69,
- 0xb4, 0x82, 0xc1, 0x7b, 0x1a, 0xed, 0x27, 0xd8, 0x6f, 0xf9, 0x0c, 0x95, 0xa6, 0x43, 0x50, 0x3e,
- }, {
- 0xac, 0xf1, 0x4a, 0x2f, 0x79, 0xc2, 0x96, 0x58, 0x60, 0x1d, 0xd3, 0xe4, 0x0e, 0xb7, 0x35, 0x8b,
- 0x49, 0x3e, 0x2f, 0xc5, 0x92, 0x58, 0xfc, 0xa3, 0xb7, 0xe0, 0x14, 0x7a, 0x61, 0x0d, 0x8b, 0xd6,
- }, {
- 0xd4, 0x0b, 0xb2, 0x7e, 0x4f, 0x90, 0x18, 0xad, 0xe3, 0x3c, 0x59, 0xc7, 0x25, 0xfa, 0x86, 0x61,
- 0x61, 0xb4, 0xdb, 0x8d, 0x1c, 0x43, 0xa7, 0x7e, 0x9a, 0x5f, 0x06, 0xf8, 0xe0, 0x25, 0x39, 0xc2,
- }, {
- 0x1d, 0xf2, 0xd8, 0x84, 0xa6, 0x3f, 0x7b, 0x41, 0xca, 0x59, 0x63, 0xbe, 0x05, 0xe0, 0x9c, 0x27,
- 0x27, 0x1b, 0xe4, 0x71, 0x49, 0xac, 0x8e, 0xd2, 0xf0, 0xc6, 0x9a, 0x0d, 0x3f, 0x53, 0x65, 0xb8,
+ { 0x0e, 0xf4, 0x7d, 0x41, 0xe2, 0x2f, 0xdb, 0x18, 0xa3, 0x6a, 0xc6, 0xbc, 0x95, 0x59, 0x30, 0x87,
+ 0xf4, 0xc1, 0x8e, 0x28, 0x4d, 0x96, 0x12, 0x7b, 0x5f, 0xbc, 0x39, 0xe7, 0xa3, 0x0a, 0x65, 0xd0, },
+ { 0x3f, 0xd1, 0x48, 0x7e, 0xf6, 0x2b, 0x83, 0xe4, 0xc9, 0x07, 0x12, 0xad, 0x6c, 0x90, 0xb5, 0x5a,
+ 0xd0, 0x8e, 0xa7, 0x1b, 0x3a, 0xf4, 0x4d, 0x21, 0xb5, 0x68, 0x7c, 0xc6, 0x09, 0x53, 0xe2, 0x9f, },
+ { 0xda, 0x70, 0x09, 0x9e, 0x36, 0x43, 0x6f, 0xa5, 0x21, 0x8d, 0x5c, 0xe7, 0xcb, 0xb4, 0xf2, 0x18,
+ 0x1d, 0xa6, 0xd4, 0x09, 0x68, 0x9f, 0x83, 0x70, 0x4b, 0xf1, 0xe2, 0x3c, 0xb5, 0x5a, 0x2e, 0xc7, },
+ { 0xd7, 0x8d, 0xbe, 0x53, 0x60, 0xf6, 0x09, 0x3a, 0x41, 0x72, 0x28, 0xc5, 0x1b, 0xac, 0xe4, 0x9f,
+ 0x3a, 0xf6, 0x09, 0x60, 0xac, 0x1b, 0xd7, 0x8d, 0x9f, 0x41, 0x53, 0xbe, 0xc5, 0x72, 0x28, 0xe4, },
+ { 0xe2, 0xbc, 0x24, 0xc1, 0x47, 0x7a, 0xdb, 0x16, 0x58, 0x05, 0xf3, 0xaf, 0x3d, 0x90, 0x8e, 0x69,
+ 0xb4, 0x82, 0xc1, 0x7b, 0x1a, 0xed, 0x27, 0xd8, 0x6f, 0xf9, 0x0c, 0x95, 0xa6, 0x43, 0x50, 0x3e, },
+ { 0xac, 0xf1, 0x4a, 0x2f, 0x79, 0xc2, 0x96, 0x58, 0x60, 0x1d, 0xd3, 0xe4, 0x0e, 0xb7, 0x35, 0x8b,
+ 0x49, 0x3e, 0x2f, 0xc5, 0x92, 0x58, 0xfc, 0xa3, 0xb7, 0xe0, 0x14, 0x7a, 0x61, 0x0d, 0x8b, 0xd6, },
+ { 0xd4, 0x0b, 0xb2, 0x7e, 0x4f, 0x90, 0x18, 0xad, 0xe3, 0x3c, 0x59, 0xc7, 0x25, 0xfa, 0x86, 0x61,
+ 0x61, 0xb4, 0xdb, 0x8d, 0x1c, 0x43, 0xa7, 0x7e, 0x9a, 0x5f, 0x06, 0xf8, 0xe0, 0x25, 0x39, 0xc2, },
+ { 0x1d, 0xf2, 0xd8, 0x84, 0xa6, 0x3f, 0x7b, 0x41, 0xca, 0x59, 0x63, 0xbe, 0x05, 0xe0, 0x9c, 0x27,
+ 0x27, 0x1b, 0xe4, 0x71, 0x49, 0xac, 0x8e, 0xd2, 0xf0, 0xc6, 0x9a, 0x0d, 0x3f, 0x53, 0x65, 0xb8,
}
};
#else
@@ -115,90 +107,75 @@ static const uint8_t S_boxes[8][32] = {
* It can be regenerated by compiling this file with -DCONFIG_SMALL -DTEST -DGENTABLES
*/
static const uint32_t S_boxes_P_shuffle[8][64] = {
- {
- 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000,
- 0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002,
- 0x00000202, 0x00800200, 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202,
- 0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, 0x00008202, 0x00800000,
- 0x00008000, 0x00808202, 0x00000002, 0x00808000, 0x00808200, 0x00800000, 0x00800000, 0x00000200,
- 0x00808002, 0x00008000, 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202,
- 0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, 0x00008202, 0x00808200,
- 0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002,
- },
- {
- 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010,
- 0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010,
- 0x00084000, 0x00080010, 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000,
- 0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, 0x40080000, 0x00004010,
- 0x00000000, 0x00084010, 0x40080010, 0x00080000, 0x40004010, 0x40080000, 0x40084000, 0x00004000,
- 0x40080000, 0x40004000, 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000,
- 0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, 0x40000010, 0x00080010,
- 0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000,
- },
- {
- 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100,
- 0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104,
- 0x04000000, 0x00000004, 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104,
- 0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, 0x00000100, 0x04000000,
- 0x04010100, 0x04000000, 0x00010004, 0x00000104, 0x00010000, 0x04010100, 0x04000100, 0x00000000,
- 0x00000100, 0x00010004, 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004,
- 0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, 0x00010100, 0x04000004,
- 0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100,
- },
- {
- 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000,
- 0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000,
- 0x80000000, 0x00001000, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040,
- 0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, 0x80401040, 0x80000040,
- 0x00400040, 0x80400000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00000000, 0x00401000,
- 0x00001040, 0x00400040, 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040,
- 0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, 0x00401040, 0x80400040,
- 0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040,
- },
- {
- 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000,
- 0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000,
- 0x01000000, 0x20040000, 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080,
- 0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, 0x21000000, 0x00040080,
- 0x00040000, 0x21000080, 0x00000080, 0x01000000, 0x20000000, 0x01040000, 0x21000080, 0x20040080,
- 0x01000080, 0x20000000, 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000,
- 0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, 0x20040000, 0x21000000,
- 0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080,
- },
- {
- 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000,
- 0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008,
- 0x00000000, 0x00200008, 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008,
- 0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, 0x10202000, 0x10000000,
- 0x10002000, 0x00000008, 0x10200008, 0x00202000, 0x10202008, 0x00200000, 0x00002008, 0x10000008,
- 0x00200000, 0x10002000, 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000,
- 0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, 0x10200000, 0x00202008,
- 0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008,
- },
- {
- 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400,
- 0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401,
- 0x02000400, 0x00100401, 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001,
- 0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, 0x02000000, 0x00100400,
- 0x02000000, 0x00100400, 0x00100000, 0x02000401, 0x02000401, 0x02100001, 0x02100001, 0x00000001,
- 0x00100001, 0x02000000, 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400,
- 0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, 0x00000001, 0x02100401,
- 0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001,
- },
- {
- 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000,
- 0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020,
- 0x08020000, 0x08000020, 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800,
- 0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, 0x00020820, 0x00020000,
- 0x00020820, 0x00020000, 0x08020800, 0x00000800, 0x00000020, 0x08020020, 0x00000800, 0x00020820,
- 0x08000800, 0x00000020, 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820,
- 0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, 0x08000820, 0x00000000,
- 0x08020820, 0x00020800, 0x00020800, 0x00000820, 0x00000820, 0x00020020, 0x08000000, 0x08020800,
- },
+ { 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000,
+ 0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002,
+ 0x00000202, 0x00800200, 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202,
+ 0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, 0x00008202, 0x00800000,
+ 0x00008000, 0x00808202, 0x00000002, 0x00808000, 0x00808200, 0x00800000, 0x00800000, 0x00000200,
+ 0x00808002, 0x00008000, 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202,
+ 0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, 0x00008202, 0x00808200,
+ 0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002, },
+ { 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010,
+ 0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010,
+ 0x00084000, 0x00080010, 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000,
+ 0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, 0x40080000, 0x00004010,
+ 0x00000000, 0x00084010, 0x40080010, 0x00080000, 0x40004010, 0x40080000, 0x40084000, 0x00004000,
+ 0x40080000, 0x40004000, 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000,
+ 0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, 0x40000010, 0x00080010,
+ 0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000, },
+ { 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100,
+ 0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104,
+ 0x04000000, 0x00000004, 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104,
+ 0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, 0x00000100, 0x04000000,
+ 0x04010100, 0x04000000, 0x00010004, 0x00000104, 0x00010000, 0x04010100, 0x04000100, 0x00000000,
+ 0x00000100, 0x00010004, 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004,
+ 0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, 0x00010100, 0x04000004,
+ 0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100, },
+ { 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000,
+ 0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000,
+ 0x80000000, 0x00001000, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040,
+ 0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, 0x80401040, 0x80000040,
+ 0x00400040, 0x80400000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00000000, 0x00401000,
+ 0x00001040, 0x00400040, 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040,
+ 0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, 0x00401040, 0x80400040,
+ 0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040, },
+ { 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000,
+ 0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000,
+ 0x01000000, 0x20040000, 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080,
+ 0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, 0x21000000, 0x00040080,
+ 0x00040000, 0x21000080, 0x00000080, 0x01000000, 0x20000000, 0x01040000, 0x21000080, 0x20040080,
+ 0x01000080, 0x20000000, 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000,
+ 0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, 0x20040000, 0x21000000,
+ 0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080, },
+ { 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000,
+ 0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008,
+ 0x00000000, 0x00200008, 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008,
+ 0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, 0x10202000, 0x10000000,
+ 0x10002000, 0x00000008, 0x10200008, 0x00202000, 0x10202008, 0x00200000, 0x00002008, 0x10000008,
+ 0x00200000, 0x10002000, 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000,
+ 0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, 0x10200000, 0x00202008,
+ 0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008, },
+ { 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400,
+ 0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401,
+ 0x02000400, 0x00100401, 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001,
+ 0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, 0x02000000, 0x00100400,
+ 0x02000000, 0x00100400, 0x00100000, 0x02000401, 0x02000401, 0x02100001, 0x02100001, 0x00000001,
+ 0x00100001, 0x02000000, 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400,
+ 0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, 0x00000001, 0x02100401,
+ 0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001, },
+ { 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000,
+ 0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020,
+ 0x08020000, 0x08000020, 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800,
+ 0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, 0x00020820, 0x00020000,
+ 0x00020820, 0x00020000, 0x08020800, 0x00000800, 0x00000020, 0x08020020, 0x00000800, 0x00020820,
+ 0x08000800, 0x00000020, 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820,
+ 0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, 0x08000820, 0x00000000,
+ 0x08020820, 0x00020800, 0x00020800, 0x00000820, 0x00000820, 0x00020020, 0x08000000, 0x08020800, },
};
#endif
-static uint64_t shuffle(uint64_t in, const uint8_t *shuffle, int shuffle_len) {
+static uint64_t shuffle(uint64_t in, const uint8_t *shuffle, int shuffle_len)
+{
int i;
uint64_t res = 0;
for (i = 0; i < shuffle_len; i++)
@@ -206,7 +183,8 @@ static uint64_t shuffle(uint64_t in, const uint8_t *shuffle, int shuffle_len) {
return res;
}
-static uint64_t shuffle_inv(uint64_t in, const uint8_t *shuffle, int shuffle_len) {
+static uint64_t shuffle_inv(uint64_t in, const uint8_t *shuffle, int shuffle_len)
+{
int i;
uint64_t res = 0;
shuffle += shuffle_len - 1;
@@ -217,7 +195,8 @@ static uint64_t shuffle_inv(uint64_t in, const uint8_t *shuffle, int shuffle_len
return res;
}
-static uint32_t f_func(uint32_t r, uint64_t k) {
+static uint32_t f_func(uint32_t r, uint64_t k)
+{
int i;
uint32_t out = 0;
// rotate to get first part of E-shuffle in the lowest 6 bits
@@ -227,13 +206,14 @@ static uint32_t f_func(uint32_t r, uint64_t k) {
uint8_t tmp = (r ^ k) & 0x3f;
#if CONFIG_SMALL
uint8_t v = S_boxes[i][tmp >> 1];
- if (tmp & 1) v >>= 4;
+ if (tmp & 1)
+ v >>= 4;
out = (out >> 4) | (v << 28);
#else
out |= S_boxes_P_shuffle[i][tmp];
#endif
// get next 6 bits of E-shuffle and round key k into the lowest bits
- r = (r >> 4) | (r << 28);
+ r = (r >> 4) | (r << 28);
k >>= 6;
}
#if CONFIG_SMALL
@@ -248,15 +228,17 @@ static uint32_t f_func(uint32_t r, uint64_t k) {
* Note: the specification calls this "shift", so I kept it although
* it is confusing.
*/
-static uint64_t key_shift_left(uint64_t CDn) {
+static uint64_t key_shift_left(uint64_t CDn)
+{
uint64_t carries = (CDn >> 27) & 0x10000001;
CDn <<= 1;
- CDn &= ~0x10000001;
- CDn |= carries;
+ CDn &= ~0x10000001;
+ CDn |= carries;
return CDn;
}
-static void gen_roundkeys(uint64_t K[16], uint64_t key) {
+static void gen_roundkeys(uint64_t K[16], uint64_t key)
+{
int i;
// discard parity bits from key and shuffle it into C and D parts
uint64_t CDn = shuffle(key, PC1_shuffle, sizeof(PC1_shuffle));
@@ -269,7 +251,8 @@ static void gen_roundkeys(uint64_t K[16], uint64_t key) {
}
}
-static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) {
+static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt)
+{
int i;
// used to apply round keys in reverse order for decryption
decrypt = decrypt ? 15 : 0;
@@ -278,8 +261,8 @@ static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) {
for (i = 0; i < 16; i++) {
uint32_t f_res;
f_res = f_func(in, K[decrypt ^ i]);
- in = (in << 32) | (in >> 32);
- in ^= f_res;
+ in = (in << 32) | (in >> 32);
+ in ^= f_res;
}
in = (in << 32) | (in >> 32);
// reverse shuffle used to ease hardware implementations
@@ -304,7 +287,9 @@ int av_des_init(AVDES *d, const uint8_t *key, int key_bits, av_unused int decryp
return 0;
}
-static void av_des_crypt_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt, int mac) {
+static void av_des_crypt_mac(AVDES *d, uint8_t *dst, const uint8_t *src,
+ int count, uint8_t *iv, int decrypt, int mac)
+{
uint64_t iv_val = iv ? AV_RB64(iv) : 0;
while (count-- > 0) {
uint64_t dst_val;
@@ -316,7 +301,7 @@ static void av_des_crypt_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int cou
src_val = des_encdec(src_val, d->round_keys[1], 0);
}
dst_val = des_encdec(src_val, d->round_keys[0], 1) ^ iv_val;
- iv_val = iv ? tmp : 0;
+ iv_val = iv ? tmp : 0;
} else {
dst_val = des_encdec(src_val ^ iv_val, d->round_keys[0], 0);
if (d->triple_des) {
@@ -334,12 +319,15 @@ static void av_des_crypt_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int cou
AV_WB64(iv, iv_val);
}
-void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt) {
+void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src,
+ int count, uint8_t *iv, int decrypt)
+{
av_des_crypt_mac(d, dst, src, count, iv, decrypt, 0);
}
-void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count) {
- av_des_crypt_mac(d, dst, src, count, (uint8_t[8]){0}, 0, 1);
+void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count)
+{
+ av_des_crypt_mac(d, dst, src, count, (uint8_t[8]) { 0 }, 0, 1);
}
#ifdef TEST
@@ -348,15 +336,16 @@ void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count) {
#include "time.h"
-static uint64_t rand64(void) {
+static uint64_t rand64(void)
+{
uint64_t r = rand();
r = (r << 32) | rand();
return r;
}
-static const uint8_t test_key[] = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0};
-static const DECLARE_ALIGNED(8, uint8_t, plain)[] = {0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10};
-static const DECLARE_ALIGNED(8, uint8_t, crypt)[] = {0x4a, 0xb6, 0x5b, 0x3d, 0x4b, 0x06, 0x15, 0x18};
+static const uint8_t test_key[] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 };
+static const DECLARE_ALIGNED(8, uint8_t, plain)[] = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 };
+static const DECLARE_ALIGNED(8, uint8_t, crypt)[] = { 0x4a, 0xb6, 0x5b, 0x3d, 0x4b, 0x06, 0x15, 0x18 };
static DECLARE_ALIGNED(8, uint8_t, tmp)[8];
static DECLARE_ALIGNED(8, uint8_t, large_buffer)[10002][8];
static const uint8_t cbc_key[] = {
@@ -365,7 +354,8 @@ static const uint8_t cbc_key[] = {
0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23
};
-static int run_test(int cbc, int decrypt) {
+static int run_test(int cbc, int decrypt)
+{
AVDES d;
int delay = cbc && !decrypt ? 2 : 1;
uint64_t res;
@@ -388,7 +378,8 @@ static int run_test(int cbc, int decrypt) {
}
}
-int main(void) {
+int main(void)
+{
AVDES d;
int i;
uint64_t key[3];
@@ -397,7 +388,7 @@ int main(void) {
uint64_t roundkeys[16];
srand(av_gettime());
key[0] = AV_RB64(test_key);
- data = AV_RB64(plain);
+ data = AV_RB64(plain);
gen_roundkeys(roundkeys, key[0]);
if (des_encdec(data, roundkeys, 0) != AV_RB64(crypt)) {
printf("Test 1 failed\n");
@@ -414,12 +405,14 @@ int main(void) {
return 1;
}
for (i = 0; i < 1000; i++) {
- key[0] = rand64(); key[1] = rand64(); key[2] = rand64();
- data = rand64();
- av_des_init(&d, (uint8_t*)key, 192, 0);
- av_des_crypt(&d, (uint8_t*)&ct, (uint8_t*)&data, 1, NULL, 0);
- av_des_init(&d, (uint8_t*)key, 192, 1);
- av_des_crypt(&d, (uint8_t*)&ct, (uint8_t*)&ct, 1, NULL, 1);
+ key[0] = rand64();
+ key[1] = rand64();
+ key[2] = rand64();
+ data = rand64();
+ av_des_init(&d, (uint8_t *) key, 192, 0);
+ av_des_crypt(&d, (uint8_t *) &ct, (uint8_t *) &data, 1, NULL, 0);
+ av_des_init(&d, (uint8_t *) key, 192, 1);
+ av_des_crypt(&d, (uint8_t *) &ct, (uint8_t *) &ct, 1, NULL, 1);
if (ct != data) {
printf("Test 2 failed\n");
return 1;
@@ -432,9 +425,9 @@ int main(void) {
printf(" {");
for (j = 0; j < 64; j++) {
uint32_t v = S_boxes[i][j >> 1];
- v = j & 1 ? v >> 4 : v & 0xf;
+ v = j & 1 ? v >> 4 : v & 0xf;
v <<= 28 - 4 * i;
- v = shuffle(v, P_shuffle, sizeof(P_shuffle));
+ v = shuffle(v, P_shuffle, sizeof(P_shuffle));
printf((j & 7) == 0 ? "\n " : " ");
printf("0x%08X,", v);
}
diff --git a/libavutil/lls.c b/libavutil/lls.c
index de3d58f6d9..c5753ae574 100644
--- a/libavutil/lls.c
+++ b/libavutil/lls.c
@@ -141,7 +141,7 @@ int main(void)
LOCAL_ALIGNED(32, double, var, [4]);
double eval;
- var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2;
+ var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2;
var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
diff --git a/libavutil/md5.c b/libavutil/md5.c
index 876bd557d4..482582b5d1 100644
--- a/libavutil/md5.c
+++ b/libavutil/md5.c
@@ -31,12 +31,13 @@
*/
#include <stdint.h>
+
#include "bswap.h"
#include "intreadwrite.h"
-#include "md5.h"
#include "mem.h"
+#include "md5.h"
-typedef struct AVMD5{
+typedef struct AVMD5 {
uint64_t len;
uint8_t block[64];
uint32_t ABCD[4];
@@ -78,16 +79,21 @@ static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32)
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
};
-#define CORE(i, a, b, c, d) do { \
- t = S[i >> 4][i & 3]; \
+#define CORE(i, a, b, c, d) \
+ do { \
+ t = S[i >> 4][i & 3]; \
a += T[i]; \
\
if (i < 32) { \
- if (i < 16) a += (d ^ (b & (c ^ d))) + X[ i & 15]; \
- else a += ((d & b) | (~d & c)) + X[(1 + 5*i) & 15]; \
+ if (i < 16) \
+ a += (d ^ (b & (c ^ d))) + X[ i & 15]; \
+ else \
+ a += ((d & b) | (~d & c)) + X[(1 + 5*i) & 15]; \
} else { \
- if (i < 48) a += (b ^ c ^ d) + X[(5 + 3*i) & 15]; \
- else a += (c ^ (b | ~d)) + X[( 7*i) & 15]; \
+ if (i < 48) \
+ a += (b ^ c ^ d) + X[(5 + 3*i) & 15]; \
+ else \
+ a += (c ^ (b | ~d)) + X[( 7*i) & 15]; \
} \
a = b + (a << t | a >> (32 - t)); \
} while (0)
@@ -122,10 +128,13 @@ static void body(uint32_t ABCD[4], uint32_t *src, int nblocks)
}
#else
#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)
-#define CORE4(i) CORE2(i); CORE2((i+4)); CORE2((i+8)); CORE2((i+12))
- CORE4(0); CORE4(16); CORE4(32); CORE4(48);
+ 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)
+#define CORE4(i) CORE2(i); CORE2((i + 4)); CORE2((i + 8)); CORE2((i + 12))
+ CORE4(0);
+ CORE4(16);
+ CORE4(32);
+ CORE4(48);
#endif
ABCD[0] += d;
@@ -150,7 +159,7 @@ void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len)
const uint8_t *end;
int j;
- j = ctx->len & 63;
+ j = ctx->len & 63;
ctx->len += len;
if (j) {
@@ -189,10 +198,10 @@ void av_md5_final(AVMD5 *ctx, uint8_t *dst)
while ((ctx->len & 63) != 56)
av_md5_update(ctx, "", 1);
- av_md5_update(ctx, (uint8_t *)&finalcount, 8);
+ av_md5_update(ctx, (uint8_t *) &finalcount, 8);
for (i = 0; i < 4; i++)
- AV_WL32(dst + 4*i, ctx->ABCD[3 - i]);
+ AV_WL32(dst + 4 * i, ctx->ABCD[3 - i]);
}
void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len)
@@ -215,7 +224,8 @@ static void print_md5(uint8_t *md5)
printf("\n");
}
-int main(void){
+int main(void)
+{
uint8_t md5val[16];
int i;
volatile uint8_t in[1000]; // volatile to workaround http://llvm.org/bugs/show_bug.cgi?id=20849
@@ -223,13 +233,18 @@ int main(void){
for (i = 0; i < 1000; i++)
in[i] = i * i;
- av_md5_sum(md5val, in, 1000); print_md5(md5val);
- av_md5_sum(md5val, in, 63); print_md5(md5val);
- av_md5_sum(md5val, in, 64); print_md5(md5val);
- av_md5_sum(md5val, in, 65); print_md5(md5val);
+ av_md5_sum(md5val, in, 1000);
+ print_md5(md5val);
+ av_md5_sum(md5val, in, 63);
+ print_md5(md5val);
+ av_md5_sum(md5val, in, 64);
+ print_md5(md5val);
+ av_md5_sum(md5val, in, 65);
+ print_md5(md5val);
for (i = 0; i < 1000; i++)
in[i] = i % 127;
- av_md5_sum(md5val, in, 999); print_md5(md5val);
+ av_md5_sum(md5val, in, 999);
+ print_md5(md5val);
return 0;
}
diff --git a/libavutil/opt.c b/libavutil/opt.c
index cbe36dfd92..ae92da06c4 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -30,13 +30,13 @@
#include "avstring.h"
#include "channel_layout.h"
#include "common.h"
-#include "opt.h"
-#include "eval.h"
#include "dict.h"
+#include "eval.h"
#include "log.h"
#include "parseutils.h"
#include "pixdesc.h"
#include "mathematics.h"
+#include "opt.h"
#include "samplefmt.h"
#include "bprint.h"
@@ -58,20 +58,37 @@ const AVOption *av_opt_next(const void *obj, const AVOption *last)
static int read_number(const AVOption *o, const void *dst, double *num, int *den, int64_t *intnum)
{
switch (o->type) {
- case AV_OPT_TYPE_FLAGS: *intnum = *(unsigned int*)dst;return 0;
- case AV_OPT_TYPE_PIXEL_FMT: *intnum = *(enum AVPixelFormat *)dst;return 0;
- case AV_OPT_TYPE_SAMPLE_FMT:*intnum = *(enum AVSampleFormat*)dst;return 0;
+ case AV_OPT_TYPE_FLAGS:
+ *intnum = *(unsigned int*)dst;
+ return 0;
+ case AV_OPT_TYPE_PIXEL_FMT:
+ *intnum = *(enum AVPixelFormat *)dst;
+ return 0;
+ case AV_OPT_TYPE_SAMPLE_FMT:
+ *intnum = *(enum AVSampleFormat *)dst;
+ return 0;
case AV_OPT_TYPE_BOOL:
- case AV_OPT_TYPE_INT: *intnum = *(int *)dst;return 0;
+ case AV_OPT_TYPE_INT:
+ *intnum = *(int *)dst;
+ return 0;
case AV_OPT_TYPE_CHANNEL_LAYOUT:
case AV_OPT_TYPE_DURATION:
- case AV_OPT_TYPE_INT64: *intnum = *(int64_t *)dst;return 0;
- case AV_OPT_TYPE_FLOAT: *num = *(float *)dst;return 0;
- case AV_OPT_TYPE_DOUBLE: *num = *(double *)dst;return 0;
- case AV_OPT_TYPE_RATIONAL: *intnum = ((AVRational*)dst)->num;
- *den = ((AVRational*)dst)->den;
- return 0;
- case AV_OPT_TYPE_CONST: *num = o->default_val.dbl; return 0;
+ case AV_OPT_TYPE_INT64:
+ *intnum = *(int64_t *)dst;
+ return 0;
+ case AV_OPT_TYPE_FLOAT:
+ *num = *(float *)dst;
+ return 0;
+ case AV_OPT_TYPE_DOUBLE:
+ *num = *(double *)dst;
+ return 0;
+ case AV_OPT_TYPE_RATIONAL:
+ *intnum = ((AVRational *)dst)->num;
+ *den = ((AVRational *)dst)->den;
+ return 0;
+ case AV_OPT_TYPE_CONST:
+ *num = o->default_val.dbl;
+ return 0;
}
return AVERROR(EINVAL);
}
@@ -80,7 +97,7 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int
{
if (o->type != AV_OPT_TYPE_FLAGS &&
(o->max * den < num * intnum || o->min * den > num * intnum)) {
- num = den ? num*intnum/den : (num*intnum ? INFINITY : NAN);
+ num = den ? num * intnum / den : (num * intnum ? INFINITY : NAN);
av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range [%g - %g]\n",
num, o->name, o->min, o->max);
return AVERROR(ERANGE);
@@ -96,19 +113,33 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int
}
switch (o->type) {
- case AV_OPT_TYPE_PIXEL_FMT: *(enum AVPixelFormat *)dst = llrint(num/den) * intnum; break;
- case AV_OPT_TYPE_SAMPLE_FMT:*(enum AVSampleFormat*)dst = llrint(num/den) * intnum; break;
+ case AV_OPT_TYPE_PIXEL_FMT:
+ *(enum AVPixelFormat *)dst = llrint(num / den) * intnum;
+ break;
+ case AV_OPT_TYPE_SAMPLE_FMT:
+ *(enum AVSampleFormat *)dst = llrint(num / den) * intnum;
+ break;
case AV_OPT_TYPE_BOOL:
case AV_OPT_TYPE_FLAGS:
- case AV_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break;
+ case AV_OPT_TYPE_INT:
+ *(int *)dst = llrint(num / den) * intnum;
+ break;
case AV_OPT_TYPE_DURATION:
case AV_OPT_TYPE_CHANNEL_LAYOUT:
- case AV_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break;
- case AV_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break;
- case AV_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break;
+ case AV_OPT_TYPE_INT64:
+ *(int64_t *)dst = llrint(num / den) * intnum;
+ break;
+ case AV_OPT_TYPE_FLOAT:
+ *(float *)dst = num * intnum / den;
+ break;
+ case AV_OPT_TYPE_DOUBLE:
+ *(double *)dst = num * intnum / den;
+ break;
case AV_OPT_TYPE_RATIONAL:
- if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den};
- else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
+ if ((int) num == num)
+ *(AVRational *)dst = (AVRational) { num *intnum, den };
+ else
+ *(AVRational *)dst = av_d2q(num * intnum / den, 1 << 24);
break;
default:
return AVERROR(EINVAL);
@@ -117,9 +148,12 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int
}
static int hexchar2int(char c) {
- if (c >= '0' && c <= '9') return c - '0';
- if (c >= 'a' && c <= 'f') return c - 'a' + 10;
- if (c >= 'A' && c <= 'F') return c - 'A' + 10;
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ if (c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
return -1;
}
@@ -151,7 +185,7 @@ static int set_string_binary(void *obj, const AVOption *o, const char *val, uint
}
*ptr++ = (a << 4) | b;
}
- *dst = bin;
+ *dst = bin;
*lendst = len;
return 0;
@@ -167,8 +201,9 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d
#define DEFAULT_NUMVAL(opt) ((opt->type == AV_OPT_TYPE_INT64 || \
opt->type == AV_OPT_TYPE_CONST || \
opt->type == AV_OPT_TYPE_FLAGS || \
- opt->type == AV_OPT_TYPE_INT) ? \
- opt->default_val.i64 : opt->default_val.dbl)
+ opt->type == AV_OPT_TYPE_INT) \
+ ? opt->default_val.i64 \
+ : opt->default_val.dbl)
static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst)
{
@@ -243,8 +278,10 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con
}
if (o->type == AV_OPT_TYPE_FLAGS) {
read_number(o, dst, NULL, NULL, &intnum);
- if (cmd == '+') d = intnum | (int64_t)d;
- else if (cmd == '-') d = intnum &~(int64_t)d;
+ if (cmd == '+')
+ d = intnum | (int64_t)d;
+ else if (cmd == '-')
+ d = intnum &~(int64_t)d;
}
if ((ret = write_number(obj, o, dst, d, 1, 1)) < 0)
@@ -407,21 +444,29 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
if (o->flags & AV_OPT_FLAG_READONLY)
return AVERROR(EINVAL);
- dst = ((uint8_t*)target_obj) + o->offset;
+ dst = ((uint8_t *)target_obj) + o->offset;
switch (o->type) {
- case AV_OPT_TYPE_BOOL: return set_string_bool(obj, o, val, dst);
- case AV_OPT_TYPE_STRING: return set_string(obj, o, val, dst);
- case AV_OPT_TYPE_BINARY: return set_string_binary(obj, o, val, dst);
+ case AV_OPT_TYPE_BOOL:
+ return set_string_bool(obj, o, val, dst);
+ case AV_OPT_TYPE_STRING:
+ return set_string(obj, o, val, dst);
+ case AV_OPT_TYPE_BINARY:
+ return set_string_binary(obj, o, val, dst);
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_INT64:
case AV_OPT_TYPE_FLOAT:
case AV_OPT_TYPE_DOUBLE:
- case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, target_obj, o, val, dst);
- case AV_OPT_TYPE_IMAGE_SIZE: return set_string_image_size(obj, o, val, dst);
- case AV_OPT_TYPE_VIDEO_RATE: return set_string_video_rate(obj, o, val, dst);
- case AV_OPT_TYPE_PIXEL_FMT: return set_string_pixel_fmt(obj, o, val, dst);
- case AV_OPT_TYPE_SAMPLE_FMT: return set_string_sample_fmt(obj, o, val, dst);
+ case AV_OPT_TYPE_RATIONAL:
+ return set_string_number(obj, target_obj, o, val, dst);
+ case AV_OPT_TYPE_IMAGE_SIZE:
+ return set_string_image_size(obj, o, val, dst);
+ case AV_OPT_TYPE_VIDEO_RATE:
+ return set_string_video_rate(obj, o, val, dst);
+ case AV_OPT_TYPE_PIXEL_FMT:
+ return set_string_pixel_fmt(obj, o, val, dst);
+ case AV_OPT_TYPE_SAMPLE_FMT:
+ return set_string_sample_fmt(obj, o, val, dst);
case AV_OPT_TYPE_DURATION:
if (!val) {
*(int64_t *)dst = 0;
@@ -432,7 +477,8 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
return ret;
}
break;
- case AV_OPT_TYPE_COLOR: return set_string_color(obj, o, val, dst);
+ case AV_OPT_TYPE_COLOR:
+ return set_string_color(obj, o, val, dst);
case AV_OPT_TYPE_CHANNEL_LAYOUT:
if (!val || !strcmp(val, "none")) {
*(int64_t *)dst = 0;
@@ -452,13 +498,14 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
return AVERROR(EINVAL);
}
-#define OPT_EVAL_NUMBER(name, opttype, vartype)\
- int av_opt_eval_ ## name(void *obj, const AVOption *o, const char *val, vartype *name ## _out)\
- {\
- if (!o || o->type != opttype || o->flags & AV_OPT_FLAG_READONLY)\
- return AVERROR(EINVAL);\
- return set_string_number(obj, obj, o, val, name ## _out);\
- }
+#define OPT_EVAL_NUMBER(name, opttype, vartype) \
+int av_opt_eval_ ## name(void *obj, const AVOption *o, \
+ const char *val, vartype *name ## _out) \
+{ \
+ if (!o || o->type != opttype || o->flags & AV_OPT_FLAG_READONLY) \
+ return AVERROR(EINVAL); \
+ return set_string_number(obj, obj, o, val, name ## _out); \
+}
OPT_EVAL_NUMBER(flags, AV_OPT_TYPE_FLAGS, int)
OPT_EVAL_NUMBER(int, AV_OPT_TYPE_INT, int)
@@ -468,7 +515,7 @@ OPT_EVAL_NUMBER(double, AV_OPT_TYPE_DOUBLE, double)
OPT_EVAL_NUMBER(q, AV_OPT_TYPE_RATIONAL, AVRational)
static int set_number(void *obj, const char *name, double num, int den, int64_t intnum,
- int search_flags)
+ int search_flags)
{
void *dst, *target_obj;
const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
@@ -479,7 +526,7 @@ static int set_number(void *obj, const char *name, double num, int den, int64_t
if (o->flags & AV_OPT_FLAG_READONLY)
return AVERROR(EINVAL);
- dst = ((uint8_t*)target_obj) + o->offset;
+ dst = ((uint8_t *)target_obj) + o->offset;
return write_number(obj, o, dst, num, den, intnum);
}
@@ -516,11 +563,11 @@ int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int
if (len && !ptr)
return AVERROR(ENOMEM);
- dst = (uint8_t **)(((uint8_t *)target_obj) + o->offset);
+ dst = (uint8_t **)(((uint8_t *)target_obj) + o->offset);
lendst = (int *)(dst + 1);
av_free(*dst);
- *dst = ptr;
+ *dst = ptr;
*lendst = len;
if (len)
memcpy(ptr, val, len);
@@ -622,7 +669,8 @@ int av_opt_set_channel_layout(void *obj, const char *name, int64_t cl, int searc
return 0;
}
-int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags)
+int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val,
+ int search_flags)
{
void *target_obj;
AVDictionary **dst;
@@ -686,24 +734,38 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
if (!o || !target_obj || (o->offset<=0 && o->type != AV_OPT_TYPE_CONST))
return AVERROR_OPTION_NOT_FOUND;
- dst = (uint8_t*)target_obj + o->offset;
+ dst = (uint8_t *)target_obj + o->offset;
buf[0] = 0;
switch (o->type) {
case AV_OPT_TYPE_BOOL:
ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(get_bool_name(*(int *)dst), "invalid"));
break;
- case AV_OPT_TYPE_FLAGS: ret = snprintf(buf, sizeof(buf), "0x%08X", *(int *)dst);break;
- case AV_OPT_TYPE_INT: ret = snprintf(buf, sizeof(buf), "%d" , *(int *)dst);break;
- case AV_OPT_TYPE_INT64: ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break;
- case AV_OPT_TYPE_FLOAT: ret = snprintf(buf, sizeof(buf), "%f" , *(float *)dst);break;
- case AV_OPT_TYPE_DOUBLE: ret = snprintf(buf, sizeof(buf), "%f" , *(double *)dst);break;
+ case AV_OPT_TYPE_FLAGS:
+ ret = snprintf(buf, sizeof(buf), "0x%08X", *(int *)dst);
+ break;
+ case AV_OPT_TYPE_INT:
+ ret = snprintf(buf, sizeof(buf), "%d", *(int *)dst);
+ break;
+ case AV_OPT_TYPE_INT64:
+ ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t *)dst);
+ break;
+ case AV_OPT_TYPE_FLOAT:
+ ret = snprintf(buf, sizeof(buf), "%f", *(float *)dst);
+ break;
+ case AV_OPT_TYPE_DOUBLE:
+ ret = snprintf(buf, sizeof(buf), "%f", *(double *)dst);
+ break;
case AV_OPT_TYPE_VIDEO_RATE:
- case AV_OPT_TYPE_RATIONAL: ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
- case AV_OPT_TYPE_CONST: ret = snprintf(buf, sizeof(buf), "%f" , o->default_val.dbl);break;
+ case AV_OPT_TYPE_RATIONAL:
+ ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational *)dst)->num, ((AVRational *)dst)->den);
+ break;
+ case AV_OPT_TYPE_CONST:
+ ret = snprintf(buf, sizeof(buf), "%f", o->default_val.dbl);
+ break;
case AV_OPT_TYPE_STRING:
- if (*(uint8_t**)dst) {
- *out_val = av_strdup(*(uint8_t**)dst);
+ if (*(uint8_t **)dst) {
+ *out_val = av_strdup(*(uint8_t **)dst);
} else if (search_flags & AV_OPT_ALLOW_NULL) {
*out_val = NULL;
return 0;
@@ -712,22 +774,22 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
}
return *out_val ? 0 : AVERROR(ENOMEM);
case AV_OPT_TYPE_BINARY:
- if (!*(uint8_t**)dst && (search_flags & AV_OPT_ALLOW_NULL)) {
+ if (!*(uint8_t **)dst && (search_flags & AV_OPT_ALLOW_NULL)) {
*out_val = NULL;
return 0;
}
- len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
- if ((uint64_t)len*2 + 1 > INT_MAX)
+ len = *(int *)(((uint8_t *)dst) + sizeof(uint8_t *));
+ if ((uint64_t)len * 2 + 1 > INT_MAX)
return AVERROR(EINVAL);
- if (!(*out_val = av_malloc(len*2 + 1)))
+ if (!(*out_val = av_malloc(len * 2 + 1)))
return AVERROR(ENOMEM);
if (!len) {
*out_val[0] = '\0';
return 0;
}
- bin = *(uint8_t**)dst;
+ bin = *(uint8_t **)dst;
for (i = 0; i < len; i++)
- snprintf(*out_val + i*2, 3, "%02X", bin[i]);
+ snprintf(*out_val + i * 2, 3, "%02X", bin[i]);
return 0;
case AV_OPT_TYPE_IMAGE_SIZE:
ret = snprintf(buf, sizeof(buf), "%dx%d", ((int *)dst)[0], ((int *)dst)[1]);
@@ -770,46 +832,47 @@ static int get_number(void *obj, const char *name, const AVOption **o_out, doubl
if (!o || !target_obj)
goto error;
- dst = ((uint8_t*)target_obj) + o->offset;
+ dst = ((uint8_t *)target_obj) + o->offset;
if (o_out) *o_out= o;
return read_number(o, dst, num, den, intnum);
error:
- *den=*intnum=0;
+ *den =
+ *intnum = 0;
return -1;
}
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
{
int64_t intnum = 1;
- double num = 1;
- int ret, den = 1;
+ double num = 1;
+ int ret, den = 1;
if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0)
return ret;
- *out_val = num*intnum/den;
+ *out_val = num * intnum / den;
return 0;
}
int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val)
{
int64_t intnum = 1;
- double num = 1;
- int ret, den = 1;
+ double num = 1;
+ int ret, den = 1;
if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0)
return ret;
- *out_val = num*intnum/den;
+ *out_val = num * intnum / den;
return 0;
}
int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_val)
{
int64_t intnum = 1;
- double num = 1;
- int ret, den = 1;
+ double num = 1;
+ int ret, den = 1;
if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0)
return ret;
@@ -849,9 +912,9 @@ int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRatio
return ret;
if (num == 1.0 && (int)intnum == intnum)
- *out_val = (AVRational){intnum, den};
+ *out_val = (AVRational) { intnum, den };
else
- *out_val = av_d2q(num*intnum/den, 1<<24);
+ *out_val = av_d2q(num * intnum / den, 1 << 24);
return 0;
}
@@ -1000,7 +1063,7 @@ static char *get_opt_flags_string(void *obj, const char *unit, int64_t value)
static void opt_list(void *obj, void *av_log_obj, const char *unit,
int req_flags, int rej_flags)
{
- const AVOption *opt=NULL;
+ const AVOption *opt = NULL;
AVOptionRanges *r;
int i;
@@ -1012,11 +1075,11 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit,
* Don't print anything but CONST's on level two.
* Only print items from the requested unit.
*/
- if (!unit && opt->type==AV_OPT_TYPE_CONST)
+ if (!unit && opt->type == AV_OPT_TYPE_CONST)
continue;
- else if (unit && opt->type!=AV_OPT_TYPE_CONST)
+ else if (unit && opt->type != AV_OPT_TYPE_CONST)
continue;
- else if (unit && opt->type==AV_OPT_TYPE_CONST && strcmp(unit, opt->unit))
+ else if (unit && opt->type == AV_OPT_TYPE_CONST && strcmp(unit, opt->unit))
continue;
else if (unit && opt->type == AV_OPT_TYPE_CONST)
av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name);
@@ -1175,9 +1238,8 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit,
}
av_log(av_log_obj, AV_LOG_INFO, "\n");
- if (opt->unit && opt->type != AV_OPT_TYPE_CONST) {
+ if (opt->unit && opt->type != AV_OPT_TYPE_CONST)
opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags);
- }
}
}
@@ -1186,7 +1248,7 @@ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
if (!obj)
return -1;
- av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name);
+ av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass **)obj)->class_name);
opt_list(obj, av_log_obj, NULL, req_flags, rej_flags);
@@ -1213,7 +1275,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
switch (opt->type) {
case AV_OPT_TYPE_CONST:
/* Nothing to be done here */
- break;
+ break;
case AV_OPT_TYPE_BOOL:
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT:
@@ -1255,8 +1317,9 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
case AV_OPT_TYPE_DICT:
/* Cannot set defaults for these types */
break;
- default:
- av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name);
+ default:
+ av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n",
+ opt->type, opt->name);
}
}
}
@@ -1546,7 +1609,7 @@ const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
void *av_opt_child_next(void *obj, void *prev)
{
- const AVClass *c = *(AVClass**)obj;
+ const AVClass *c = *(AVClass **)obj;
if (c->child_next)
return c->child_next(obj, prev);
return NULL;
@@ -1572,20 +1635,31 @@ static int opt_size(enum AVOptionType type)
switch(type) {
case AV_OPT_TYPE_BOOL:
case AV_OPT_TYPE_INT:
- case AV_OPT_TYPE_FLAGS: return sizeof(int);
+ case AV_OPT_TYPE_FLAGS:
+ return sizeof(int);
case AV_OPT_TYPE_DURATION:
case AV_OPT_TYPE_CHANNEL_LAYOUT:
- case AV_OPT_TYPE_INT64: return sizeof(int64_t);
- case AV_OPT_TYPE_DOUBLE: return sizeof(double);
- case AV_OPT_TYPE_FLOAT: return sizeof(float);
- case AV_OPT_TYPE_STRING: return sizeof(uint8_t*);
+ case AV_OPT_TYPE_INT64:
+ return sizeof(int64_t);
+ case AV_OPT_TYPE_DOUBLE:
+ return sizeof(double);
+ case AV_OPT_TYPE_FLOAT:
+ return sizeof(float);
+ case AV_OPT_TYPE_STRING:
+ return sizeof(uint8_t*);
case AV_OPT_TYPE_VIDEO_RATE:
- case AV_OPT_TYPE_RATIONAL: return sizeof(AVRational);
- case AV_OPT_TYPE_BINARY: return sizeof(uint8_t*) + sizeof(int);
- case AV_OPT_TYPE_IMAGE_SIZE:return sizeof(int[2]);
- case AV_OPT_TYPE_PIXEL_FMT: return sizeof(enum AVPixelFormat);
- case AV_OPT_TYPE_SAMPLE_FMT:return sizeof(enum AVSampleFormat);
- case AV_OPT_TYPE_COLOR: return 4;
+ case AV_OPT_TYPE_RATIONAL:
+ return sizeof(AVRational);
+ case AV_OPT_TYPE_BINARY:
+ return sizeof(uint8_t*) + sizeof(int);
+ case AV_OPT_TYPE_IMAGE_SIZE:
+ return sizeof(int[2]);
+ case AV_OPT_TYPE_PIXEL_FMT:
+ return sizeof(enum AVPixelFormat);
+ case AV_OPT_TYPE_SAMPLE_FMT:
+ return sizeof(enum AVSampleFormat);
+ case AV_OPT_TYPE_COLOR:
+ return 4;
}
return AVERROR(EINVAL);
}
@@ -1599,15 +1673,15 @@ int av_opt_copy(void *dst, const void *src)
if (!src)
return AVERROR(EINVAL);
- c = *(AVClass**)src;
- if (!c || c != *(AVClass**)dst)
+ c = *(AVClass **)src;
+ if (!c || c != *(AVClass **)dst)
return AVERROR(EINVAL);
while ((o = av_opt_next(src, o))) {
- void *field_dst = ((uint8_t*)dst) + o->offset;
- void *field_src = ((uint8_t*)src) + o->offset;
- uint8_t **field_dst8 = (uint8_t**)field_dst;
- uint8_t **field_src8 = (uint8_t**)field_src;
+ void *field_dst = (uint8_t *)dst + o->offset;
+ void *field_src = (uint8_t *)src + o->offset;
+ uint8_t **field_dst8 = (uint8_t **)field_dst;
+ uint8_t **field_src8 = (uint8_t **)field_src;
if (o->type == AV_OPT_TYPE_STRING) {
if (*field_dst8 != *field_src8)
@@ -1616,7 +1690,7 @@ int av_opt_copy(void *dst, const void *src)
if (*field_src8 && !*field_dst8)
ret = AVERROR(ENOMEM);
} else if (o->type == AV_OPT_TYPE_BINARY) {
- int len = *(int*)(field_src8 + 1);
+ int len = *(int *)(field_src8 + 1);
if (*field_dst8 != *field_src8)
av_freep(field_dst8);
*field_dst8 = av_memdup(*field_src8, len);
@@ -1624,7 +1698,7 @@ int av_opt_copy(void *dst, const void *src)
ret = AVERROR(ENOMEM);
len = 0;
}
- *(int*)(field_dst8 + 1) = len;
+ *(int *)(field_dst8 + 1) = len;
} else if (o->type == AV_OPT_TYPE_CONST) {
// do nothing
} else if (o->type == AV_OPT_TYPE_DICT) {
@@ -1915,8 +1989,7 @@ int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer,
#ifdef TEST
-typedef struct TestContext
-{
+typedef struct TestContext {
const AVClass *class;
int num;
int toggle;
@@ -1952,32 +2025,32 @@ typedef struct TestContext
#define TEST_FLAG_MU 04
static const AVOption test_options[]= {
-{"num", "set num", OFFSET(num), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 100, 1 },
-{"toggle", "set toggle", OFFSET(toggle), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, 1 },
-{"rational", "set rational", OFFSET(rational), AV_OPT_TYPE_RATIONAL, {.dbl = 1}, 0, 10, 1 },
-{"string", "set string", OFFSET(string), AV_OPT_TYPE_STRING, {.str = "default"}, CHAR_MIN, CHAR_MAX, 1 },
-{"escape", "set escape str", OFFSET(escape), AV_OPT_TYPE_STRING, {.str = "\\=,"}, CHAR_MIN, CHAR_MAX, 1 },
-{"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 1}, 0, INT_MAX, 1, "flags" },
-{"cool", "set cool flag", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_COOL}, INT_MIN, INT_MAX, 1, "flags" },
-{"lame", "set lame flag", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_LAME}, INT_MIN, INT_MAX, 1, "flags" },
-{"mu", "set mu flag", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_MU}, INT_MIN, INT_MAX, 1, "flags" },
-{"size", "set size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE,{.str="200x300"}, 0, 0, 1},
-{"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, {.i64 = AV_PIX_FMT_0BGR}, -1, INT_MAX, 1},
-{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_S16}, -1, INT_MAX, 1},
-{"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0 , 1},
-{"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 1000}, 0, INT64_MAX, 1},
-{"color", "set color", OFFSET(color), AV_OPT_TYPE_COLOR, {.str = "pink"}, 0, 0, 1},
-{"cl", "set channel layout", OFFSET(channel_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64 = AV_CH_LAYOUT_HEXAGONAL}, 0, INT64_MAX, 1},
-{"bin", "set binary value", OFFSET(binary), AV_OPT_TYPE_BINARY, {.str="62696e00"}, 0, 0, 1 },
-{"bin1", "set binary value", OFFSET(binary1), AV_OPT_TYPE_BINARY, {.str=NULL}, 0, 0, 1 },
-{"bin2", "set binary value", OFFSET(binary2), AV_OPT_TYPE_BINARY, {.str=""}, 0, 0, 1 },
-{"num64", "set num 64bit", OFFSET(num64), AV_OPT_TYPE_INT64, {.i64 = 1}, 0, 100, 1 },
-{"flt", "set float", OFFSET(flt), AV_OPT_TYPE_FLOAT, {.dbl = 1.0/3}, 0, 100, 1},
-{"dbl", "set double", OFFSET(dbl), AV_OPT_TYPE_DOUBLE, {.dbl = 1.0/3}, 0, 100, 1 },
-{"bool1", "set boolean value", OFFSET(bool1), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, 1 },
-{"bool2", "set boolean value", OFFSET(bool2), AV_OPT_TYPE_BOOL, {.i64 = 1}, -1, 1, 1 },
-{"bool3", "set boolean value", OFFSET(bool3), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 1 },
-{NULL},
+ {"num", "set num", OFFSET(num), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, 1 },
+ {"toggle", "set toggle", OFFSET(toggle), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, 1 },
+ {"rational", "set rational", OFFSET(rational), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, 10, 1 },
+ {"string", "set string", OFFSET(string), AV_OPT_TYPE_STRING, { .str = "default" }, CHAR_MIN, CHAR_MAX, 1 },
+ {"escape", "set escape str", OFFSET(escape), AV_OPT_TYPE_STRING, { .str = "\\=," }, CHAR_MIN, CHAR_MAX, 1 },
+ {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 1 }, 0, INT_MAX, 1, "flags" },
+ {"cool", "set cool flag", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_COOL }, INT_MIN, INT_MAX, 1, "flags" },
+ {"lame", "set lame flag", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_LAME }, INT_MIN, INT_MAX, 1, "flags" },
+ {"mu", "set mu flag", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_MU }, INT_MIN, INT_MAX, 1, "flags" },
+ {"size", "set size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str="200x300" }, 0, 0, 1 },
+ {"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_0BGR }, -1, INT_MAX, 1 },
+ {"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, { .i64 = AV_SAMPLE_FMT_S16 }, -1, INT_MAX, 1 },
+ {"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, 0, 1 },
+ {"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = 1000 }, 0, INT64_MAX, 1 },
+ {"color", "set color", OFFSET(color), AV_OPT_TYPE_COLOR, { .str = "pink" }, 0, 0, 1 },
+ {"cl", "set channel layout", OFFSET(channel_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, { .i64 = AV_CH_LAYOUT_HEXAGONAL }, 0, INT64_MAX, 1 },
+ {"bin", "set binary value", OFFSET(binary), AV_OPT_TYPE_BINARY, { .str="62696e00" }, 0, 0, 1 },
+ {"bin1", "set binary value", OFFSET(binary1), AV_OPT_TYPE_BINARY, { .str=NULL }, 0, 0, 1 },
+ {"bin2", "set binary value", OFFSET(binary2), AV_OPT_TYPE_BINARY, { .str="" }, 0, 0, 1 },
+ {"num64", "set num 64bit", OFFSET(num64), AV_OPT_TYPE_INT64, { .i64 = 1 }, 0, 100, 1 },
+ {"flt", "set float", OFFSET(flt), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 / 3 }, 0, 100, 1 },
+ {"dbl", "set double", OFFSET(dbl), AV_OPT_TYPE_DOUBLE, { .dbl = 1.0 / 3 }, 0, 100, 1 },
+ {"bool1", "set boolean value", OFFSET(bool1), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, 1 },
+ {"bool2", "set boolean value", OFFSET(bool2), AV_OPT_TYPE_BOOL, { .i64 = 1 }, -1, 1, 1 },
+ {"bool3", "set boolean value", OFFSET(bool3), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 1 },
+ { NULL },
};
static const char *test_get_name(void *ctx)