Merge commit '3b08d9d932eef09403074d5af31e10d8011e840b'
* commit '3b08d9d932eef09403074d5af31e10d8011e840b': testprogs: K&R formatting cosmetics Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
commit
5f587b1daf
@ -24,11 +24,13 @@
|
||||
* 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
|
||||
*/
|
||||
@ -93,8 +95,7 @@ static av_cold int butterworth_init_coeffs(void *avc,
|
||||
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--)
|
||||
{
|
||||
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];
|
||||
@ -211,12 +212,14 @@ 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; \
|
||||
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; \
|
||||
@ -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++) {
|
||||
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);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "aes_internal.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "timer.h"
|
||||
#include "aes.h"
|
||||
|
||||
const int av_aes_size= sizeof(AVAES);
|
||||
|
||||
@ -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,7 +107,8 @@ 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]);
|
||||
@ -257,10 +260,9 @@ 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++) {
|
||||
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"
|
||||
|
||||
@ -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);
|
||||
|
@ -19,8 +19,9 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "bswap.h"
|
||||
#include "common.h"
|
||||
#include "crc.h"
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
@ -383,8 +384,8 @@ int main(void)
|
||||
{
|
||||
uint8_t buf[1999];
|
||||
int i;
|
||||
unsigned
|
||||
p[6][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 },
|
||||
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 },
|
||||
|
131
libavutil/des.c
131
libavutil/des.c
@ -83,29 +83,21 @@ 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,
|
||||
{ 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,
|
||||
}
|
||||
};
|
||||
@ -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,
|
||||
{ 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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
},
|
||||
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,7 +206,8 @@ 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];
|
||||
@ -248,7 +228,8 @@ 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;
|
||||
@ -256,7 +237,8 @@ static uint64_t key_shift_left(uint64_t CDn) {
|
||||
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;
|
||||
@ -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;
|
||||
@ -334,11 +319,14 @@ 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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -348,7 +336,8 @@ 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;
|
||||
@ -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];
|
||||
@ -414,7 +405,9 @@ int main(void) {
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < 1000; i++) {
|
||||
key[0] = rand64(); key[1] = rand64(); key[2] = rand64();
|
||||
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);
|
||||
|
@ -31,10 +31,11 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bswap.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "md5.h"
|
||||
#include "mem.h"
|
||||
#include "md5.h"
|
||||
|
||||
typedef struct AVMD5 {
|
||||
uint64_t len;
|
||||
@ -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 { \
|
||||
#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)
|
||||
@ -125,7 +131,10 @@ static void body(uint32_t ABCD[4], uint32_t *src, int nblocks)
|
||||
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);
|
||||
CORE4(0);
|
||||
CORE4(16);
|
||||
CORE4(32);
|
||||
CORE4(48);
|
||||
#endif
|
||||
|
||||
ABCD[0] += d;
|
||||
@ -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;
|
||||
}
|
||||
|
199
libavutil/opt.c
199
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;
|
||||
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_CONST:
|
||||
*num = o->default_val.dbl;
|
||||
return 0;
|
||||
}
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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)
|
||||
@ -409,19 +446,27 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
|
||||
|
||||
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;
|
||||
@ -453,7 +499,8 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
|
||||
}
|
||||
|
||||
#define OPT_EVAL_NUMBER(name, opttype, vartype) \
|
||||
int av_opt_eval_ ## name(void *obj, const AVOption *o, const char *val, vartype *name ## _out)\
|
||||
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); \
|
||||
@ -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;
|
||||
@ -693,14 +741,28 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
|
||||
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);
|
||||
@ -777,7 +839,8 @@ static int get_number(void *obj, const char *name, const AVOption **o_out, doubl
|
||||
return read_number(o, dst, num, den, intnum);
|
||||
|
||||
error:
|
||||
*den=*intnum=0;
|
||||
*den =
|
||||
*intnum = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1175,11 +1238,10 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
|
||||
{
|
||||
@ -1256,7 +1318,8 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
|
||||
/* 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);
|
||||
av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n",
|
||||
opt->type, opt->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -1604,8 +1678,8 @@ int av_opt_copy(void *dst, const void *src)
|
||||
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;
|
||||
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;
|
||||
|
||||
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user