mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 15:27:32 +09:00
ffvpx: update ffmpeg to 3.4.4 with AVC/AAC/HEVC/FLAC added.
This commit is contained in:
parent
eb361970c5
commit
113a86e60a
377 changed files with 133192 additions and 291 deletions
268
media/ffvpx/libavutil/aes.c
Normal file
268
media/ffvpx/libavutil/aes.c
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
/*
|
||||
* copyright (c) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* some optimization ideas from aes128.c by Reimar Doeffinger
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "aes.h"
|
||||
#include "aes_internal.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "timer.h"
|
||||
|
||||
const int av_aes_size= sizeof(AVAES);
|
||||
|
||||
struct AVAES *av_aes_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVAES));
|
||||
}
|
||||
|
||||
static const uint8_t rcon[10] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36
|
||||
};
|
||||
|
||||
static uint8_t sbox[256];
|
||||
static uint8_t inv_sbox[256];
|
||||
#if CONFIG_SMALL
|
||||
static uint32_t enc_multbl[1][256];
|
||||
static uint32_t dec_multbl[1][256];
|
||||
#else
|
||||
static uint32_t enc_multbl[4][256];
|
||||
static uint32_t dec_multbl[4][256];
|
||||
#endif
|
||||
|
||||
#if HAVE_BIGENDIAN
|
||||
# define ROT(x, s) (((x) >> (s)) | ((x) << (32-(s))))
|
||||
#else
|
||||
# define ROT(x, s) (((x) << (s)) | ((x) >> (32-(s))))
|
||||
#endif
|
||||
|
||||
static inline void addkey(av_aes_block *dst, const av_aes_block *src,
|
||||
const av_aes_block *round_key)
|
||||
{
|
||||
dst->u64[0] = src->u64[0] ^ round_key->u64[0];
|
||||
dst->u64[1] = src->u64[1] ^ round_key->u64[1];
|
||||
}
|
||||
|
||||
static inline void addkey_s(av_aes_block *dst, const uint8_t *src,
|
||||
const av_aes_block *round_key)
|
||||
{
|
||||
dst->u64[0] = AV_RN64(src) ^ round_key->u64[0];
|
||||
dst->u64[1] = AV_RN64(src + 8) ^ round_key->u64[1];
|
||||
}
|
||||
|
||||
static inline void addkey_d(uint8_t *dst, const av_aes_block *src,
|
||||
const av_aes_block *round_key)
|
||||
{
|
||||
AV_WN64(dst, src->u64[0] ^ round_key->u64[0]);
|
||||
AV_WN64(dst + 8, src->u64[1] ^ round_key->u64[1]);
|
||||
}
|
||||
|
||||
static void subshift(av_aes_block s0[2], int s, const uint8_t *box)
|
||||
{
|
||||
av_aes_block *s1 = (av_aes_block *) (s0[0].u8 - s);
|
||||
av_aes_block *s3 = (av_aes_block *) (s0[0].u8 + s);
|
||||
|
||||
s0[0].u8[ 0] = box[s0[1].u8[ 0]];
|
||||
s0[0].u8[ 4] = box[s0[1].u8[ 4]];
|
||||
s0[0].u8[ 8] = box[s0[1].u8[ 8]];
|
||||
s0[0].u8[12] = box[s0[1].u8[12]];
|
||||
s1[0].u8[ 3] = box[s1[1].u8[ 7]];
|
||||
s1[0].u8[ 7] = box[s1[1].u8[11]];
|
||||
s1[0].u8[11] = box[s1[1].u8[15]];
|
||||
s1[0].u8[15] = box[s1[1].u8[ 3]];
|
||||
s0[0].u8[ 2] = box[s0[1].u8[10]];
|
||||
s0[0].u8[10] = box[s0[1].u8[ 2]];
|
||||
s0[0].u8[ 6] = box[s0[1].u8[14]];
|
||||
s0[0].u8[14] = box[s0[1].u8[ 6]];
|
||||
s3[0].u8[ 1] = box[s3[1].u8[13]];
|
||||
s3[0].u8[13] = box[s3[1].u8[ 9]];
|
||||
s3[0].u8[ 9] = box[s3[1].u8[ 5]];
|
||||
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)
|
||||
{
|
||||
#if CONFIG_SMALL
|
||||
return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24);
|
||||
#else
|
||||
return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d];
|
||||
#endif
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
static inline void aes_crypt(AVAES *a, int s, const uint8_t *sbox,
|
||||
uint32_t multbl[][256])
|
||||
{
|
||||
int r;
|
||||
|
||||
for (r = a->rounds - 1; r > 0; r--) {
|
||||
mix(a->state, multbl, 3 - s, 1 + s);
|
||||
addkey(&a->state[1], &a->state[0], &a->round_key[r]);
|
||||
}
|
||||
|
||||
subshift(&a->state[0], s, sbox);
|
||||
}
|
||||
|
||||
static void aes_encrypt(AVAES *a, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int rounds)
|
||||
{
|
||||
while (count--) {
|
||||
addkey_s(&a->state[1], src, &a->round_key[rounds]);
|
||||
if (iv)
|
||||
addkey_s(&a->state[1], iv, &a->state[1]);
|
||||
aes_crypt(a, 2, sbox, enc_multbl);
|
||||
addkey_d(dst, &a->state[0], &a->round_key[0]);
|
||||
if (iv)
|
||||
memcpy(iv, dst, 16);
|
||||
src += 16;
|
||||
dst += 16;
|
||||
}
|
||||
}
|
||||
|
||||
static void aes_decrypt(AVAES *a, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int rounds)
|
||||
{
|
||||
while (count--) {
|
||||
addkey_s(&a->state[1], src, &a->round_key[rounds]);
|
||||
aes_crypt(a, 0, inv_sbox, dec_multbl);
|
||||
if (iv) {
|
||||
addkey_s(&a->state[0], iv, &a->state[0]);
|
||||
memcpy(iv, src, 16);
|
||||
}
|
||||
addkey_d(dst, &a->state[0], &a->round_key[0]);
|
||||
src += 16;
|
||||
dst += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int decrypt)
|
||||
{
|
||||
a->crypt(a, dst, src, count, iv, a->rounds);
|
||||
}
|
||||
|
||||
static void init_multbl2(uint32_t tbl[][256], const int c[4],
|
||||
const uint8_t *log8, const uint8_t *alog8,
|
||||
const uint8_t *sbox)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
int x = sbox[i];
|
||||
if (x) {
|
||||
int k, l, m, n;
|
||||
x = log8[x];
|
||||
k = alog8[x + log8[c[0]]];
|
||||
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));
|
||||
#if !CONFIG_SMALL
|
||||
tbl[1][i] = ROT(tbl[0][i], 8);
|
||||
tbl[2][i] = ROT(tbl[0][i], 16);
|
||||
tbl[3][i] = ROT(tbl[0][i], 24);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this is based on the reference AES code by Paulo Barreto and Vincent Rijmen
|
||||
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
|
||||
{
|
||||
int i, j, t, rconpointer = 0;
|
||||
uint8_t tk[8][4];
|
||||
int KC = key_bits >> 5;
|
||||
int rounds = KC + 6;
|
||||
uint8_t log8[256];
|
||||
uint8_t alog8[512];
|
||||
|
||||
a->crypt = decrypt ? aes_decrypt : aes_encrypt;
|
||||
|
||||
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;
|
||||
log8[j] = i;
|
||||
j ^= j + j;
|
||||
if (j > 255)
|
||||
j ^= 0x11B;
|
||||
}
|
||||
for (i = 0; i < 256; i++) {
|
||||
j = i ? alog8[255 - log8[i]] : 0;
|
||||
j ^= (j << 1) ^ (j << 2) ^ (j << 3) ^ (j << 4);
|
||||
j = (j ^ (j >> 8) ^ 99) & 255;
|
||||
inv_sbox[j] = i;
|
||||
sbox[i] = j;
|
||||
}
|
||||
init_multbl2(dec_multbl, (const int[4]) { 0xe, 0x9, 0xd, 0xb },
|
||||
log8, alog8, inv_sbox);
|
||||
init_multbl2(enc_multbl, (const int[4]) { 0x2, 0x1, 0x1, 0x3 },
|
||||
log8, alog8, sbox);
|
||||
}
|
||||
|
||||
if (key_bits != 128 && key_bits != 192 && key_bits != 256)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
a->rounds = rounds;
|
||||
|
||||
memcpy(tk, key, KC * 4);
|
||||
memcpy(a->round_key[0].u8, key, KC * 4);
|
||||
|
||||
for (t = KC * 4; t < (rounds + 1) * 16; t += KC * 4) {
|
||||
for (i = 0; i < 4; i++)
|
||||
tk[0][i] ^= sbox[tk[KC - 1][(i + 1) & 3]];
|
||||
tk[0][0] ^= rcon[rconpointer++];
|
||||
|
||||
for (j = 1; j < KC; j++) {
|
||||
if (KC != 8 || j != KC >> 1)
|
||||
for (i = 0; i < 4; i++)
|
||||
tk[j][i] ^= tk[j - 1][i];
|
||||
else
|
||||
for (i = 0; i < 4; i++)
|
||||
tk[j][i] ^= sbox[tk[j - 1][i]];
|
||||
}
|
||||
|
||||
memcpy(a->round_key[0].u8 + t, tk, KC * 4);
|
||||
}
|
||||
|
||||
if (decrypt) {
|
||||
for (i = 1; i < rounds; i++) {
|
||||
av_aes_block tmp[3];
|
||||
tmp[2] = a->round_key[i];
|
||||
subshift(&tmp[1], 0, sbox);
|
||||
mix(tmp, dec_multbl, 1, 3);
|
||||
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]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
65
media/ffvpx/libavutil/aes.h
Normal file
65
media/ffvpx/libavutil/aes.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* copyright (c) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AES_H
|
||||
#define AVUTIL_AES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_aes AES
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_aes_size;
|
||||
|
||||
struct AVAES;
|
||||
|
||||
/**
|
||||
* Allocate an AVAES context.
|
||||
*/
|
||||
struct AVAES *av_aes_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVAES context.
|
||||
* @param key_bits 128, 192 or 256
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
* @param count number of 16 byte blocks
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AES_H */
|
||||
129
media/ffvpx/libavutil/aes_ctr.c
Normal file
129
media/ffvpx/libavutil/aes_ctr.c
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* AES-CTR cipher
|
||||
* Copyright (c) 2015 Eran Kornblau <erankor at gmail dot com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "aes_ctr.h"
|
||||
#include "aes.h"
|
||||
#include "ff_random_seed.h"
|
||||
|
||||
#define AES_BLOCK_SIZE (16)
|
||||
|
||||
typedef struct AVAESCTR {
|
||||
struct AVAES* aes;
|
||||
uint8_t counter[AES_BLOCK_SIZE];
|
||||
uint8_t encrypted_counter[AES_BLOCK_SIZE];
|
||||
int block_offset;
|
||||
} AVAESCTR;
|
||||
|
||||
struct AVAESCTR *av_aes_ctr_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVAESCTR));
|
||||
}
|
||||
|
||||
void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv)
|
||||
{
|
||||
memcpy(a->counter, iv, AES_CTR_IV_SIZE);
|
||||
memset(a->counter + AES_CTR_IV_SIZE, 0, sizeof(a->counter) - AES_CTR_IV_SIZE);
|
||||
a->block_offset = 0;
|
||||
}
|
||||
|
||||
const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a)
|
||||
{
|
||||
return a->counter;
|
||||
}
|
||||
|
||||
void av_aes_ctr_set_random_iv(struct AVAESCTR *a)
|
||||
{
|
||||
uint32_t iv[2];
|
||||
|
||||
iv[0] = av_get_random_seed();
|
||||
iv[1] = av_get_random_seed();
|
||||
|
||||
av_aes_ctr_set_iv(a, (uint8_t*)iv);
|
||||
}
|
||||
|
||||
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
|
||||
{
|
||||
a->aes = av_aes_alloc();
|
||||
if (!a->aes) {
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
av_aes_init(a->aes, key, 128, 0);
|
||||
|
||||
memset(a->counter, 0, sizeof(a->counter));
|
||||
a->block_offset = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_aes_ctr_free(struct AVAESCTR *a)
|
||||
{
|
||||
if (a) {
|
||||
av_freep(&a->aes);
|
||||
av_free(a);
|
||||
}
|
||||
}
|
||||
|
||||
static void av_aes_ctr_increment_be64(uint8_t* counter)
|
||||
{
|
||||
uint8_t* cur_pos;
|
||||
|
||||
for (cur_pos = counter + 7; cur_pos >= counter; cur_pos--) {
|
||||
(*cur_pos)++;
|
||||
if (*cur_pos != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void av_aes_ctr_increment_iv(struct AVAESCTR *a)
|
||||
{
|
||||
av_aes_ctr_increment_be64(a->counter);
|
||||
memset(a->counter + AES_CTR_IV_SIZE, 0, sizeof(a->counter) - AES_CTR_IV_SIZE);
|
||||
a->block_offset = 0;
|
||||
}
|
||||
|
||||
void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int count)
|
||||
{
|
||||
const uint8_t* src_end = src + count;
|
||||
const uint8_t* cur_end_pos;
|
||||
uint8_t* encrypted_counter_pos;
|
||||
|
||||
while (src < src_end) {
|
||||
if (a->block_offset == 0) {
|
||||
av_aes_crypt(a->aes, a->encrypted_counter, a->counter, 1, NULL, 0);
|
||||
|
||||
av_aes_ctr_increment_be64(a->counter + 8);
|
||||
}
|
||||
|
||||
encrypted_counter_pos = a->encrypted_counter + a->block_offset;
|
||||
cur_end_pos = src + AES_BLOCK_SIZE - a->block_offset;
|
||||
cur_end_pos = FFMIN(cur_end_pos, src_end);
|
||||
|
||||
a->block_offset += cur_end_pos - src;
|
||||
a->block_offset &= (AES_BLOCK_SIZE - 1);
|
||||
|
||||
while (src < cur_end_pos) {
|
||||
*dst++ = *src++ ^ *encrypted_counter_pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
83
media/ffvpx/libavutil/aes_ctr.h
Normal file
83
media/ffvpx/libavutil/aes_ctr.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* AES-CTR cipher
|
||||
* Copyright (c) 2015 Eran Kornblau <erankor at gmail dot com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AES_CTR_H
|
||||
#define AVUTIL_AES_CTR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
#define AES_CTR_KEY_SIZE (16)
|
||||
#define AES_CTR_IV_SIZE (8)
|
||||
|
||||
struct AVAESCTR;
|
||||
|
||||
/**
|
||||
* Allocate an AVAESCTR context.
|
||||
*/
|
||||
struct AVAESCTR *av_aes_ctr_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVAESCTR context.
|
||||
* @param key encryption key, must have a length of AES_CTR_KEY_SIZE
|
||||
*/
|
||||
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key);
|
||||
|
||||
/**
|
||||
* Release an AVAESCTR context.
|
||||
*/
|
||||
void av_aes_ctr_free(struct AVAESCTR *a);
|
||||
|
||||
/**
|
||||
* Process a buffer using a previously initialized context.
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param size the size of src and dst
|
||||
*/
|
||||
void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int size);
|
||||
|
||||
/**
|
||||
* Get the current iv
|
||||
*/
|
||||
const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a);
|
||||
|
||||
/**
|
||||
* Generate a random iv
|
||||
*/
|
||||
void av_aes_ctr_set_random_iv(struct AVAESCTR *a);
|
||||
|
||||
/**
|
||||
* Forcefully change the iv
|
||||
*/
|
||||
void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv);
|
||||
|
||||
/**
|
||||
* Increment the top 64 bit of the iv (performed after each frame)
|
||||
*/
|
||||
void av_aes_ctr_increment_iv(struct AVAESCTR *a);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AES_CTR_H */
|
||||
43
media/ffvpx/libavutil/aes_internal.h
Normal file
43
media/ffvpx/libavutil/aes_internal.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* copyright (c) 2015 Rodger Combs <rodger.combs@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AES_INTERNAL_H
|
||||
#define AVUTIL_AES_INTERNAL_H
|
||||
|
||||
#include "mem.h"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef union {
|
||||
uint64_t u64[2];
|
||||
uint32_t u32[4];
|
||||
uint8_t u8x4[4][4];
|
||||
uint8_t u8[16];
|
||||
} av_aes_block;
|
||||
|
||||
typedef struct AVAES {
|
||||
// Note: round_key[16] is accessed in the init code, but this only
|
||||
// overwrites state, which does not matter (see also commit ba554c0).
|
||||
DECLARE_ALIGNED(16, av_aes_block, round_key)[15];
|
||||
DECLARE_ALIGNED(16, av_aes_block, state)[2];
|
||||
int rounds;
|
||||
void (*crypt)(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int rounds);
|
||||
} AVAES;
|
||||
|
||||
#endif /* AVUTIL_AES_INTERNAL_H */
|
||||
54
media/ffvpx/libavutil/atomic_suncc.h
Normal file
54
media/ffvpx/libavutil/atomic_suncc.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_ATOMIC_SUNCC_H
|
||||
#define AVUTIL_ATOMIC_SUNCC_H
|
||||
|
||||
#include <atomic.h>
|
||||
#include <mbarrier.h>
|
||||
|
||||
#include "atomic.h"
|
||||
|
||||
#define avpriv_atomic_int_get atomic_int_get_suncc
|
||||
static inline int atomic_int_get_suncc(volatile int *ptr)
|
||||
{
|
||||
__machine_rw_barrier();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
#define avpriv_atomic_int_set atomic_int_set_suncc
|
||||
static inline void atomic_int_set_suncc(volatile int *ptr, int val)
|
||||
{
|
||||
*ptr = val;
|
||||
__machine_rw_barrier();
|
||||
}
|
||||
|
||||
#define avpriv_atomic_int_add_and_fetch atomic_int_add_and_fetch_suncc
|
||||
static inline int atomic_int_add_and_fetch_suncc(volatile int *ptr, int inc)
|
||||
{
|
||||
return atomic_add_int_nv(ptr, inc);
|
||||
}
|
||||
|
||||
#define avpriv_atomic_ptr_cas atomic_ptr_cas_suncc
|
||||
static inline void *atomic_ptr_cas_suncc(void * volatile *ptr,
|
||||
void *oldval, void *newval)
|
||||
{
|
||||
return atomic_cas_ptr(ptr, oldval, newval);
|
||||
}
|
||||
|
||||
#endif /* AVUTIL_ATOMIC_SUNCC_H */
|
||||
236
media/ffvpx/libavutil/audio_fifo.c
Normal file
236
media/ffvpx/libavutil/audio_fifo.c
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
/*
|
||||
* Audio FIFO
|
||||
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Audio FIFO
|
||||
*/
|
||||
|
||||
#include "avutil.h"
|
||||
#include "audio_fifo.h"
|
||||
#include "common.h"
|
||||
#include "fifo.h"
|
||||
#include "mem.h"
|
||||
#include "samplefmt.h"
|
||||
|
||||
struct AVAudioFifo {
|
||||
AVFifoBuffer **buf; /**< single buffer for interleaved, per-channel buffers for planar */
|
||||
int nb_buffers; /**< number of buffers */
|
||||
int nb_samples; /**< number of samples currently in the FIFO */
|
||||
int allocated_samples; /**< current allocated size, in samples */
|
||||
|
||||
int channels; /**< number of channels */
|
||||
enum AVSampleFormat sample_fmt; /**< sample format */
|
||||
int sample_size; /**< size, in bytes, of one sample in a buffer */
|
||||
};
|
||||
|
||||
void av_audio_fifo_free(AVAudioFifo *af)
|
||||
{
|
||||
if (af) {
|
||||
if (af->buf) {
|
||||
int i;
|
||||
for (i = 0; i < af->nb_buffers; i++) {
|
||||
av_fifo_freep(&af->buf[i]);
|
||||
}
|
||||
av_freep(&af->buf);
|
||||
}
|
||||
av_free(af);
|
||||
}
|
||||
}
|
||||
|
||||
AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
|
||||
int nb_samples)
|
||||
{
|
||||
AVAudioFifo *af;
|
||||
int buf_size, i;
|
||||
|
||||
/* get channel buffer size (also validates parameters) */
|
||||
if (av_samples_get_buffer_size(&buf_size, channels, nb_samples, sample_fmt, 1) < 0)
|
||||
return NULL;
|
||||
|
||||
af = av_mallocz(sizeof(*af));
|
||||
if (!af)
|
||||
return NULL;
|
||||
|
||||
af->channels = channels;
|
||||
af->sample_fmt = sample_fmt;
|
||||
af->sample_size = buf_size / nb_samples;
|
||||
af->nb_buffers = av_sample_fmt_is_planar(sample_fmt) ? channels : 1;
|
||||
|
||||
af->buf = av_mallocz_array(af->nb_buffers, sizeof(*af->buf));
|
||||
if (!af->buf)
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < af->nb_buffers; i++) {
|
||||
af->buf[i] = av_fifo_alloc(buf_size);
|
||||
if (!af->buf[i])
|
||||
goto error;
|
||||
}
|
||||
af->allocated_samples = nb_samples;
|
||||
|
||||
return af;
|
||||
|
||||
error:
|
||||
av_audio_fifo_free(af);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples)
|
||||
{
|
||||
int i, ret, buf_size;
|
||||
|
||||
if ((ret = av_samples_get_buffer_size(&buf_size, af->channels, nb_samples,
|
||||
af->sample_fmt, 1)) < 0)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < af->nb_buffers; i++) {
|
||||
if ((ret = av_fifo_realloc2(af->buf[i], buf_size)) < 0)
|
||||
return ret;
|
||||
}
|
||||
af->allocated_samples = nb_samples;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
|
||||
{
|
||||
int i, ret, size;
|
||||
|
||||
/* automatically reallocate buffers if needed */
|
||||
if (av_audio_fifo_space(af) < nb_samples) {
|
||||
int current_size = av_audio_fifo_size(af);
|
||||
/* check for integer overflow in new size calculation */
|
||||
if (INT_MAX / 2 - current_size < nb_samples)
|
||||
return AVERROR(EINVAL);
|
||||
/* reallocate buffers */
|
||||
if ((ret = av_audio_fifo_realloc(af, 2 * (current_size + nb_samples))) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
size = nb_samples * af->sample_size;
|
||||
for (i = 0; i < af->nb_buffers; i++) {
|
||||
ret = av_fifo_generic_write(af->buf[i], data[i], size, NULL);
|
||||
if (ret != size)
|
||||
return AVERROR_BUG;
|
||||
}
|
||||
af->nb_samples += nb_samples;
|
||||
|
||||
return nb_samples;
|
||||
}
|
||||
|
||||
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples)
|
||||
{
|
||||
int i, ret, size;
|
||||
|
||||
if (nb_samples < 0)
|
||||
return AVERROR(EINVAL);
|
||||
nb_samples = FFMIN(nb_samples, af->nb_samples);
|
||||
if (!nb_samples)
|
||||
return 0;
|
||||
|
||||
size = nb_samples * af->sample_size;
|
||||
for (i = 0; i < af->nb_buffers; i++) {
|
||||
if ((ret = av_fifo_generic_peek(af->buf[i], data[i], size, NULL)) < 0)
|
||||
return AVERROR_BUG;
|
||||
}
|
||||
|
||||
return nb_samples;
|
||||
}
|
||||
|
||||
int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset)
|
||||
{
|
||||
int i, ret, size;
|
||||
|
||||
if (offset < 0 || offset >= af->nb_samples)
|
||||
return AVERROR(EINVAL);
|
||||
if (nb_samples < 0)
|
||||
return AVERROR(EINVAL);
|
||||
nb_samples = FFMIN(nb_samples, af->nb_samples);
|
||||
if (!nb_samples)
|
||||
return 0;
|
||||
if (offset > af->nb_samples - nb_samples)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
offset *= af->sample_size;
|
||||
size = nb_samples * af->sample_size;
|
||||
for (i = 0; i < af->nb_buffers; i++) {
|
||||
if ((ret = av_fifo_generic_peek_at(af->buf[i], data[i], offset, size, NULL)) < 0)
|
||||
return AVERROR_BUG;
|
||||
}
|
||||
|
||||
return nb_samples;
|
||||
}
|
||||
|
||||
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
|
||||
{
|
||||
int i, size;
|
||||
|
||||
if (nb_samples < 0)
|
||||
return AVERROR(EINVAL);
|
||||
nb_samples = FFMIN(nb_samples, af->nb_samples);
|
||||
if (!nb_samples)
|
||||
return 0;
|
||||
|
||||
size = nb_samples * af->sample_size;
|
||||
for (i = 0; i < af->nb_buffers; i++) {
|
||||
if (av_fifo_generic_read(af->buf[i], data[i], size, NULL) < 0)
|
||||
return AVERROR_BUG;
|
||||
}
|
||||
af->nb_samples -= nb_samples;
|
||||
|
||||
return nb_samples;
|
||||
}
|
||||
|
||||
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
|
||||
{
|
||||
int i, size;
|
||||
|
||||
if (nb_samples < 0)
|
||||
return AVERROR(EINVAL);
|
||||
nb_samples = FFMIN(nb_samples, af->nb_samples);
|
||||
|
||||
if (nb_samples) {
|
||||
size = nb_samples * af->sample_size;
|
||||
for (i = 0; i < af->nb_buffers; i++)
|
||||
av_fifo_drain(af->buf[i], size);
|
||||
af->nb_samples -= nb_samples;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_audio_fifo_reset(AVAudioFifo *af)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < af->nb_buffers; i++)
|
||||
av_fifo_reset(af->buf[i]);
|
||||
|
||||
af->nb_samples = 0;
|
||||
}
|
||||
|
||||
int av_audio_fifo_size(AVAudioFifo *af)
|
||||
{
|
||||
return af->nb_samples;
|
||||
}
|
||||
|
||||
int av_audio_fifo_space(AVAudioFifo *af)
|
||||
{
|
||||
return af->allocated_samples - af->nb_samples;
|
||||
}
|
||||
187
media/ffvpx/libavutil/audio_fifo.h
Normal file
187
media/ffvpx/libavutil/audio_fifo.h
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* Audio FIFO
|
||||
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Audio FIFO Buffer
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AUDIO_FIFO_H
|
||||
#define AVUTIL_AUDIO_FIFO_H
|
||||
|
||||
#include "avutil.h"
|
||||
#include "fifo.h"
|
||||
#include "samplefmt.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_audiofifo Audio FIFO Buffer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Context for an Audio FIFO Buffer.
|
||||
*
|
||||
* - Operates at the sample level rather than the byte level.
|
||||
* - Supports multiple channels with either planar or packed sample format.
|
||||
* - Automatic reallocation when writing to a full buffer.
|
||||
*/
|
||||
typedef struct AVAudioFifo AVAudioFifo;
|
||||
|
||||
/**
|
||||
* Free an AVAudioFifo.
|
||||
*
|
||||
* @param af AVAudioFifo to free
|
||||
*/
|
||||
void av_audio_fifo_free(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Allocate an AVAudioFifo.
|
||||
*
|
||||
* @param sample_fmt sample format
|
||||
* @param channels number of channels
|
||||
* @param nb_samples initial allocation size, in samples
|
||||
* @return newly allocated AVAudioFifo, or NULL on error
|
||||
*/
|
||||
AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
|
||||
int nb_samples);
|
||||
|
||||
/**
|
||||
* Reallocate an AVAudioFifo.
|
||||
*
|
||||
* @param af AVAudioFifo to reallocate
|
||||
* @param nb_samples new allocation size, in samples
|
||||
* @return 0 if OK, or negative AVERROR code on failure
|
||||
*/
|
||||
av_warn_unused_result
|
||||
int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
|
||||
|
||||
/**
|
||||
* Write data to an AVAudioFifo.
|
||||
*
|
||||
* The AVAudioFifo will be reallocated automatically if the available space
|
||||
* is less than nb_samples.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to write to
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to write
|
||||
* @return number of samples actually written, or negative AVERROR
|
||||
* code on failure. If successful, the number of samples
|
||||
* actually written will always be nb_samples.
|
||||
*/
|
||||
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Peek data from an AVAudioFifo.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to read from
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to peek
|
||||
* @return number of samples actually peek, or negative AVERROR code
|
||||
* on failure. The number of samples actually peek will not
|
||||
* be greater than nb_samples, and will only be less than
|
||||
* nb_samples if av_audio_fifo_size is less than nb_samples.
|
||||
*/
|
||||
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Peek data from an AVAudioFifo.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to read from
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to peek
|
||||
* @param offset offset from current read position
|
||||
* @return number of samples actually peek, or negative AVERROR code
|
||||
* on failure. The number of samples actually peek will not
|
||||
* be greater than nb_samples, and will only be less than
|
||||
* nb_samples if av_audio_fifo_size is less than nb_samples.
|
||||
*/
|
||||
int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset);
|
||||
|
||||
/**
|
||||
* Read data from an AVAudioFifo.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to read from
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to read
|
||||
* @return number of samples actually read, or negative AVERROR code
|
||||
* on failure. The number of samples actually read will not
|
||||
* be greater than nb_samples, and will only be less than
|
||||
* nb_samples if av_audio_fifo_size is less than nb_samples.
|
||||
*/
|
||||
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Drain data from an AVAudioFifo.
|
||||
*
|
||||
* Removes the data without reading it.
|
||||
*
|
||||
* @param af AVAudioFifo to drain
|
||||
* @param nb_samples number of samples to drain
|
||||
* @return 0 if OK, or negative AVERROR code on failure
|
||||
*/
|
||||
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);
|
||||
|
||||
/**
|
||||
* Reset the AVAudioFifo buffer.
|
||||
*
|
||||
* This empties all data in the buffer.
|
||||
*
|
||||
* @param af AVAudioFifo to reset
|
||||
*/
|
||||
void av_audio_fifo_reset(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Get the current number of samples in the AVAudioFifo available for reading.
|
||||
*
|
||||
* @param af the AVAudioFifo to query
|
||||
* @return number of samples available for reading
|
||||
*/
|
||||
int av_audio_fifo_size(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Get the current number of samples in the AVAudioFifo available for writing.
|
||||
*
|
||||
* @param af the AVAudioFifo to query
|
||||
* @return number of samples available for writing
|
||||
*/
|
||||
int av_audio_fifo_space(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AUDIO_FIFO_H */
|
||||
|
|
@ -1,11 +1,41 @@
|
|||
av_add_i
|
||||
av_add_q
|
||||
av_add_stable
|
||||
av_adler32_update
|
||||
av_aes_alloc
|
||||
av_aes_crypt
|
||||
av_aes_ctr_alloc
|
||||
av_aes_ctr_crypt
|
||||
av_aes_ctr_free
|
||||
av_aes_ctr_get_iv
|
||||
av_aes_ctr_increment_iv
|
||||
av_aes_ctr_init
|
||||
av_aes_ctr_set_iv
|
||||
av_aes_ctr_set_random_iv
|
||||
av_aes_init
|
||||
av_aes_size
|
||||
av_append_path_component
|
||||
av_asprintf
|
||||
av_assert0_fpu
|
||||
av_audio_fifo_alloc
|
||||
av_audio_fifo_drain
|
||||
av_audio_fifo_free
|
||||
av_audio_fifo_peek
|
||||
av_audio_fifo_peek_at
|
||||
av_audio_fifo_read
|
||||
av_audio_fifo_realloc
|
||||
av_audio_fifo_reset
|
||||
av_audio_fifo_size
|
||||
av_audio_fifo_space
|
||||
av_audio_fifo_write
|
||||
av_base64_decode
|
||||
av_base64_encode
|
||||
av_basename
|
||||
av_blowfish_alloc
|
||||
av_blowfish_crypt
|
||||
av_blowfish_crypt_ecb
|
||||
av_blowfish_init
|
||||
av_bmg_get
|
||||
av_bprint_append_data
|
||||
av_bprint_channel_layout
|
||||
av_bprint_chars
|
||||
|
|
@ -27,19 +57,31 @@ av_buffer_is_writable
|
|||
av_buffer_make_writable
|
||||
av_buffer_pool_get
|
||||
av_buffer_pool_init
|
||||
av_buffer_pool_init2
|
||||
av_buffer_pool_uninit
|
||||
av_buffer_realloc
|
||||
av_buffer_ref
|
||||
av_buffer_unref
|
||||
av_calloc
|
||||
av_camellia_alloc
|
||||
av_camellia_crypt
|
||||
av_camellia_init
|
||||
av_camellia_size
|
||||
av_cast5_alloc
|
||||
av_cast5_crypt
|
||||
av_cast5_crypt2
|
||||
av_cast5_init
|
||||
av_cast5_size
|
||||
av_channel_layout_extract_channel
|
||||
av_chroma_location_name
|
||||
av_cmp_i
|
||||
av_color_primaries_name
|
||||
av_color_range_name
|
||||
av_color_space_name
|
||||
av_color_transfer_name
|
||||
av_compare_mod
|
||||
av_compare_ts
|
||||
av_content_light_metadata_create_side_data
|
||||
av_cpu_count
|
||||
av_crc
|
||||
av_crc_get_table
|
||||
|
|
@ -48,6 +90,10 @@ av_d2q
|
|||
av_d2str
|
||||
av_default_get_category
|
||||
av_default_item_name
|
||||
av_des_alloc
|
||||
av_des_crypt
|
||||
av_des_init
|
||||
av_des_mac
|
||||
av_dict_copy
|
||||
av_dict_count
|
||||
av_dict_free
|
||||
|
|
@ -57,7 +103,12 @@ av_dict_parse_string
|
|||
av_dict_set
|
||||
av_dict_set_int
|
||||
av_dirname
|
||||
av_display_matrix_flip
|
||||
av_display_rotation_get
|
||||
av_display_rotation_set
|
||||
av_div_i
|
||||
av_div_q
|
||||
av_downmix_info_update_side_data
|
||||
av_dynarray2_add
|
||||
av_dynarray_add
|
||||
av_dynarray_add_nofree
|
||||
|
|
@ -67,6 +118,7 @@ av_expr_free
|
|||
av_expr_parse
|
||||
av_expr_parse_and_eval
|
||||
av_fast_malloc
|
||||
av_fast_mallocz
|
||||
av_fast_realloc
|
||||
av_fifo_alloc
|
||||
av_fifo_alloc_array
|
||||
|
|
@ -74,6 +126,7 @@ av_fifo_drain
|
|||
av_fifo_free
|
||||
av_fifo_freep
|
||||
av_fifo_generic_peek
|
||||
av_fifo_generic_peek_at
|
||||
av_fifo_generic_read
|
||||
av_fifo_generic_write
|
||||
av_fifo_grow
|
||||
|
|
@ -81,9 +134,12 @@ av_fifo_realloc2
|
|||
av_fifo_reset
|
||||
av_fifo_size
|
||||
av_fifo_space
|
||||
av_file_map
|
||||
av_file_unmap
|
||||
av_find_best_pix_fmt_of_2
|
||||
av_find_info_tag
|
||||
av_find_nearest_q_idx
|
||||
av_fopen_utf8
|
||||
av_force_cpu_flags
|
||||
av_fourcc_make_string
|
||||
av_frame_alloc
|
||||
|
|
@ -161,7 +217,35 @@ av_get_token
|
|||
av_gettime
|
||||
av_gettime_relative
|
||||
av_gettime_relative_is_monotonic
|
||||
av_hash_alloc
|
||||
av_hash_final
|
||||
av_hash_final_b64
|
||||
av_hash_final_bin
|
||||
av_hash_final_hex
|
||||
av_hash_freep
|
||||
av_hash_get_name
|
||||
av_hash_get_size
|
||||
av_hash_init
|
||||
av_hash_names
|
||||
av_hash_update
|
||||
av_hmac_alloc
|
||||
av_hmac_calc
|
||||
av_hmac_final
|
||||
av_hmac_free
|
||||
av_hmac_init
|
||||
av_hmac_update
|
||||
av_hwdevice_ctx_alloc
|
||||
av_hwdevice_ctx_create
|
||||
av_hwdevice_ctx_init
|
||||
av_hwdevice_get_hwframe_constraints
|
||||
av_hwdevice_hwconfig_alloc
|
||||
av_hwframe_constraints_free
|
||||
av_hwframe_ctx_alloc
|
||||
av_hwframe_ctx_init
|
||||
av_hwframe_get_buffer
|
||||
av_hwframe_transfer_data
|
||||
av_hwframe_transfer_get_formats
|
||||
av_i2int
|
||||
av_image_alloc
|
||||
av_image_check_sar
|
||||
av_image_check_size
|
||||
|
|
@ -175,12 +259,16 @@ av_image_fill_max_pixsteps
|
|||
av_image_fill_pointers
|
||||
av_image_get_buffer_size
|
||||
av_image_get_linesize
|
||||
av_int2i
|
||||
av_int_list_length_for_size
|
||||
av_lfg_init
|
||||
av_log
|
||||
av_log2
|
||||
av_log2_16bit
|
||||
av_log2_i
|
||||
av_log_default_callback
|
||||
av_log_format_line
|
||||
av_log_format_line2
|
||||
av_log_get_flags
|
||||
av_log_get_level
|
||||
av_log_set_callback
|
||||
|
|
@ -188,12 +276,27 @@ av_log_set_flags
|
|||
av_log_set_level
|
||||
av_malloc
|
||||
av_mallocz
|
||||
av_mastering_display_metadata_alloc
|
||||
av_mastering_display_metadata_create_side_data
|
||||
av_match_list
|
||||
av_match_name
|
||||
av_max_alloc
|
||||
av_md5_alloc
|
||||
av_md5_final
|
||||
av_md5_init
|
||||
av_md5_size
|
||||
av_md5_sum
|
||||
av_md5_update
|
||||
av_memcpy_backptr
|
||||
av_memdup
|
||||
av_mod_i
|
||||
av_mul_i
|
||||
av_mul_q
|
||||
av_murmur3_alloc
|
||||
av_murmur3_final
|
||||
av_murmur3_init
|
||||
av_murmur3_init_seeded
|
||||
av_murmur3_update
|
||||
av_nearer_q
|
||||
av_opt_child_class_next
|
||||
av_opt_child_next
|
||||
|
|
@ -259,6 +362,9 @@ av_pix_fmt_get_chroma_sub_sample
|
|||
av_pix_fmt_swap_endianness
|
||||
av_pixelutils_get_sad_fn
|
||||
av_q2intfloat
|
||||
av_rc4_alloc
|
||||
av_rc4_crypt
|
||||
av_rc4_init
|
||||
av_read_image_line
|
||||
av_realloc
|
||||
av_realloc_array
|
||||
|
|
@ -271,6 +377,11 @@ av_rescale_delta
|
|||
av_rescale_q
|
||||
av_rescale_q_rnd
|
||||
av_rescale_rnd
|
||||
av_ripemd_alloc
|
||||
av_ripemd_final
|
||||
av_ripemd_init
|
||||
av_ripemd_size
|
||||
av_ripemd_update
|
||||
av_sample_fmt_is_planar
|
||||
av_samples_alloc
|
||||
av_samples_alloc_array_and_samples
|
||||
|
|
@ -280,7 +391,22 @@ av_samples_get_buffer_size
|
|||
av_samples_set_silence
|
||||
av_set_cpu_flags_mask
|
||||
av_set_options_string
|
||||
av_sha512_alloc
|
||||
av_sha512_final
|
||||
av_sha512_init
|
||||
av_sha512_size
|
||||
av_sha512_update
|
||||
av_sha_alloc
|
||||
av_sha_final
|
||||
av_sha_init
|
||||
av_sha_size
|
||||
av_sha_update
|
||||
av_shr_i
|
||||
av_small_strptime
|
||||
av_stereo3d_alloc
|
||||
av_stereo3d_create_side_data
|
||||
av_stereo3d_from_name
|
||||
av_stereo3d_type_name
|
||||
av_strcasecmp
|
||||
av_strdup
|
||||
av_strerror
|
||||
|
|
@ -295,13 +421,21 @@ av_strnstr
|
|||
av_strstart
|
||||
av_strtod
|
||||
av_strtok
|
||||
av_sub_i
|
||||
av_sub_q
|
||||
av_tea_alloc
|
||||
av_tea_crypt
|
||||
av_tea_init
|
||||
av_tea_size
|
||||
av_tempfile
|
||||
av_thread_message_flush
|
||||
av_thread_message_queue_alloc
|
||||
av_thread_message_queue_free
|
||||
av_thread_message_queue_recv
|
||||
av_thread_message_queue_send
|
||||
av_thread_message_queue_set_err_recv
|
||||
av_thread_message_queue_set_err_send
|
||||
av_thread_message_queue_set_free_func
|
||||
av_timecode_adjust_ntsc_framenum2
|
||||
av_timecode_check_frame_rate
|
||||
av_timecode_get_smpte_from_framenum
|
||||
|
|
@ -311,6 +445,16 @@ av_timecode_make_mpeg_tc_string
|
|||
av_timecode_make_smpte_tc_string
|
||||
av_timecode_make_string
|
||||
av_timegm
|
||||
av_tree_destroy
|
||||
av_tree_enumerate
|
||||
av_tree_find
|
||||
av_tree_insert
|
||||
av_tree_node_alloc
|
||||
av_tree_node_size
|
||||
av_twofish_alloc
|
||||
av_twofish_crypt
|
||||
av_twofish_init
|
||||
av_twofish_size
|
||||
av_usleep
|
||||
av_utf8_decode
|
||||
av_util_ffversion
|
||||
|
|
@ -318,16 +462,25 @@ av_vbprintf
|
|||
av_version_info
|
||||
av_vlog
|
||||
av_write_image_line
|
||||
av_xtea_alloc
|
||||
av_xtea_crypt
|
||||
av_xtea_init
|
||||
av_xtea_le_crypt
|
||||
av_xtea_le_init
|
||||
avpriv_alloc_fixed_dsp
|
||||
avpriv_cga_font
|
||||
avpriv_dict_set_timestamp
|
||||
avpriv_float_dsp_alloc
|
||||
avpriv_frame_get_metadatap
|
||||
avpriv_get_gamma_from_trc
|
||||
avpriv_get_trc_function_from_trc
|
||||
avpriv_init_lls
|
||||
avpriv_report_missing_feature
|
||||
avpriv_request_sample
|
||||
avpriv_scalarproduct_float_c
|
||||
avpriv_set_systematic_pal2
|
||||
avpriv_solve_lls
|
||||
avpriv_vga16_font
|
||||
avutil_configuration
|
||||
avutil_license
|
||||
avutil_version
|
||||
|
|
|
|||
424
media/ffvpx/libavutil/blowfish.c
Normal file
424
media/ffvpx/libavutil/blowfish.c
Normal file
|
|
@ -0,0 +1,424 @@
|
|||
/*
|
||||
* Blowfish algorithm
|
||||
* Copyright (c) 2012 Samuel Pitoiset
|
||||
*
|
||||
* loosely based on Paul Kocher's implementation
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "avutil.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "mem.h"
|
||||
#include "blowfish.h"
|
||||
|
||||
static const uint32_t orig_p[AV_BF_ROUNDS + 2] = {
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
|
||||
0x9216D5D9, 0x8979FB1B
|
||||
};
|
||||
|
||||
static const uint32_t orig_s[4][256] = {
|
||||
{ 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
|
||||
0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
|
||||
0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
|
||||
0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
|
||||
0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
|
||||
0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
|
||||
0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
|
||||
0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
|
||||
0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
|
||||
0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
|
||||
0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
|
||||
0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
|
||||
0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
|
||||
0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
|
||||
0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
|
||||
0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
|
||||
0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
|
||||
0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
|
||||
0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
|
||||
0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
|
||||
0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
|
||||
0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
|
||||
0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
|
||||
0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
|
||||
0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
|
||||
0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
|
||||
0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
|
||||
0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
|
||||
0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
|
||||
0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
|
||||
0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
|
||||
0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
|
||||
0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
|
||||
0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
|
||||
0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
|
||||
0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
|
||||
0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
|
||||
0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
|
||||
0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
|
||||
0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
|
||||
0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
|
||||
0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
|
||||
0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
|
||||
0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
|
||||
0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
|
||||
0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
|
||||
0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
|
||||
0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
|
||||
0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
|
||||
0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
|
||||
0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
|
||||
0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
|
||||
0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
|
||||
0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
|
||||
0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
|
||||
0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
|
||||
0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
|
||||
0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
|
||||
0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
|
||||
0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
|
||||
0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
|
||||
0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
|
||||
0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
|
||||
0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A },
|
||||
{ 0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
|
||||
0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
|
||||
0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
|
||||
0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
|
||||
0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
|
||||
0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
|
||||
0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
|
||||
0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
|
||||
0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
|
||||
0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
|
||||
0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
|
||||
0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
|
||||
0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
|
||||
0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
|
||||
0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
|
||||
0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
|
||||
0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
|
||||
0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
|
||||
0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
|
||||
0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
|
||||
0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
|
||||
0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
|
||||
0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
|
||||
0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
|
||||
0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
|
||||
0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
|
||||
0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
|
||||
0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
|
||||
0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
|
||||
0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
|
||||
0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
|
||||
0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
|
||||
0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
|
||||
0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
|
||||
0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
|
||||
0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
|
||||
0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
|
||||
0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
|
||||
0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
|
||||
0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
|
||||
0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
|
||||
0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
|
||||
0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
|
||||
0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
|
||||
0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
|
||||
0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
|
||||
0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
|
||||
0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
|
||||
0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
|
||||
0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
|
||||
0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
|
||||
0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
|
||||
0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
|
||||
0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
|
||||
0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
|
||||
0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
|
||||
0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
|
||||
0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
|
||||
0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
|
||||
0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
|
||||
0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
|
||||
0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
|
||||
0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
|
||||
0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7 },
|
||||
{ 0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
|
||||
0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
|
||||
0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
|
||||
0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
|
||||
0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
|
||||
0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
|
||||
0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
|
||||
0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
|
||||
0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
|
||||
0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
|
||||
0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
|
||||
0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
|
||||
0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
|
||||
0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
|
||||
0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
|
||||
0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
|
||||
0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
|
||||
0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
|
||||
0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
|
||||
0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
|
||||
0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
|
||||
0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
|
||||
0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
|
||||
0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
|
||||
0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
|
||||
0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
|
||||
0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
|
||||
0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
|
||||
0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
|
||||
0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
|
||||
0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
|
||||
0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
|
||||
0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
|
||||
0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
|
||||
0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
|
||||
0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
|
||||
0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
|
||||
0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
|
||||
0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
|
||||
0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
|
||||
0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
|
||||
0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
|
||||
0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
|
||||
0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
|
||||
0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
|
||||
0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
|
||||
0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
|
||||
0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
|
||||
0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
|
||||
0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
|
||||
0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
|
||||
0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
|
||||
0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
|
||||
0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
|
||||
0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
|
||||
0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
|
||||
0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
|
||||
0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
|
||||
0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
|
||||
0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
|
||||
0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
|
||||
0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
|
||||
0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
|
||||
0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0 },
|
||||
{ 0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
|
||||
0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
|
||||
0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
|
||||
0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
|
||||
0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
|
||||
0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
|
||||
0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
|
||||
0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
|
||||
0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
|
||||
0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
|
||||
0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
|
||||
0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
|
||||
0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
|
||||
0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
|
||||
0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
|
||||
0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
|
||||
0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
|
||||
0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
|
||||
0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
|
||||
0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
|
||||
0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
|
||||
0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
|
||||
0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
|
||||
0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
|
||||
0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
|
||||
0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
|
||||
0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
|
||||
0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
|
||||
0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
|
||||
0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
|
||||
0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
|
||||
0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
|
||||
0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
|
||||
0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
|
||||
0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
|
||||
0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
|
||||
0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
|
||||
0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
|
||||
0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
|
||||
0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
|
||||
0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
|
||||
0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
|
||||
0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
|
||||
0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
|
||||
0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
|
||||
0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
|
||||
0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
|
||||
0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
|
||||
0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
|
||||
0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
|
||||
0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
|
||||
0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
|
||||
0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
|
||||
0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
|
||||
0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
|
||||
0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
|
||||
0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
|
||||
0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
|
||||
0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
|
||||
0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
|
||||
0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
|
||||
0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
|
||||
0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
|
||||
0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6 }
|
||||
};
|
||||
|
||||
#define F(Xl, Xr, P) \
|
||||
Xr ^=((( ctx->s[0][ Xl >> 24 ] \
|
||||
+ ctx->s[1][(Xl >> 16) & 0xFF])\
|
||||
^ ctx->s[2][(Xl >> 8) & 0xFF])\
|
||||
+ ctx->s[3][ Xl & 0xFF])\
|
||||
^ P;
|
||||
|
||||
AVBlowfish *av_blowfish_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVBlowfish));
|
||||
}
|
||||
|
||||
av_cold void av_blowfish_init(AVBlowfish *ctx, const uint8_t *key, int key_len)
|
||||
{
|
||||
uint32_t data, data_l, data_r;
|
||||
int i, j, k;
|
||||
|
||||
memcpy(ctx->s, orig_s, sizeof(orig_s));
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < AV_BF_ROUNDS + 2; ++i) {
|
||||
data = 0;
|
||||
for (k = 0; k < 4; k++) {
|
||||
data = (data << 8) | key[j];
|
||||
if (++j >= key_len)
|
||||
j = 0;
|
||||
}
|
||||
ctx->p[i] = orig_p[i] ^ data;
|
||||
}
|
||||
|
||||
data_l = data_r = 0;
|
||||
|
||||
for (i = 0; i < AV_BF_ROUNDS + 2; i += 2) {
|
||||
av_blowfish_crypt_ecb(ctx, &data_l, &data_r, 0);
|
||||
ctx->p[i] = data_l;
|
||||
ctx->p[i + 1] = data_r;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
for (j = 0; j < 256; j += 2) {
|
||||
av_blowfish_crypt_ecb(ctx, &data_l, &data_r, 0);
|
||||
ctx->s[i][j] = data_l;
|
||||
ctx->s[i][j + 1] = data_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void av_blowfish_crypt_ecb(AVBlowfish *ctx, uint32_t *xl, uint32_t *xr,
|
||||
int decrypt)
|
||||
{
|
||||
uint32_t Xl, Xr;
|
||||
int i;
|
||||
|
||||
Xl = *xl;
|
||||
Xr = *xr;
|
||||
|
||||
if (decrypt) {
|
||||
Xl ^= ctx->p[AV_BF_ROUNDS + 1];
|
||||
for (i = AV_BF_ROUNDS; i > 0; i-=2) {
|
||||
F(Xl, Xr, ctx->p[i ]);
|
||||
F(Xr, Xl, ctx->p[i-1]);
|
||||
}
|
||||
|
||||
Xr ^= ctx->p[0];
|
||||
} else {
|
||||
Xl ^= ctx->p[0];
|
||||
for (i = 1; i < AV_BF_ROUNDS+1; i+=2){
|
||||
F(Xl, Xr, ctx->p[i ]);
|
||||
F(Xr, Xl, ctx->p[i+1]);
|
||||
}
|
||||
|
||||
Xr ^= ctx->p[AV_BF_ROUNDS + 1];
|
||||
}
|
||||
|
||||
*xl = Xr;
|
||||
*xr = Xl;
|
||||
}
|
||||
|
||||
void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int decrypt)
|
||||
{
|
||||
uint32_t v0, v1;
|
||||
int i;
|
||||
|
||||
if (decrypt) {
|
||||
while (count--) {
|
||||
v0 = AV_RB32(src);
|
||||
v1 = AV_RB32(src + 4);
|
||||
|
||||
av_blowfish_crypt_ecb(ctx, &v0, &v1, decrypt);
|
||||
|
||||
if (iv) {
|
||||
v0 ^= AV_RB32(iv);
|
||||
v1 ^= AV_RB32(iv + 4);
|
||||
memcpy(iv, src, 8);
|
||||
}
|
||||
|
||||
AV_WB32(dst, v0);
|
||||
AV_WB32(dst + 4, v1);
|
||||
|
||||
src += 8;
|
||||
dst += 8;
|
||||
}
|
||||
} else {
|
||||
while (count--) {
|
||||
if (iv) {
|
||||
for (i = 0; i < 8; i++)
|
||||
dst[i] = src[i] ^ iv[i];
|
||||
v0 = AV_RB32(dst);
|
||||
v1 = AV_RB32(dst + 4);
|
||||
} else {
|
||||
v0 = AV_RB32(src);
|
||||
v1 = AV_RB32(src + 4);
|
||||
}
|
||||
|
||||
av_blowfish_crypt_ecb(ctx, &v0, &v1, decrypt);
|
||||
|
||||
AV_WB32(dst, v0);
|
||||
AV_WB32(dst + 4, v1);
|
||||
|
||||
if (iv)
|
||||
memcpy(iv, dst, 8);
|
||||
|
||||
src += 8;
|
||||
dst += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
82
media/ffvpx/libavutil/blowfish.h
Normal file
82
media/ffvpx/libavutil/blowfish.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Blowfish algorithm
|
||||
* Copyright (c) 2012 Samuel Pitoiset
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BLOWFISH_H
|
||||
#define AVUTIL_BLOWFISH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_blowfish Blowfish
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_BF_ROUNDS 16
|
||||
|
||||
typedef struct AVBlowfish {
|
||||
uint32_t p[AV_BF_ROUNDS + 2];
|
||||
uint32_t s[4][256];
|
||||
} AVBlowfish;
|
||||
|
||||
/**
|
||||
* Allocate an AVBlowfish context.
|
||||
*/
|
||||
AVBlowfish *av_blowfish_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVBlowfish context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param key a key
|
||||
* @param key_len length of the key
|
||||
*/
|
||||
void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param xl left four bytes halves of input to be encrypted
|
||||
* @param xr right four bytes halves of input to be encrypted
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr,
|
||||
int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 8 byte blocks
|
||||
* @param iv initialization vector for CBC mode, if NULL ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_BLOWFISH_H */
|
||||
412
media/ffvpx/libavutil/camellia.c
Normal file
412
media/ffvpx/libavutil/camellia.c
Normal file
|
|
@ -0,0 +1,412 @@
|
|||
/*
|
||||
* An implementation of the CAMELLIA algorithm as mentioned in RFC3713
|
||||
* Copyright (c) 2014 Supraja Meedinti
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "camellia.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "attributes.h"
|
||||
|
||||
#define LR32(x,c) ((x) << (c) | (x) >> (32 - (c)))
|
||||
#define RR32(x,c) ((x) >> (c) | (x) << (32 - (c)))
|
||||
|
||||
#define MASK8 0xff
|
||||
#define MASK32 0xffffffff
|
||||
#define MASK64 0xffffffffffffffff
|
||||
|
||||
#define Sigma1 0xA09E667F3BCC908B
|
||||
#define Sigma2 0xB67AE8584CAA73B2
|
||||
#define Sigma3 0xC6EF372FE94F82BE
|
||||
#define Sigma4 0x54FF53A5F1D36F1C
|
||||
#define Sigma5 0x10E527FADE682D1D
|
||||
#define Sigma6 0xB05688C2B3E6C1FD
|
||||
|
||||
static uint64_t SP[8][256];
|
||||
|
||||
typedef struct AVCAMELLIA {
|
||||
uint64_t Kw[4];
|
||||
uint64_t Ke[6];
|
||||
uint64_t K[24];
|
||||
int key_bits;
|
||||
} AVCAMELLIA;
|
||||
|
||||
static const uint8_t SBOX1[256] = {
|
||||
112, 130, 44, 236, 179, 39, 192, 229, 228, 133, 87, 53, 234, 12, 174, 65,
|
||||
35, 239, 107, 147, 69, 25, 165, 33, 237, 14, 79, 78, 29, 101, 146, 189,
|
||||
134, 184, 175, 143, 124, 235, 31, 206, 62, 48, 220, 95, 94, 197, 11, 26,
|
||||
166, 225, 57, 202, 213, 71, 93, 61, 217, 1, 90, 214, 81, 86, 108, 77,
|
||||
139, 13, 154, 102, 251, 204, 176, 45, 116, 18, 43, 32, 240, 177, 132, 153,
|
||||
223, 76, 203, 194, 52, 126, 118, 5, 109, 183, 169, 49, 209, 23, 4, 215,
|
||||
20, 88, 58, 97, 222, 27, 17, 28, 50, 15, 156, 22, 83, 24, 242, 34,
|
||||
254, 68, 207, 178, 195, 181, 122, 145, 36, 8, 232, 168, 96, 252, 105, 80,
|
||||
170, 208, 160, 125, 161, 137, 98, 151, 84, 91, 30, 149, 224, 255, 100, 210,
|
||||
16, 196, 0, 72, 163, 247, 117, 219, 138, 3, 230, 218, 9, 63, 221, 148,
|
||||
135, 92, 131, 2, 205, 74, 144, 51, 115, 103, 246, 243, 157, 127, 191, 226,
|
||||
82, 155, 216, 38, 200, 55, 198, 59, 129, 150, 111, 75, 19, 190, 99, 46,
|
||||
233, 121, 167, 140, 159, 110, 188, 142, 41, 245, 249, 182, 47, 253, 180, 89,
|
||||
120, 152, 6, 106, 231, 70, 113, 186, 212, 37, 171, 66, 136, 162, 141, 250,
|
||||
114, 7, 185, 85, 248, 238, 172, 10, 54, 73, 42, 104, 60, 56, 241, 164,
|
||||
64, 40, 211, 123, 187, 201, 67, 193, 21, 227, 173, 244, 119, 199, 128, 158
|
||||
};
|
||||
|
||||
static const uint8_t SBOX2[256] = {
|
||||
224, 5, 88, 217, 103, 78, 129, 203, 201, 11, 174, 106, 213, 24, 93, 130,
|
||||
70, 223, 214, 39, 138, 50, 75, 66, 219, 28, 158, 156, 58, 202, 37, 123,
|
||||
13, 113, 95, 31, 248, 215, 62, 157, 124, 96, 185, 190, 188, 139, 22, 52,
|
||||
77, 195, 114, 149, 171, 142, 186, 122, 179, 2, 180, 173, 162, 172, 216, 154,
|
||||
23, 26, 53, 204, 247, 153, 97, 90, 232, 36, 86, 64, 225, 99, 9, 51,
|
||||
191, 152, 151, 133, 104, 252, 236, 10, 218, 111, 83, 98, 163, 46, 8, 175,
|
||||
40, 176, 116, 194, 189, 54, 34, 56, 100, 30, 57, 44, 166, 48, 229, 68,
|
||||
253, 136, 159, 101, 135, 107, 244, 35, 72, 16, 209, 81, 192, 249, 210, 160,
|
||||
85, 161, 65, 250, 67, 19, 196, 47, 168, 182, 60, 43, 193, 255, 200, 165,
|
||||
32, 137, 0, 144, 71, 239, 234, 183, 21, 6, 205, 181, 18, 126, 187, 41,
|
||||
15, 184, 7, 4, 155, 148, 33, 102, 230, 206, 237, 231, 59, 254, 127, 197,
|
||||
164, 55, 177, 76, 145, 110, 141, 118, 3, 45, 222, 150, 38, 125, 198, 92,
|
||||
211, 242, 79, 25, 63, 220, 121, 29, 82, 235, 243, 109, 94, 251, 105, 178,
|
||||
240, 49, 12, 212, 207, 140, 226, 117, 169, 74, 87, 132, 17, 69, 27, 245,
|
||||
228, 14, 115, 170, 241, 221, 89, 20, 108, 146, 84, 208, 120, 112, 227, 73,
|
||||
128, 80, 167, 246, 119, 147, 134, 131, 42, 199, 91, 233, 238, 143, 1, 61
|
||||
};
|
||||
|
||||
static const uint8_t SBOX3[256] = {
|
||||
56, 65, 22, 118, 217, 147, 96, 242, 114, 194, 171, 154, 117, 6, 87, 160,
|
||||
145, 247, 181, 201, 162, 140, 210, 144, 246, 7, 167, 39, 142, 178, 73, 222,
|
||||
67, 92, 215, 199, 62, 245, 143, 103, 31, 24, 110, 175, 47, 226, 133, 13,
|
||||
83, 240, 156, 101, 234, 163, 174, 158, 236, 128, 45, 107, 168, 43, 54, 166,
|
||||
197, 134, 77, 51, 253, 102, 88, 150, 58, 9, 149, 16, 120, 216, 66, 204,
|
||||
239, 38, 229, 97, 26, 63, 59, 130, 182, 219, 212, 152, 232, 139, 2, 235,
|
||||
10, 44, 29, 176, 111, 141, 136, 14, 25, 135, 78, 11, 169, 12, 121, 17,
|
||||
127, 34, 231, 89, 225, 218, 61, 200, 18, 4, 116, 84, 48, 126, 180, 40,
|
||||
85, 104, 80, 190, 208, 196, 49, 203, 42, 173, 15, 202, 112, 255, 50, 105,
|
||||
8, 98, 0, 36, 209, 251, 186, 237, 69, 129, 115, 109, 132, 159, 238, 74,
|
||||
195, 46, 193, 1, 230, 37, 72, 153, 185, 179, 123, 249, 206, 191, 223, 113,
|
||||
41, 205, 108, 19, 100, 155, 99, 157, 192, 75, 183, 165, 137, 95, 177, 23,
|
||||
244, 188, 211, 70, 207, 55, 94, 71, 148, 250, 252, 91, 151, 254, 90, 172,
|
||||
60, 76, 3, 53, 243, 35, 184, 93, 106, 146, 213, 33, 68, 81, 198, 125,
|
||||
57, 131, 220, 170, 124, 119, 86, 5, 27, 164, 21, 52, 30, 28, 248, 82,
|
||||
32, 20, 233, 189, 221, 228, 161, 224, 138, 241, 214, 122, 187, 227, 64, 79
|
||||
};
|
||||
|
||||
static const uint8_t SBOX4[256] = {
|
||||
112, 44, 179, 192, 228, 87, 234, 174, 35, 107, 69, 165, 237, 79, 29, 146,
|
||||
134, 175, 124, 31, 62, 220, 94, 11, 166, 57, 213, 93, 217, 90, 81, 108,
|
||||
139, 154, 251, 176, 116, 43, 240, 132, 223, 203, 52, 118, 109, 169, 209, 4,
|
||||
20, 58, 222, 17, 50, 156, 83, 242, 254, 207, 195, 122, 36, 232, 96, 105,
|
||||
170, 160, 161, 98, 84, 30, 224, 100, 16, 0, 163, 117, 138, 230, 9, 221,
|
||||
135, 131, 205, 144, 115, 246, 157, 191, 82, 216, 200, 198, 129, 111, 19, 99,
|
||||
233, 167, 159, 188, 41, 249, 47, 180, 120, 6, 231, 113, 212, 171, 136, 141,
|
||||
114, 185, 248, 172, 54, 42, 60, 241, 64, 211, 187, 67, 21, 173, 119, 128,
|
||||
130, 236, 39, 229, 133, 53, 12, 65, 239, 147, 25, 33, 14, 78, 101, 189,
|
||||
184, 143, 235, 206, 48, 95, 197, 26, 225, 202, 71, 61, 1, 214, 86, 77,
|
||||
13, 102, 204, 45, 18, 32, 177, 153, 76, 194, 126, 5, 183, 49, 23, 215,
|
||||
88, 97, 27, 28, 15, 22, 24, 34, 68, 178, 181, 145, 8, 168, 252, 80,
|
||||
208, 125, 137, 151, 91, 149, 255, 210, 196, 72, 247, 219, 3, 218, 63, 148,
|
||||
92, 2, 74, 51, 103, 243, 127, 226, 155, 38, 55, 59, 150, 75, 190, 46,
|
||||
121, 140, 110, 142, 245, 182, 253, 89, 152, 106, 70, 186, 37, 66, 162, 250,
|
||||
7, 85, 238, 10, 73, 104, 56, 164, 40, 123, 201, 193, 227, 244, 199, 158
|
||||
};
|
||||
|
||||
const int av_camellia_size = sizeof(AVCAMELLIA);
|
||||
|
||||
static void LR128(uint64_t d[2], const uint64_t K[2], int x)
|
||||
{
|
||||
int i = 0;
|
||||
if (64 <= x && x < 128) {
|
||||
i = 1;
|
||||
x -= 64;
|
||||
}
|
||||
if (x <= 0 || x >= 128) {
|
||||
d[0] = K[i];
|
||||
d[1] = K[!i];
|
||||
return;
|
||||
}
|
||||
d[0] = (K[i] << x | K[!i] >> (64 - x));
|
||||
d[1] = (K[!i] << x | K[i] >> (64 - x));
|
||||
}
|
||||
|
||||
static uint64_t F(uint64_t F_IN, uint64_t KE)
|
||||
{
|
||||
KE ^= F_IN;
|
||||
F_IN=SP[0][KE >> 56]^SP[1][(KE >> 48) & MASK8]^SP[2][(KE >> 40) & MASK8]^SP[3][(KE >> 32) & MASK8]^SP[4][(KE >> 24) & MASK8]^SP[5][(KE >> 16) & MASK8]^SP[6][(KE >> 8) & MASK8]^SP[7][KE & MASK8];
|
||||
return F_IN;
|
||||
}
|
||||
|
||||
static uint64_t FL(uint64_t FL_IN, uint64_t KE)
|
||||
{
|
||||
uint32_t x1, x2, k1, k2;
|
||||
x1 = FL_IN >> 32;
|
||||
x2 = FL_IN & MASK32;
|
||||
k1 = KE >> 32;
|
||||
k2 = KE & MASK32;
|
||||
x2 = x2 ^ LR32((x1 & k1), 1);
|
||||
x1 = x1 ^ (x2 | k2);
|
||||
return ((uint64_t)x1 << 32) | (uint64_t)x2;
|
||||
}
|
||||
|
||||
static uint64_t FLINV(uint64_t FLINV_IN, uint64_t KE)
|
||||
{
|
||||
uint32_t x1, x2, k1, k2;
|
||||
x1 = FLINV_IN >> 32;
|
||||
x2 = FLINV_IN & MASK32;
|
||||
k1 = KE >> 32;
|
||||
k2 = KE & MASK32;
|
||||
x1 = x1 ^ (x2 | k2);
|
||||
x2 = x2 ^ LR32((x1 & k1), 1);
|
||||
return ((uint64_t)x1 << 32) | (uint64_t)x2;
|
||||
}
|
||||
|
||||
static const uint8_t shifts[2][12] = {
|
||||
{0, 15, 15, 45, 45, 60, 94, 94, 111},
|
||||
{0, 15, 15, 30, 45, 45, 60, 60, 77, 94, 94, 111}
|
||||
};
|
||||
|
||||
static const uint8_t vars[2][12] = {
|
||||
{2, 0, 2, 0, 2, 2, 0, 2, 0},
|
||||
{3, 1, 2, 3, 0, 2, 1, 3, 0, 1, 2, 0}
|
||||
};
|
||||
|
||||
static void generate_round_keys(AVCAMELLIA *cs, uint64_t Kl[2], uint64_t Kr[2], uint64_t Ka[2], uint64_t Kb[2])
|
||||
{
|
||||
int i;
|
||||
uint64_t *Kd[4], d[2];
|
||||
Kd[0] = Kl;
|
||||
Kd[1] = Kr;
|
||||
Kd[2] = Ka;
|
||||
Kd[3] = Kb;
|
||||
cs->Kw[0] = Kl[0];
|
||||
cs->Kw[1] = Kl[1];
|
||||
if (cs->key_bits == 128) {
|
||||
for (i = 0; i < 9; i++) {
|
||||
LR128(d, Kd[vars[0][i]], shifts[0][i]);
|
||||
cs->K[2*i] = d[0];
|
||||
cs->K[2*i+1] = d[1];
|
||||
}
|
||||
LR128(d, Kd[0], 60);
|
||||
cs->K[9] = d[1];
|
||||
LR128(d, Kd[2], 30);
|
||||
cs->Ke[0] = d[0];
|
||||
cs->Ke[1] = d[1];
|
||||
LR128(d, Kd[0], 77);
|
||||
cs->Ke[2] = d[0];
|
||||
cs->Ke[3] = d[1];
|
||||
LR128(d, Kd[2], 111);
|
||||
cs->Kw[2] = d[0];
|
||||
cs->Kw[3] = d[1];
|
||||
} else {
|
||||
for (i = 0; i < 12; i++) {
|
||||
LR128(d, Kd[vars[1][i]], shifts[1][i]);
|
||||
cs->K[2*i] = d[0];
|
||||
cs->K[2*i+1] = d[1];
|
||||
}
|
||||
LR128(d, Kd[1], 30);
|
||||
cs->Ke[0] = d[0];
|
||||
cs->Ke[1] = d[1];
|
||||
LR128(d, Kd[0], 60);
|
||||
cs->Ke[2] = d[0];
|
||||
cs->Ke[3] = d[1];
|
||||
LR128(d, Kd[2], 77);
|
||||
cs->Ke[4] = d[0];
|
||||
cs->Ke[5] = d[1];
|
||||
LR128(d, Kd[3], 111);
|
||||
cs->Kw[2] = d[0];
|
||||
cs->Kw[3] = d[1];
|
||||
}
|
||||
}
|
||||
|
||||
static void camellia_encrypt(AVCAMELLIA *cs, uint8_t *dst, const uint8_t *src)
|
||||
{
|
||||
uint64_t D1, D2;
|
||||
D1 = AV_RB64(src);
|
||||
D2 = AV_RB64(src + 8);
|
||||
D1 ^= cs->Kw[0];
|
||||
D2 ^= cs->Kw[1];
|
||||
D2 ^= F(D1, cs->K[0]);
|
||||
D1 ^= F(D2, cs->K[1]);
|
||||
D2 ^= F(D1, cs->K[2]);
|
||||
D1 ^= F(D2, cs->K[3]);
|
||||
D2 ^= F(D1, cs->K[4]);
|
||||
D1 ^= F(D2, cs->K[5]);
|
||||
D1 = FL(D1, cs->Ke[0]);
|
||||
D2 = FLINV(D2, cs->Ke[1]);
|
||||
D2 ^= F(D1, cs->K[6]);
|
||||
D1 ^= F(D2, cs->K[7]);
|
||||
D2 ^= F(D1, cs->K[8]);
|
||||
D1 ^= F(D2, cs->K[9]);
|
||||
D2 ^= F(D1, cs->K[10]);
|
||||
D1 ^= F(D2, cs->K[11]);
|
||||
D1 = FL(D1, cs->Ke[2]);
|
||||
D2 = FLINV(D2, cs->Ke[3]);
|
||||
D2 ^= F(D1, cs->K[12]);
|
||||
D1 ^= F(D2, cs->K[13]);
|
||||
D2 ^= F(D1, cs->K[14]);
|
||||
D1 ^= F(D2, cs->K[15]);
|
||||
D2 ^= F(D1, cs->K[16]);
|
||||
D1 ^= F(D2, cs->K[17]);
|
||||
if (cs->key_bits != 128) {
|
||||
D1 = FL(D1, cs->Ke[4]);
|
||||
D2 = FLINV(D2, cs->Ke[5]);
|
||||
D2 ^= F(D1, cs->K[18]);
|
||||
D1 ^= F(D2, cs->K[19]);
|
||||
D2 ^= F(D1, cs->K[20]);
|
||||
D1 ^= F(D2, cs->K[21]);
|
||||
D2 ^= F(D1, cs->K[22]);
|
||||
D1 ^= F(D2, cs->K[23]);
|
||||
}
|
||||
D2 ^= cs->Kw[2];
|
||||
D1 ^= cs->Kw[3];
|
||||
AV_WB64(dst, D2);
|
||||
AV_WB64(dst + 8, D1);
|
||||
}
|
||||
|
||||
static void camellia_decrypt(AVCAMELLIA *cs, uint8_t *dst, const uint8_t *src, uint8_t *iv)
|
||||
{
|
||||
uint64_t D1, D2;
|
||||
D1 = AV_RB64(src);
|
||||
D2 = AV_RB64(src + 8);
|
||||
D1 ^= cs->Kw[2];
|
||||
D2 ^= cs->Kw[3];
|
||||
if (cs->key_bits != 128) {
|
||||
D2 ^= F(D1, cs->K[23]);
|
||||
D1 ^= F(D2, cs->K[22]);
|
||||
D2 ^= F(D1, cs->K[21]);
|
||||
D1 ^= F(D2, cs->K[20]);
|
||||
D2 ^= F(D1, cs->K[19]);
|
||||
D1 ^= F(D2, cs->K[18]);
|
||||
D1 = FL(D1, cs->Ke[5]);
|
||||
D2 = FLINV(D2, cs->Ke[4]);
|
||||
}
|
||||
D2 ^= F(D1, cs->K[17]);
|
||||
D1 ^= F(D2, cs->K[16]);
|
||||
D2 ^= F(D1, cs->K[15]);
|
||||
D1 ^= F(D2, cs->K[14]);
|
||||
D2 ^= F(D1, cs->K[13]);
|
||||
D1 ^= F(D2, cs->K[12]);
|
||||
D1 = FL(D1, cs->Ke[3]);
|
||||
D2 = FLINV(D2, cs->Ke[2]);
|
||||
D2 ^= F(D1, cs->K[11]);
|
||||
D1 ^= F(D2, cs->K[10]);
|
||||
D2 ^= F(D1, cs->K[9]);
|
||||
D1 ^= F(D2, cs->K[8]);
|
||||
D2 ^= F(D1, cs->K[7]);
|
||||
D1 ^= F(D2, cs->K[6]);
|
||||
D1 = FL(D1, cs->Ke[1]);
|
||||
D2 = FLINV(D2, cs->Ke[0]);
|
||||
D2 ^= F(D1, cs->K[5]);
|
||||
D1 ^= F(D2, cs->K[4]);
|
||||
D2 ^= F(D1, cs->K[3]);
|
||||
D1 ^= F(D2, cs->K[2]);
|
||||
D2 ^= F(D1, cs->K[1]);
|
||||
D1 ^= F(D2, cs->K[0]);
|
||||
D2 ^= cs->Kw[0];
|
||||
D1 ^= cs->Kw[1];
|
||||
if (iv) {
|
||||
D2 ^= AV_RB64(iv);
|
||||
D1 ^= AV_RB64(iv + 8);
|
||||
memcpy(iv, src, 16);
|
||||
}
|
||||
AV_WB64(dst, D2);
|
||||
AV_WB64(dst + 8, D1);
|
||||
}
|
||||
|
||||
static void computeSP(void)
|
||||
{
|
||||
uint64_t z;
|
||||
int i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
z = SBOX1[i];
|
||||
SP[0][i] = (z << 56) ^ (z << 48) ^ (z << 40) ^ (z << 24) ^ z;
|
||||
SP[7][i] = (z << 56) ^ (z << 48) ^ (z << 40) ^ (z << 24) ^ (z << 16) ^ (z << 8);
|
||||
z = SBOX2[i];
|
||||
SP[1][i] = (z << 48) ^ (z << 40) ^ (z << 32) ^ (z << 24) ^ (z << 16);
|
||||
SP[4][i] = (z << 48) ^ (z << 40) ^ (z << 32) ^ (z << 16) ^ (z << 8) ^ z;
|
||||
z = SBOX3[i];
|
||||
SP[2][i] = (z << 56) ^ (z << 40) ^ (z << 32) ^ (z << 16) ^ (z << 8);
|
||||
SP[5][i] = (z << 56) ^ (z << 40) ^ (z << 32) ^ (z << 24) ^ (z << 8) ^ z;
|
||||
z = SBOX4[i];
|
||||
SP[3][i] = (z << 56) ^ (z << 48) ^ (z << 32) ^ (z << 8) ^ z;
|
||||
SP[6][i] = (z << 56) ^ (z << 48) ^ (z << 32) ^ (z << 24) ^ (z << 16) ^ z;
|
||||
}
|
||||
}
|
||||
|
||||
struct AVCAMELLIA *av_camellia_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVCAMELLIA));
|
||||
}
|
||||
|
||||
av_cold int av_camellia_init(AVCAMELLIA *cs, const uint8_t *key, int key_bits)
|
||||
{
|
||||
uint64_t Kl[2], Kr[2], Ka[2], Kb[2];
|
||||
uint64_t D1, D2;
|
||||
if (key_bits != 128 && key_bits != 192 && key_bits != 256)
|
||||
return AVERROR(EINVAL);
|
||||
memset(Kb, 0, sizeof(Kb));
|
||||
memset(Kr, 0, sizeof(Kr));
|
||||
cs->key_bits = key_bits;
|
||||
Kl[0] = AV_RB64(key);
|
||||
Kl[1] = AV_RB64(key + 8);
|
||||
if (key_bits == 192) {
|
||||
Kr[0] = AV_RB64(key + 16);
|
||||
Kr[1] = ~Kr[0];
|
||||
} else if (key_bits == 256) {
|
||||
Kr[0] = AV_RB64(key + 16);
|
||||
Kr[1] = AV_RB64(key + 24);
|
||||
}
|
||||
computeSP();
|
||||
D1 = Kl[0] ^ Kr[0];
|
||||
D2 = Kl[1] ^ Kr[1];
|
||||
D2 ^= F(D1, Sigma1);
|
||||
D1 ^= F(D2, Sigma2);
|
||||
D1 ^= Kl[0];
|
||||
D2 ^= Kl[1];
|
||||
D2 ^= F(D1, Sigma3);
|
||||
D1 ^= F(D2, Sigma4);
|
||||
Ka[0] = D1;
|
||||
Ka[1] = D2;
|
||||
if (key_bits != 128) {
|
||||
D1 = Ka[0] ^ Kr[0];
|
||||
D2 = Ka[1] ^ Kr[1];
|
||||
D2 ^= F(D1, Sigma5);
|
||||
D1 ^= F(D2, Sigma6);
|
||||
Kb[0] = D1;
|
||||
Kb[1] = D2;
|
||||
}
|
||||
generate_round_keys(cs, Kl, Kr, Ka, Kb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_camellia_crypt(AVCAMELLIA *cs, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
|
||||
{
|
||||
int i;
|
||||
while (count--) {
|
||||
if (decrypt) {
|
||||
camellia_decrypt(cs, dst, src, iv);
|
||||
} else {
|
||||
if (iv) {
|
||||
for (i = 0; i < 16; i++)
|
||||
dst[i] = src[i] ^ iv[i];
|
||||
camellia_encrypt(cs, dst, dst);
|
||||
memcpy(iv, dst, 16);
|
||||
} else {
|
||||
camellia_encrypt(cs, dst, src);
|
||||
}
|
||||
}
|
||||
src = src + 16;
|
||||
dst = dst + 16;
|
||||
}
|
||||
}
|
||||
70
media/ffvpx/libavutil/camellia.h
Normal file
70
media/ffvpx/libavutil/camellia.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* An implementation of the CAMELLIA algorithm as mentioned in RFC3713
|
||||
* Copyright (c) 2014 Supraja Meedinti
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_CAMELLIA_H
|
||||
#define AVUTIL_CAMELLIA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Public header for libavutil CAMELLIA algorithm
|
||||
* @defgroup lavu_camellia CAMELLIA
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_camellia_size;
|
||||
|
||||
struct AVCAMELLIA;
|
||||
|
||||
/**
|
||||
* Allocate an AVCAMELLIA context
|
||||
* To free the struct: av_free(ptr)
|
||||
*/
|
||||
struct AVCAMELLIA *av_camellia_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVCAMELLIA context.
|
||||
*
|
||||
* @param ctx an AVCAMELLIA context
|
||||
* @param key a key of 16, 24, 32 bytes used for encryption/decryption
|
||||
* @param key_bits number of keybits: possible are 128, 192, 256
|
||||
*/
|
||||
int av_camellia_init(struct AVCAMELLIA *ctx, const uint8_t *key, int key_bits);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context
|
||||
*
|
||||
* @param ctx an AVCAMELLIA context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 16 byte blocks
|
||||
* @paran iv initialization vector for CBC mode, NULL for ECB mode
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_camellia_crypt(struct AVCAMELLIA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* AVUTIL_CAMELLIA_H */
|
||||
507
media/ffvpx/libavutil/cast5.c
Normal file
507
media/ffvpx/libavutil/cast5.c
Normal file
|
|
@ -0,0 +1,507 @@
|
|||
/*
|
||||
* An implementation of the CAST128 algorithm as mentioned in RFC2144
|
||||
* Copyright (c) 2014 Supraja Meedinti
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "cast5.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "attributes.h"
|
||||
|
||||
#define IA(x) ((x) >> 24)
|
||||
#define IB(x) (((x) >> 16) & 0xff)
|
||||
#define IC(x) (((x) >> 8) & 0xff)
|
||||
#define ID(x) ((x) & 0xff)
|
||||
|
||||
#define LR(x, c) (((x) << (c)) | ((x) >> (32 - (c))))
|
||||
|
||||
#define F3(l, r, i) \
|
||||
do { \
|
||||
I = LR(cs->Km[i] - r, cs->Kr[i]); \
|
||||
f = ((S1[IA(I)] + S2[IB(I)]) ^ S3[IC(I)]) - S4[ID(I)]; \
|
||||
l = f ^ l; \
|
||||
} while (0)
|
||||
|
||||
#define F2(l, r, i) \
|
||||
do { \
|
||||
I = LR(cs->Km[i] ^ r, cs->Kr[i]); \
|
||||
f = ((S1[IA(I)] - S2[IB(I)]) + S3[IC(I)]) ^ S4[ID(I)]; \
|
||||
l = f ^ l; \
|
||||
} while (0)
|
||||
|
||||
#define F1(l, r, i) \
|
||||
do { \
|
||||
I = LR(cs->Km[i] + r, cs->Kr[i]); \
|
||||
f = ((S1[IA(I)] ^ S2[IB(I)]) - S3[IC(I)]) + S4[ID(I)]; \
|
||||
l = f ^ l; \
|
||||
} while (0)
|
||||
|
||||
#define COMPUTE_Z \
|
||||
do { \
|
||||
z[0] = x[0] ^ S5[IB(x[3])] ^ S6[ID(x[3])] ^ S7[IA(x[3])] ^ S8[IC(x[3])] ^ S7[IA(x[2])]; \
|
||||
z[1] = x[2] ^ S5[IA(z[0])] ^ S6[IC(z[0])] ^ S7[IB(z[0])] ^ S8[ID(z[0])] ^ S8[IC(x[2])]; \
|
||||
z[2] = x[3] ^ S5[ID(z[1])] ^ S6[IC(z[1])] ^ S7[IB(z[1])] ^ S8[IA(z[1])] ^ S5[IB(x[2])]; \
|
||||
z[3] = x[1] ^ S5[IC(z[2])] ^ S6[IB(z[2])] ^ S7[ID(z[2])] ^ S8[IA(z[2])] ^ S6[ID(x[2])]; \
|
||||
} while (0)
|
||||
|
||||
#define COMPUTE_X \
|
||||
do { \
|
||||
x[0] = z[2] ^ S5[IB(z[1])] ^ S6[ID(z[1])] ^ S7[IA(z[1])] ^ S8[IC(z[1])] ^ S7[IA(z[0])]; \
|
||||
x[1] = z[0] ^ S5[IA(x[0])] ^ S6[IC(x[0])] ^ S7[IB(x[0])] ^ S8[ID(x[0])] ^ S8[IC(z[0])]; \
|
||||
x[2] = z[1] ^ S5[ID(x[1])] ^ S6[IC(x[1])] ^ S7[IB(x[1])] ^ S8[IA(x[1])] ^ S5[IB(z[0])]; \
|
||||
x[3] = z[3] ^ S5[IC(x[2])] ^ S6[IB(x[2])] ^ S7[ID(x[2])] ^ S8[IA(x[2])] ^ S6[ID(z[0])]; \
|
||||
} while (0)
|
||||
|
||||
|
||||
typedef struct AVCAST5 {
|
||||
uint32_t Km[17];
|
||||
uint32_t Kr[17];
|
||||
int rounds;
|
||||
} AVCAST5;
|
||||
|
||||
const int av_cast5_size = sizeof(AVCAST5);
|
||||
|
||||
static const uint32_t S1[256] = {
|
||||
0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9c004dd3, 0x6003e540, 0xcf9fc949,
|
||||
0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, 0x15c361d2, 0xc2e7661d, 0x22d4ff8e,
|
||||
0x28683b6f, 0xc07fd059, 0xff2379c8, 0x775f50e2, 0x43c340d3, 0xdf2f8656, 0x887ca41a, 0xa2d2bd2d,
|
||||
0xa1c9e0d6, 0x346c4819, 0x61b76d87, 0x22540f2f, 0x2abe32e1, 0xaa54166b, 0x22568e3a, 0xa2d341d0,
|
||||
0x66db40c8, 0xa784392f, 0x004dff2f, 0x2db9d2de, 0x97943fac, 0x4a97c1d8, 0x527644b7, 0xb5f437a7,
|
||||
0xb82cbaef, 0xd751d159, 0x6ff7f0ed, 0x5a097a1f, 0x827b68d0, 0x90ecf52e, 0x22b0c054, 0xbc8e5935,
|
||||
0x4b6d2f7f, 0x50bb64a2, 0xd2664910, 0xbee5812d, 0xb7332290, 0xe93b159f, 0xb48ee411, 0x4bff345d,
|
||||
0xfd45c240, 0xad31973f, 0xc4f6d02e, 0x55fc8165, 0xd5b1caad, 0xa1ac2dae, 0xa2d4b76d, 0xc19b0c50,
|
||||
0x882240f2, 0x0c6e4f38, 0xa4e4bfd7, 0x4f5ba272, 0x564c1d2f, 0xc59c5319, 0xb949e354, 0xb04669fe,
|
||||
0xb1b6ab8a, 0xc71358dd, 0x6385c545, 0x110f935d, 0x57538ad5, 0x6a390493, 0xe63d37e0, 0x2a54f6b3,
|
||||
0x3a787d5f, 0x6276a0b5, 0x19a6fcdf, 0x7a42206a, 0x29f9d4d5, 0xf61b1891, 0xbb72275e, 0xaa508167,
|
||||
0x38901091, 0xc6b505eb, 0x84c7cb8c, 0x2ad75a0f, 0x874a1427, 0xa2d1936b, 0x2ad286af, 0xaa56d291,
|
||||
0xd7894360, 0x425c750d, 0x93b39e26, 0x187184c9, 0x6c00b32d, 0x73e2bb14, 0xa0bebc3c, 0x54623779,
|
||||
0x64459eab, 0x3f328b82, 0x7718cf82, 0x59a2cea6, 0x04ee002e, 0x89fe78e6, 0x3fab0950, 0x325ff6c2,
|
||||
0x81383f05, 0x6963c5c8, 0x76cb5ad6, 0xd49974c9, 0xca180dcf, 0x380782d5, 0xc7fa5cf6, 0x8ac31511,
|
||||
0x35e79e13, 0x47da91d0, 0xf40f9086, 0xa7e2419e, 0x31366241, 0x051ef495, 0xaa573b04, 0x4a805d8d,
|
||||
0x548300d0, 0x00322a3c, 0xbf64cddf, 0xba57a68e, 0x75c6372b, 0x50afd341, 0xa7c13275, 0x915a0bf5,
|
||||
0x6b54bfab, 0x2b0b1426, 0xab4cc9d7, 0x449ccd82, 0xf7fbf265, 0xab85c5f3, 0x1b55db94, 0xaad4e324,
|
||||
0xcfa4bd3f, 0x2deaa3e2, 0x9e204d02, 0xc8bd25ac, 0xeadf55b3, 0xd5bd9e98, 0xe31231b2, 0x2ad5ad6c,
|
||||
0x954329de, 0xadbe4528, 0xd8710f69, 0xaa51c90f, 0xaa786bf6, 0x22513f1e, 0xaa51a79b, 0x2ad344cc,
|
||||
0x7b5a41f0, 0xd37cfbad, 0x1b069505, 0x41ece491, 0xb4c332e6, 0x032268d4, 0xc9600acc, 0xce387e6d,
|
||||
0xbf6bb16c, 0x6a70fb78, 0x0d03d9c9, 0xd4df39de, 0xe01063da, 0x4736f464, 0x5ad328d8, 0xb347cc96,
|
||||
0x75bb0fc3, 0x98511bfb, 0x4ffbcc35, 0xb58bcf6a, 0xe11f0abc, 0xbfc5fe4a, 0xa70aec10, 0xac39570a,
|
||||
0x3f04442f, 0x6188b153, 0xe0397a2e, 0x5727cb79, 0x9ceb418f, 0x1cacd68d, 0x2ad37c96, 0x0175cb9d,
|
||||
0xc69dff09, 0xc75b65f0, 0xd9db40d8, 0xec0e7779, 0x4744ead4, 0xb11c3274, 0xdd24cb9e, 0x7e1c54bd,
|
||||
0xf01144f9, 0xd2240eb1, 0x9675b3fd, 0xa3ac3755, 0xd47c27af, 0x51c85f4d, 0x56907596, 0xa5bb15e6,
|
||||
0x580304f0, 0xca042cf1, 0x011a37ea, 0x8dbfaadb, 0x35ba3e4a, 0x3526ffa0, 0xc37b4d09, 0xbc306ed9,
|
||||
0x98a52666, 0x5648f725, 0xff5e569d, 0x0ced63d0, 0x7c63b2cf, 0x700b45e1, 0xd5ea50f1, 0x85a92872,
|
||||
0xaf1fbda7, 0xd4234870, 0xa7870bf3, 0x2d3b4d79, 0x42e04198, 0x0cd0ede7, 0x26470db8, 0xf881814c,
|
||||
0x474d6ad7, 0x7c0c5e5c, 0xd1231959, 0x381b7298, 0xf5d2f4db, 0xab838653, 0x6e2f1e23, 0x83719c9e,
|
||||
0xbd91e046, 0x9a56456e, 0xdc39200c, 0x20c8c571, 0x962bda1c, 0xe1e696ff, 0xb141ab08, 0x7cca89b9,
|
||||
0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c, 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf
|
||||
};
|
||||
|
||||
static const uint32_t S2[256] = {
|
||||
0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, 0xeec5207a, 0x55889c94, 0x72fc0651,
|
||||
0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, 0x5f0c0794, 0x18dcdb7d, 0xa1d6eff3,
|
||||
0xa0b52f7b, 0x59e83605, 0xee15b094, 0xe9ffd909, 0xdc440086, 0xef944459, 0xba83ccb3, 0xe0c3cdfb,
|
||||
0xd1da4181, 0x3b092ab1, 0xf997f1c1, 0xa5e6cf7b, 0x01420ddb, 0xe4e7ef5b, 0x25a1ff41, 0xe180f806,
|
||||
0x1fc41080, 0x179bee7a, 0xd37ac6a9, 0xfe5830a4, 0x98de8b7f, 0x77e83f4e, 0x79929269, 0x24fa9f7b,
|
||||
0xe113c85b, 0xacc40083, 0xd7503525, 0xf7ea615f, 0x62143154, 0x0d554b63, 0x5d681121, 0xc866c359,
|
||||
0x3d63cf73, 0xcee234c0, 0xd4d87e87, 0x5c672b21, 0x071f6181, 0x39f7627f, 0x361e3084, 0xe4eb573b,
|
||||
0x602f64a4, 0xd63acd9c, 0x1bbc4635, 0x9e81032d, 0x2701f50c, 0x99847ab4, 0xa0e3df79, 0xba6cf38c,
|
||||
0x10843094, 0x2537a95e, 0xf46f6ffe, 0xa1ff3b1f, 0x208cfb6a, 0x8f458c74, 0xd9e0a227, 0x4ec73a34,
|
||||
0xfc884f69, 0x3e4de8df, 0xef0e0088, 0x3559648d, 0x8a45388c, 0x1d804366, 0x721d9bfd, 0xa58684bb,
|
||||
0xe8256333, 0x844e8212, 0x128d8098, 0xfed33fb4, 0xce280ae1, 0x27e19ba5, 0xd5a6c252, 0xe49754bd,
|
||||
0xc5d655dd, 0xeb667064, 0x77840b4d, 0xa1b6a801, 0x84db26a9, 0xe0b56714, 0x21f043b7, 0xe5d05860,
|
||||
0x54f03084, 0x066ff472, 0xa31aa153, 0xdadc4755, 0xb5625dbf, 0x68561be6, 0x83ca6b94, 0x2d6ed23b,
|
||||
0xeccf01db, 0xa6d3d0ba, 0xb6803d5c, 0xaf77a709, 0x33b4a34c, 0x397bc8d6, 0x5ee22b95, 0x5f0e5304,
|
||||
0x81ed6f61, 0x20e74364, 0xb45e1378, 0xde18639b, 0x881ca122, 0xb96726d1, 0x8049a7e8, 0x22b7da7b,
|
||||
0x5e552d25, 0x5272d237, 0x79d2951c, 0xc60d894c, 0x488cb402, 0x1ba4fe5b, 0xa4b09f6b, 0x1ca815cf,
|
||||
0xa20c3005, 0x8871df63, 0xb9de2fcb, 0x0cc6c9e9, 0x0beeff53, 0xe3214517, 0xb4542835, 0x9f63293c,
|
||||
0xee41e729, 0x6e1d2d7c, 0x50045286, 0x1e6685f3, 0xf33401c6, 0x30a22c95, 0x31a70850, 0x60930f13,
|
||||
0x73f98417, 0xa1269859, 0xec645c44, 0x52c877a9, 0xcdff33a6, 0xa02b1741, 0x7cbad9a2, 0x2180036f,
|
||||
0x50d99c08, 0xcb3f4861, 0xc26bd765, 0x64a3f6ab, 0x80342676, 0x25a75e7b, 0xe4e6d1fc, 0x20c710e6,
|
||||
0xcdf0b680, 0x17844d3b, 0x31eef84d, 0x7e0824e4, 0x2ccb49eb, 0x846a3bae, 0x8ff77888, 0xee5d60f6,
|
||||
0x7af75673, 0x2fdd5cdb, 0xa11631c1, 0x30f66f43, 0xb3faec54, 0x157fd7fa, 0xef8579cc, 0xd152de58,
|
||||
0xdb2ffd5e, 0x8f32ce19, 0x306af97a, 0x02f03ef8, 0x99319ad5, 0xc242fa0f, 0xa7e3ebb0, 0xc68e4906,
|
||||
0xb8da230c, 0x80823028, 0xdcdef3c8, 0xd35fb171, 0x088a1bc8, 0xbec0c560, 0x61a3c9e8, 0xbca8f54d,
|
||||
0xc72feffa, 0x22822e99, 0x82c570b4, 0xd8d94e89, 0x8b1c34bc, 0x301e16e6, 0x273be979, 0xb0ffeaa6,
|
||||
0x61d9b8c6, 0x00b24869, 0xb7ffce3f, 0x08dc283b, 0x43daf65a, 0xf7e19798, 0x7619b72f, 0x8f1c9ba4,
|
||||
0xdc8637a0, 0x16a7d3b1, 0x9fc393b7, 0xa7136eeb, 0xc6bcc63e, 0x1a513742, 0xef6828bc, 0x520365d6,
|
||||
0x2d6a77ab, 0x3527ed4b, 0x821fd216, 0x095c6e2e, 0xdb92f2fb, 0x5eea29cb, 0x145892f5, 0x91584f7f,
|
||||
0x5483697b, 0x2667a8cc, 0x85196048, 0x8c4bacea, 0x833860d4, 0x0d23e0f9, 0x6c387e8a, 0x0ae6d249,
|
||||
0xb284600c, 0xd835731d, 0xdcb1c647, 0xac4c56ea, 0x3ebd81b3, 0x230eabb0, 0x6438bc87, 0xf0b5b1fa,
|
||||
0x8f5ea2b3, 0xfc184642, 0x0a036b7a, 0x4fb089bd, 0x649da589, 0xa345415e, 0x5c038323, 0x3e5d3bb9,
|
||||
0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539, 0x73bfbe70, 0x83877605, 0x4523ecf1
|
||||
};
|
||||
|
||||
static const uint32_t S3[256] = {
|
||||
0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, 0x369fe44b, 0x8c1fc644, 0xaececa90,
|
||||
0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, 0xf0ad0548, 0xe13c8d83, 0x927010d5,
|
||||
0x11107d9f, 0x07647db9, 0xb2e3e4d4, 0x3d4f285e, 0xb9afa820, 0xfade82e0, 0xa067268b, 0x8272792e,
|
||||
0x553fb2c0, 0x489ae22b, 0xd4ef9794, 0x125e3fbc, 0x21fffcee, 0x825b1bfd, 0x9255c5ed, 0x1257a240,
|
||||
0x4e1a8302, 0xbae07fff, 0x528246e7, 0x8e57140e, 0x3373f7bf, 0x8c9f8188, 0xa6fc4ee8, 0xc982b5a5,
|
||||
0xa8c01db7, 0x579fc264, 0x67094f31, 0xf2bd3f5f, 0x40fff7c1, 0x1fb78dfc, 0x8e6bd2c1, 0x437be59b,
|
||||
0x99b03dbf, 0xb5dbc64b, 0x638dc0e6, 0x55819d99, 0xa197c81c, 0x4a012d6e, 0xc5884a28, 0xccc36f71,
|
||||
0xb843c213, 0x6c0743f1, 0x8309893c, 0x0feddd5f, 0x2f7fe850, 0xd7c07f7e, 0x02507fbf, 0x5afb9a04,
|
||||
0xa747d2d0, 0x1651192e, 0xaf70bf3e, 0x58c31380, 0x5f98302e, 0x727cc3c4, 0x0a0fb402, 0x0f7fef82,
|
||||
0x8c96fdad, 0x5d2c2aae, 0x8ee99a49, 0x50da88b8, 0x8427f4a0, 0x1eac5790, 0x796fb449, 0x8252dc15,
|
||||
0xefbd7d9b, 0xa672597d, 0xada840d8, 0x45f54504, 0xfa5d7403, 0xe83ec305, 0x4f91751a, 0x925669c2,
|
||||
0x23efe941, 0xa903f12e, 0x60270df2, 0x0276e4b6, 0x94fd6574, 0x927985b2, 0x8276dbcb, 0x02778176,
|
||||
0xf8af918d, 0x4e48f79e, 0x8f616ddf, 0xe29d840e, 0x842f7d83, 0x340ce5c8, 0x96bbb682, 0x93b4b148,
|
||||
0xef303cab, 0x984faf28, 0x779faf9b, 0x92dc560d, 0x224d1e20, 0x8437aa88, 0x7d29dc96, 0x2756d3dc,
|
||||
0x8b907cee, 0xb51fd240, 0xe7c07ce3, 0xe566b4a1, 0xc3e9615e, 0x3cf8209d, 0x6094d1e3, 0xcd9ca341,
|
||||
0x5c76460e, 0x00ea983b, 0xd4d67881, 0xfd47572c, 0xf76cedd9, 0xbda8229c, 0x127dadaa, 0x438a074e,
|
||||
0x1f97c090, 0x081bdb8a, 0x93a07ebe, 0xb938ca15, 0x97b03cff, 0x3dc2c0f8, 0x8d1ab2ec, 0x64380e51,
|
||||
0x68cc7bfb, 0xd90f2788, 0x12490181, 0x5de5ffd4, 0xdd7ef86a, 0x76a2e214, 0xb9a40368, 0x925d958f,
|
||||
0x4b39fffa, 0xba39aee9, 0xa4ffd30b, 0xfaf7933b, 0x6d498623, 0x193cbcfa, 0x27627545, 0x825cf47a,
|
||||
0x61bd8ba0, 0xd11e42d1, 0xcead04f4, 0x127ea392, 0x10428db7, 0x8272a972, 0x9270c4a8, 0x127de50b,
|
||||
0x285ba1c8, 0x3c62f44f, 0x35c0eaa5, 0xe805d231, 0x428929fb, 0xb4fcdf82, 0x4fb66a53, 0x0e7dc15b,
|
||||
0x1f081fab, 0x108618ae, 0xfcfd086d, 0xf9ff2889, 0x694bcc11, 0x236a5cae, 0x12deca4d, 0x2c3f8cc5,
|
||||
0xd2d02dfe, 0xf8ef5896, 0xe4cf52da, 0x95155b67, 0x494a488c, 0xb9b6a80c, 0x5c8f82bc, 0x89d36b45,
|
||||
0x3a609437, 0xec00c9a9, 0x44715253, 0x0a874b49, 0xd773bc40, 0x7c34671c, 0x02717ef6, 0x4feb5536,
|
||||
0xa2d02fff, 0xd2bf60c4, 0xd43f03c0, 0x50b4ef6d, 0x07478cd1, 0x006e1888, 0xa2e53f55, 0xb9e6d4bc,
|
||||
0xa2048016, 0x97573833, 0xd7207d67, 0xde0f8f3d, 0x72f87b33, 0xabcc4f33, 0x7688c55d, 0x7b00a6b0,
|
||||
0x947b0001, 0x570075d2, 0xf9bb88f8, 0x8942019e, 0x4264a5ff, 0x856302e0, 0x72dbd92b, 0xee971b69,
|
||||
0x6ea22fde, 0x5f08ae2b, 0xaf7a616d, 0xe5c98767, 0xcf1febd2, 0x61efc8c2, 0xf1ac2571, 0xcc8239c2,
|
||||
0x67214cb8, 0xb1e583d1, 0xb7dc3e62, 0x7f10bdce, 0xf90a5c38, 0x0ff0443d, 0x606e6dc6, 0x60543a49,
|
||||
0x5727c148, 0x2be98a1d, 0x8ab41738, 0x20e1be24, 0xaf96da0f, 0x68458425, 0x99833be5, 0x600d457d,
|
||||
0x282f9350, 0x8334b362, 0xd91d1120, 0x2b6d8da0, 0x642b1e31, 0x9c305a00, 0x52bce688, 0x1b03588a,
|
||||
0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636, 0xa133c501, 0xe9d3531c, 0xee353783
|
||||
};
|
||||
|
||||
static const uint32_t S4[256] = {
|
||||
0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, 0x64ad8c57, 0x85510443, 0xfa020ed1,
|
||||
0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, 0x6497b7b1, 0xf3641f63, 0x241e4adf,
|
||||
0x28147f5f, 0x4fa2b8cd, 0xc9430040, 0x0cc32220, 0xfdd30b30, 0xc0a5374f, 0x1d2d00d9, 0x24147b15,
|
||||
0xee4d111a, 0x0fca5167, 0x71ff904c, 0x2d195ffe, 0x1a05645f, 0x0c13fefe, 0x081b08ca, 0x05170121,
|
||||
0x80530100, 0xe83e5efe, 0xac9af4f8, 0x7fe72701, 0xd2b8ee5f, 0x06df4261, 0xbb9e9b8a, 0x7293ea25,
|
||||
0xce84ffdf, 0xf5718801, 0x3dd64b04, 0xa26f263b, 0x7ed48400, 0x547eebe6, 0x446d4ca0, 0x6cf3d6f5,
|
||||
0x2649abdf, 0xaea0c7f5, 0x36338cc1, 0x503f7e93, 0xd3772061, 0x11b638e1, 0x72500e03, 0xf80eb2bb,
|
||||
0xabe0502e, 0xec8d77de, 0x57971e81, 0xe14f6746, 0xc9335400, 0x6920318f, 0x081dbb99, 0xffc304a5,
|
||||
0x4d351805, 0x7f3d5ce3, 0xa6c866c6, 0x5d5bcca9, 0xdaec6fea, 0x9f926f91, 0x9f46222f, 0x3991467d,
|
||||
0xa5bf6d8e, 0x1143c44f, 0x43958302, 0xd0214eeb, 0x022083b8, 0x3fb6180c, 0x18f8931e, 0x281658e6,
|
||||
0x26486e3e, 0x8bd78a70, 0x7477e4c1, 0xb506e07c, 0xf32d0a25, 0x79098b02, 0xe4eabb81, 0x28123b23,
|
||||
0x69dead38, 0x1574ca16, 0xdf871b62, 0x211c40b7, 0xa51a9ef9, 0x0014377b, 0x041e8ac8, 0x09114003,
|
||||
0xbd59e4d2, 0xe3d156d5, 0x4fe876d5, 0x2f91a340, 0x557be8de, 0x00eae4a7, 0x0ce5c2ec, 0x4db4bba6,
|
||||
0xe756bdff, 0xdd3369ac, 0xec17b035, 0x06572327, 0x99afc8b0, 0x56c8c391, 0x6b65811c, 0x5e146119,
|
||||
0x6e85cb75, 0xbe07c002, 0xc2325577, 0x893ff4ec, 0x5bbfc92d, 0xd0ec3b25, 0xb7801ab7, 0x8d6d3b24,
|
||||
0x20c763ef, 0xc366a5fc, 0x9c382880, 0x0ace3205, 0xaac9548a, 0xeca1d7c7, 0x041afa32, 0x1d16625a,
|
||||
0x6701902c, 0x9b757a54, 0x31d477f7, 0x9126b031, 0x36cc6fdb, 0xc70b8b46, 0xd9e66a48, 0x56e55a79,
|
||||
0x026a4ceb, 0x52437eff, 0x2f8f76b4, 0x0df980a5, 0x8674cde3, 0xedda04eb, 0x17a9be04, 0x2c18f4df,
|
||||
0xb7747f9d, 0xab2af7b4, 0xefc34d20, 0x2e096b7c, 0x1741a254, 0xe5b6a035, 0x213d42f6, 0x2c1c7c26,
|
||||
0x61c2f50f, 0x6552daf9, 0xd2c231f8, 0x25130f69, 0xd8167fa2, 0x0418f2c8, 0x001a96a6, 0x0d1526ab,
|
||||
0x63315c21, 0x5e0a72ec, 0x49bafefd, 0x187908d9, 0x8d0dbd86, 0x311170a7, 0x3e9b640c, 0xcc3e10d7,
|
||||
0xd5cad3b6, 0x0caec388, 0xf73001e1, 0x6c728aff, 0x71eae2a1, 0x1f9af36e, 0xcfcbd12f, 0xc1de8417,
|
||||
0xac07be6b, 0xcb44a1d8, 0x8b9b0f56, 0x013988c3, 0xb1c52fca, 0xb4be31cd, 0xd8782806, 0x12a3a4e2,
|
||||
0x6f7de532, 0x58fd7eb6, 0xd01ee900, 0x24adffc2, 0xf4990fc5, 0x9711aac5, 0x001d7b95, 0x82e5e7d2,
|
||||
0x109873f6, 0x00613096, 0xc32d9521, 0xada121ff, 0x29908415, 0x7fbb977f, 0xaf9eb3db, 0x29c9ed2a,
|
||||
0x5ce2a465, 0xa730f32c, 0xd0aa3fe8, 0x8a5cc091, 0xd49e2ce7, 0x0ce454a9, 0xd60acd86, 0x015f1919,
|
||||
0x77079103, 0xdea03af6, 0x78a8565e, 0xdee356df, 0x21f05cbe, 0x8b75e387, 0xb3c50651, 0xb8a5c3ef,
|
||||
0xd8eeb6d2, 0xe523be77, 0xc2154529, 0x2f69efdf, 0xafe67afb, 0xf470c4b2, 0xf3e0eb5b, 0xd6cc9876,
|
||||
0x39e4460c, 0x1fda8538, 0x1987832f, 0xca007367, 0xa99144f8, 0x296b299e, 0x492fc295, 0x9266beab,
|
||||
0xb5676e69, 0x9bd3ddda, 0xdf7e052f, 0xdb25701c, 0x1b5e51ee, 0xf65324e6, 0x6afce36c, 0x0316cc04,
|
||||
0x8644213e, 0xb7dc59d0, 0x7965291f, 0xccd6fd43, 0x41823979, 0x932bcdf6, 0xb657c34d, 0x4edfd282,
|
||||
0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0, 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2
|
||||
};
|
||||
|
||||
static const uint32_t S5[256] = {
|
||||
0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff, 0x1dd358f5, 0x44dd9d44, 0x1731167f,
|
||||
0x08fbf1fa, 0xe7f511cc, 0xd2051b00, 0x735aba00, 0x2ab722d8, 0x386381cb, 0xacf6243a, 0x69befd7a,
|
||||
0xe6a2e77f, 0xf0c720cd, 0xc4494816, 0xccf5c180, 0x38851640, 0x15b0a848, 0xe68b18cb, 0x4caadeff,
|
||||
0x5f480a01, 0x0412b2aa, 0x259814fc, 0x41d0efe2, 0x4e40b48d, 0x248eb6fb, 0x8dba1cfe, 0x41a99b02,
|
||||
0x1a550a04, 0xba8f65cb, 0x7251f4e7, 0x95a51725, 0xc106ecd7, 0x97a5980a, 0xc539b9aa, 0x4d79fe6a,
|
||||
0xf2f3f763, 0x68af8040, 0xed0c9e56, 0x11b4958b, 0xe1eb5a88, 0x8709e6b0, 0xd7e07156, 0x4e29fea7,
|
||||
0x6366e52d, 0x02d1c000, 0xc4ac8e05, 0x9377f571, 0x0c05372a, 0x578535f2, 0x2261be02, 0xd642a0c9,
|
||||
0xdf13a280, 0x74b55bd2, 0x682199c0, 0xd421e5ec, 0x53fb3ce8, 0xc8adedb3, 0x28a87fc9, 0x3d959981,
|
||||
0x5c1ff900, 0xfe38d399, 0x0c4eff0b, 0x062407ea, 0xaa2f4fb1, 0x4fb96976, 0x90c79505, 0xb0a8a774,
|
||||
0xef55a1ff, 0xe59ca2c2, 0xa6b62d27, 0xe66a4263, 0xdf65001f, 0x0ec50966, 0xdfdd55bc, 0x29de0655,
|
||||
0x911e739a, 0x17af8975, 0x32c7911c, 0x89f89468, 0x0d01e980, 0x524755f4, 0x03b63cc9, 0x0cc844b2,
|
||||
0xbcf3f0aa, 0x87ac36e9, 0xe53a7426, 0x01b3d82b, 0x1a9e7449, 0x64ee2d7e, 0xcddbb1da, 0x01c94910,
|
||||
0xb868bf80, 0x0d26f3fd, 0x9342ede7, 0x04a5c284, 0x636737b6, 0x50f5b616, 0xf24766e3, 0x8eca36c1,
|
||||
0x136e05db, 0xfef18391, 0xfb887a37, 0xd6e7f7d4, 0xc7fb7dc9, 0x3063fcdf, 0xb6f589de, 0xec2941da,
|
||||
0x26e46695, 0xb7566419, 0xf654efc5, 0xd08d58b7, 0x48925401, 0xc1bacb7f, 0xe5ff550f, 0xb6083049,
|
||||
0x5bb5d0e8, 0x87d72e5a, 0xab6a6ee1, 0x223a66ce, 0xc62bf3cd, 0x9e0885f9, 0x68cb3e47, 0x086c010f,
|
||||
0xa21de820, 0xd18b69de, 0xf3f65777, 0xfa02c3f6, 0x407edac3, 0xcbb3d550, 0x1793084d, 0xb0d70eba,
|
||||
0x0ab378d5, 0xd951fb0c, 0xded7da56, 0x4124bbe4, 0x94ca0b56, 0x0f5755d1, 0xe0e1e56e, 0x6184b5be,
|
||||
0x580a249f, 0x94f74bc0, 0xe327888e, 0x9f7b5561, 0xc3dc0280, 0x05687715, 0x646c6bd7, 0x44904db3,
|
||||
0x66b4f0a3, 0xc0f1648a, 0x697ed5af, 0x49e92ff6, 0x309e374f, 0x2cb6356a, 0x85808573, 0x4991f840,
|
||||
0x76f0ae02, 0x083be84d, 0x28421c9a, 0x44489406, 0x736e4cb8, 0xc1092910, 0x8bc95fc6, 0x7d869cf4,
|
||||
0x134f616f, 0x2e77118d, 0xb31b2be1, 0xaa90b472, 0x3ca5d717, 0x7d161bba, 0x9cad9010, 0xaf462ba2,
|
||||
0x9fe459d2, 0x45d34559, 0xd9f2da13, 0xdbc65487, 0xf3e4f94e, 0x176d486f, 0x097c13ea, 0x631da5c7,
|
||||
0x445f7382, 0x175683f4, 0xcdc66a97, 0x70be0288, 0xb3cdcf72, 0x6e5dd2f3, 0x20936079, 0x459b80a5,
|
||||
0xbe60e2db, 0xa9c23101, 0xeba5315c, 0x224e42f2, 0x1c5c1572, 0xf6721b2c, 0x1ad2fff3, 0x8c25404e,
|
||||
0x324ed72f, 0x4067b7fd, 0x0523138e, 0x5ca3bc78, 0xdc0fd66e, 0x75922283, 0x784d6b17, 0x58ebb16e,
|
||||
0x44094f85, 0x3f481d87, 0xfcfeae7b, 0x77b5ff76, 0x8c2302bf, 0xaaf47556, 0x5f46b02a, 0x2b092801,
|
||||
0x3d38f5f7, 0x0ca81f36, 0x52af4a8a, 0x66d5e7c0, 0xdf3b0874, 0x95055110, 0x1b5ad7a8, 0xf61ed5ad,
|
||||
0x6cf6e479, 0x20758184, 0xd0cefa65, 0x88f7be58, 0x4a046826, 0x0ff6f8f3, 0xa09c7f70, 0x5346aba0,
|
||||
0x5ce96c28, 0xe176eda3, 0x6bac307f, 0x376829d2, 0x85360fa9, 0x17e3fe2a, 0x24b79767, 0xf5a96b20,
|
||||
0xd6cd2595, 0x68ff1ebf, 0x7555442c, 0xf19f06be, 0xf9e0659a, 0xeeb9491d, 0x34010718, 0xbb30cab8,
|
||||
0xe822fe15, 0x88570983, 0x750e6249, 0xda627e55, 0x5e76ffa8, 0xb1534546, 0x6d47de08, 0xefe9e7d4
|
||||
};
|
||||
|
||||
static const uint32_t S6[256] = {
|
||||
0xf6fa8f9d, 0x2cac6ce1, 0x4ca34867, 0xe2337f7c, 0x95db08e7, 0x016843b4, 0xeced5cbc, 0x325553ac,
|
||||
0xbf9f0960, 0xdfa1e2ed, 0x83f0579d, 0x63ed86b9, 0x1ab6a6b8, 0xde5ebe39, 0xf38ff732, 0x8989b138,
|
||||
0x33f14961, 0xc01937bd, 0xf506c6da, 0xe4625e7e, 0xa308ea99, 0x4e23e33c, 0x79cbd7cc, 0x48a14367,
|
||||
0xa3149619, 0xfec94bd5, 0xa114174a, 0xeaa01866, 0xa084db2d, 0x09a8486f, 0xa888614a, 0x2900af98,
|
||||
0x01665991, 0xe1992863, 0xc8f30c60, 0x2e78ef3c, 0xd0d51932, 0xcf0fec14, 0xf7ca07d2, 0xd0a82072,
|
||||
0xfd41197e, 0x9305a6b0, 0xe86be3da, 0x74bed3cd, 0x372da53c, 0x4c7f4448, 0xdab5d440, 0x6dba0ec3,
|
||||
0x083919a7, 0x9fbaeed9, 0x49dbcfb0, 0x4e670c53, 0x5c3d9c01, 0x64bdb941, 0x2c0e636a, 0xba7dd9cd,
|
||||
0xea6f7388, 0xe70bc762, 0x35f29adb, 0x5c4cdd8d, 0xf0d48d8c, 0xb88153e2, 0x08a19866, 0x1ae2eac8,
|
||||
0x284caf89, 0xaa928223, 0x9334be53, 0x3b3a21bf, 0x16434be3, 0x9aea3906, 0xefe8c36e, 0xf890cdd9,
|
||||
0x80226dae, 0xc340a4a3, 0xdf7e9c09, 0xa694a807, 0x5b7c5ecc, 0x221db3a6, 0x9a69a02f, 0x68818a54,
|
||||
0xceb2296f, 0x53c0843a, 0xfe893655, 0x25bfe68a, 0xb4628abc, 0xcf222ebf, 0x25ac6f48, 0xa9a99387,
|
||||
0x53bddb65, 0xe76ffbe7, 0xe967fd78, 0x0ba93563, 0x8e342bc1, 0xe8a11be9, 0x4980740d, 0xc8087dfc,
|
||||
0x8de4bf99, 0xa11101a0, 0x7fd37975, 0xda5a26c0, 0xe81f994f, 0x9528cd89, 0xfd339fed, 0xb87834bf,
|
||||
0x5f04456d, 0x22258698, 0xc9c4c83b, 0x2dc156be, 0x4f628daa, 0x57f55ec5, 0xe2220abe, 0xd2916ebf,
|
||||
0x4ec75b95, 0x24f2c3c0, 0x42d15d99, 0xcd0d7fa0, 0x7b6e27ff, 0xa8dc8af0, 0x7345c106, 0xf41e232f,
|
||||
0x35162386, 0xe6ea8926, 0x3333b094, 0x157ec6f2, 0x372b74af, 0x692573e4, 0xe9a9d848, 0xf3160289,
|
||||
0x3a62ef1d, 0xa787e238, 0xf3a5f676, 0x74364853, 0x20951063, 0x4576698d, 0xb6fad407, 0x592af950,
|
||||
0x36f73523, 0x4cfb6e87, 0x7da4cec0, 0x6c152daa, 0xcb0396a8, 0xc50dfe5d, 0xfcd707ab, 0x0921c42f,
|
||||
0x89dff0bb, 0x5fe2be78, 0x448f4f33, 0x754613c9, 0x2b05d08d, 0x48b9d585, 0xdc049441, 0xc8098f9b,
|
||||
0x7dede786, 0xc39a3373, 0x42410005, 0x6a091751, 0x0ef3c8a6, 0x890072d6, 0x28207682, 0xa9a9f7be,
|
||||
0xbf32679d, 0xd45b5b75, 0xb353fd00, 0xcbb0e358, 0x830f220a, 0x1f8fb214, 0xd372cf08, 0xcc3c4a13,
|
||||
0x8cf63166, 0x061c87be, 0x88c98f88, 0x6062e397, 0x47cf8e7a, 0xb6c85283, 0x3cc2acfb, 0x3fc06976,
|
||||
0x4e8f0252, 0x64d8314d, 0xda3870e3, 0x1e665459, 0xc10908f0, 0x513021a5, 0x6c5b68b7, 0x822f8aa0,
|
||||
0x3007cd3e, 0x74719eef, 0xdc872681, 0x073340d4, 0x7e432fd9, 0x0c5ec241, 0x8809286c, 0xf592d891,
|
||||
0x08a930f6, 0x957ef305, 0xb7fbffbd, 0xc266e96f, 0x6fe4ac98, 0xb173ecc0, 0xbc60b42a, 0x953498da,
|
||||
0xfba1ae12, 0x2d4bd736, 0x0f25faab, 0xa4f3fceb, 0xe2969123, 0x257f0c3d, 0x9348af49, 0x361400bc,
|
||||
0xe8816f4a, 0x3814f200, 0xa3f94043, 0x9c7a54c2, 0xbc704f57, 0xda41e7f9, 0xc25ad33a, 0x54f4a084,
|
||||
0xb17f5505, 0x59357cbe, 0xedbd15c8, 0x7f97c5ab, 0xba5ac7b5, 0xb6f6deaf, 0x3a479c3a, 0x5302da25,
|
||||
0x653d7e6a, 0x54268d49, 0x51a477ea, 0x5017d55b, 0xd7d25d88, 0x44136c76, 0x0404a8c8, 0xb8e5a121,
|
||||
0xb81a928a, 0x60ed5869, 0x97c55b96, 0xeaec991b, 0x29935913, 0x01fdb7f1, 0x088e8dfa, 0x9ab6f6f5,
|
||||
0x3b4cbf9f, 0x4a5de3ab, 0xe6051d35, 0xa0e1d855, 0xd36b4cf1, 0xf544edeb, 0xb0e93524, 0xbebb8fbd,
|
||||
0xa2d762cf, 0x49c92f54, 0x38b5f331, 0x7128a454, 0x48392905, 0xa65b1db8, 0x851c97bd, 0xd675cf2f
|
||||
};
|
||||
|
||||
static const uint32_t S7[256] = {
|
||||
0x85e04019, 0x332bf567, 0x662dbfff, 0xcfc65693, 0x2a8d7f6f, 0xab9bc912, 0xde6008a1, 0x2028da1f,
|
||||
0x0227bce7, 0x4d642916, 0x18fac300, 0x50f18b82, 0x2cb2cb11, 0xb232e75c, 0x4b3695f2, 0xb28707de,
|
||||
0xa05fbcf6, 0xcd4181e9, 0xe150210c, 0xe24ef1bd, 0xb168c381, 0xfde4e789, 0x5c79b0d8, 0x1e8bfd43,
|
||||
0x4d495001, 0x38be4341, 0x913cee1d, 0x92a79c3f, 0x089766be, 0xbaeeadf4, 0x1286becf, 0xb6eacb19,
|
||||
0x2660c200, 0x7565bde4, 0x64241f7a, 0x8248dca9, 0xc3b3ad66, 0x28136086, 0x0bd8dfa8, 0x356d1cf2,
|
||||
0x107789be, 0xb3b2e9ce, 0x0502aa8f, 0x0bc0351e, 0x166bf52a, 0xeb12ff82, 0xe3486911, 0xd34d7516,
|
||||
0x4e7b3aff, 0x5f43671b, 0x9cf6e037, 0x4981ac83, 0x334266ce, 0x8c9341b7, 0xd0d854c0, 0xcb3a6c88,
|
||||
0x47bc2829, 0x4725ba37, 0xa66ad22b, 0x7ad61f1e, 0x0c5cbafa, 0x4437f107, 0xb6e79962, 0x42d2d816,
|
||||
0x0a961288, 0xe1a5c06e, 0x13749e67, 0x72fc081a, 0xb1d139f7, 0xf9583745, 0xcf19df58, 0xbec3f756,
|
||||
0xc06eba30, 0x07211b24, 0x45c28829, 0xc95e317f, 0xbc8ec511, 0x38bc46e9, 0xc6e6fa14, 0xbae8584a,
|
||||
0xad4ebc46, 0x468f508b, 0x7829435f, 0xf124183b, 0x821dba9f, 0xaff60ff4, 0xea2c4e6d, 0x16e39264,
|
||||
0x92544a8b, 0x009b4fc3, 0xaba68ced, 0x9ac96f78, 0x06a5b79a, 0xb2856e6e, 0x1aec3ca9, 0xbe838688,
|
||||
0x0e0804e9, 0x55f1be56, 0xe7e5363b, 0xb3a1f25d, 0xf7debb85, 0x61fe033c, 0x16746233, 0x3c034c28,
|
||||
0xda6d0c74, 0x79aac56c, 0x3ce4e1ad, 0x51f0c802, 0x98f8f35a, 0x1626a49f, 0xeed82b29, 0x1d382fe3,
|
||||
0x0c4fb99a, 0xbb325778, 0x3ec6d97b, 0x6e77a6a9, 0xcb658b5c, 0xd45230c7, 0x2bd1408b, 0x60c03eb7,
|
||||
0xb9068d78, 0xa33754f4, 0xf430c87d, 0xc8a71302, 0xb96d8c32, 0xebd4e7be, 0xbe8b9d2d, 0x7979fb06,
|
||||
0xe7225308, 0x8b75cf77, 0x11ef8da4, 0xe083c858, 0x8d6b786f, 0x5a6317a6, 0xfa5cf7a0, 0x5dda0033,
|
||||
0xf28ebfb0, 0xf5b9c310, 0xa0eac280, 0x08b9767a, 0xa3d9d2b0, 0x79d34217, 0x021a718d, 0x9ac6336a,
|
||||
0x2711fd60, 0x438050e3, 0x069908a8, 0x3d7fedc4, 0x826d2bef, 0x4eeb8476, 0x488dcf25, 0x36c9d566,
|
||||
0x28e74e41, 0xc2610aca, 0x3d49a9cf, 0xbae3b9df, 0xb65f8de6, 0x92aeaf64, 0x3ac7d5e6, 0x9ea80509,
|
||||
0xf22b017d, 0xa4173f70, 0xdd1e16c3, 0x15e0d7f9, 0x50b1b887, 0x2b9f4fd5, 0x625aba82, 0x6a017962,
|
||||
0x2ec01b9c, 0x15488aa9, 0xd716e740, 0x40055a2c, 0x93d29a22, 0xe32dbf9a, 0x058745b9, 0x3453dc1e,
|
||||
0xd699296e, 0x496cff6f, 0x1c9f4986, 0xdfe2ed07, 0xb87242d1, 0x19de7eae, 0x053e561a, 0x15ad6f8c,
|
||||
0x66626c1c, 0x7154c24c, 0xea082b2a, 0x93eb2939, 0x17dcb0f0, 0x58d4f2ae, 0x9ea294fb, 0x52cf564c,
|
||||
0x9883fe66, 0x2ec40581, 0x763953c3, 0x01d6692e, 0xd3a0c108, 0xa1e7160e, 0xe4f2dfa6, 0x693ed285,
|
||||
0x74904698, 0x4c2b0edd, 0x4f757656, 0x5d393378, 0xa132234f, 0x3d321c5d, 0xc3f5e194, 0x4b269301,
|
||||
0xc79f022f, 0x3c997e7e, 0x5e4f9504, 0x3ffafbbd, 0x76f7ad0e, 0x296693f4, 0x3d1fce6f, 0xc61e45be,
|
||||
0xd3b5ab34, 0xf72bf9b7, 0x1b0434c0, 0x4e72b567, 0x5592a33d, 0xb5229301, 0xcfd2a87f, 0x60aeb767,
|
||||
0x1814386b, 0x30bcc33d, 0x38a0c07d, 0xfd1606f2, 0xc363519b, 0x589dd390, 0x5479f8e6, 0x1cb8d647,
|
||||
0x97fd61a9, 0xea7759f4, 0x2d57539d, 0x569a58cf, 0xe84e63ad, 0x462e1b78, 0x6580f87e, 0xf3817914,
|
||||
0x91da55f4, 0x40a230f3, 0xd1988f35, 0xb6e318d2, 0x3ffa50bc, 0x3d40f021, 0xc3c0bdae, 0x4958c24c,
|
||||
0x518f36b2, 0x84b1d370, 0x0fedce83, 0x878ddada, 0xf2a279c7, 0x94e01be8, 0x90716f4b, 0x954b8aa3
|
||||
};
|
||||
|
||||
static const uint32_t S8[256] = {
|
||||
0xe216300d, 0xbbddfffc, 0xa7ebdabd, 0x35648095, 0x7789f8b7, 0xe6c1121b, 0x0e241600, 0x052ce8b5,
|
||||
0x11a9cfb0, 0xe5952f11, 0xece7990a, 0x9386d174, 0x2a42931c, 0x76e38111, 0xb12def3a, 0x37ddddfc,
|
||||
0xde9adeb1, 0x0a0cc32c, 0xbe197029, 0x84a00940, 0xbb243a0f, 0xb4d137cf, 0xb44e79f0, 0x049eedfd,
|
||||
0x0b15a15d, 0x480d3168, 0x8bbbde5a, 0x669ded42, 0xc7ece831, 0x3f8f95e7, 0x72df191b, 0x7580330d,
|
||||
0x94074251, 0x5c7dcdfa, 0xabbe6d63, 0xaa402164, 0xb301d40a, 0x02e7d1ca, 0x53571dae, 0x7a3182a2,
|
||||
0x12a8ddec, 0xfdaa335d, 0x176f43e8, 0x71fb46d4, 0x38129022, 0xce949ad4, 0xb84769ad, 0x965bd862,
|
||||
0x82f3d055, 0x66fb9767, 0x15b80b4e, 0x1d5b47a0, 0x4cfde06f, 0xc28ec4b8, 0x57e8726e, 0x647a78fc,
|
||||
0x99865d44, 0x608bd593, 0x6c200e03, 0x39dc5ff6, 0x5d0b00a3, 0xae63aff2, 0x7e8bd632, 0x70108c0c,
|
||||
0xbbd35049, 0x2998df04, 0x980cf42a, 0x9b6df491, 0x9e7edd53, 0x06918548, 0x58cb7e07, 0x3b74ef2e,
|
||||
0x522fffb1, 0xd24708cc, 0x1c7e27cd, 0xa4eb215b, 0x3cf1d2e2, 0x19b47a38, 0x424f7618, 0x35856039,
|
||||
0x9d17dee7, 0x27eb35e6, 0xc9aff67b, 0x36baf5b8, 0x09c467cd, 0xc18910b1, 0xe11dbf7b, 0x06cd1af8,
|
||||
0x7170c608, 0x2d5e3354, 0xd4de495a, 0x64c6d006, 0xbcc0c62c, 0x3dd00db3, 0x708f8f34, 0x77d51b42,
|
||||
0x264f620f, 0x24b8d2bf, 0x15c1b79e, 0x46a52564, 0xf8d7e54e, 0x3e378160, 0x7895cda5, 0x859c15a5,
|
||||
0xe6459788, 0xc37bc75f, 0xdb07ba0c, 0x0676a3ab, 0x7f229b1e, 0x31842e7b, 0x24259fd7, 0xf8bef472,
|
||||
0x835ffcb8, 0x6df4c1f2, 0x96f5b195, 0xfd0af0fc, 0xb0fe134c, 0xe2506d3d, 0x4f9b12ea, 0xf215f225,
|
||||
0xa223736f, 0x9fb4c428, 0x25d04979, 0x34c713f8, 0xc4618187, 0xea7a6e98, 0x7cd16efc, 0x1436876c,
|
||||
0xf1544107, 0xbedeee14, 0x56e9af27, 0xa04aa441, 0x3cf7c899, 0x92ecbae6, 0xdd67016d, 0x151682eb,
|
||||
0xa842eedf, 0xfdba60b4, 0xf1907b75, 0x20e3030f, 0x24d8c29e, 0xe139673b, 0xefa63fb8, 0x71873054,
|
||||
0xb6f2cf3b, 0x9f326442, 0xcb15a4cc, 0xb01a4504, 0xf1e47d8d, 0x844a1be5, 0xbae7dfdc, 0x42cbda70,
|
||||
0xcd7dae0a, 0x57e85b7a, 0xd53f5af6, 0x20cf4d8c, 0xcea4d428, 0x79d130a4, 0x3486ebfb, 0x33d3cddc,
|
||||
0x77853b53, 0x37effcb5, 0xc5068778, 0xe580b3e6, 0x4e68b8f4, 0xc5c8b37e, 0x0d809ea2, 0x398feb7c,
|
||||
0x132a4f94, 0x43b7950e, 0x2fee7d1c, 0x223613bd, 0xdd06caa2, 0x37df932b, 0xc4248289, 0xacf3ebc3,
|
||||
0x5715f6b7, 0xef3478dd, 0xf267616f, 0xc148cbe4, 0x9052815e, 0x5e410fab, 0xb48a2465, 0x2eda7fa4,
|
||||
0xe87b40e4, 0xe98ea084, 0x5889e9e1, 0xefd390fc, 0xdd07d35b, 0xdb485694, 0x38d7e5b2, 0x57720101,
|
||||
0x730edebc, 0x5b643113, 0x94917e4f, 0x503c2fba, 0x646f1282, 0x7523d24a, 0xe0779695, 0xf9c17a8f,
|
||||
0x7a5b2121, 0xd187b896, 0x29263a4d, 0xba510cdf, 0x81f47c9f, 0xad1163ed, 0xea7b5965, 0x1a00726e,
|
||||
0x11403092, 0x00da6d77, 0x4a0cdd61, 0xad1f4603, 0x605bdfb0, 0x9eedc364, 0x22ebe6a8, 0xcee7d28a,
|
||||
0xa0e736a0, 0x5564a6b9, 0x10853209, 0xc7eb8f37, 0x2de705ca, 0x8951570f, 0xdf09822b, 0xbd691a6c,
|
||||
0xaa12e4f2, 0x87451c0f, 0xe0f6a27a, 0x3ada4819, 0x4cf1764f, 0x0d771c2b, 0x67cdb156, 0x350d8384,
|
||||
0x5938fa0f, 0x42399ef3, 0x36997b07, 0x0e84093d, 0x4aa93e61, 0x8360d87b, 0x1fa98b0c, 0x1149382c,
|
||||
0xe97625a5, 0x0614d1b7, 0x0e25244b, 0x0c768347, 0x589e8d82, 0x0d2059d1, 0xa466bb1e, 0xf8da0a82,
|
||||
0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d, 0x50b2ad80, 0xeaee6801, 0x8db2a283, 0xea8bf59e
|
||||
};
|
||||
|
||||
static void generate_round_keys(int rnds, uint32_t* K, uint32_t* x, uint32_t* z)
|
||||
{
|
||||
COMPUTE_Z;
|
||||
|
||||
K[1] = S5[IA(z[2])] ^ S6[IB(z[2])] ^ S7[ID(z[1])] ^ S8[IC(z[1])] ^ S5[IC(z[0])];
|
||||
K[2] = S5[IC(z[2])] ^ S6[ID(z[2])] ^ S7[IB(z[1])] ^ S8[IA(z[1])] ^ S6[IC(z[1])];
|
||||
K[3] = S5[IA(z[3])] ^ S6[IB(z[3])] ^ S7[ID(z[0])] ^ S8[IC(z[0])] ^ S7[IB(z[2])];
|
||||
K[4] = S5[IC(z[3])] ^ S6[ID(z[3])] ^ S7[IB(z[0])] ^ S8[IA(z[0])] ^ S8[IA(z[3])];
|
||||
|
||||
COMPUTE_X;
|
||||
|
||||
K[5] = S5[ID(x[0])] ^ S6[IC(x[0])] ^ S7[IA(x[3])] ^ S8[IB(x[3])] ^ S5[IA(x[2])];
|
||||
K[6] = S5[IB(x[0])] ^ S6[IA(x[0])] ^ S7[IC(x[3])] ^ S8[ID(x[3])] ^ S6[IB(x[3])];
|
||||
K[7] = S5[ID(x[1])] ^ S6[IC(x[1])] ^ S7[IA(x[2])] ^ S8[IB(x[2])] ^ S7[ID(x[0])];
|
||||
K[8] = S5[IB(x[1])] ^ S6[IA(x[1])] ^ S7[IC(x[2])] ^ S8[ID(x[2])] ^ S8[ID(x[1])];
|
||||
|
||||
COMPUTE_Z;
|
||||
|
||||
K[9] = S5[ID(z[0])] ^ S6[IC(z[0])] ^ S7[IA(z[3])] ^ S8[IB(z[3])] ^ S5[IB(z[2])];
|
||||
K[10] = S5[IB(z[0])] ^ S6[IA(z[0])] ^ S7[IC(z[3])] ^ S8[ID(z[3])] ^ S6[IA(z[3])];
|
||||
K[11] = S5[ID(z[1])] ^ S6[IC(z[1])] ^ S7[IA(z[2])] ^ S8[IB(z[2])] ^ S7[IC(z[0])];
|
||||
K[12] = S5[IB(z[1])] ^ S6[IA(z[1])] ^ S7[IC(z[2])] ^ S8[ID(z[2])] ^ S8[IC(z[1])];
|
||||
|
||||
COMPUTE_X;
|
||||
|
||||
if (rnds == 16) {
|
||||
K[13] = S5[IA(x[2])] ^ S6[IB(x[2])] ^ S7[ID(x[1])] ^ S8[IC(x[1])] ^ S5[ID(x[0])];
|
||||
K[14] = S5[IC(x[2])] ^ S6[ID(x[2])] ^ S7[IB(x[1])] ^ S8[IA(x[1])] ^ S6[ID(x[1])];
|
||||
K[15] = S5[IA(x[3])] ^ S6[IB(x[3])] ^ S7[ID(x[0])] ^ S8[IC(x[0])] ^ S7[IA(x[2])];
|
||||
K[16] = S5[IC(x[3])] ^ S6[ID(x[3])] ^ S7[IB(x[0])] ^ S8[IA(x[0])] ^ S8[IB(x[3])];
|
||||
}
|
||||
}
|
||||
|
||||
static void encipher(AVCAST5* cs, uint8_t* dst, const uint8_t* src)
|
||||
{
|
||||
uint32_t r, l, f, I;
|
||||
l = AV_RB32(src);
|
||||
r = AV_RB32(src + 4);
|
||||
F1(l, r, 1);
|
||||
F2(r, l, 2);
|
||||
F3(l, r, 3);
|
||||
F1(r, l, 4);
|
||||
F2(l, r, 5);
|
||||
F3(r, l, 6);
|
||||
F1(l, r, 7);
|
||||
F2(r, l, 8);
|
||||
F3(l, r, 9);
|
||||
F1(r, l, 10);
|
||||
F2(l, r, 11);
|
||||
F3(r, l, 12);
|
||||
if (cs->rounds == 16) {
|
||||
F1(l, r, 13);
|
||||
F2(r, l, 14);
|
||||
F3(l, r, 15);
|
||||
F1(r, l, 16);
|
||||
}
|
||||
AV_WB32(dst, r);
|
||||
AV_WB32(dst + 4, l);
|
||||
}
|
||||
|
||||
static void decipher(AVCAST5* cs, uint8_t* dst, const uint8_t* src, uint8_t *iv)
|
||||
{
|
||||
uint32_t f, I, r, l;
|
||||
l = AV_RB32(src);
|
||||
r = AV_RB32(src + 4);
|
||||
if (cs->rounds == 16) {
|
||||
F1(l, r, 16);
|
||||
F3(r, l, 15);
|
||||
F2(l, r, 14);
|
||||
F1(r, l, 13);
|
||||
}
|
||||
F3(l, r, 12);
|
||||
F2(r, l, 11);
|
||||
F1(l, r, 10);
|
||||
F3(r, l, 9);
|
||||
F2(l, r, 8);
|
||||
F1(r, l, 7);
|
||||
F3(l, r, 6);
|
||||
F2(r, l, 5);
|
||||
F1(l, r, 4);
|
||||
F3(r, l, 3);
|
||||
F2(l, r, 2);
|
||||
F1(r, l, 1);
|
||||
if (iv) {
|
||||
r ^= AV_RB32(iv);
|
||||
l ^= AV_RB32(iv + 4);
|
||||
memcpy(iv, src, 8);
|
||||
}
|
||||
AV_WB32(dst, r);
|
||||
AV_WB32(dst + 4, l);
|
||||
}
|
||||
|
||||
struct AVCAST5 *av_cast5_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVCAST5));
|
||||
}
|
||||
|
||||
av_cold int av_cast5_init(AVCAST5* cs, const uint8_t *key, int key_bits)
|
||||
{
|
||||
uint8_t newKey[16];
|
||||
int i;
|
||||
uint32_t p[4], q[4];
|
||||
if (key_bits % 8 || key_bits < 40 || key_bits > 128)
|
||||
return AVERROR(EINVAL);
|
||||
memset(newKey, 0, sizeof(newKey));
|
||||
memcpy(newKey, key, key_bits >> 3);
|
||||
|
||||
cs->rounds = key_bits <= 80 ? 12 : 16;
|
||||
for (i = 0; i < 4; i++)
|
||||
q[i] = AV_RB32(newKey + (4 * i));
|
||||
generate_round_keys(cs->rounds, cs->Km, q, p);
|
||||
generate_round_keys(cs->rounds, cs->Kr, q, p);
|
||||
for (i = 0; i <= cs->rounds; i++)
|
||||
cs->Kr[i] = cs->Kr[i] & 0x1f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_cast5_crypt2(AVCAST5* cs, uint8_t* dst, const uint8_t* src, int count, uint8_t *iv, int decrypt)
|
||||
{
|
||||
int i;
|
||||
while (count--) {
|
||||
if (decrypt) {
|
||||
decipher(cs, dst, src, iv);
|
||||
} else {
|
||||
if (iv) {
|
||||
for (i = 0; i < 8; i++)
|
||||
dst[i] = src[i] ^ iv[i];
|
||||
encipher(cs, dst, dst);
|
||||
memcpy(iv, dst, 8);
|
||||
} else {
|
||||
encipher(cs, dst, src);
|
||||
}
|
||||
}
|
||||
src = src + 8;
|
||||
dst = dst + 8;
|
||||
}
|
||||
}
|
||||
void av_cast5_crypt(AVCAST5* cs, uint8_t* dst, const uint8_t* src, int count, int decrypt)
|
||||
{
|
||||
while (count--) {
|
||||
if (decrypt){
|
||||
decipher(cs, dst, src, NULL);
|
||||
} else {
|
||||
encipher(cs, dst, src);
|
||||
}
|
||||
src = src + 8;
|
||||
dst = dst + 8;
|
||||
}
|
||||
}
|
||||
80
media/ffvpx/libavutil/cast5.h
Normal file
80
media/ffvpx/libavutil/cast5.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* An implementation of the CAST128 algorithm as mentioned in RFC2144
|
||||
* Copyright (c) 2014 Supraja Meedinti
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_CAST5_H
|
||||
#define AVUTIL_CAST5_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Public header for libavutil CAST5 algorithm
|
||||
* @defgroup lavu_cast5 CAST5
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_cast5_size;
|
||||
|
||||
struct AVCAST5;
|
||||
|
||||
/**
|
||||
* Allocate an AVCAST5 context
|
||||
* To free the struct: av_free(ptr)
|
||||
*/
|
||||
struct AVCAST5 *av_cast5_alloc(void);
|
||||
/**
|
||||
* Initialize an AVCAST5 context.
|
||||
*
|
||||
* @param ctx an AVCAST5 context
|
||||
* @param key a key of 5,6,...16 bytes used for encryption/decryption
|
||||
* @param key_bits number of keybits: possible are 40,48,...,128
|
||||
* @return 0 on success, less than 0 on failure
|
||||
*/
|
||||
int av_cast5_init(struct AVCAST5 *ctx, const uint8_t *key, int key_bits);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context, ECB mode only
|
||||
*
|
||||
* @param ctx an AVCAST5 context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 8 byte blocks
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_cast5_crypt(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context
|
||||
*
|
||||
* @param ctx an AVCAST5 context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 8 byte blocks
|
||||
* @param iv initialization vector for CBC mode, NULL for ECB mode
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_cast5_crypt2(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* AVUTIL_CAST5_H */
|
||||
|
|
@ -158,7 +158,7 @@ static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, in
|
|||
*/
|
||||
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
|
||||
{
|
||||
if (a&(~0xFF)) return (-a)>>31;
|
||||
if (a&(~0xFF)) return (~a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ static av_always_inline av_const int8_t av_clip_int8_c(int a)
|
|||
*/
|
||||
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
|
||||
{
|
||||
if (a&(~0xFFFF)) return (-a)>>31;
|
||||
if (a&(~0xFFFF)) return (~a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ static av_always_inline av_const int av_clip_intp2_c(int a, int p)
|
|||
*/
|
||||
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
|
||||
{
|
||||
if (a & ~((1<<p) - 1)) return -a >> 31 & ((1<<p) - 1);
|
||||
if (a & ~((1<<p) - 1)) return (~a) >> 31 & ((1<<p) - 1);
|
||||
else return a;
|
||||
}
|
||||
|
||||
|
|
|
|||
331
media/ffvpx/libavutil/des.c
Normal file
331
media/ffvpx/libavutil/des.c
Normal file
|
|
@ -0,0 +1,331 @@
|
|||
/*
|
||||
* DES encryption/decryption
|
||||
* Copyright (c) 2007 Reimar Doeffinger
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avutil.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#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
|
||||
static const uint8_t IP_shuffle[] = {
|
||||
T(58, 50, 42, 34, 26, 18, 10, 2),
|
||||
T(60, 52, 44, 36, 28, 20, 12, 4),
|
||||
T(62, 54, 46, 38, 30, 22, 14, 6),
|
||||
T(64, 56, 48, 40, 32, 24, 16, 8),
|
||||
T(57, 49, 41, 33, 25, 17, 9, 1),
|
||||
T(59, 51, 43, 35, 27, 19, 11, 3),
|
||||
T(61, 53, 45, 37, 29, 21, 13, 5),
|
||||
T(63, 55, 47, 39, 31, 23, 15, 7)
|
||||
};
|
||||
#undef T
|
||||
|
||||
#if CONFIG_SMALL || defined(GENTABLES)
|
||||
#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),
|
||||
T( 1, 15, 23, 26),
|
||||
T( 5, 18, 31, 10),
|
||||
T( 2, 8, 24, 14),
|
||||
T(32, 27, 3, 9),
|
||||
T(19, 13, 30, 6),
|
||||
T(22, 11, 4, 25)
|
||||
};
|
||||
#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
|
||||
static const uint8_t PC1_shuffle[] = {
|
||||
T(57, 49, 41, 33, 25, 17, 9),
|
||||
T( 1, 58, 50, 42, 34, 26, 18),
|
||||
T(10, 2, 59, 51, 43, 35, 27),
|
||||
T(19, 11, 3, 60, 52, 44, 36),
|
||||
T(63, 55, 47, 39, 31, 23, 15),
|
||||
T( 7, 62, 54, 46, 38, 30, 22),
|
||||
T(14, 6, 61, 53, 45, 37, 29),
|
||||
T(21, 13, 5, 28, 20, 12, 4)
|
||||
};
|
||||
#undef T
|
||||
|
||||
#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),
|
||||
T(23, 19, 12, 4, 26, 8),
|
||||
T(16, 7, 27, 20, 13, 2),
|
||||
T(41, 52, 31, 37, 47, 55),
|
||||
T(30, 40, 51, 45, 33, 48),
|
||||
T(44, 49, 39, 56, 34, 53),
|
||||
T(46, 42, 50, 36, 29, 32)
|
||||
};
|
||||
#undef T
|
||||
|
||||
#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,
|
||||
}
|
||||
};
|
||||
#else
|
||||
/**
|
||||
* This table contains the results of applying both the S-box and P-shuffle.
|
||||
* It can be regenerated by compiling tests/des.c with "-DCONFIG_SMALL -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, },
|
||||
};
|
||||
#endif
|
||||
|
||||
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++)
|
||||
res += res + ((in >> *shuffle++) & 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
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;
|
||||
for (i = 0; i < shuffle_len; i++) {
|
||||
res |= (in & 1) << *shuffle--;
|
||||
in >>= 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
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
|
||||
r = (r << 1) | (r >> 31);
|
||||
// apply S-boxes, those compress the data again from 8 * 6 to 8 * 4 bits
|
||||
for (i = 7; i >= 0; i--) {
|
||||
uint8_t tmp = (r ^ k) & 0x3f;
|
||||
#if CONFIG_SMALL
|
||||
uint8_t v = S_boxes[i][tmp >> 1];
|
||||
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);
|
||||
k >>= 6;
|
||||
}
|
||||
#if CONFIG_SMALL
|
||||
out = shuffle(out, P_shuffle, sizeof(P_shuffle));
|
||||
#endif
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief rotate the two halves of the expanded 56 bit key each 1 bit left
|
||||
*
|
||||
* Note: the specification calls this "shift", so I kept it although
|
||||
* it is confusing.
|
||||
*/
|
||||
static uint64_t key_shift_left(uint64_t CDn)
|
||||
{
|
||||
uint64_t carries = (CDn >> 27) & 0x10000001;
|
||||
CDn <<= 1;
|
||||
CDn &= ~0x10000001;
|
||||
CDn |= carries;
|
||||
return CDn;
|
||||
}
|
||||
|
||||
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));
|
||||
// generate round keys
|
||||
for (i = 0; i < 16; i++) {
|
||||
CDn = key_shift_left(CDn);
|
||||
if (i > 1 && i != 8 && i != 15)
|
||||
CDn = key_shift_left(CDn);
|
||||
K[i] = shuffle(CDn, PC2_shuffle, sizeof(PC2_shuffle));
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
// shuffle irrelevant to security but to ease hardware implementations
|
||||
in = shuffle(in, IP_shuffle, sizeof(IP_shuffle));
|
||||
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);
|
||||
// reverse shuffle used to ease hardware implementations
|
||||
in = shuffle_inv(in, IP_shuffle, sizeof(IP_shuffle));
|
||||
return in;
|
||||
}
|
||||
|
||||
AVDES *av_des_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVDES));
|
||||
}
|
||||
|
||||
int av_des_init(AVDES *d, const uint8_t *key, int key_bits, av_unused int decrypt) {
|
||||
if (key_bits != 64 && key_bits != 192)
|
||||
return AVERROR(EINVAL);
|
||||
d->triple_des = key_bits > 64;
|
||||
gen_roundkeys(d->round_keys[0], AV_RB64(key));
|
||||
if (d->triple_des) {
|
||||
gen_roundkeys(d->round_keys[1], AV_RB64(key + 8));
|
||||
gen_roundkeys(d->round_keys[2], AV_RB64(key + 16));
|
||||
}
|
||||
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)
|
||||
{
|
||||
uint64_t iv_val = iv ? AV_RB64(iv) : 0;
|
||||
while (count-- > 0) {
|
||||
uint64_t dst_val;
|
||||
uint64_t src_val = src ? AV_RB64(src) : 0;
|
||||
if (decrypt) {
|
||||
uint64_t tmp = src_val;
|
||||
if (d->triple_des) {
|
||||
src_val = des_encdec(src_val, d->round_keys[2], 1);
|
||||
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;
|
||||
} else {
|
||||
dst_val = des_encdec(src_val ^ iv_val, d->round_keys[0], 0);
|
||||
if (d->triple_des) {
|
||||
dst_val = des_encdec(dst_val, d->round_keys[1], 1);
|
||||
dst_val = des_encdec(dst_val, d->round_keys[2], 0);
|
||||
}
|
||||
iv_val = iv ? dst_val : 0;
|
||||
}
|
||||
AV_WB64(dst, dst_val);
|
||||
src += 8;
|
||||
if (!mac)
|
||||
dst += 8;
|
||||
}
|
||||
if (iv)
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
77
media/ffvpx/libavutil/des.h
Normal file
77
media/ffvpx/libavutil/des.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* DES encryption/decryption
|
||||
* Copyright (c) 2007 Reimar Doeffinger
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_DES_H
|
||||
#define AVUTIL_DES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_des DES
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef struct AVDES {
|
||||
uint64_t round_keys[3][16];
|
||||
int triple_des;
|
||||
} AVDES;
|
||||
|
||||
/**
|
||||
* Allocate an AVDES context.
|
||||
*/
|
||||
AVDES *av_des_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Initializes an AVDES context.
|
||||
*
|
||||
* @param key_bits must be 64 or 192
|
||||
* @param decrypt 0 for encryption/CBC-MAC, 1 for decryption
|
||||
* @return zero on success, negative value otherwise
|
||||
*/
|
||||
int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt);
|
||||
|
||||
/**
|
||||
* @brief Encrypts / decrypts using the DES algorithm.
|
||||
*
|
||||
* @param count number of 8 byte blocks
|
||||
* @param dst destination array, can be equal to src, must be 8-byte aligned
|
||||
* @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used,
|
||||
* must be 8-byte aligned
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @brief Calculates CBC-MAC using the DES algorithm.
|
||||
*
|
||||
* @param count number of 8 byte blocks
|
||||
* @param dst destination array, can be equal to src, must be 8-byte aligned
|
||||
* @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL
|
||||
*/
|
||||
void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_DES_H */
|
||||
73
media/ffvpx/libavutil/display.c
Normal file
73
media/ffvpx/libavutil/display.c
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Vittorio Giovara <vittorio.giovara@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "display.h"
|
||||
#include "mathematics.h"
|
||||
|
||||
// fixed point to double
|
||||
#define CONV_FP(x) ((double) (x)) / (1 << 16)
|
||||
|
||||
// double to fixed point
|
||||
#define CONV_DB(x) (int32_t) ((x) * (1 << 16))
|
||||
|
||||
double av_display_rotation_get(const int32_t matrix[9])
|
||||
{
|
||||
double rotation, scale[2];
|
||||
|
||||
scale[0] = hypot(CONV_FP(matrix[0]), CONV_FP(matrix[3]));
|
||||
scale[1] = hypot(CONV_FP(matrix[1]), CONV_FP(matrix[4]));
|
||||
|
||||
if (scale[0] == 0.0 || scale[1] == 0.0)
|
||||
return NAN;
|
||||
|
||||
rotation = atan2(CONV_FP(matrix[1]) / scale[1],
|
||||
CONV_FP(matrix[0]) / scale[0]) * 180 / M_PI;
|
||||
|
||||
return -rotation;
|
||||
}
|
||||
|
||||
void av_display_rotation_set(int32_t matrix[9], double angle)
|
||||
{
|
||||
double radians = -angle * M_PI / 180.0f;
|
||||
double c = cos(radians);
|
||||
double s = sin(radians);
|
||||
|
||||
memset(matrix, 0, 9 * sizeof(int32_t));
|
||||
|
||||
matrix[0] = CONV_DB(c);
|
||||
matrix[1] = CONV_DB(-s);
|
||||
matrix[3] = CONV_DB(s);
|
||||
matrix[4] = CONV_DB(c);
|
||||
matrix[8] = 1 << 30;
|
||||
}
|
||||
|
||||
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
|
||||
{
|
||||
int i;
|
||||
const int flip[] = { 1 - 2 * (!!hflip), 1 - 2 * (!!vflip), 1 };
|
||||
|
||||
if (hflip || vflip)
|
||||
for (i = 0; i < 9; i++)
|
||||
matrix[i] *= flip[i % 3];
|
||||
}
|
||||
114
media/ffvpx/libavutil/display.h
Normal file
114
media/ffvpx/libavutil/display.h
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Vittorio Giovara <vittorio.giovara@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Display matrix
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_DISPLAY_H
|
||||
#define AVUTIL_DISPLAY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_video
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_video_display Display transformation matrix functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_video_display
|
||||
* The display transformation matrix specifies an affine transformation that
|
||||
* should be applied to video frames for correct presentation. It is compatible
|
||||
* with the matrices stored in the ISO/IEC 14496-12 container format.
|
||||
*
|
||||
* The data is a 3x3 matrix represented as a 9-element array:
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* | a b u |
|
||||
* (a, b, u, c, d, v, x, y, w) -> | c d v |
|
||||
* | x y w |
|
||||
* @endcode
|
||||
*
|
||||
* All numbers are stored in native endianness, as 16.16 fixed-point values,
|
||||
* except for u, v and w, which are stored as 2.30 fixed-point values.
|
||||
*
|
||||
* The transformation maps a point (p, q) in the source (pre-transformation)
|
||||
* frame to the point (p', q') in the destination (post-transformation) frame as
|
||||
* follows:
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* | a b u |
|
||||
* (p, q, 1) . | c d v | = z * (p', q', 1)
|
||||
* | x y w |
|
||||
* @endcode
|
||||
*
|
||||
* The transformation can also be more explicitly written in components as
|
||||
* follows:
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* p' = (a * p + c * q + x) / z;
|
||||
* q' = (b * p + d * q + y) / z;
|
||||
* z = u * p + v * q + w
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extract the rotation component of the transformation matrix.
|
||||
*
|
||||
* @param matrix the transformation matrix
|
||||
* @return the angle (in degrees) by which the transformation rotates the frame
|
||||
* counterclockwise. The angle will be in range [-180.0, 180.0],
|
||||
* or NaN if the matrix is singular.
|
||||
*
|
||||
* @note floating point numbers are inherently inexact, so callers are
|
||||
* recommended to round the return value to nearest integer before use.
|
||||
*/
|
||||
double av_display_rotation_get(const int32_t matrix[9]);
|
||||
|
||||
/**
|
||||
* Initialize a transformation matrix describing a pure counterclockwise
|
||||
* rotation by the specified angle (in degrees).
|
||||
*
|
||||
* @param matrix an allocated transformation matrix (will be fully overwritten
|
||||
* by this function)
|
||||
* @param angle rotation angle in degrees.
|
||||
*/
|
||||
void av_display_rotation_set(int32_t matrix[9], double angle);
|
||||
|
||||
/**
|
||||
* Flip the input matrix horizontally and/or vertically.
|
||||
*
|
||||
* @param matrix an allocated transformation matrix
|
||||
* @param hflip whether the matrix should be flipped horizontally
|
||||
* @param vflip whether the matrix should be flipped vertically
|
||||
*/
|
||||
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_DISPLAY_H */
|
||||
38
media/ffvpx/libavutil/downmix_info.c
Normal file
38
media/ffvpx/libavutil/downmix_info.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "downmix_info.h"
|
||||
#include "frame.h"
|
||||
|
||||
AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame)
|
||||
{
|
||||
AVFrameSideData *side_data;
|
||||
|
||||
side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO);
|
||||
|
||||
if (!side_data)
|
||||
side_data = av_frame_new_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO,
|
||||
sizeof(AVDownmixInfo));
|
||||
|
||||
if (!side_data)
|
||||
return NULL;
|
||||
|
||||
return (AVDownmixInfo*)side_data->data;
|
||||
}
|
||||
115
media/ffvpx/libavutil/downmix_info.h
Normal file
115
media/ffvpx/libavutil/downmix_info.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_DOWNMIX_INFO_H
|
||||
#define AVUTIL_DOWNMIX_INFO_H
|
||||
|
||||
#include "frame.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* audio downmix medatata
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup downmix_info Audio downmix metadata
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Possible downmix types.
|
||||
*/
|
||||
enum AVDownmixType {
|
||||
AV_DOWNMIX_TYPE_UNKNOWN, /**< Not indicated. */
|
||||
AV_DOWNMIX_TYPE_LORO, /**< Lo/Ro 2-channel downmix (Stereo). */
|
||||
AV_DOWNMIX_TYPE_LTRT, /**< Lt/Rt 2-channel downmix, Dolby Surround compatible. */
|
||||
AV_DOWNMIX_TYPE_DPLII, /**< Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible. */
|
||||
AV_DOWNMIX_TYPE_NB /**< Number of downmix types. Not part of ABI. */
|
||||
};
|
||||
|
||||
/**
|
||||
* This structure describes optional metadata relevant to a downmix procedure.
|
||||
*
|
||||
* All fields are set by the decoder to the value indicated in the audio
|
||||
* bitstream (if present), or to a "sane" default otherwise.
|
||||
*/
|
||||
typedef struct AVDownmixInfo {
|
||||
/**
|
||||
* Type of downmix preferred by the mastering engineer.
|
||||
*/
|
||||
enum AVDownmixType preferred_downmix_type;
|
||||
|
||||
/**
|
||||
* Absolute scale factor representing the nominal level of the center
|
||||
* channel during a regular downmix.
|
||||
*/
|
||||
double center_mix_level;
|
||||
|
||||
/**
|
||||
* Absolute scale factor representing the nominal level of the center
|
||||
* channel during an Lt/Rt compatible downmix.
|
||||
*/
|
||||
double center_mix_level_ltrt;
|
||||
|
||||
/**
|
||||
* Absolute scale factor representing the nominal level of the surround
|
||||
* channels during a regular downmix.
|
||||
*/
|
||||
double surround_mix_level;
|
||||
|
||||
/**
|
||||
* Absolute scale factor representing the nominal level of the surround
|
||||
* channels during an Lt/Rt compatible downmix.
|
||||
*/
|
||||
double surround_mix_level_ltrt;
|
||||
|
||||
/**
|
||||
* Absolute scale factor representing the level at which the LFE data is
|
||||
* mixed into L/R channels during downmixing.
|
||||
*/
|
||||
double lfe_mix_level;
|
||||
} AVDownmixInfo;
|
||||
|
||||
/**
|
||||
* Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing.
|
||||
*
|
||||
* If the side data is absent, it is created and added to the frame.
|
||||
*
|
||||
* @param frame the frame for which the side data is to be obtained or created
|
||||
*
|
||||
* @return the AVDownmixInfo structure to be edited by the caller, or NULL if
|
||||
* the structure cannot be allocated.
|
||||
*/
|
||||
AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_DOWNMIX_INFO_H */
|
||||
43
media/ffvpx/libavutil/ff_random_seed.h
Normal file
43
media/ffvpx/libavutil/ff_random_seed.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_RANDOM_SEED_H
|
||||
#define AVUTIL_RANDOM_SEED_H
|
||||
|
||||
#include <stdint.h>
|
||||
/**
|
||||
* @addtogroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get a seed to use in conjunction with random functions.
|
||||
* This function tries to provide a good seed at a best effort bases.
|
||||
* Its possible to call this function multiple times if more bits are needed.
|
||||
* It can be quite slow, which is why it should only be used as seed for a faster
|
||||
* PRNG. The quality of the seed depends on the platform.
|
||||
*/
|
||||
uint32_t av_get_random_seed(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_RANDOM_SEED_H */
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/* Automatically generated by version.sh, do not manually edit! */
|
||||
#ifndef AVUTIL_FFVERSION_H
|
||||
#define AVUTIL_FFVERSION_H
|
||||
#define FFMPEG_VERSION "n3.4.2"
|
||||
#define FFMPEG_VERSION "3.4.2"
|
||||
#endif /* AVUTIL_FFVERSION_H */
|
||||
|
|
|
|||
142
media/ffvpx/libavutil/file.c
Normal file
142
media/ffvpx/libavutil/file.c
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "file.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
#if HAVE_MMAP
|
||||
#include <sys/mman.h>
|
||||
#elif HAVE_MAPVIEWOFFILE
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
typedef struct FileLogContext {
|
||||
const AVClass *class;
|
||||
int log_offset;
|
||||
void *log_ctx;
|
||||
} FileLogContext;
|
||||
|
||||
static const AVClass file_log_ctx_class = {
|
||||
"FILE", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT,
|
||||
offsetof(FileLogContext, log_offset), offsetof(FileLogContext, log_ctx)
|
||||
};
|
||||
|
||||
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
|
||||
int log_offset, void *log_ctx)
|
||||
{
|
||||
FileLogContext file_log_ctx = { &file_log_ctx_class, log_offset, log_ctx };
|
||||
int err, fd = avpriv_open(filename, O_RDONLY);
|
||||
struct stat st;
|
||||
av_unused void *ptr;
|
||||
off_t off_size;
|
||||
char errbuf[128];
|
||||
*bufptr = NULL;
|
||||
|
||||
if (fd < 0) {
|
||||
err = AVERROR(errno);
|
||||
av_strerror(err, errbuf, sizeof(errbuf));
|
||||
av_log(&file_log_ctx, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, errbuf);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (fstat(fd, &st) < 0) {
|
||||
err = AVERROR(errno);
|
||||
av_strerror(err, errbuf, sizeof(errbuf));
|
||||
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in fstat(): %s\n", errbuf);
|
||||
close(fd);
|
||||
return err;
|
||||
}
|
||||
|
||||
off_size = st.st_size;
|
||||
if (off_size > SIZE_MAX) {
|
||||
av_log(&file_log_ctx, AV_LOG_ERROR,
|
||||
"File size for file '%s' is too big\n", filename);
|
||||
close(fd);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
*size = off_size;
|
||||
|
||||
#if HAVE_MMAP
|
||||
ptr = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
if (ptr == MAP_FAILED) {
|
||||
err = AVERROR(errno);
|
||||
av_strerror(err, errbuf, sizeof(errbuf));
|
||||
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in mmap(): %s\n", errbuf);
|
||||
close(fd);
|
||||
return err;
|
||||
}
|
||||
*bufptr = ptr;
|
||||
#elif HAVE_MAPVIEWOFFILE
|
||||
{
|
||||
HANDLE mh, fh = (HANDLE)_get_osfhandle(fd);
|
||||
|
||||
mh = CreateFileMapping(fh, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (!mh) {
|
||||
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in CreateFileMapping()\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = MapViewOfFile(mh, FILE_MAP_READ, 0, 0, *size);
|
||||
CloseHandle(mh);
|
||||
if (!ptr) {
|
||||
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in MapViewOfFile()\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*bufptr = ptr;
|
||||
}
|
||||
#else
|
||||
*bufptr = av_malloc(*size);
|
||||
if (!*bufptr) {
|
||||
av_log(&file_log_ctx, AV_LOG_ERROR, "Memory allocation error occurred\n");
|
||||
close(fd);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
read(fd, *bufptr, *size);
|
||||
#endif
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_file_unmap(uint8_t *bufptr, size_t size)
|
||||
{
|
||||
#if HAVE_MMAP
|
||||
munmap(bufptr, size);
|
||||
#elif HAVE_MAPVIEWOFFILE
|
||||
UnmapViewOfFile(bufptr);
|
||||
#else
|
||||
av_free(bufptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx) {
|
||||
return avpriv_tempfile(prefix, filename, log_offset, log_ctx);
|
||||
}
|
||||
69
media/ffvpx/libavutil/file.h
Normal file
69
media/ffvpx/libavutil/file.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_FILE_H
|
||||
#define AVUTIL_FILE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avutil.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Misc file utilities.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read the file with name filename, and put its content in a newly
|
||||
* allocated buffer or map it with mmap() when available.
|
||||
* In case of success set *bufptr to the read or mmapped buffer, and
|
||||
* *size to the size in bytes of the buffer in *bufptr.
|
||||
* The returned buffer must be released with av_file_unmap().
|
||||
*
|
||||
* @param log_offset loglevel offset used for logging
|
||||
* @param log_ctx context used for logging
|
||||
* @return a non negative number in case of success, a negative value
|
||||
* corresponding to an AVERROR error code in case of failure
|
||||
*/
|
||||
av_warn_unused_result
|
||||
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
|
||||
int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Unmap or free the buffer bufptr created by av_file_map().
|
||||
*
|
||||
* @param size size in bytes of bufptr, must be the same as returned
|
||||
* by av_file_map()
|
||||
*/
|
||||
void av_file_unmap(uint8_t *bufptr, size_t size);
|
||||
|
||||
/**
|
||||
* Wrapper to work around the lack of mkstemp() on mingw.
|
||||
* Also, tries to create file in /tmp first, if possible.
|
||||
* *prefix can be a character constant; *filename will be allocated internally.
|
||||
* @return file descriptor of opened file (or negative value corresponding to an
|
||||
* AVERROR code on error)
|
||||
* and opened file name in **filename.
|
||||
* @note On very old libcs it is necessary to set a secure umask before
|
||||
* calling this, av_tempfile() can't call umask itself as it is used in
|
||||
* libraries and could interfere with the calling application.
|
||||
* @deprecated as fd numbers cannot be passed saftely between libs on some platforms
|
||||
*/
|
||||
int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx);
|
||||
|
||||
#endif /* AVUTIL_FILE_H */
|
||||
186
media/ffvpx/libavutil/file_open.c
Normal file
186
media/ffvpx/libavutil/file_open.c
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "internal.h"
|
||||
#include "mem.h"
|
||||
#include <stdarg.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32CE__)
|
||||
#undef open
|
||||
#undef lseek
|
||||
#undef stat
|
||||
#undef fstat
|
||||
#include <windows.h>
|
||||
#include <share.h>
|
||||
#include <errno.h>
|
||||
#include "wchar_filename.h"
|
||||
|
||||
static int win32_open(const char *filename_utf8, int oflag, int pmode)
|
||||
{
|
||||
int fd;
|
||||
wchar_t *filename_w;
|
||||
|
||||
/* convert UTF-8 to wide chars */
|
||||
if (utf8towchar(filename_utf8, &filename_w))
|
||||
return -1;
|
||||
if (!filename_w)
|
||||
goto fallback;
|
||||
|
||||
fd = _wsopen(filename_w, oflag, SH_DENYNO, pmode);
|
||||
av_freep(&filename_w);
|
||||
|
||||
if (fd != -1 || (oflag & O_CREAT))
|
||||
return fd;
|
||||
|
||||
fallback:
|
||||
/* filename may be in CP_ACP */
|
||||
return _sopen(filename_utf8, oflag, SH_DENYNO, pmode);
|
||||
}
|
||||
#define open win32_open
|
||||
#endif
|
||||
|
||||
int avpriv_open(const char *filename, int flags, ...)
|
||||
{
|
||||
int fd;
|
||||
unsigned int mode = 0;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, flags);
|
||||
if (flags & O_CREAT)
|
||||
mode = va_arg(ap, unsigned int);
|
||||
va_end(ap);
|
||||
|
||||
#ifdef O_CLOEXEC
|
||||
flags |= O_CLOEXEC;
|
||||
#endif
|
||||
#ifdef O_NOINHERIT
|
||||
flags |= O_NOINHERIT;
|
||||
#endif
|
||||
|
||||
fd = open(filename, flags, mode);
|
||||
#if HAVE_FCNTL
|
||||
if (fd != -1) {
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
av_log(NULL, AV_LOG_DEBUG, "Failed to set close on exec\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
typedef struct FileLogContext {
|
||||
const AVClass *class;
|
||||
int log_offset;
|
||||
void *log_ctx;
|
||||
} FileLogContext;
|
||||
|
||||
static const AVClass file_log_ctx_class = {
|
||||
"TEMPFILE", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT,
|
||||
offsetof(FileLogContext, log_offset), offsetof(FileLogContext, log_ctx)
|
||||
};
|
||||
|
||||
int avpriv_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx)
|
||||
{
|
||||
FileLogContext file_log_ctx = { &file_log_ctx_class, log_offset, log_ctx };
|
||||
int fd = -1;
|
||||
#if !HAVE_MKSTEMP
|
||||
void *ptr= tempnam(NULL, prefix);
|
||||
if(!ptr)
|
||||
ptr= tempnam(".", prefix);
|
||||
*filename = av_strdup(ptr);
|
||||
#undef free
|
||||
free(ptr);
|
||||
#else
|
||||
size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */
|
||||
*filename = av_malloc(len);
|
||||
#endif
|
||||
/* -----common section-----*/
|
||||
if (!*filename) {
|
||||
av_log(&file_log_ctx, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
#if !HAVE_MKSTEMP
|
||||
# ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
# endif
|
||||
# ifndef O_EXCL
|
||||
# define O_EXCL 0
|
||||
# endif
|
||||
fd = open(*filename, O_RDWR | O_BINARY | O_CREAT | O_EXCL, 0600);
|
||||
#else
|
||||
snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
|
||||
fd = mkstemp(*filename);
|
||||
#if defined(_WIN32) || defined (__ANDROID__)
|
||||
if (fd < 0) {
|
||||
snprintf(*filename, len, "./%sXXXXXX", prefix);
|
||||
fd = mkstemp(*filename);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* -----common section-----*/
|
||||
if (fd < 0) {
|
||||
int err = AVERROR(errno);
|
||||
av_log(&file_log_ctx, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
|
||||
av_freep(filename);
|
||||
return err;
|
||||
}
|
||||
return fd; /* success */
|
||||
}
|
||||
|
||||
FILE *av_fopen_utf8(const char *path, const char *mode)
|
||||
{
|
||||
int fd;
|
||||
int access;
|
||||
const char *m = mode;
|
||||
|
||||
switch (*m++) {
|
||||
case 'r': access = O_RDONLY; break;
|
||||
case 'w': access = O_CREAT|O_WRONLY|O_TRUNC; break;
|
||||
case 'a': access = O_CREAT|O_WRONLY|O_APPEND; break;
|
||||
default :
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
while (*m) {
|
||||
if (*m == '+') {
|
||||
access &= ~(O_RDONLY | O_WRONLY);
|
||||
access |= O_RDWR;
|
||||
} else if (*m == 'b') {
|
||||
#ifdef O_BINARY
|
||||
access |= O_BINARY;
|
||||
#endif
|
||||
} else if (*m) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
m++;
|
||||
}
|
||||
fd = avpriv_open(path, access, 0666);
|
||||
if (fd == -1)
|
||||
return NULL;
|
||||
return fdopen(fd, mode);
|
||||
}
|
||||
239
media/ffvpx/libavutil/hash.c
Normal file
239
media/ffvpx/libavutil/hash.c
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
/*
|
||||
* Copyright (C) 2013 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include "hash.h"
|
||||
|
||||
#include "adler32.h"
|
||||
#include "crc.h"
|
||||
#include "md5.h"
|
||||
#include "murmur3.h"
|
||||
#include "ripemd.h"
|
||||
#include "sha.h"
|
||||
#include "sha512.h"
|
||||
|
||||
#include "avstring.h"
|
||||
#include "base64.h"
|
||||
#include "error.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "mem.h"
|
||||
|
||||
enum hashtype {
|
||||
MD5,
|
||||
MURMUR3,
|
||||
RIPEMD128,
|
||||
RIPEMD160,
|
||||
RIPEMD256,
|
||||
RIPEMD320,
|
||||
SHA160,
|
||||
SHA224,
|
||||
SHA256,
|
||||
SHA512_224,
|
||||
SHA512_256,
|
||||
SHA384,
|
||||
SHA512,
|
||||
CRC32,
|
||||
ADLER32,
|
||||
NUM_HASHES
|
||||
};
|
||||
|
||||
typedef struct AVHashContext {
|
||||
void *ctx;
|
||||
enum hashtype type;
|
||||
const AVCRC *crctab;
|
||||
uint32_t crc;
|
||||
} AVHashContext;
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
int size;
|
||||
} hashdesc[] = {
|
||||
[MD5] = {"MD5", 16},
|
||||
[MURMUR3] = {"murmur3", 16},
|
||||
[RIPEMD128] = {"RIPEMD128", 16},
|
||||
[RIPEMD160] = {"RIPEMD160", 20},
|
||||
[RIPEMD256] = {"RIPEMD256", 32},
|
||||
[RIPEMD320] = {"RIPEMD320", 40},
|
||||
[SHA160] = {"SHA160", 20},
|
||||
[SHA224] = {"SHA224", 28},
|
||||
[SHA256] = {"SHA256", 32},
|
||||
[SHA512_224] = {"SHA512/224", 28},
|
||||
[SHA512_256] = {"SHA512/256", 32},
|
||||
[SHA384] = {"SHA384", 48},
|
||||
[SHA512] = {"SHA512", 64},
|
||||
[CRC32] = {"CRC32", 4},
|
||||
[ADLER32] = {"adler32", 4},
|
||||
};
|
||||
|
||||
const char *av_hash_names(int i)
|
||||
{
|
||||
if (i < 0 || i >= NUM_HASHES) return NULL;
|
||||
return hashdesc[i].name;
|
||||
}
|
||||
|
||||
const char *av_hash_get_name(const AVHashContext *ctx)
|
||||
{
|
||||
return hashdesc[ctx->type].name;
|
||||
}
|
||||
|
||||
int av_hash_get_size(const AVHashContext *ctx)
|
||||
{
|
||||
return hashdesc[ctx->type].size;
|
||||
}
|
||||
|
||||
int av_hash_alloc(AVHashContext **ctx, const char *name)
|
||||
{
|
||||
AVHashContext *res;
|
||||
int i;
|
||||
*ctx = NULL;
|
||||
for (i = 0; i < NUM_HASHES; i++)
|
||||
if (av_strcasecmp(name, hashdesc[i].name) == 0)
|
||||
break;
|
||||
if (i >= NUM_HASHES) return AVERROR(EINVAL);
|
||||
res = av_mallocz(sizeof(*res));
|
||||
if (!res) return AVERROR(ENOMEM);
|
||||
res->type = i;
|
||||
switch (i) {
|
||||
case MD5: res->ctx = av_md5_alloc(); break;
|
||||
case MURMUR3: res->ctx = av_murmur3_alloc(); break;
|
||||
case RIPEMD128:
|
||||
case RIPEMD160:
|
||||
case RIPEMD256:
|
||||
case RIPEMD320: res->ctx = av_ripemd_alloc(); break;
|
||||
case SHA160:
|
||||
case SHA224:
|
||||
case SHA256: res->ctx = av_sha_alloc(); break;
|
||||
case SHA512_224:
|
||||
case SHA512_256:
|
||||
case SHA384:
|
||||
case SHA512: res->ctx = av_sha512_alloc(); break;
|
||||
case CRC32: res->crctab = av_crc_get_table(AV_CRC_32_IEEE_LE); break;
|
||||
case ADLER32: break;
|
||||
}
|
||||
if (i != ADLER32 && i != CRC32 && !res->ctx) {
|
||||
av_free(res);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
*ctx = res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_hash_init(AVHashContext *ctx)
|
||||
{
|
||||
switch (ctx->type) {
|
||||
case MD5: av_md5_init(ctx->ctx); break;
|
||||
case MURMUR3: av_murmur3_init(ctx->ctx); break;
|
||||
case RIPEMD128: av_ripemd_init(ctx->ctx, 128); break;
|
||||
case RIPEMD160: av_ripemd_init(ctx->ctx, 160); break;
|
||||
case RIPEMD256: av_ripemd_init(ctx->ctx, 256); break;
|
||||
case RIPEMD320: av_ripemd_init(ctx->ctx, 320); break;
|
||||
case SHA160: av_sha_init(ctx->ctx, 160); break;
|
||||
case SHA224: av_sha_init(ctx->ctx, 224); break;
|
||||
case SHA256: av_sha_init(ctx->ctx, 256); break;
|
||||
case SHA512_224: av_sha512_init(ctx->ctx, 224); break;
|
||||
case SHA512_256: av_sha512_init(ctx->ctx, 256); break;
|
||||
case SHA384: av_sha512_init(ctx->ctx, 384); break;
|
||||
case SHA512: av_sha512_init(ctx->ctx, 512); break;
|
||||
case CRC32: ctx->crc = UINT32_MAX; break;
|
||||
case ADLER32: ctx->crc = 1; break;
|
||||
}
|
||||
}
|
||||
|
||||
void av_hash_update(AVHashContext *ctx, const uint8_t *src, int len)
|
||||
{
|
||||
switch (ctx->type) {
|
||||
case MD5: av_md5_update(ctx->ctx, src, len); break;
|
||||
case MURMUR3: av_murmur3_update(ctx->ctx, src, len); break;
|
||||
case RIPEMD128:
|
||||
case RIPEMD160:
|
||||
case RIPEMD256:
|
||||
case RIPEMD320: av_ripemd_update(ctx->ctx, src, len); break;
|
||||
case SHA160:
|
||||
case SHA224:
|
||||
case SHA256: av_sha_update(ctx->ctx, src, len); break;
|
||||
case SHA512_224:
|
||||
case SHA512_256:
|
||||
case SHA384:
|
||||
case SHA512: av_sha512_update(ctx->ctx, src, len); break;
|
||||
case CRC32: ctx->crc = av_crc(ctx->crctab, ctx->crc, src, len); break;
|
||||
case ADLER32: ctx->crc = av_adler32_update(ctx->crc, src, len); break;
|
||||
}
|
||||
}
|
||||
|
||||
void av_hash_final(AVHashContext *ctx, uint8_t *dst)
|
||||
{
|
||||
switch (ctx->type) {
|
||||
case MD5: av_md5_final(ctx->ctx, dst); break;
|
||||
case MURMUR3: av_murmur3_final(ctx->ctx, dst); break;
|
||||
case RIPEMD128:
|
||||
case RIPEMD160:
|
||||
case RIPEMD256:
|
||||
case RIPEMD320: av_ripemd_final(ctx->ctx, dst); break;
|
||||
case SHA160:
|
||||
case SHA224:
|
||||
case SHA256: av_sha_final(ctx->ctx, dst); break;
|
||||
case SHA512_224:
|
||||
case SHA512_256:
|
||||
case SHA384:
|
||||
case SHA512: av_sha512_final(ctx->ctx, dst); break;
|
||||
case CRC32: AV_WB32(dst, ctx->crc ^ UINT32_MAX); break;
|
||||
case ADLER32: AV_WB32(dst, ctx->crc); break;
|
||||
}
|
||||
}
|
||||
|
||||
void av_hash_final_bin(struct AVHashContext *ctx, uint8_t *dst, int size)
|
||||
{
|
||||
uint8_t buf[AV_HASH_MAX_SIZE];
|
||||
unsigned rsize = av_hash_get_size(ctx);
|
||||
|
||||
av_hash_final(ctx, buf);
|
||||
memcpy(dst, buf, FFMIN(size, rsize));
|
||||
if (size > rsize)
|
||||
memset(dst + rsize, 0, size - rsize);
|
||||
}
|
||||
|
||||
void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size)
|
||||
{
|
||||
uint8_t buf[AV_HASH_MAX_SIZE];
|
||||
unsigned rsize = av_hash_get_size(ctx), i;
|
||||
|
||||
av_hash_final(ctx, buf);
|
||||
for (i = 0; i < FFMIN(rsize, size / 2); i++)
|
||||
snprintf(dst + i * 2, size - i * 2, "%02x", buf[i]);
|
||||
}
|
||||
|
||||
void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size)
|
||||
{
|
||||
uint8_t buf[AV_HASH_MAX_SIZE], b64[AV_BASE64_SIZE(AV_HASH_MAX_SIZE)];
|
||||
unsigned rsize = av_hash_get_size(ctx), osize;
|
||||
|
||||
av_hash_final(ctx, buf);
|
||||
av_base64_encode(b64, sizeof(b64), buf, rsize);
|
||||
osize = AV_BASE64_SIZE(rsize);
|
||||
memcpy(dst, b64, FFMIN(osize, size));
|
||||
if (size < osize)
|
||||
dst[size - 1] = 0;
|
||||
}
|
||||
|
||||
void av_hash_freep(AVHashContext **ctx)
|
||||
{
|
||||
if (*ctx)
|
||||
av_freep(&(*ctx)->ctx);
|
||||
av_freep(ctx);
|
||||
}
|
||||
263
media/ffvpx/libavutil/hash.h
Normal file
263
media/ffvpx/libavutil/hash.h
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
/*
|
||||
* Copyright (C) 2013 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavu_hash_generic
|
||||
* Generic hashing API
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_HASH_H
|
||||
#define AVUTIL_HASH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_hash Hash Functions
|
||||
* @ingroup lavu_crypto
|
||||
* Hash functions useful in multimedia.
|
||||
*
|
||||
* Hash functions are widely used in multimedia, from error checking and
|
||||
* concealment to internal regression testing. libavutil has efficient
|
||||
* implementations of a variety of hash functions that may be useful for
|
||||
* FFmpeg and other multimedia applications.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_hash_generic Generic Hashing API
|
||||
* An abstraction layer for all hash functions supported by libavutil.
|
||||
*
|
||||
* If your application needs to support a wide range of different hash
|
||||
* functions, then the Generic Hashing API is for you. It provides a generic,
|
||||
* reusable API for @ref lavu_hash "all hash functions" implemented in libavutil.
|
||||
* If you just need to use one particular hash function, use the @ref lavu_hash
|
||||
* "individual hash" directly.
|
||||
*
|
||||
* @section Sample Code
|
||||
*
|
||||
* A basic template for using the Generic Hashing API follows:
|
||||
*
|
||||
* @code
|
||||
* struct AVHashContext *ctx = NULL;
|
||||
* const char *hash_name = NULL;
|
||||
* uint8_t *output_buf = NULL;
|
||||
*
|
||||
* // Select from a string returned by av_hash_names()
|
||||
* hash_name = ...;
|
||||
*
|
||||
* // Allocate a hash context
|
||||
* ret = av_hash_alloc(&ctx, hash_name);
|
||||
* if (ret < 0)
|
||||
* return ret;
|
||||
*
|
||||
* // Initialize the hash context
|
||||
* av_hash_init(ctx);
|
||||
*
|
||||
* // Update the hash context with data
|
||||
* while (data_left) {
|
||||
* av_hash_update(ctx, data, size);
|
||||
* }
|
||||
*
|
||||
* // Now we have no more data, so it is time to finalize the hash and get the
|
||||
* // output. But we need to first allocate an output buffer. Note that you can
|
||||
* // use any memory allocation function, including malloc(), not just
|
||||
* // av_malloc().
|
||||
* output_buf = av_malloc(av_hash_get_size(ctx));
|
||||
* if (!output_buf)
|
||||
* return AVERROR(ENOMEM);
|
||||
*
|
||||
* // Finalize the hash context.
|
||||
* // You can use any of the av_hash_final*() functions provided, for other
|
||||
* // output formats. If you do so, be sure to adjust the memory allocation
|
||||
* // above. See the function documentation below for the exact amount of extra
|
||||
* // memory needed.
|
||||
* av_hash_final(ctx, output_buffer);
|
||||
*
|
||||
* // Free the context
|
||||
* av_hash_freep(&ctx);
|
||||
* @endcode
|
||||
*
|
||||
* @section Hash Function-Specific Information
|
||||
* If the CRC32 hash is selected, the #AV_CRC_32_IEEE polynomial will be
|
||||
* used.
|
||||
*
|
||||
* If the Murmur3 hash is selected, the default seed will be used. See @ref
|
||||
* lavu_murmur3_seedinfo "Murmur3" for more information.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example ffhash.c
|
||||
* This example is a simple command line application that takes one or more
|
||||
* arguments. It demonstrates a typical use of the hashing API with allocation,
|
||||
* initialization, updating, and finalizing.
|
||||
*/
|
||||
|
||||
struct AVHashContext;
|
||||
|
||||
/**
|
||||
* Allocate a hash context for the algorithm specified by name.
|
||||
*
|
||||
* @return >= 0 for success, a negative error code for failure
|
||||
*
|
||||
* @note The context is not initialized after a call to this function; you must
|
||||
* call av_hash_init() to do so.
|
||||
*/
|
||||
int av_hash_alloc(struct AVHashContext **ctx, const char *name);
|
||||
|
||||
/**
|
||||
* Get the names of available hash algorithms.
|
||||
*
|
||||
* This function can be used to enumerate the algorithms.
|
||||
*
|
||||
* @param[in] i Index of the hash algorithm, starting from 0
|
||||
* @return Pointer to a static string or `NULL` if `i` is out of range
|
||||
*/
|
||||
const char *av_hash_names(int i);
|
||||
|
||||
/**
|
||||
* Get the name of the algorithm corresponding to the given hash context.
|
||||
*/
|
||||
const char *av_hash_get_name(const struct AVHashContext *ctx);
|
||||
|
||||
/**
|
||||
* Maximum value that av_hash_get_size() will currently return.
|
||||
*
|
||||
* You can use this if you absolutely want or need to use static allocation for
|
||||
* the output buffer and are fine with not supporting hashes newly added to
|
||||
* libavutil without recompilation.
|
||||
*
|
||||
* @warning
|
||||
* Adding new hashes with larger sizes, and increasing the macro while doing
|
||||
* so, will not be considered an ABI change. To prevent your code from
|
||||
* overflowing a buffer, either dynamically allocate the output buffer with
|
||||
* av_hash_get_size(), or limit your use of the Hashing API to hashes that are
|
||||
* already in FFmpeg during the time of compilation.
|
||||
*/
|
||||
#define AV_HASH_MAX_SIZE 64
|
||||
|
||||
/**
|
||||
* Get the size of the resulting hash value in bytes.
|
||||
*
|
||||
* The maximum value this function will currently return is available as macro
|
||||
* #AV_HASH_MAX_SIZE.
|
||||
*
|
||||
* @param[in] ctx Hash context
|
||||
* @return Size of the hash value in bytes
|
||||
*/
|
||||
int av_hash_get_size(const struct AVHashContext *ctx);
|
||||
|
||||
/**
|
||||
* Initialize or reset a hash context.
|
||||
*
|
||||
* @param[in,out] ctx Hash context
|
||||
*/
|
||||
void av_hash_init(struct AVHashContext *ctx);
|
||||
|
||||
/**
|
||||
* Update a hash context with additional data.
|
||||
*
|
||||
* @param[in,out] ctx Hash context
|
||||
* @param[in] src Data to be added to the hash context
|
||||
* @param[in] len Size of the additional data
|
||||
*/
|
||||
void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, int len);
|
||||
|
||||
/**
|
||||
* Finalize a hash context and compute the actual hash value.
|
||||
*
|
||||
* The minimum size of `dst` buffer is given by av_hash_get_size() or
|
||||
* #AV_HASH_MAX_SIZE. The use of the latter macro is discouraged.
|
||||
*
|
||||
* It is not safe to update or finalize a hash context again, if it has already
|
||||
* been finalized.
|
||||
*
|
||||
* @param[in,out] ctx Hash context
|
||||
* @param[out] dst Where the final hash value will be stored
|
||||
*
|
||||
* @see av_hash_final_bin() provides an alternative API
|
||||
*/
|
||||
void av_hash_final(struct AVHashContext *ctx, uint8_t *dst);
|
||||
|
||||
/**
|
||||
* Finalize a hash context and store the actual hash value in a buffer.
|
||||
*
|
||||
* It is not safe to update or finalize a hash context again, if it has already
|
||||
* been finalized.
|
||||
*
|
||||
* If `size` is smaller than the hash size (given by av_hash_get_size()), the
|
||||
* hash is truncated; if size is larger, the buffer is padded with 0.
|
||||
*
|
||||
* @param[in,out] ctx Hash context
|
||||
* @param[out] dst Where the final hash value will be stored
|
||||
* @param[in] size Number of bytes to write to `dst`
|
||||
*/
|
||||
void av_hash_final_bin(struct AVHashContext *ctx, uint8_t *dst, int size);
|
||||
|
||||
/**
|
||||
* Finalize a hash context and store the hexadecimal representation of the
|
||||
* actual hash value as a string.
|
||||
*
|
||||
* It is not safe to update or finalize a hash context again, if it has already
|
||||
* been finalized.
|
||||
*
|
||||
* The string is always 0-terminated.
|
||||
*
|
||||
* If `size` is smaller than `2 * hash_size + 1`, where `hash_size` is the
|
||||
* value returned by av_hash_get_size(), the string will be truncated.
|
||||
*
|
||||
* @param[in,out] ctx Hash context
|
||||
* @param[out] dst Where the string will be stored
|
||||
* @param[in] size Maximum number of bytes to write to `dst`
|
||||
*/
|
||||
void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size);
|
||||
|
||||
/**
|
||||
* Finalize a hash context and store the Base64 representation of the
|
||||
* actual hash value as a string.
|
||||
*
|
||||
* It is not safe to update or finalize a hash context again, if it has already
|
||||
* been finalized.
|
||||
*
|
||||
* The string is always 0-terminated.
|
||||
*
|
||||
* If `size` is smaller than AV_BASE64_SIZE(hash_size), where `hash_size` is
|
||||
* the value returned by av_hash_get_size(), the string will be truncated.
|
||||
*
|
||||
* @param[in,out] ctx Hash context
|
||||
* @param[out] dst Where the final hash value will be stored
|
||||
* @param[in] size Maximum number of bytes to write to `dst`
|
||||
*/
|
||||
void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size);
|
||||
|
||||
/**
|
||||
* Free hash context and set hash context pointer to `NULL`.
|
||||
*
|
||||
* @param[in,out] ctx Pointer to hash context
|
||||
*/
|
||||
void av_hash_freep(struct AVHashContext **ctx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_HASH_H */
|
||||
196
media/ffvpx/libavutil/hmac.c
Normal file
196
media/ffvpx/libavutil/hmac.c
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Martin Storsjo
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "hmac.h"
|
||||
#include "md5.h"
|
||||
#include "sha.h"
|
||||
#include "sha512.h"
|
||||
#include "mem.h"
|
||||
#include "version.h"
|
||||
|
||||
#define MAX_HASHLEN 64
|
||||
#define MAX_BLOCKLEN 128
|
||||
|
||||
typedef void (*hmac_final)(void *ctx, uint8_t *dst);
|
||||
#if FF_API_CRYPTO_SIZE_T
|
||||
typedef void (*hmac_update)(void *ctx, const uint8_t *src, int len);
|
||||
#else
|
||||
typedef void (*hmac_update)(void *ctx, const uint8_t *src, size_t len);
|
||||
#endif
|
||||
typedef void (*hmac_init)(void *ctx);
|
||||
|
||||
struct AVHMAC {
|
||||
void *hash;
|
||||
int blocklen, hashlen;
|
||||
hmac_final final;
|
||||
hmac_update update;
|
||||
hmac_init init;
|
||||
uint8_t key[MAX_BLOCKLEN];
|
||||
int keylen;
|
||||
};
|
||||
|
||||
#define DEFINE_SHA(bits) \
|
||||
static av_cold void sha ## bits ##_init(void *ctx) \
|
||||
{ \
|
||||
av_sha_init(ctx, bits); \
|
||||
}
|
||||
|
||||
#define DEFINE_SHA512(bits) \
|
||||
static av_cold void sha ## bits ##_init(void *ctx) \
|
||||
{ \
|
||||
av_sha512_init(ctx, bits); \
|
||||
}
|
||||
|
||||
DEFINE_SHA(160)
|
||||
DEFINE_SHA(224)
|
||||
DEFINE_SHA(256)
|
||||
DEFINE_SHA512(384)
|
||||
DEFINE_SHA512(512)
|
||||
|
||||
AVHMAC *av_hmac_alloc(enum AVHMACType type)
|
||||
{
|
||||
AVHMAC *c = av_mallocz(sizeof(*c));
|
||||
if (!c)
|
||||
return NULL;
|
||||
switch (type) {
|
||||
case AV_HMAC_MD5:
|
||||
c->blocklen = 64;
|
||||
c->hashlen = 16;
|
||||
c->init = (hmac_init) av_md5_init;
|
||||
c->update = (hmac_update) av_md5_update;
|
||||
c->final = (hmac_final) av_md5_final;
|
||||
c->hash = av_md5_alloc();
|
||||
break;
|
||||
case AV_HMAC_SHA1:
|
||||
c->blocklen = 64;
|
||||
c->hashlen = 20;
|
||||
c->init = sha160_init;
|
||||
c->update = (hmac_update) av_sha_update;
|
||||
c->final = (hmac_final) av_sha_final;
|
||||
c->hash = av_sha_alloc();
|
||||
break;
|
||||
case AV_HMAC_SHA224:
|
||||
c->blocklen = 64;
|
||||
c->hashlen = 28;
|
||||
c->init = sha224_init;
|
||||
c->update = (hmac_update) av_sha_update;
|
||||
c->final = (hmac_final) av_sha_final;
|
||||
c->hash = av_sha_alloc();
|
||||
break;
|
||||
case AV_HMAC_SHA256:
|
||||
c->blocklen = 64;
|
||||
c->hashlen = 32;
|
||||
c->init = sha256_init;
|
||||
c->update = (hmac_update) av_sha_update;
|
||||
c->final = (hmac_final) av_sha_final;
|
||||
c->hash = av_sha_alloc();
|
||||
break;
|
||||
case AV_HMAC_SHA384:
|
||||
c->blocklen = 128;
|
||||
c->hashlen = 48;
|
||||
c->init = sha384_init;
|
||||
c->update = (hmac_update) av_sha512_update;
|
||||
c->final = (hmac_final) av_sha512_final;
|
||||
c->hash = av_sha512_alloc();
|
||||
break;
|
||||
case AV_HMAC_SHA512:
|
||||
c->blocklen = 128;
|
||||
c->hashlen = 64;
|
||||
c->init = sha512_init;
|
||||
c->update = (hmac_update) av_sha512_update;
|
||||
c->final = (hmac_final) av_sha512_final;
|
||||
c->hash = av_sha512_alloc();
|
||||
break;
|
||||
default:
|
||||
av_free(c);
|
||||
return NULL;
|
||||
}
|
||||
if (!c->hash) {
|
||||
av_free(c);
|
||||
return NULL;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
void av_hmac_free(AVHMAC *c)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
av_freep(&c->hash);
|
||||
av_free(c);
|
||||
}
|
||||
|
||||
void av_hmac_init(AVHMAC *c, const uint8_t *key, unsigned int keylen)
|
||||
{
|
||||
int i;
|
||||
uint8_t block[MAX_BLOCKLEN];
|
||||
if (keylen > c->blocklen) {
|
||||
c->init(c->hash);
|
||||
c->update(c->hash, key, keylen);
|
||||
c->final(c->hash, c->key);
|
||||
c->keylen = c->hashlen;
|
||||
} else {
|
||||
memcpy(c->key, key, keylen);
|
||||
c->keylen = keylen;
|
||||
}
|
||||
c->init(c->hash);
|
||||
for (i = 0; i < c->keylen; i++)
|
||||
block[i] = c->key[i] ^ 0x36;
|
||||
for (i = c->keylen; i < c->blocklen; i++)
|
||||
block[i] = 0x36;
|
||||
c->update(c->hash, block, c->blocklen);
|
||||
}
|
||||
|
||||
void av_hmac_update(AVHMAC *c, const uint8_t *data, unsigned int len)
|
||||
{
|
||||
c->update(c->hash, data, len);
|
||||
}
|
||||
|
||||
int av_hmac_final(AVHMAC *c, uint8_t *out, unsigned int outlen)
|
||||
{
|
||||
uint8_t block[MAX_BLOCKLEN];
|
||||
int i;
|
||||
if (outlen < c->hashlen)
|
||||
return AVERROR(EINVAL);
|
||||
c->final(c->hash, out);
|
||||
c->init(c->hash);
|
||||
for (i = 0; i < c->keylen; i++)
|
||||
block[i] = c->key[i] ^ 0x5C;
|
||||
for (i = c->keylen; i < c->blocklen; i++)
|
||||
block[i] = 0x5C;
|
||||
c->update(c->hash, block, c->blocklen);
|
||||
c->update(c->hash, out, c->hashlen);
|
||||
c->final(c->hash, out);
|
||||
return c->hashlen;
|
||||
}
|
||||
|
||||
int av_hmac_calc(AVHMAC *c, const uint8_t *data, unsigned int len,
|
||||
const uint8_t *key, unsigned int keylen,
|
||||
uint8_t *out, unsigned int outlen)
|
||||
{
|
||||
av_hmac_init(c, key, keylen);
|
||||
av_hmac_update(c, data, len);
|
||||
return av_hmac_final(c, out, outlen);
|
||||
}
|
||||
100
media/ffvpx/libavutil/hmac.h
Normal file
100
media/ffvpx/libavutil/hmac.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Martin Storsjo
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_HMAC_H
|
||||
#define AVUTIL_HMAC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "version.h"
|
||||
/**
|
||||
* @defgroup lavu_hmac HMAC
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
enum AVHMACType {
|
||||
AV_HMAC_MD5,
|
||||
AV_HMAC_SHA1,
|
||||
AV_HMAC_SHA224,
|
||||
AV_HMAC_SHA256,
|
||||
AV_HMAC_SHA384 = 12,
|
||||
AV_HMAC_SHA512,
|
||||
};
|
||||
|
||||
typedef struct AVHMAC AVHMAC;
|
||||
|
||||
/**
|
||||
* Allocate an AVHMAC context.
|
||||
* @param type The hash function used for the HMAC.
|
||||
*/
|
||||
AVHMAC *av_hmac_alloc(enum AVHMACType type);
|
||||
|
||||
/**
|
||||
* Free an AVHMAC context.
|
||||
* @param ctx The context to free, may be NULL
|
||||
*/
|
||||
void av_hmac_free(AVHMAC *ctx);
|
||||
|
||||
/**
|
||||
* Initialize an AVHMAC context with an authentication key.
|
||||
* @param ctx The HMAC context
|
||||
* @param key The authentication key
|
||||
* @param keylen The length of the key, in bytes
|
||||
*/
|
||||
void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen);
|
||||
|
||||
/**
|
||||
* Hash data with the HMAC.
|
||||
* @param ctx The HMAC context
|
||||
* @param data The data to hash
|
||||
* @param len The length of the data, in bytes
|
||||
*/
|
||||
void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len);
|
||||
|
||||
/**
|
||||
* Finish hashing and output the HMAC digest.
|
||||
* @param ctx The HMAC context
|
||||
* @param out The output buffer to write the digest into
|
||||
* @param outlen The length of the out buffer, in bytes
|
||||
* @return The number of bytes written to out, or a negative error code.
|
||||
*/
|
||||
int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen);
|
||||
|
||||
/**
|
||||
* Hash an array of data with a key.
|
||||
* @param ctx The HMAC context
|
||||
* @param data The data to hash
|
||||
* @param len The length of the data, in bytes
|
||||
* @param key The authentication key
|
||||
* @param keylen The length of the key, in bytes
|
||||
* @param out The output buffer to write the digest into
|
||||
* @param outlen The length of the out buffer, in bytes
|
||||
* @return The number of bytes written to out, or a negative error code.
|
||||
*/
|
||||
int av_hmac_calc(AVHMAC *ctx, const uint8_t *data, unsigned int len,
|
||||
const uint8_t *key, unsigned int keylen,
|
||||
uint8_t *out, unsigned int outlen);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_HMAC_H */
|
||||
865
media/ffvpx/libavutil/hwcontext.c
Normal file
865
media/ffvpx/libavutil/hwcontext.c
Normal file
|
|
@ -0,0 +1,865 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "common.h"
|
||||
#include "hwcontext.h"
|
||||
#include "hwcontext_internal.h"
|
||||
#include "imgutils.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
#include "pixdesc.h"
|
||||
#include "pixfmt.h"
|
||||
|
||||
static const HWContextType * const hw_table[] = {
|
||||
#if CONFIG_CUDA
|
||||
&ff_hwcontext_type_cuda,
|
||||
#endif
|
||||
#if CONFIG_D3D11VA
|
||||
&ff_hwcontext_type_d3d11va,
|
||||
#endif
|
||||
#if CONFIG_LIBDRM
|
||||
&ff_hwcontext_type_drm,
|
||||
#endif
|
||||
#if CONFIG_DXVA2
|
||||
&ff_hwcontext_type_dxva2,
|
||||
#endif
|
||||
#if CONFIG_QSV
|
||||
&ff_hwcontext_type_qsv,
|
||||
#endif
|
||||
#if CONFIG_VAAPI
|
||||
&ff_hwcontext_type_vaapi,
|
||||
#endif
|
||||
#if CONFIG_VDPAU
|
||||
&ff_hwcontext_type_vdpau,
|
||||
#endif
|
||||
#if CONFIG_VIDEOTOOLBOX
|
||||
&ff_hwcontext_type_videotoolbox,
|
||||
#endif
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *const hw_type_names[] = {
|
||||
[AV_HWDEVICE_TYPE_CUDA] = "cuda",
|
||||
[AV_HWDEVICE_TYPE_DRM] = "drm",
|
||||
[AV_HWDEVICE_TYPE_DXVA2] = "dxva2",
|
||||
[AV_HWDEVICE_TYPE_D3D11VA] = "d3d11va",
|
||||
[AV_HWDEVICE_TYPE_QSV] = "qsv",
|
||||
[AV_HWDEVICE_TYPE_VAAPI] = "vaapi",
|
||||
[AV_HWDEVICE_TYPE_VDPAU] = "vdpau",
|
||||
[AV_HWDEVICE_TYPE_VIDEOTOOLBOX] = "videotoolbox",
|
||||
};
|
||||
|
||||
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
|
||||
{
|
||||
int type;
|
||||
for (type = 0; type < FF_ARRAY_ELEMS(hw_type_names); type++) {
|
||||
if (hw_type_names[type] && !strcmp(hw_type_names[type], name))
|
||||
return type;
|
||||
}
|
||||
return AV_HWDEVICE_TYPE_NONE;
|
||||
}
|
||||
|
||||
const char *av_hwdevice_get_type_name(enum AVHWDeviceType type)
|
||||
{
|
||||
if (type >= 0 && type < FF_ARRAY_ELEMS(hw_type_names))
|
||||
return hw_type_names[type];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev)
|
||||
{
|
||||
enum AVHWDeviceType next;
|
||||
int i, set = 0;
|
||||
for (i = 0; hw_table[i]; i++) {
|
||||
if (prev != AV_HWDEVICE_TYPE_NONE && hw_table[i]->type <= prev)
|
||||
continue;
|
||||
if (!set || hw_table[i]->type < next) {
|
||||
next = hw_table[i]->type;
|
||||
set = 1;
|
||||
}
|
||||
}
|
||||
return set ? next : AV_HWDEVICE_TYPE_NONE;
|
||||
}
|
||||
|
||||
static const AVClass hwdevice_ctx_class = {
|
||||
.class_name = "AVHWDeviceContext",
|
||||
.item_name = av_default_item_name,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
static void hwdevice_ctx_free(void *opaque, uint8_t *data)
|
||||
{
|
||||
AVHWDeviceContext *ctx = (AVHWDeviceContext*)data;
|
||||
|
||||
/* uninit might still want access the hw context and the user
|
||||
* free() callback might destroy it, so uninit has to be called first */
|
||||
if (ctx->internal->hw_type->device_uninit)
|
||||
ctx->internal->hw_type->device_uninit(ctx);
|
||||
|
||||
if (ctx->free)
|
||||
ctx->free(ctx);
|
||||
|
||||
av_buffer_unref(&ctx->internal->source_device);
|
||||
|
||||
av_freep(&ctx->hwctx);
|
||||
av_freep(&ctx->internal->priv);
|
||||
av_freep(&ctx->internal);
|
||||
av_freep(&ctx);
|
||||
}
|
||||
|
||||
AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type)
|
||||
{
|
||||
AVHWDeviceContext *ctx;
|
||||
AVBufferRef *buf;
|
||||
const HWContextType *hw_type = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; hw_table[i]; i++) {
|
||||
if (hw_table[i]->type == type) {
|
||||
hw_type = hw_table[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hw_type)
|
||||
return NULL;
|
||||
|
||||
ctx = av_mallocz(sizeof(*ctx));
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
ctx->internal = av_mallocz(sizeof(*ctx->internal));
|
||||
if (!ctx->internal)
|
||||
goto fail;
|
||||
|
||||
if (hw_type->device_priv_size) {
|
||||
ctx->internal->priv = av_mallocz(hw_type->device_priv_size);
|
||||
if (!ctx->internal->priv)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (hw_type->device_hwctx_size) {
|
||||
ctx->hwctx = av_mallocz(hw_type->device_hwctx_size);
|
||||
if (!ctx->hwctx)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
buf = av_buffer_create((uint8_t*)ctx, sizeof(*ctx),
|
||||
hwdevice_ctx_free, NULL,
|
||||
AV_BUFFER_FLAG_READONLY);
|
||||
if (!buf)
|
||||
goto fail;
|
||||
|
||||
ctx->type = type;
|
||||
ctx->av_class = &hwdevice_ctx_class;
|
||||
|
||||
ctx->internal->hw_type = hw_type;
|
||||
|
||||
return buf;
|
||||
|
||||
fail:
|
||||
if (ctx->internal)
|
||||
av_freep(&ctx->internal->priv);
|
||||
av_freep(&ctx->internal);
|
||||
av_freep(&ctx->hwctx);
|
||||
av_freep(&ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int av_hwdevice_ctx_init(AVBufferRef *ref)
|
||||
{
|
||||
AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data;
|
||||
int ret;
|
||||
|
||||
if (ctx->internal->hw_type->device_init) {
|
||||
ret = ctx->internal->hw_type->device_init(ctx);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
if (ctx->internal->hw_type->device_uninit)
|
||||
ctx->internal->hw_type->device_uninit(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const AVClass hwframe_ctx_class = {
|
||||
.class_name = "AVHWFramesContext",
|
||||
.item_name = av_default_item_name,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
static void hwframe_ctx_free(void *opaque, uint8_t *data)
|
||||
{
|
||||
AVHWFramesContext *ctx = (AVHWFramesContext*)data;
|
||||
|
||||
if (ctx->internal->source_frames) {
|
||||
av_buffer_unref(&ctx->internal->source_frames);
|
||||
|
||||
} else {
|
||||
if (ctx->internal->pool_internal)
|
||||
av_buffer_pool_uninit(&ctx->internal->pool_internal);
|
||||
|
||||
if (ctx->internal->hw_type->frames_uninit)
|
||||
ctx->internal->hw_type->frames_uninit(ctx);
|
||||
|
||||
if (ctx->free)
|
||||
ctx->free(ctx);
|
||||
}
|
||||
|
||||
av_buffer_unref(&ctx->device_ref);
|
||||
|
||||
av_freep(&ctx->hwctx);
|
||||
av_freep(&ctx->internal->priv);
|
||||
av_freep(&ctx->internal);
|
||||
av_freep(&ctx);
|
||||
}
|
||||
|
||||
AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
|
||||
{
|
||||
AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)device_ref_in->data;
|
||||
const HWContextType *hw_type = device_ctx->internal->hw_type;
|
||||
AVHWFramesContext *ctx;
|
||||
AVBufferRef *buf, *device_ref = NULL;
|
||||
|
||||
ctx = av_mallocz(sizeof(*ctx));
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
ctx->internal = av_mallocz(sizeof(*ctx->internal));
|
||||
if (!ctx->internal)
|
||||
goto fail;
|
||||
|
||||
if (hw_type->frames_priv_size) {
|
||||
ctx->internal->priv = av_mallocz(hw_type->frames_priv_size);
|
||||
if (!ctx->internal->priv)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (hw_type->frames_hwctx_size) {
|
||||
ctx->hwctx = av_mallocz(hw_type->frames_hwctx_size);
|
||||
if (!ctx->hwctx)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
device_ref = av_buffer_ref(device_ref_in);
|
||||
if (!device_ref)
|
||||
goto fail;
|
||||
|
||||
buf = av_buffer_create((uint8_t*)ctx, sizeof(*ctx),
|
||||
hwframe_ctx_free, NULL,
|
||||
AV_BUFFER_FLAG_READONLY);
|
||||
if (!buf)
|
||||
goto fail;
|
||||
|
||||
ctx->av_class = &hwframe_ctx_class;
|
||||
ctx->device_ref = device_ref;
|
||||
ctx->device_ctx = device_ctx;
|
||||
ctx->format = AV_PIX_FMT_NONE;
|
||||
ctx->sw_format = AV_PIX_FMT_NONE;
|
||||
|
||||
ctx->internal->hw_type = hw_type;
|
||||
|
||||
return buf;
|
||||
|
||||
fail:
|
||||
if (device_ref)
|
||||
av_buffer_unref(&device_ref);
|
||||
if (ctx->internal)
|
||||
av_freep(&ctx->internal->priv);
|
||||
av_freep(&ctx->internal);
|
||||
av_freep(&ctx->hwctx);
|
||||
av_freep(&ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int hwframe_pool_prealloc(AVBufferRef *ref)
|
||||
{
|
||||
AVHWFramesContext *ctx = (AVHWFramesContext*)ref->data;
|
||||
AVFrame **frames;
|
||||
int i, ret = 0;
|
||||
|
||||
frames = av_mallocz_array(ctx->initial_pool_size, sizeof(*frames));
|
||||
if (!frames)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for (i = 0; i < ctx->initial_pool_size; i++) {
|
||||
frames[i] = av_frame_alloc();
|
||||
if (!frames[i])
|
||||
goto fail;
|
||||
|
||||
ret = av_hwframe_get_buffer(ref, frames[i], 0);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fail:
|
||||
for (i = 0; i < ctx->initial_pool_size; i++)
|
||||
av_frame_free(&frames[i]);
|
||||
av_freep(&frames);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int av_hwframe_ctx_init(AVBufferRef *ref)
|
||||
{
|
||||
AVHWFramesContext *ctx = (AVHWFramesContext*)ref->data;
|
||||
const enum AVPixelFormat *pix_fmt;
|
||||
int ret;
|
||||
|
||||
if (ctx->internal->source_frames) {
|
||||
/* A derived frame context is already initialised. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* validate the pixel format */
|
||||
for (pix_fmt = ctx->internal->hw_type->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++) {
|
||||
if (*pix_fmt == ctx->format)
|
||||
break;
|
||||
}
|
||||
if (*pix_fmt == AV_PIX_FMT_NONE) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"The hardware pixel format '%s' is not supported by the device type '%s'\n",
|
||||
av_get_pix_fmt_name(ctx->format), ctx->internal->hw_type->name);
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
/* validate the dimensions */
|
||||
ret = av_image_check_size(ctx->width, ctx->height, 0, ctx);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* format-specific init */
|
||||
if (ctx->internal->hw_type->frames_init) {
|
||||
ret = ctx->internal->hw_type->frames_init(ctx);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ctx->internal->pool_internal && !ctx->pool)
|
||||
ctx->pool = ctx->internal->pool_internal;
|
||||
|
||||
/* preallocate the frames in the pool, if requested */
|
||||
if (ctx->initial_pool_size > 0) {
|
||||
ret = hwframe_pool_prealloc(ref);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
if (ctx->internal->hw_type->frames_uninit)
|
||||
ctx->internal->hw_type->frames_uninit(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ref,
|
||||
enum AVHWFrameTransferDirection dir,
|
||||
enum AVPixelFormat **formats, int flags)
|
||||
{
|
||||
AVHWFramesContext *ctx = (AVHWFramesContext*)hwframe_ref->data;
|
||||
|
||||
if (!ctx->internal->hw_type->transfer_get_formats)
|
||||
return AVERROR(ENOSYS);
|
||||
|
||||
return ctx->internal->hw_type->transfer_get_formats(ctx, dir, formats);
|
||||
}
|
||||
|
||||
static int transfer_data_alloc(AVFrame *dst, const AVFrame *src, int flags)
|
||||
{
|
||||
AVHWFramesContext *ctx = (AVHWFramesContext*)src->hw_frames_ctx->data;
|
||||
AVFrame *frame_tmp;
|
||||
int ret = 0;
|
||||
|
||||
frame_tmp = av_frame_alloc();
|
||||
if (!frame_tmp)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
/* if the format is set, use that
|
||||
* otherwise pick the first supported one */
|
||||
if (dst->format >= 0) {
|
||||
frame_tmp->format = dst->format;
|
||||
} else {
|
||||
enum AVPixelFormat *formats;
|
||||
|
||||
ret = av_hwframe_transfer_get_formats(src->hw_frames_ctx,
|
||||
AV_HWFRAME_TRANSFER_DIRECTION_FROM,
|
||||
&formats, 0);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
frame_tmp->format = formats[0];
|
||||
av_freep(&formats);
|
||||
}
|
||||
frame_tmp->width = ctx->width;
|
||||
frame_tmp->height = ctx->height;
|
||||
|
||||
ret = av_frame_get_buffer(frame_tmp, 32);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
ret = av_hwframe_transfer_data(frame_tmp, src, flags);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
frame_tmp->width = src->width;
|
||||
frame_tmp->height = src->height;
|
||||
|
||||
av_frame_move_ref(dst, frame_tmp);
|
||||
|
||||
fail:
|
||||
av_frame_free(&frame_tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
|
||||
{
|
||||
AVHWFramesContext *ctx;
|
||||
int ret;
|
||||
|
||||
if (!dst->buf[0])
|
||||
return transfer_data_alloc(dst, src, flags);
|
||||
|
||||
if (src->hw_frames_ctx) {
|
||||
ctx = (AVHWFramesContext*)src->hw_frames_ctx->data;
|
||||
|
||||
ret = ctx->internal->hw_type->transfer_data_from(ctx, dst, src);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else if (dst->hw_frames_ctx) {
|
||||
ctx = (AVHWFramesContext*)dst->hw_frames_ctx->data;
|
||||
|
||||
ret = ctx->internal->hw_type->transfer_data_to(ctx, dst, src);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else
|
||||
return AVERROR(ENOSYS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
|
||||
{
|
||||
AVHWFramesContext *ctx = (AVHWFramesContext*)hwframe_ref->data;
|
||||
int ret;
|
||||
|
||||
if (ctx->internal->source_frames) {
|
||||
// This is a derived frame context, so we allocate in the source
|
||||
// and map the frame immediately.
|
||||
AVFrame *src_frame;
|
||||
|
||||
frame->format = ctx->format;
|
||||
frame->hw_frames_ctx = av_buffer_ref(hwframe_ref);
|
||||
if (!frame->hw_frames_ctx)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
src_frame = av_frame_alloc();
|
||||
if (!src_frame)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ret = av_hwframe_get_buffer(ctx->internal->source_frames,
|
||||
src_frame, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = av_hwframe_map(frame, src_frame,
|
||||
ctx->internal->source_allocation_map_flags);
|
||||
if (ret) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Failed to map frame into derived "
|
||||
"frame context: %d.\n", ret);
|
||||
av_frame_free(&src_frame);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Free the source frame immediately - the mapped frame still
|
||||
// contains a reference to it.
|
||||
av_frame_free(&src_frame);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!ctx->internal->hw_type->frames_get_buffer)
|
||||
return AVERROR(ENOSYS);
|
||||
|
||||
if (!ctx->pool)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
frame->hw_frames_ctx = av_buffer_ref(hwframe_ref);
|
||||
if (!frame->hw_frames_ctx)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ret = ctx->internal->hw_type->frames_get_buffer(ctx, frame);
|
||||
if (ret < 0) {
|
||||
av_buffer_unref(&frame->hw_frames_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *av_hwdevice_hwconfig_alloc(AVBufferRef *ref)
|
||||
{
|
||||
AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data;
|
||||
const HWContextType *hw_type = ctx->internal->hw_type;
|
||||
|
||||
if (hw_type->device_hwconfig_size == 0)
|
||||
return NULL;
|
||||
|
||||
return av_mallocz(hw_type->device_hwconfig_size);
|
||||
}
|
||||
|
||||
AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref,
|
||||
const void *hwconfig)
|
||||
{
|
||||
AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data;
|
||||
const HWContextType *hw_type = ctx->internal->hw_type;
|
||||
AVHWFramesConstraints *constraints;
|
||||
|
||||
if (!hw_type->frames_get_constraints)
|
||||
return NULL;
|
||||
|
||||
constraints = av_mallocz(sizeof(*constraints));
|
||||
if (!constraints)
|
||||
return NULL;
|
||||
|
||||
constraints->min_width = constraints->min_height = 0;
|
||||
constraints->max_width = constraints->max_height = INT_MAX;
|
||||
|
||||
if (hw_type->frames_get_constraints(ctx, hwconfig, constraints) >= 0) {
|
||||
return constraints;
|
||||
} else {
|
||||
av_hwframe_constraints_free(&constraints);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
|
||||
{
|
||||
if (*constraints) {
|
||||
av_freep(&(*constraints)->valid_hw_formats);
|
||||
av_freep(&(*constraints)->valid_sw_formats);
|
||||
}
|
||||
av_freep(constraints);
|
||||
}
|
||||
|
||||
int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type,
|
||||
const char *device, AVDictionary *opts, int flags)
|
||||
{
|
||||
AVBufferRef *device_ref = NULL;
|
||||
AVHWDeviceContext *device_ctx;
|
||||
int ret = 0;
|
||||
|
||||
device_ref = av_hwdevice_ctx_alloc(type);
|
||||
if (!device_ref) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
device_ctx = (AVHWDeviceContext*)device_ref->data;
|
||||
|
||||
if (!device_ctx->internal->hw_type->device_create) {
|
||||
ret = AVERROR(ENOSYS);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = device_ctx->internal->hw_type->device_create(device_ctx, device,
|
||||
opts, flags);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
ret = av_hwdevice_ctx_init(device_ref);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
*pdevice_ref = device_ref;
|
||||
return 0;
|
||||
fail:
|
||||
av_buffer_unref(&device_ref);
|
||||
*pdevice_ref = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
|
||||
enum AVHWDeviceType type,
|
||||
AVBufferRef *src_ref, int flags)
|
||||
{
|
||||
AVBufferRef *dst_ref = NULL, *tmp_ref;
|
||||
AVHWDeviceContext *dst_ctx, *tmp_ctx;
|
||||
int ret = 0;
|
||||
|
||||
tmp_ref = src_ref;
|
||||
while (tmp_ref) {
|
||||
tmp_ctx = (AVHWDeviceContext*)tmp_ref->data;
|
||||
if (tmp_ctx->type == type) {
|
||||
dst_ref = av_buffer_ref(tmp_ref);
|
||||
if (!dst_ref) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
tmp_ref = tmp_ctx->internal->source_device;
|
||||
}
|
||||
|
||||
dst_ref = av_hwdevice_ctx_alloc(type);
|
||||
if (!dst_ref) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
dst_ctx = (AVHWDeviceContext*)dst_ref->data;
|
||||
|
||||
tmp_ref = src_ref;
|
||||
while (tmp_ref) {
|
||||
tmp_ctx = (AVHWDeviceContext*)tmp_ref->data;
|
||||
if (dst_ctx->internal->hw_type->device_derive) {
|
||||
ret = dst_ctx->internal->hw_type->device_derive(dst_ctx,
|
||||
tmp_ctx,
|
||||
flags);
|
||||
if (ret == 0) {
|
||||
dst_ctx->internal->source_device = av_buffer_ref(src_ref);
|
||||
if (!dst_ctx->internal->source_device) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
if (ret != AVERROR(ENOSYS))
|
||||
goto fail;
|
||||
}
|
||||
tmp_ref = tmp_ctx->internal->source_device;
|
||||
}
|
||||
|
||||
ret = AVERROR(ENOSYS);
|
||||
goto fail;
|
||||
|
||||
done:
|
||||
ret = av_hwdevice_ctx_init(dst_ref);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
*dst_ref_ptr = dst_ref;
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
av_buffer_unref(&dst_ref);
|
||||
*dst_ref_ptr = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ff_hwframe_unmap(void *opaque, uint8_t *data)
|
||||
{
|
||||
HWMapDescriptor *hwmap = (HWMapDescriptor*)data;
|
||||
AVHWFramesContext *ctx = opaque;
|
||||
|
||||
if (hwmap->unmap)
|
||||
hwmap->unmap(ctx, hwmap);
|
||||
|
||||
av_frame_free(&hwmap->source);
|
||||
|
||||
av_buffer_unref(&hwmap->hw_frames_ctx);
|
||||
|
||||
av_free(hwmap);
|
||||
}
|
||||
|
||||
int ff_hwframe_map_create(AVBufferRef *hwframe_ref,
|
||||
AVFrame *dst, const AVFrame *src,
|
||||
void (*unmap)(AVHWFramesContext *ctx,
|
||||
HWMapDescriptor *hwmap),
|
||||
void *priv)
|
||||
{
|
||||
AVHWFramesContext *ctx = (AVHWFramesContext*)hwframe_ref->data;
|
||||
HWMapDescriptor *hwmap;
|
||||
int ret;
|
||||
|
||||
hwmap = av_mallocz(sizeof(*hwmap));
|
||||
if (!hwmap) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hwmap->source = av_frame_alloc();
|
||||
if (!hwmap->source) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
ret = av_frame_ref(hwmap->source, src);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
hwmap->hw_frames_ctx = av_buffer_ref(hwframe_ref);
|
||||
if (!hwmap->hw_frames_ctx) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hwmap->unmap = unmap;
|
||||
hwmap->priv = priv;
|
||||
|
||||
dst->buf[0] = av_buffer_create((uint8_t*)hwmap, sizeof(*hwmap),
|
||||
&ff_hwframe_unmap, ctx, 0);
|
||||
if (!dst->buf[0]) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (hwmap) {
|
||||
av_buffer_unref(&hwmap->hw_frames_ctx);
|
||||
av_frame_free(&hwmap->source);
|
||||
}
|
||||
av_free(hwmap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags)
|
||||
{
|
||||
AVHWFramesContext *src_frames, *dst_frames;
|
||||
HWMapDescriptor *hwmap;
|
||||
int ret;
|
||||
|
||||
if (src->hw_frames_ctx && dst->hw_frames_ctx) {
|
||||
src_frames = (AVHWFramesContext*)src->hw_frames_ctx->data;
|
||||
dst_frames = (AVHWFramesContext*)dst->hw_frames_ctx->data;
|
||||
|
||||
if ((src_frames == dst_frames &&
|
||||
src->format == dst_frames->sw_format &&
|
||||
dst->format == dst_frames->format) ||
|
||||
(src_frames->internal->source_frames &&
|
||||
src_frames->internal->source_frames->data ==
|
||||
(uint8_t*)dst_frames)) {
|
||||
// This is an unmap operation. We don't need to directly
|
||||
// do anything here other than fill in the original frame,
|
||||
// because the real unmap will be invoked when the last
|
||||
// reference to the mapped frame disappears.
|
||||
if (!src->buf[0]) {
|
||||
av_log(src_frames, AV_LOG_ERROR, "Invalid mapping "
|
||||
"found when attempting unmap.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
hwmap = (HWMapDescriptor*)src->buf[0]->data;
|
||||
av_frame_unref(dst);
|
||||
return av_frame_ref(dst, hwmap->source);
|
||||
}
|
||||
}
|
||||
|
||||
if (src->hw_frames_ctx) {
|
||||
src_frames = (AVHWFramesContext*)src->hw_frames_ctx->data;
|
||||
|
||||
if (src_frames->format == src->format &&
|
||||
src_frames->internal->hw_type->map_from) {
|
||||
ret = src_frames->internal->hw_type->map_from(src_frames,
|
||||
dst, src, flags);
|
||||
if (ret != AVERROR(ENOSYS))
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (dst->hw_frames_ctx) {
|
||||
dst_frames = (AVHWFramesContext*)dst->hw_frames_ctx->data;
|
||||
|
||||
if (dst_frames->format == dst->format &&
|
||||
dst_frames->internal->hw_type->map_to) {
|
||||
ret = dst_frames->internal->hw_type->map_to(dst_frames,
|
||||
dst, src, flags);
|
||||
if (ret != AVERROR(ENOSYS))
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx,
|
||||
enum AVPixelFormat format,
|
||||
AVBufferRef *derived_device_ctx,
|
||||
AVBufferRef *source_frame_ctx,
|
||||
int flags)
|
||||
{
|
||||
AVBufferRef *dst_ref = NULL;
|
||||
AVHWFramesContext *dst = NULL;
|
||||
AVHWFramesContext *src = (AVHWFramesContext*)source_frame_ctx->data;
|
||||
int ret;
|
||||
|
||||
if (src->internal->source_frames) {
|
||||
AVHWFramesContext *src_src =
|
||||
(AVHWFramesContext*)src->internal->source_frames->data;
|
||||
AVHWDeviceContext *dst_dev =
|
||||
(AVHWDeviceContext*)derived_device_ctx->data;
|
||||
|
||||
if (src_src->device_ctx == dst_dev) {
|
||||
// This is actually an unmapping, so we just return a
|
||||
// reference to the source frame context.
|
||||
*derived_frame_ctx =
|
||||
av_buffer_ref(src->internal->source_frames);
|
||||
if (!*derived_frame_ctx) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
dst_ref = av_hwframe_ctx_alloc(derived_device_ctx);
|
||||
if (!dst_ref) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dst = (AVHWFramesContext*)dst_ref->data;
|
||||
|
||||
dst->format = format;
|
||||
dst->sw_format = src->sw_format;
|
||||
dst->width = src->width;
|
||||
dst->height = src->height;
|
||||
|
||||
dst->internal->source_frames = av_buffer_ref(source_frame_ctx);
|
||||
if (!dst->internal->source_frames) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dst->internal->source_allocation_map_flags =
|
||||
flags & (AV_HWFRAME_MAP_READ |
|
||||
AV_HWFRAME_MAP_WRITE |
|
||||
AV_HWFRAME_MAP_OVERWRITE |
|
||||
AV_HWFRAME_MAP_DIRECT);
|
||||
|
||||
ret = AVERROR(ENOSYS);
|
||||
if (src->internal->hw_type->frames_derive_from)
|
||||
ret = src->internal->hw_type->frames_derive_from(dst, src, flags);
|
||||
if (ret == AVERROR(ENOSYS) &&
|
||||
dst->internal->hw_type->frames_derive_to)
|
||||
ret = dst->internal->hw_type->frames_derive_to(dst, src, flags);
|
||||
if (ret == AVERROR(ENOSYS))
|
||||
ret = 0;
|
||||
if (ret)
|
||||
goto fail;
|
||||
|
||||
*derived_frame_ctx = dst_ref;
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (dst)
|
||||
av_buffer_unref(&dst->internal->source_frames);
|
||||
av_buffer_unref(&dst_ref);
|
||||
return ret;
|
||||
}
|
||||
418
media/ffvpx/libavutil/hwcontext_cuda.c
Normal file
418
media/ffvpx/libavutil/hwcontext_cuda.c
Normal file
|
|
@ -0,0 +1,418 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "buffer.h"
|
||||
#include "common.h"
|
||||
#include "hwcontext.h"
|
||||
#include "hwcontext_internal.h"
|
||||
#include "hwcontext_cuda_internal.h"
|
||||
#include "mem.h"
|
||||
#include "pixdesc.h"
|
||||
#include "pixfmt.h"
|
||||
|
||||
#define CUDA_FRAME_ALIGNMENT 256
|
||||
|
||||
typedef struct CUDAFramesContext {
|
||||
int shift_width, shift_height;
|
||||
} CUDAFramesContext;
|
||||
|
||||
static const enum AVPixelFormat supported_formats[] = {
|
||||
AV_PIX_FMT_NV12,
|
||||
AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_YUV444P,
|
||||
AV_PIX_FMT_P010,
|
||||
AV_PIX_FMT_P016,
|
||||
AV_PIX_FMT_YUV444P16,
|
||||
};
|
||||
|
||||
static int cuda_frames_get_constraints(AVHWDeviceContext *ctx,
|
||||
const void *hwconfig,
|
||||
AVHWFramesConstraints *constraints)
|
||||
{
|
||||
int i;
|
||||
|
||||
constraints->valid_sw_formats = av_malloc_array(FF_ARRAY_ELEMS(supported_formats) + 1,
|
||||
sizeof(*constraints->valid_sw_formats));
|
||||
if (!constraints->valid_sw_formats)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
|
||||
constraints->valid_sw_formats[i] = supported_formats[i];
|
||||
constraints->valid_sw_formats[FF_ARRAY_ELEMS(supported_formats)] = AV_PIX_FMT_NONE;
|
||||
|
||||
constraints->valid_hw_formats = av_malloc_array(2, sizeof(*constraints->valid_hw_formats));
|
||||
if (!constraints->valid_hw_formats)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
constraints->valid_hw_formats[0] = AV_PIX_FMT_CUDA;
|
||||
constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cuda_buffer_free(void *opaque, uint8_t *data)
|
||||
{
|
||||
AVHWFramesContext *ctx = opaque;
|
||||
AVCUDADeviceContext *hwctx = ctx->device_ctx->hwctx;
|
||||
CudaFunctions *cu = hwctx->internal->cuda_dl;
|
||||
|
||||
CUcontext dummy;
|
||||
|
||||
cu->cuCtxPushCurrent(hwctx->cuda_ctx);
|
||||
|
||||
cu->cuMemFree((CUdeviceptr)data);
|
||||
|
||||
cu->cuCtxPopCurrent(&dummy);
|
||||
}
|
||||
|
||||
static AVBufferRef *cuda_pool_alloc(void *opaque, int size)
|
||||
{
|
||||
AVHWFramesContext *ctx = opaque;
|
||||
AVCUDADeviceContext *hwctx = ctx->device_ctx->hwctx;
|
||||
CudaFunctions *cu = hwctx->internal->cuda_dl;
|
||||
|
||||
AVBufferRef *ret = NULL;
|
||||
CUcontext dummy = NULL;
|
||||
CUdeviceptr data;
|
||||
CUresult err;
|
||||
|
||||
err = cu->cuCtxPushCurrent(hwctx->cuda_ctx);
|
||||
if (err != CUDA_SUCCESS) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Error setting current CUDA context\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = cu->cuMemAlloc(&data, size);
|
||||
if (err != CUDA_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
ret = av_buffer_create((uint8_t*)data, size, cuda_buffer_free, ctx, 0);
|
||||
if (!ret) {
|
||||
cu->cuMemFree(data);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fail:
|
||||
cu->cuCtxPopCurrent(&dummy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cuda_frames_init(AVHWFramesContext *ctx)
|
||||
{
|
||||
CUDAFramesContext *priv = ctx->internal->priv;
|
||||
int aligned_width = FFALIGN(ctx->width, CUDA_FRAME_ALIGNMENT);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) {
|
||||
if (ctx->sw_format == supported_formats[i])
|
||||
break;
|
||||
}
|
||||
if (i == FF_ARRAY_ELEMS(supported_formats)) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Pixel format '%s' is not supported\n",
|
||||
av_get_pix_fmt_name(ctx->sw_format));
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
av_pix_fmt_get_chroma_sub_sample(ctx->sw_format, &priv->shift_width, &priv->shift_height);
|
||||
|
||||
if (!ctx->pool) {
|
||||
int size;
|
||||
|
||||
switch (ctx->sw_format) {
|
||||
case AV_PIX_FMT_NV12:
|
||||
case AV_PIX_FMT_YUV420P:
|
||||
size = aligned_width * ctx->height * 3 / 2;
|
||||
break;
|
||||
case AV_PIX_FMT_YUV444P:
|
||||
case AV_PIX_FMT_P010:
|
||||
case AV_PIX_FMT_P016:
|
||||
size = aligned_width * ctx->height * 3;
|
||||
break;
|
||||
case AV_PIX_FMT_YUV444P16:
|
||||
size = aligned_width * ctx->height * 6;
|
||||
break;
|
||||
default:
|
||||
av_log(ctx, AV_LOG_ERROR, "BUG: Pixel format missing from size calculation.");
|
||||
return AVERROR_BUG;
|
||||
}
|
||||
|
||||
ctx->internal->pool_internal = av_buffer_pool_init2(size, ctx, cuda_pool_alloc, NULL);
|
||||
if (!ctx->internal->pool_internal)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
|
||||
{
|
||||
int aligned_width;
|
||||
int width_in_bytes = ctx->width;
|
||||
|
||||
if (ctx->sw_format == AV_PIX_FMT_P010 ||
|
||||
ctx->sw_format == AV_PIX_FMT_P016 ||
|
||||
ctx->sw_format == AV_PIX_FMT_YUV444P16) {
|
||||
width_in_bytes *= 2;
|
||||
}
|
||||
aligned_width = FFALIGN(width_in_bytes, CUDA_FRAME_ALIGNMENT);
|
||||
|
||||
frame->buf[0] = av_buffer_pool_get(ctx->pool);
|
||||
if (!frame->buf[0])
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
switch (ctx->sw_format) {
|
||||
case AV_PIX_FMT_NV12:
|
||||
case AV_PIX_FMT_P010:
|
||||
case AV_PIX_FMT_P016:
|
||||
frame->data[0] = frame->buf[0]->data;
|
||||
frame->data[1] = frame->data[0] + aligned_width * ctx->height;
|
||||
frame->linesize[0] = aligned_width;
|
||||
frame->linesize[1] = aligned_width;
|
||||
break;
|
||||
case AV_PIX_FMT_YUV420P:
|
||||
frame->data[0] = frame->buf[0]->data;
|
||||
frame->data[2] = frame->data[0] + aligned_width * ctx->height;
|
||||
frame->data[1] = frame->data[2] + aligned_width * ctx->height / 4;
|
||||
frame->linesize[0] = aligned_width;
|
||||
frame->linesize[1] = aligned_width / 2;
|
||||
frame->linesize[2] = aligned_width / 2;
|
||||
break;
|
||||
case AV_PIX_FMT_YUV444P:
|
||||
case AV_PIX_FMT_YUV444P16:
|
||||
frame->data[0] = frame->buf[0]->data;
|
||||
frame->data[1] = frame->data[0] + aligned_width * ctx->height;
|
||||
frame->data[2] = frame->data[1] + aligned_width * ctx->height;
|
||||
frame->linesize[0] = aligned_width;
|
||||
frame->linesize[1] = aligned_width;
|
||||
frame->linesize[2] = aligned_width;
|
||||
break;
|
||||
default:
|
||||
av_frame_unref(frame);
|
||||
return AVERROR_BUG;
|
||||
}
|
||||
|
||||
frame->format = AV_PIX_FMT_CUDA;
|
||||
frame->width = ctx->width;
|
||||
frame->height = ctx->height;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cuda_transfer_get_formats(AVHWFramesContext *ctx,
|
||||
enum AVHWFrameTransferDirection dir,
|
||||
enum AVPixelFormat **formats)
|
||||
{
|
||||
enum AVPixelFormat *fmts;
|
||||
|
||||
fmts = av_malloc_array(2, sizeof(*fmts));
|
||||
if (!fmts)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
fmts[0] = ctx->sw_format;
|
||||
fmts[1] = AV_PIX_FMT_NONE;
|
||||
|
||||
*formats = fmts;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cuda_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
|
||||
const AVFrame *src)
|
||||
{
|
||||
CUDAFramesContext *priv = ctx->internal->priv;
|
||||
AVCUDADeviceContext *device_hwctx = ctx->device_ctx->hwctx;
|
||||
CudaFunctions *cu = device_hwctx->internal->cuda_dl;
|
||||
|
||||
CUcontext dummy;
|
||||
CUresult err;
|
||||
int i;
|
||||
|
||||
err = cu->cuCtxPushCurrent(device_hwctx->cuda_ctx);
|
||||
if (err != CUDA_SUCCESS)
|
||||
return AVERROR_UNKNOWN;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(src->data) && src->data[i]; i++) {
|
||||
CUDA_MEMCPY2D cpy = {
|
||||
.srcMemoryType = CU_MEMORYTYPE_DEVICE,
|
||||
.dstMemoryType = CU_MEMORYTYPE_HOST,
|
||||
.srcDevice = (CUdeviceptr)src->data[i],
|
||||
.dstHost = dst->data[i],
|
||||
.srcPitch = src->linesize[i],
|
||||
.dstPitch = dst->linesize[i],
|
||||
.WidthInBytes = FFMIN(src->linesize[i], dst->linesize[i]),
|
||||
.Height = src->height >> (i ? priv->shift_height : 0),
|
||||
};
|
||||
|
||||
err = cu->cuMemcpy2D(&cpy);
|
||||
if (err != CUDA_SUCCESS) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Error transferring the data from the CUDA frame\n");
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
cu->cuCtxPopCurrent(&dummy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cuda_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
|
||||
const AVFrame *src)
|
||||
{
|
||||
CUDAFramesContext *priv = ctx->internal->priv;
|
||||
AVCUDADeviceContext *device_hwctx = ctx->device_ctx->hwctx;
|
||||
CudaFunctions *cu = device_hwctx->internal->cuda_dl;
|
||||
|
||||
CUcontext dummy;
|
||||
CUresult err;
|
||||
int i;
|
||||
|
||||
err = cu->cuCtxPushCurrent(device_hwctx->cuda_ctx);
|
||||
if (err != CUDA_SUCCESS)
|
||||
return AVERROR_UNKNOWN;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(src->data) && src->data[i]; i++) {
|
||||
CUDA_MEMCPY2D cpy = {
|
||||
.srcMemoryType = CU_MEMORYTYPE_HOST,
|
||||
.dstMemoryType = CU_MEMORYTYPE_DEVICE,
|
||||
.srcHost = src->data[i],
|
||||
.dstDevice = (CUdeviceptr)dst->data[i],
|
||||
.srcPitch = src->linesize[i],
|
||||
.dstPitch = dst->linesize[i],
|
||||
.WidthInBytes = FFMIN(src->linesize[i], dst->linesize[i]),
|
||||
.Height = src->height >> (i ? priv->shift_height : 0),
|
||||
};
|
||||
|
||||
err = cu->cuMemcpy2D(&cpy);
|
||||
if (err != CUDA_SUCCESS) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Error transferring the data from the CUDA frame\n");
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
cu->cuCtxPopCurrent(&dummy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cuda_device_uninit(AVHWDeviceContext *ctx)
|
||||
{
|
||||
AVCUDADeviceContext *hwctx = ctx->hwctx;
|
||||
|
||||
if (hwctx->internal) {
|
||||
if (hwctx->internal->is_allocated && hwctx->cuda_ctx) {
|
||||
hwctx->internal->cuda_dl->cuCtxDestroy(hwctx->cuda_ctx);
|
||||
hwctx->cuda_ctx = NULL;
|
||||
}
|
||||
cuda_free_functions(&hwctx->internal->cuda_dl);
|
||||
}
|
||||
|
||||
av_freep(&hwctx->internal);
|
||||
}
|
||||
|
||||
static int cuda_device_init(AVHWDeviceContext *ctx)
|
||||
{
|
||||
AVCUDADeviceContext *hwctx = ctx->hwctx;
|
||||
int ret;
|
||||
|
||||
if (!hwctx->internal) {
|
||||
hwctx->internal = av_mallocz(sizeof(*hwctx->internal));
|
||||
if (!hwctx->internal)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
if (!hwctx->internal->cuda_dl) {
|
||||
ret = cuda_load_functions(&hwctx->internal->cuda_dl);
|
||||
if (ret < 0) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Could not dynamically load CUDA\n");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
cuda_device_uninit(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cuda_device_create(AVHWDeviceContext *ctx, const char *device,
|
||||
AVDictionary *opts, int flags)
|
||||
{
|
||||
AVCUDADeviceContext *hwctx = ctx->hwctx;
|
||||
CudaFunctions *cu;
|
||||
CUdevice cu_device;
|
||||
CUcontext dummy;
|
||||
CUresult err;
|
||||
int device_idx = 0;
|
||||
|
||||
if (device)
|
||||
device_idx = strtol(device, NULL, 0);
|
||||
|
||||
if (cuda_device_init(ctx) < 0)
|
||||
goto error;
|
||||
|
||||
cu = hwctx->internal->cuda_dl;
|
||||
|
||||
err = cu->cuInit(0);
|
||||
if (err != CUDA_SUCCESS) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Could not initialize the CUDA driver API\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
err = cu->cuDeviceGet(&cu_device, device_idx);
|
||||
if (err != CUDA_SUCCESS) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Could not get the device number %d\n", device_idx);
|
||||
goto error;
|
||||
}
|
||||
|
||||
err = cu->cuCtxCreate(&hwctx->cuda_ctx, CU_CTX_SCHED_BLOCKING_SYNC, cu_device);
|
||||
if (err != CUDA_SUCCESS) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Error creating a CUDA context\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
cu->cuCtxPopCurrent(&dummy);
|
||||
|
||||
hwctx->internal->is_allocated = 1;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
cuda_device_uninit(ctx);
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
const HWContextType ff_hwcontext_type_cuda = {
|
||||
.type = AV_HWDEVICE_TYPE_CUDA,
|
||||
.name = "CUDA",
|
||||
|
||||
.device_hwctx_size = sizeof(AVCUDADeviceContext),
|
||||
.frames_priv_size = sizeof(CUDAFramesContext),
|
||||
|
||||
.device_create = cuda_device_create,
|
||||
.device_init = cuda_device_init,
|
||||
.device_uninit = cuda_device_uninit,
|
||||
.frames_get_constraints = cuda_frames_get_constraints,
|
||||
.frames_init = cuda_frames_init,
|
||||
.frames_get_buffer = cuda_get_buffer,
|
||||
.transfer_get_formats = cuda_transfer_get_formats,
|
||||
.transfer_data_to = cuda_transfer_data_to,
|
||||
.transfer_data_from = cuda_transfer_data_from,
|
||||
|
||||
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE },
|
||||
};
|
||||
51
media/ffvpx/libavutil/hwcontext_cuda.h
Normal file
51
media/ffvpx/libavutil/hwcontext_cuda.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AVUTIL_HWCONTEXT_CUDA_H
|
||||
#define AVUTIL_HWCONTEXT_CUDA_H
|
||||
|
||||
#ifndef CUDA_VERSION
|
||||
#include <cuda.h>
|
||||
#endif
|
||||
|
||||
#include "pixfmt.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* An API-specific header for AV_HWDEVICE_TYPE_CUDA.
|
||||
*
|
||||
* This API supports dynamic frame pools. AVHWFramesContext.pool must return
|
||||
* AVBufferRefs whose data pointer is a CUdeviceptr.
|
||||
*/
|
||||
|
||||
typedef struct AVCUDADeviceContextInternal AVCUDADeviceContextInternal;
|
||||
|
||||
/**
|
||||
* This struct is allocated as AVHWDeviceContext.hwctx
|
||||
*/
|
||||
typedef struct AVCUDADeviceContext {
|
||||
CUcontext cuda_ctx;
|
||||
AVCUDADeviceContextInternal *internal;
|
||||
} AVCUDADeviceContext;
|
||||
|
||||
/**
|
||||
* AVHWFramesContext.hwctx is currently not used
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_HWCONTEXT_CUDA_H */
|
||||
37
media/ffvpx/libavutil/hwcontext_cuda_internal.h
Normal file
37
media/ffvpx/libavutil/hwcontext_cuda_internal.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AVUTIL_HWCONTEXT_CUDA_INTERNAL_H
|
||||
#define AVUTIL_HWCONTEXT_CUDA_INTERNAL_H
|
||||
|
||||
#include "compat/cuda/dynlink_loader.h"
|
||||
#include "hwcontext_cuda.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* FFmpeg internal API for CUDA.
|
||||
*/
|
||||
|
||||
struct AVCUDADeviceContextInternal {
|
||||
CudaFunctions *cuda_dl;
|
||||
int is_allocated;
|
||||
};
|
||||
|
||||
#endif /* AVUTIL_HWCONTEXT_CUDA_INTERNAL_H */
|
||||
|
||||
169
media/ffvpx/libavutil/hwcontext_internal.h
Normal file
169
media/ffvpx/libavutil/hwcontext_internal.h
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_HWCONTEXT_INTERNAL_H
|
||||
#define AVUTIL_HWCONTEXT_INTERNAL_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "buffer.h"
|
||||
#include "hwcontext.h"
|
||||
#include "frame.h"
|
||||
#include "pixfmt.h"
|
||||
|
||||
typedef struct HWContextType {
|
||||
enum AVHWDeviceType type;
|
||||
const char *name;
|
||||
|
||||
/**
|
||||
* An array of pixel formats supported by the AVHWFramesContext instances
|
||||
* Terminated by AV_PIX_FMT_NONE.
|
||||
*/
|
||||
const enum AVPixelFormat *pix_fmts;
|
||||
|
||||
/**
|
||||
* size of the public hardware-specific context,
|
||||
* i.e. AVHWDeviceContext.hwctx
|
||||
*/
|
||||
size_t device_hwctx_size;
|
||||
/**
|
||||
* size of the private data, i.e.
|
||||
* AVHWDeviceInternal.priv
|
||||
*/
|
||||
size_t device_priv_size;
|
||||
|
||||
/**
|
||||
* Size of the hardware-specific device configuration.
|
||||
* (Used to query hwframe constraints.)
|
||||
*/
|
||||
size_t device_hwconfig_size;
|
||||
|
||||
/**
|
||||
* size of the public frame pool hardware-specific context,
|
||||
* i.e. AVHWFramesContext.hwctx
|
||||
*/
|
||||
size_t frames_hwctx_size;
|
||||
/**
|
||||
* size of the private data, i.e.
|
||||
* AVHWFramesInternal.priv
|
||||
*/
|
||||
size_t frames_priv_size;
|
||||
|
||||
int (*device_create)(AVHWDeviceContext *ctx, const char *device,
|
||||
AVDictionary *opts, int flags);
|
||||
int (*device_derive)(AVHWDeviceContext *dst_ctx,
|
||||
AVHWDeviceContext *src_ctx, int flags);
|
||||
|
||||
int (*device_init)(AVHWDeviceContext *ctx);
|
||||
void (*device_uninit)(AVHWDeviceContext *ctx);
|
||||
|
||||
int (*frames_get_constraints)(AVHWDeviceContext *ctx,
|
||||
const void *hwconfig,
|
||||
AVHWFramesConstraints *constraints);
|
||||
|
||||
int (*frames_init)(AVHWFramesContext *ctx);
|
||||
void (*frames_uninit)(AVHWFramesContext *ctx);
|
||||
|
||||
int (*frames_get_buffer)(AVHWFramesContext *ctx, AVFrame *frame);
|
||||
int (*transfer_get_formats)(AVHWFramesContext *ctx,
|
||||
enum AVHWFrameTransferDirection dir,
|
||||
enum AVPixelFormat **formats);
|
||||
int (*transfer_data_to)(AVHWFramesContext *ctx, AVFrame *dst,
|
||||
const AVFrame *src);
|
||||
int (*transfer_data_from)(AVHWFramesContext *ctx, AVFrame *dst,
|
||||
const AVFrame *src);
|
||||
|
||||
int (*map_to)(AVHWFramesContext *ctx, AVFrame *dst,
|
||||
const AVFrame *src, int flags);
|
||||
int (*map_from)(AVHWFramesContext *ctx, AVFrame *dst,
|
||||
const AVFrame *src, int flags);
|
||||
|
||||
int (*frames_derive_to)(AVHWFramesContext *dst_ctx,
|
||||
AVHWFramesContext *src_ctx, int flags);
|
||||
int (*frames_derive_from)(AVHWFramesContext *dst_ctx,
|
||||
AVHWFramesContext *src_ctx, int flags);
|
||||
} HWContextType;
|
||||
|
||||
struct AVHWDeviceInternal {
|
||||
const HWContextType *hw_type;
|
||||
void *priv;
|
||||
|
||||
/**
|
||||
* For a derived device, a reference to the original device
|
||||
* context it was derived from.
|
||||
*/
|
||||
AVBufferRef *source_device;
|
||||
};
|
||||
|
||||
struct AVHWFramesInternal {
|
||||
const HWContextType *hw_type;
|
||||
void *priv;
|
||||
|
||||
AVBufferPool *pool_internal;
|
||||
|
||||
/**
|
||||
* For a derived context, a reference to the original frames
|
||||
* context it was derived from.
|
||||
*/
|
||||
AVBufferRef *source_frames;
|
||||
/**
|
||||
* Flags to apply to the mapping from the source to the derived
|
||||
* frame context when trying to allocate in the derived context.
|
||||
*/
|
||||
int source_allocation_map_flags;
|
||||
};
|
||||
|
||||
typedef struct HWMapDescriptor {
|
||||
/**
|
||||
* A reference to the original source of the mapping.
|
||||
*/
|
||||
AVFrame *source;
|
||||
/**
|
||||
* A reference to the hardware frames context in which this
|
||||
* mapping was made. May be the same as source->hw_frames_ctx,
|
||||
* but need not be.
|
||||
*/
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
/**
|
||||
* Unmap function.
|
||||
*/
|
||||
void (*unmap)(AVHWFramesContext *ctx,
|
||||
struct HWMapDescriptor *hwmap);
|
||||
/**
|
||||
* Hardware-specific private data associated with the mapping.
|
||||
*/
|
||||
void *priv;
|
||||
} HWMapDescriptor;
|
||||
|
||||
int ff_hwframe_map_create(AVBufferRef *hwframe_ref,
|
||||
AVFrame *dst, const AVFrame *src,
|
||||
void (*unmap)(AVHWFramesContext *ctx,
|
||||
HWMapDescriptor *hwmap),
|
||||
void *priv);
|
||||
|
||||
|
||||
extern const HWContextType ff_hwcontext_type_cuda;
|
||||
extern const HWContextType ff_hwcontext_type_d3d11va;
|
||||
extern const HWContextType ff_hwcontext_type_drm;
|
||||
extern const HWContextType ff_hwcontext_type_dxva2;
|
||||
extern const HWContextType ff_hwcontext_type_qsv;
|
||||
extern const HWContextType ff_hwcontext_type_vaapi;
|
||||
extern const HWContextType ff_hwcontext_type_vdpau;
|
||||
extern const HWContextType ff_hwcontext_type_videotoolbox;
|
||||
|
||||
#endif /* AVUTIL_HWCONTEXT_INTERNAL_H */
|
||||
|
|
@ -74,7 +74,7 @@ AVInteger av_mul_i(AVInteger a, AVInteger b){
|
|||
|
||||
if(a.v[i])
|
||||
for(j=i; j<AV_INTEGER_SIZE && j-i<=nb; j++){
|
||||
carry= (carry>>16) + out.v[j] + a.v[i]*b.v[j-i];
|
||||
carry= (carry>>16) + out.v[j] + a.v[i]*(unsigned)b.v[j-i];
|
||||
out.v[j]= carry;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
87
media/ffvpx/libavutil/lfg.c
Normal file
87
media/ffvpx/libavutil/lfg.c
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Lagged Fibonacci PRNG
|
||||
* Copyright (c) 2008 Michael Niedermayer
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include "lfg.h"
|
||||
#include "crc.h"
|
||||
#include "md5.h"
|
||||
#include "error.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "attributes.h"
|
||||
|
||||
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
|
||||
{
|
||||
uint8_t tmp[16] = { 0 };
|
||||
int i;
|
||||
|
||||
for (i = 8; i < 64; i += 4) {
|
||||
AV_WL32(tmp, seed);
|
||||
tmp[4] = i;
|
||||
av_md5_sum(tmp, tmp, 16);
|
||||
c->state[i ] = AV_RL32(tmp);
|
||||
c->state[i + 1] = AV_RL32(tmp + 4);
|
||||
c->state[i + 2] = AV_RL32(tmp + 8);
|
||||
c->state[i + 3] = AV_RL32(tmp + 12);
|
||||
}
|
||||
c->index = 0;
|
||||
}
|
||||
|
||||
void av_bmg_get(AVLFG *lfg, double out[2])
|
||||
{
|
||||
double x1, x2, w;
|
||||
|
||||
do {
|
||||
x1 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0;
|
||||
x2 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0;
|
||||
w = x1 * x1 + x2 * x2;
|
||||
} while (w >= 1.0);
|
||||
|
||||
w = sqrt((-2.0 * log(w)) / w);
|
||||
out[0] = x1 * w;
|
||||
out[1] = x2 * w;
|
||||
}
|
||||
|
||||
int av_lfg_init_from_data(AVLFG *c, const uint8_t *data, unsigned int length) {
|
||||
unsigned int beg, end, segm;
|
||||
const AVCRC *avcrc;
|
||||
uint32_t crc = 1;
|
||||
|
||||
/* avoid integer overflow in the loop below. */
|
||||
if (length > (UINT_MAX / 128U)) return AVERROR(EINVAL);
|
||||
|
||||
c->index = 0;
|
||||
avcrc = av_crc_get_table(AV_CRC_32_IEEE); /* This can't fail. It's a well-defined table in crc.c */
|
||||
|
||||
/* across 64 segments of the incoming data,
|
||||
* do a running crc of each segment and store the crc as the state for that slot.
|
||||
* this works even if the length of the segment is 0 bytes. */
|
||||
beg = 0;
|
||||
for (segm = 0;segm < 64;segm++) {
|
||||
end = (((segm + 1) * length) / 64);
|
||||
crc = av_crc(avcrc, crc, data + beg, end - beg);
|
||||
c->state[segm] = (unsigned int)crc;
|
||||
beg = end;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
71
media/ffvpx/libavutil/lfg.h
Normal file
71
media/ffvpx/libavutil/lfg.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Lagged Fibonacci PRNG
|
||||
* Copyright (c) 2008 Michael Niedermayer
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_LFG_H
|
||||
#define AVUTIL_LFG_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct AVLFG {
|
||||
unsigned int state[64];
|
||||
int index;
|
||||
} AVLFG;
|
||||
|
||||
void av_lfg_init(AVLFG *c, unsigned int seed);
|
||||
|
||||
/**
|
||||
* Seed the state of the ALFG using binary data.
|
||||
*
|
||||
* Return value: 0 on success, negative value (AVERROR) on failure.
|
||||
*/
|
||||
int av_lfg_init_from_data(AVLFG *c, const uint8_t *data, unsigned int length);
|
||||
|
||||
/**
|
||||
* Get the next random unsigned 32-bit number using an ALFG.
|
||||
*
|
||||
* Please also consider a simple LCG like state= state*1664525+1013904223,
|
||||
* it may be good enough and faster for your specific use case.
|
||||
*/
|
||||
static inline unsigned int av_lfg_get(AVLFG *c){
|
||||
c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
|
||||
return c->state[c->index++ & 63];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next random unsigned 32-bit number using a MLFG.
|
||||
*
|
||||
* Please also consider av_lfg_get() above, it is faster.
|
||||
*/
|
||||
static inline unsigned int av_mlfg_get(AVLFG *c){
|
||||
unsigned int a= c->state[(c->index-55) & 63];
|
||||
unsigned int b= c->state[(c->index-24) & 63];
|
||||
return c->state[c->index++ & 63] = 2*a*b+a+b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next two numbers generated by a Box-Muller Gaussian
|
||||
* generator using the random numbers issued by lfg.
|
||||
*
|
||||
* @param out array where the two generated numbers are placed
|
||||
*/
|
||||
void av_bmg_get(AVLFG *lfg, double out[2]);
|
||||
|
||||
#endif /* AVUTIL_LFG_H */
|
||||
205
media/ffvpx/libavutil/lzo.c
Normal file
205
media/ffvpx/libavutil/lzo.c
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* LZO 1x decompression
|
||||
* Copyright (c) 2006 Reimar Doeffinger
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "avutil.h"
|
||||
#include "avassert.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "lzo.h"
|
||||
|
||||
/// Define if we may write up to 12 bytes beyond the output buffer.
|
||||
#define OUTBUF_PADDED 1
|
||||
/// Define if we may read up to 8 bytes beyond the input buffer.
|
||||
#define INBUF_PADDED 1
|
||||
|
||||
typedef struct LZOContext {
|
||||
const uint8_t *in, *in_end;
|
||||
uint8_t *out_start, *out, *out_end;
|
||||
int error;
|
||||
} LZOContext;
|
||||
|
||||
/**
|
||||
* @brief Reads one byte from the input buffer, avoiding an overrun.
|
||||
* @return byte read
|
||||
*/
|
||||
static inline int get_byte(LZOContext *c)
|
||||
{
|
||||
if (c->in < c->in_end)
|
||||
return *c->in++;
|
||||
c->error |= AV_LZO_INPUT_DEPLETED;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef INBUF_PADDED
|
||||
#define GETB(c) (*(c).in++)
|
||||
#else
|
||||
#define GETB(c) get_byte(&(c))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decodes a length value in the coding used by lzo.
|
||||
* @param x previous byte value
|
||||
* @param mask bits used from x
|
||||
* @return decoded length value
|
||||
*/
|
||||
static inline int get_len(LZOContext *c, int x, int mask)
|
||||
{
|
||||
int cnt = x & mask;
|
||||
if (!cnt) {
|
||||
while (!(x = get_byte(c))) {
|
||||
if (cnt >= INT_MAX - 1000) {
|
||||
c->error |= AV_LZO_ERROR;
|
||||
break;
|
||||
}
|
||||
cnt += 255;
|
||||
}
|
||||
cnt += mask + x;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copies bytes from input to output buffer with checking.
|
||||
* @param cnt number of bytes to copy, must be >= 0
|
||||
*/
|
||||
static inline void copy(LZOContext *c, int cnt)
|
||||
{
|
||||
register const uint8_t *src = c->in;
|
||||
register uint8_t *dst = c->out;
|
||||
av_assert0(cnt >= 0);
|
||||
if (cnt > c->in_end - src) {
|
||||
cnt = FFMAX(c->in_end - src, 0);
|
||||
c->error |= AV_LZO_INPUT_DEPLETED;
|
||||
}
|
||||
if (cnt > c->out_end - dst) {
|
||||
cnt = FFMAX(c->out_end - dst, 0);
|
||||
c->error |= AV_LZO_OUTPUT_FULL;
|
||||
}
|
||||
#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
|
||||
AV_COPY32U(dst, src);
|
||||
src += 4;
|
||||
dst += 4;
|
||||
cnt -= 4;
|
||||
if (cnt > 0)
|
||||
#endif
|
||||
memcpy(dst, src, cnt);
|
||||
c->in = src + cnt;
|
||||
c->out = dst + cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copies previously decoded bytes to current position.
|
||||
* @param back how many bytes back we start, must be > 0
|
||||
* @param cnt number of bytes to copy, must be > 0
|
||||
*
|
||||
* cnt > back is valid, this will copy the bytes we just copied,
|
||||
* thus creating a repeating pattern with a period length of back.
|
||||
*/
|
||||
static inline void copy_backptr(LZOContext *c, int back, int cnt)
|
||||
{
|
||||
register uint8_t *dst = c->out;
|
||||
av_assert0(cnt > 0);
|
||||
if (dst - c->out_start < back) {
|
||||
c->error |= AV_LZO_INVALID_BACKPTR;
|
||||
return;
|
||||
}
|
||||
if (cnt > c->out_end - dst) {
|
||||
cnt = FFMAX(c->out_end - dst, 0);
|
||||
c->error |= AV_LZO_OUTPUT_FULL;
|
||||
}
|
||||
av_memcpy_backptr(dst, back, cnt);
|
||||
c->out = dst + cnt;
|
||||
}
|
||||
|
||||
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen)
|
||||
{
|
||||
int state = 0;
|
||||
int x;
|
||||
LZOContext c;
|
||||
if (*outlen <= 0 || *inlen <= 0) {
|
||||
int res = 0;
|
||||
if (*outlen <= 0)
|
||||
res |= AV_LZO_OUTPUT_FULL;
|
||||
if (*inlen <= 0)
|
||||
res |= AV_LZO_INPUT_DEPLETED;
|
||||
return res;
|
||||
}
|
||||
c.in = in;
|
||||
c.in_end = (const uint8_t *)in + *inlen;
|
||||
c.out = c.out_start = out;
|
||||
c.out_end = (uint8_t *)out + *outlen;
|
||||
c.error = 0;
|
||||
x = GETB(c);
|
||||
if (x > 17) {
|
||||
copy(&c, x - 17);
|
||||
x = GETB(c);
|
||||
if (x < 16)
|
||||
c.error |= AV_LZO_ERROR;
|
||||
}
|
||||
if (c.in > c.in_end)
|
||||
c.error |= AV_LZO_INPUT_DEPLETED;
|
||||
while (!c.error) {
|
||||
int cnt, back;
|
||||
if (x > 15) {
|
||||
if (x > 63) {
|
||||
cnt = (x >> 5) - 1;
|
||||
back = (GETB(c) << 3) + ((x >> 2) & 7) + 1;
|
||||
} else if (x > 31) {
|
||||
cnt = get_len(&c, x, 31);
|
||||
x = GETB(c);
|
||||
back = (GETB(c) << 6) + (x >> 2) + 1;
|
||||
} else {
|
||||
cnt = get_len(&c, x, 7);
|
||||
back = (1 << 14) + ((x & 8) << 11);
|
||||
x = GETB(c);
|
||||
back += (GETB(c) << 6) + (x >> 2);
|
||||
if (back == (1 << 14)) {
|
||||
if (cnt != 1)
|
||||
c.error |= AV_LZO_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (!state) {
|
||||
cnt = get_len(&c, x, 15);
|
||||
copy(&c, cnt + 3);
|
||||
x = GETB(c);
|
||||
if (x > 15)
|
||||
continue;
|
||||
cnt = 1;
|
||||
back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1;
|
||||
} else {
|
||||
cnt = 0;
|
||||
back = (GETB(c) << 2) + (x >> 2) + 1;
|
||||
}
|
||||
copy_backptr(&c, back, cnt + 2);
|
||||
state =
|
||||
cnt = x & 3;
|
||||
copy(&c, cnt);
|
||||
x = GETB(c);
|
||||
}
|
||||
*inlen = c.in_end - c.in;
|
||||
if (c.in > c.in_end)
|
||||
*inlen = 0;
|
||||
*outlen = c.out_end - c.out;
|
||||
return c.error;
|
||||
}
|
||||
66
media/ffvpx/libavutil/lzo.h
Normal file
66
media/ffvpx/libavutil/lzo.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* LZO 1x decompression
|
||||
* copyright (c) 2006 Reimar Doeffinger
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_LZO_H
|
||||
#define AVUTIL_LZO_H
|
||||
|
||||
/**
|
||||
* @defgroup lavu_lzo LZO
|
||||
* @ingroup lavu_crypto
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** @name Error flags returned by av_lzo1x_decode
|
||||
* @{ */
|
||||
/// end of the input buffer reached before decoding finished
|
||||
#define AV_LZO_INPUT_DEPLETED 1
|
||||
/// decoded data did not fit into output buffer
|
||||
#define AV_LZO_OUTPUT_FULL 2
|
||||
/// a reference to previously decoded data was wrong
|
||||
#define AV_LZO_INVALID_BACKPTR 4
|
||||
/// a non-specific error in the compressed bitstream
|
||||
#define AV_LZO_ERROR 8
|
||||
/** @} */
|
||||
|
||||
#define AV_LZO_INPUT_PADDING 8
|
||||
#define AV_LZO_OUTPUT_PADDING 12
|
||||
|
||||
/**
|
||||
* @brief Decodes LZO 1x compressed data.
|
||||
* @param out output buffer
|
||||
* @param outlen size of output buffer, number of bytes left are returned here
|
||||
* @param in input buffer
|
||||
* @param inlen size of input buffer, number of bytes left are returned here
|
||||
* @return 0 on success, otherwise a combination of the error flags above
|
||||
*
|
||||
* Make sure all buffers are appropriately padded, in must provide
|
||||
* AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes.
|
||||
*/
|
||||
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_LZO_H */
|
||||
66
media/ffvpx/libavutil/mastering_display_metadata.c
Normal file
66
media/ffvpx/libavutil/mastering_display_metadata.c
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* Copyright (c) 2016 Neil Birkbeck <neil.birkbeck@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mastering_display_metadata.h"
|
||||
#include "mem.h"
|
||||
|
||||
AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(AVMasteringDisplayMetadata));
|
||||
}
|
||||
|
||||
AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFrame *frame)
|
||||
{
|
||||
AVFrameSideData *side_data = av_frame_new_side_data(frame,
|
||||
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,
|
||||
sizeof(AVMasteringDisplayMetadata));
|
||||
if (!side_data)
|
||||
return NULL;
|
||||
|
||||
memset(side_data->data, 0, sizeof(AVMasteringDisplayMetadata));
|
||||
|
||||
return (AVMasteringDisplayMetadata *)side_data->data;
|
||||
}
|
||||
|
||||
AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size)
|
||||
{
|
||||
AVContentLightMetadata *metadata = av_mallocz(sizeof(AVContentLightMetadata));
|
||||
|
||||
if (size)
|
||||
*size = sizeof(*metadata);
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame)
|
||||
{
|
||||
AVFrameSideData *side_data = av_frame_new_side_data(frame,
|
||||
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL,
|
||||
sizeof(AVContentLightMetadata));
|
||||
if (!side_data)
|
||||
return NULL;
|
||||
|
||||
memset(side_data->data, 0, sizeof(AVContentLightMetadata));
|
||||
|
||||
return (AVContentLightMetadata *)side_data->data;
|
||||
}
|
||||
128
media/ffvpx/libavutil/mastering_display_metadata.h
Normal file
128
media/ffvpx/libavutil/mastering_display_metadata.h
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/**
|
||||
* Copyright (c) 2016 Neil Birkbeck <neil.birkbeck@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_MASTERING_DISPLAY_METADATA_H
|
||||
#define AVUTIL_MASTERING_DISPLAY_METADATA_H
|
||||
|
||||
#include "frame.h"
|
||||
#include "rational.h"
|
||||
|
||||
|
||||
/**
|
||||
* Mastering display metadata capable of representing the color volume of
|
||||
* the display used to master the content (SMPTE 2086:2014).
|
||||
*
|
||||
* To be used as payload of a AVFrameSideData or AVPacketSideData with the
|
||||
* appropriate type.
|
||||
*
|
||||
* @note The struct should be allocated with av_mastering_display_metadata_alloc()
|
||||
* and its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVMasteringDisplayMetadata {
|
||||
/**
|
||||
* CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
|
||||
*/
|
||||
AVRational display_primaries[3][2];
|
||||
|
||||
/**
|
||||
* CIE 1931 xy chromaticity coords of white point.
|
||||
*/
|
||||
AVRational white_point[2];
|
||||
|
||||
/**
|
||||
* Min luminance of mastering display (cd/m^2).
|
||||
*/
|
||||
AVRational min_luminance;
|
||||
|
||||
/**
|
||||
* Max luminance of mastering display (cd/m^2).
|
||||
*/
|
||||
AVRational max_luminance;
|
||||
|
||||
/**
|
||||
* Flag indicating whether the display primaries (and white point) are set.
|
||||
*/
|
||||
int has_primaries;
|
||||
|
||||
/**
|
||||
* Flag indicating whether the luminance (min_ and max_) have been set.
|
||||
*/
|
||||
int has_luminance;
|
||||
|
||||
} AVMasteringDisplayMetadata;
|
||||
|
||||
/**
|
||||
* Allocate an AVMasteringDisplayMetadata structure and set its fields to
|
||||
* default values. The resulting struct can be freed using av_freep().
|
||||
*
|
||||
* @return An AVMasteringDisplayMetadata filled with default values or NULL
|
||||
* on failure.
|
||||
*/
|
||||
AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
|
||||
|
||||
/**
|
||||
* Allocate a complete AVMasteringDisplayMetadata and add it to the frame.
|
||||
*
|
||||
* @param frame The frame which side data is added to.
|
||||
*
|
||||
* @return The AVMasteringDisplayMetadata structure to be filled by caller.
|
||||
*/
|
||||
AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Content light level needed by to transmit HDR over HDMI (CTA-861.3).
|
||||
*
|
||||
* To be used as payload of a AVFrameSideData or AVPacketSideData with the
|
||||
* appropriate type.
|
||||
*
|
||||
* @note The struct should be allocated with av_content_light_metadata_alloc()
|
||||
* and its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVContentLightMetadata {
|
||||
/**
|
||||
* Max content light level (cd/m^2).
|
||||
*/
|
||||
unsigned MaxCLL;
|
||||
|
||||
/**
|
||||
* Max average light level per frame (cd/m^2).
|
||||
*/
|
||||
unsigned MaxFALL;
|
||||
} AVContentLightMetadata;
|
||||
|
||||
/**
|
||||
* Allocate an AVContentLightMetadata structure and set its fields to
|
||||
* default values. The resulting struct can be freed using av_freep().
|
||||
*
|
||||
* @return An AVContentLightMetadata filled with default values or NULL
|
||||
* on failure.
|
||||
*/
|
||||
AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size);
|
||||
|
||||
/**
|
||||
* Allocate a complete AVContentLightMetadata and add it to the frame.
|
||||
*
|
||||
* @param frame The frame which side data is added to.
|
||||
*
|
||||
* @return The AVContentLightMetadata structure to be filled by caller.
|
||||
*/
|
||||
AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame);
|
||||
|
||||
#endif /* AVUTIL_MASTERING_DISPLAY_METADATA_H */
|
||||
218
media/ffvpx/libavutil/md5.c
Normal file
218
media/ffvpx/libavutil/md5.c
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
* Copyright (C) 2006 Michael Niedermayer (michaelni@gmx.at)
|
||||
* Copyright (C) 2003-2005 by Christopher R. Hertel (crh@ubiqx.mn.org)
|
||||
*
|
||||
* References:
|
||||
* IETF RFC 1321: The MD5 Message-Digest Algorithm
|
||||
* Ron Rivest. IETF, April, 1992
|
||||
*
|
||||
* based on http://ubiqx.org/libcifs/source/Auth/MD5.c
|
||||
* from Christopher R. Hertel (crh@ubiqx.mn.org)
|
||||
* Simplified, cleaned and IMO redundant comments removed by Michael.
|
||||
*
|
||||
* If you use gcc, then version 4.1 or later and -fomit-frame-pointer is
|
||||
* strongly recommended.
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bswap.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "mem.h"
|
||||
#include "md5.h"
|
||||
|
||||
typedef struct AVMD5 {
|
||||
uint64_t len;
|
||||
uint8_t block[64];
|
||||
uint32_t ABCD[4];
|
||||
} AVMD5;
|
||||
|
||||
const int av_md5_size = sizeof(AVMD5);
|
||||
|
||||
struct AVMD5 *av_md5_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVMD5));
|
||||
}
|
||||
|
||||
static const uint8_t S[4][4] = {
|
||||
{ 7, 12, 17, 22 }, /* round 1 */
|
||||
{ 5, 9, 14, 20 }, /* round 2 */
|
||||
{ 4, 11, 16, 23 }, /* round 3 */
|
||||
{ 6, 10, 15, 21 } /* round 4 */
|
||||
};
|
||||
|
||||
static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32)
|
||||
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, /* round 1 */
|
||||
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
|
||||
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
||||
|
||||
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, /* round 2 */
|
||||
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
|
||||
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
|
||||
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
|
||||
|
||||
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, /* round 3 */
|
||||
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
|
||||
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
|
||||
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
|
||||
|
||||
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, /* round 4 */
|
||||
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
|
||||
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
|
||||
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
|
||||
};
|
||||
|
||||
#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))) + AV_RL32(X+( i & 15));\
|
||||
else \
|
||||
a += ((d & b) | (~d & c)) + AV_RL32(X+((1 + 5*i) & 15));\
|
||||
} else { \
|
||||
if (i < 48) \
|
||||
a += (b ^ c ^ d) + AV_RL32(X+((5 + 3*i) & 15));\
|
||||
else \
|
||||
a += (c ^ (b | ~d)) + AV_RL32(X+(( 7*i) & 15));\
|
||||
} \
|
||||
a = b + (a << t | a >> (32 - t)); \
|
||||
} while (0)
|
||||
|
||||
static void body(uint32_t ABCD[4], const uint8_t *src, int nblocks)
|
||||
{
|
||||
int i av_unused;
|
||||
int n;
|
||||
const uint32_t *X;
|
||||
uint32_t a, b, c, d, t;
|
||||
|
||||
for (n = 0; n < nblocks; n++) {
|
||||
a = ABCD[3];
|
||||
b = ABCD[2];
|
||||
c = ABCD[1];
|
||||
d = ABCD[0];
|
||||
|
||||
X = (const uint32_t *)src + n * 16;
|
||||
|
||||
#if CONFIG_SMALL
|
||||
for (i = 0; i < 64; i++) {
|
||||
CORE(i, a, b, c, d);
|
||||
t = d;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = t;
|
||||
}
|
||||
#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);
|
||||
#endif
|
||||
|
||||
ABCD[0] += d;
|
||||
ABCD[1] += c;
|
||||
ABCD[2] += b;
|
||||
ABCD[3] += a;
|
||||
}
|
||||
}
|
||||
|
||||
void av_md5_init(AVMD5 *ctx)
|
||||
{
|
||||
ctx->len = 0;
|
||||
|
||||
ctx->ABCD[0] = 0x10325476;
|
||||
ctx->ABCD[1] = 0x98badcfe;
|
||||
ctx->ABCD[2] = 0xefcdab89;
|
||||
ctx->ABCD[3] = 0x67452301;
|
||||
}
|
||||
|
||||
#if FF_API_CRYPTO_SIZE_T
|
||||
void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len)
|
||||
#else
|
||||
void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len)
|
||||
#endif
|
||||
{
|
||||
const uint8_t *end;
|
||||
int j;
|
||||
|
||||
j = ctx->len & 63;
|
||||
ctx->len += len;
|
||||
|
||||
if (j) {
|
||||
int cnt = FFMIN(len, 64 - j);
|
||||
memcpy(ctx->block + j, src, cnt);
|
||||
src += cnt;
|
||||
len -= cnt;
|
||||
if (j + cnt < 64)
|
||||
return;
|
||||
body(ctx->ABCD, ctx->block, 1);
|
||||
}
|
||||
|
||||
end = src + (len & ~63);
|
||||
if (!HAVE_FAST_UNALIGNED && ((intptr_t)src & 3)) {
|
||||
while (src < end) {
|
||||
memcpy(ctx->block, src, 64);
|
||||
body(ctx->ABCD, ctx->block, 1);
|
||||
src += 64;
|
||||
}
|
||||
} else {
|
||||
int nblocks = len / 64;
|
||||
body(ctx->ABCD, src, nblocks);
|
||||
src = end;
|
||||
}
|
||||
len &= 63;
|
||||
if (len > 0)
|
||||
memcpy(ctx->block, src, len);
|
||||
}
|
||||
|
||||
void av_md5_final(AVMD5 *ctx, uint8_t *dst)
|
||||
{
|
||||
int i;
|
||||
uint64_t finalcount = av_le2ne64(ctx->len << 3);
|
||||
|
||||
av_md5_update(ctx, "\200", 1);
|
||||
while ((ctx->len & 63) != 56)
|
||||
av_md5_update(ctx, "", 1);
|
||||
|
||||
av_md5_update(ctx, (uint8_t *) &finalcount, 8);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
AV_WL32(dst + 4 * i, ctx->ABCD[3 - i]);
|
||||
}
|
||||
|
||||
#if FF_API_CRYPTO_SIZE_T
|
||||
void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len)
|
||||
#else
|
||||
void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len)
|
||||
#endif
|
||||
{
|
||||
AVMD5 ctx;
|
||||
|
||||
av_md5_init(&ctx);
|
||||
av_md5_update(&ctx, src, len);
|
||||
av_md5_final(&ctx, dst);
|
||||
}
|
||||
98
media/ffvpx/libavutil/md5.h
Normal file
98
media/ffvpx/libavutil/md5.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavu_md5
|
||||
* Public header for MD5 hash function implementation.
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_MD5_H
|
||||
#define AVUTIL_MD5_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_md5 MD5
|
||||
* @ingroup lavu_hash
|
||||
* MD5 hash function implementation.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_md5_size;
|
||||
|
||||
struct AVMD5;
|
||||
|
||||
/**
|
||||
* Allocate an AVMD5 context.
|
||||
*/
|
||||
struct AVMD5 *av_md5_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize MD5 hashing.
|
||||
*
|
||||
* @param ctx pointer to the function context (of size av_md5_size)
|
||||
*/
|
||||
void av_md5_init(struct AVMD5 *ctx);
|
||||
|
||||
/**
|
||||
* Update hash value.
|
||||
*
|
||||
* @param ctx hash function context
|
||||
* @param src input data to update hash with
|
||||
* @param len input data length
|
||||
*/
|
||||
#if FF_API_CRYPTO_SIZE_T
|
||||
void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, int len);
|
||||
#else
|
||||
void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, size_t len);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Finish hashing and output digest value.
|
||||
*
|
||||
* @param ctx hash function context
|
||||
* @param dst buffer where output digest value is stored
|
||||
*/
|
||||
void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
|
||||
|
||||
/**
|
||||
* Hash an array of data.
|
||||
*
|
||||
* @param dst The output buffer to write the digest into
|
||||
* @param src The data to hash
|
||||
* @param len The length of the data, in bytes
|
||||
*/
|
||||
#if FF_API_CRYPTO_SIZE_T
|
||||
void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
|
||||
#else
|
||||
void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_MD5_H */
|
||||
57
media/ffvpx/libavutil/motion_vector.h
Normal file
57
media/ffvpx/libavutil/motion_vector.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_MOTION_VECTOR_H
|
||||
#define AVUTIL_MOTION_VECTOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct AVMotionVector {
|
||||
/**
|
||||
* Where the current macroblock comes from; negative value when it comes
|
||||
* from the past, positive value when it comes from the future.
|
||||
* XXX: set exact relative ref frame reference instead of a +/- 1 "direction".
|
||||
*/
|
||||
int32_t source;
|
||||
/**
|
||||
* Width and height of the block.
|
||||
*/
|
||||
uint8_t w, h;
|
||||
/**
|
||||
* Absolute source position. Can be outside the frame area.
|
||||
*/
|
||||
int16_t src_x, src_y;
|
||||
/**
|
||||
* Absolute destination position. Can be outside the frame area.
|
||||
*/
|
||||
int16_t dst_x, dst_y;
|
||||
/**
|
||||
* Extra flag information.
|
||||
* Currently unused.
|
||||
*/
|
||||
uint64_t flags;
|
||||
/**
|
||||
* Motion vector
|
||||
* src_x = dst_x + motion_x / motion_scale
|
||||
* src_y = dst_y + motion_y / motion_scale
|
||||
*/
|
||||
int32_t motion_x, motion_y;
|
||||
uint16_t motion_scale;
|
||||
} AVMotionVector;
|
||||
|
||||
#endif /* AVUTIL_MOTION_VECTOR_H */
|
||||
|
|
@ -9,46 +9,79 @@
|
|||
if CONFIG['FFVPX_ASFLAGS']:
|
||||
DIRS += ['x86']
|
||||
|
||||
# 'dummy_funcs.c',
|
||||
|
||||
SharedLibrary('mozavutil')
|
||||
SOURCES += [
|
||||
'adler32.c',
|
||||
'aes.c',
|
||||
'aes_ctr.c',
|
||||
'atomic.c',
|
||||
'audio_fifo.c',
|
||||
'avstring.c',
|
||||
'base64.c',
|
||||
'blowfish.c',
|
||||
'bprint.c',
|
||||
'buffer.c',
|
||||
'camellia.c',
|
||||
'cast5.c',
|
||||
'channel_layout.c',
|
||||
'color_utils.c',
|
||||
'cpu.c',
|
||||
'crc.c',
|
||||
'des.c',
|
||||
'dict.c',
|
||||
'dummy_funcs.c',
|
||||
'display.c',
|
||||
'downmix_info.c',
|
||||
'error.c',
|
||||
'eval.c',
|
||||
'fifo.c',
|
||||
'file.c',
|
||||
'file_open.c',
|
||||
'fixed_dsp.c',
|
||||
'float_dsp.c',
|
||||
'frame.c',
|
||||
'hash.c',
|
||||
'hmac.c',
|
||||
'hwcontext.c',
|
||||
'hwcontext_cuda.c',
|
||||
'imgutils.c',
|
||||
'integer.c',
|
||||
'intmath.c',
|
||||
'lfg.c',
|
||||
'lls.c',
|
||||
'log.c',
|
||||
'log2_tab.c',
|
||||
'lzo.c',
|
||||
'mastering_display_metadata.c',
|
||||
'mathematics.c',
|
||||
'md5.c',
|
||||
'mem.c',
|
||||
'murmur3.c',
|
||||
'opt.c',
|
||||
'parseutils.c',
|
||||
'pixdesc.c',
|
||||
'pixelutils.c',
|
||||
'random_seed.c',
|
||||
'rational.c',
|
||||
'rc4.c',
|
||||
'reverse.c',
|
||||
'ripemd.c',
|
||||
'samplefmt.c',
|
||||
'sha.c',
|
||||
'sha512.c',
|
||||
'slicethread.c',
|
||||
'spherical.c',
|
||||
'stereo3d.c',
|
||||
'tea.c',
|
||||
'threadmessage.c',
|
||||
'time.c',
|
||||
'timecode.c',
|
||||
'tree.c',
|
||||
'twofish.c',
|
||||
'utils.c',
|
||||
'xga_font_data.c',
|
||||
'xtea.c',
|
||||
]
|
||||
|
||||
SYMBOLS_FILE = 'avutil.symbols'
|
||||
|
|
|
|||
155
media/ffvpx/libavutil/murmur3.c
Normal file
155
media/ffvpx/libavutil/murmur3.c
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright (C) 2013 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include "mem.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "murmur3.h"
|
||||
|
||||
typedef struct AVMurMur3 {
|
||||
uint64_t h1, h2;
|
||||
uint8_t state[16];
|
||||
int state_pos;
|
||||
uint64_t len;
|
||||
} AVMurMur3;
|
||||
|
||||
AVMurMur3 *av_murmur3_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(AVMurMur3));
|
||||
}
|
||||
|
||||
void av_murmur3_init_seeded(AVMurMur3 *c, uint64_t seed)
|
||||
{
|
||||
memset(c, 0, sizeof(*c));
|
||||
c->h1 = c->h2 = seed;
|
||||
}
|
||||
|
||||
void av_murmur3_init(AVMurMur3 *c)
|
||||
{
|
||||
// arbitrary random number as seed
|
||||
av_murmur3_init_seeded(c, 0x725acc55daddca55);
|
||||
}
|
||||
|
||||
static const uint64_t c1 = UINT64_C(0x87c37b91114253d5);
|
||||
static const uint64_t c2 = UINT64_C(0x4cf5ad432745937f);
|
||||
|
||||
#define ROT(a, b) (((a) << (b)) | ((a) >> (64 - (b))))
|
||||
|
||||
static uint64_t inline get_k1(const uint8_t *src)
|
||||
{
|
||||
uint64_t k = AV_RL64(src);
|
||||
k *= c1;
|
||||
k = ROT(k, 31);
|
||||
k *= c2;
|
||||
return k;
|
||||
}
|
||||
|
||||
static uint64_t inline get_k2(const uint8_t *src)
|
||||
{
|
||||
uint64_t k = AV_RL64(src + 8);
|
||||
k *= c2;
|
||||
k = ROT(k, 33);
|
||||
k *= c1;
|
||||
return k;
|
||||
}
|
||||
|
||||
static uint64_t inline update_h1(uint64_t k, uint64_t h1, uint64_t h2)
|
||||
{
|
||||
k ^= h1;
|
||||
k = ROT(k, 27);
|
||||
k += h2;
|
||||
k *= 5;
|
||||
k += 0x52dce729;
|
||||
return k;
|
||||
}
|
||||
|
||||
static uint64_t inline update_h2(uint64_t k, uint64_t h1, uint64_t h2)
|
||||
{
|
||||
k ^= h2;
|
||||
k = ROT(k, 31);
|
||||
k += h1;
|
||||
k *= 5;
|
||||
k += 0x38495ab5;
|
||||
return k;
|
||||
}
|
||||
|
||||
void av_murmur3_update(AVMurMur3 *c, const uint8_t *src, int len)
|
||||
{
|
||||
const uint8_t *end;
|
||||
uint64_t h1 = c->h1, h2 = c->h2;
|
||||
uint64_t k1, k2;
|
||||
if (len <= 0) return;
|
||||
c->len += len;
|
||||
if (c->state_pos > 0) {
|
||||
while (c->state_pos < 16) {
|
||||
c->state[c->state_pos++] = *src++;
|
||||
if (--len <= 0) return;
|
||||
}
|
||||
c->state_pos = 0;
|
||||
k1 = get_k1(c->state);
|
||||
k2 = get_k2(c->state);
|
||||
h1 = update_h1(k1, h1, h2);
|
||||
h2 = update_h2(k2, h1, h2);
|
||||
}
|
||||
|
||||
end = src + (len & ~15);
|
||||
while (src < end) {
|
||||
// These could be done sequentially instead
|
||||
// of interleaved, but like this is over 10% faster
|
||||
k1 = get_k1(src);
|
||||
k2 = get_k2(src);
|
||||
h1 = update_h1(k1, h1, h2);
|
||||
h2 = update_h2(k2, h1, h2);
|
||||
src += 16;
|
||||
}
|
||||
c->h1 = h1;
|
||||
c->h2 = h2;
|
||||
|
||||
len &= 15;
|
||||
if (len > 0) {
|
||||
memcpy(c->state, src, len);
|
||||
c->state_pos = len;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint64_t fmix(uint64_t k)
|
||||
{
|
||||
k ^= k >> 33;
|
||||
k *= UINT64_C(0xff51afd7ed558ccd);
|
||||
k ^= k >> 33;
|
||||
k *= UINT64_C(0xc4ceb9fe1a85ec53);
|
||||
k ^= k >> 33;
|
||||
return k;
|
||||
}
|
||||
|
||||
void av_murmur3_final(AVMurMur3 *c, uint8_t dst[16])
|
||||
{
|
||||
uint64_t h1 = c->h1, h2 = c->h2;
|
||||
memset(c->state + c->state_pos, 0, sizeof(c->state) - c->state_pos);
|
||||
h1 ^= get_k1(c->state) ^ c->len;
|
||||
h2 ^= get_k2(c->state) ^ c->len;
|
||||
h1 += h2;
|
||||
h2 += h1;
|
||||
h1 = fmix(h1);
|
||||
h2 = fmix(h2);
|
||||
h1 += h2;
|
||||
h2 += h1;
|
||||
AV_WL64(dst, h1);
|
||||
AV_WL64(dst + 8, h2);
|
||||
}
|
||||
114
media/ffvpx/libavutil/murmur3.h
Normal file
114
media/ffvpx/libavutil/murmur3.h
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2013 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavu_murmur3
|
||||
* Public header for MurmurHash3 hash function implementation.
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_MURMUR3_H
|
||||
#define AVUTIL_MURMUR3_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_murmur3 Murmur3
|
||||
* @ingroup lavu_hash
|
||||
* MurmurHash3 hash function implementation.
|
||||
*
|
||||
* MurmurHash3 is a non-cryptographic hash function, of which three
|
||||
* incompatible versions were created by its inventor Austin Appleby:
|
||||
*
|
||||
* - 32-bit output
|
||||
* - 128-bit output for 32-bit platforms
|
||||
* - 128-bit output for 64-bit platforms
|
||||
*
|
||||
* FFmpeg only implements the last variant: 128-bit output designed for 64-bit
|
||||
* platforms. Even though the hash function was designed for 64-bit platforms,
|
||||
* the function in reality works on 32-bit systems too, only with reduced
|
||||
* performance.
|
||||
*
|
||||
* @anchor lavu_murmur3_seedinfo
|
||||
* By design, MurmurHash3 requires a seed to operate. In response to this,
|
||||
* libavutil provides two functions for hash initiation, one that requires a
|
||||
* seed (av_murmur3_init_seeded()) and one that uses a fixed arbitrary integer
|
||||
* as the seed, and therefore does not (av_murmur3_init()).
|
||||
*
|
||||
* To make hashes comparable, you should provide the same seed for all calls to
|
||||
* this hash function -- if you are supplying one yourself, that is.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allocate an AVMurMur3 hash context.
|
||||
*
|
||||
* @return Uninitialized hash context or `NULL` in case of error
|
||||
*/
|
||||
struct AVMurMur3 *av_murmur3_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize or reinitialize an AVMurMur3 hash context with a seed.
|
||||
*
|
||||
* @param[out] c Hash context
|
||||
* @param[in] seed Random seed
|
||||
*
|
||||
* @see av_murmur3_init()
|
||||
* @see @ref lavu_murmur3_seedinfo "Detailed description" on a discussion of
|
||||
* seeds for MurmurHash3.
|
||||
*/
|
||||
void av_murmur3_init_seeded(struct AVMurMur3 *c, uint64_t seed);
|
||||
|
||||
/**
|
||||
* Initialize or reinitialize an AVMurMur3 hash context.
|
||||
*
|
||||
* Equivalent to av_murmur3_init_seeded() with a built-in seed.
|
||||
*
|
||||
* @param[out] c Hash context
|
||||
*
|
||||
* @see av_murmur3_init_seeded()
|
||||
* @see @ref lavu_murmur3_seedinfo "Detailed description" on a discussion of
|
||||
* seeds for MurmurHash3.
|
||||
*/
|
||||
void av_murmur3_init(struct AVMurMur3 *c);
|
||||
|
||||
/**
|
||||
* Update hash context with new data.
|
||||
*
|
||||
* @param[out] c Hash context
|
||||
* @param[in] src Input data to update hash with
|
||||
* @param[in] len Number of bytes to read from `src`
|
||||
*/
|
||||
void av_murmur3_update(struct AVMurMur3 *c, const uint8_t *src, int len);
|
||||
|
||||
/**
|
||||
* Finish hashing and output digest value.
|
||||
*
|
||||
* @param[in,out] c Hash context
|
||||
* @param[out] dst Buffer where output digest value is stored
|
||||
*/
|
||||
void av_murmur3_final(struct AVMurMur3 *c, uint8_t dst[16]);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_MURMUR3_H */
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
#include "common.h"
|
||||
#include "eval.h"
|
||||
#include "log.h"
|
||||
/* #include "random_seed.h" */
|
||||
#include "ff_random_seed.h"
|
||||
#include "time_internal.h"
|
||||
#include "parseutils.h"
|
||||
#include "fftime.h"
|
||||
|
|
@ -373,7 +373,7 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
|
|||
rgba_color[3] = 255;
|
||||
|
||||
if (!av_strcasecmp(color_string2, "random") || !av_strcasecmp(color_string2, "bikeshed")) {
|
||||
int rgba = 0xffffffff; /* av_get_random_seed(); */
|
||||
int rgba = av_get_random_seed();
|
||||
rgba_color[0] = rgba >> 24;
|
||||
rgba_color[1] = rgba >> 16;
|
||||
rgba_color[2] = rgba >> 8;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@
|
|||
* This is stored as BGRA on little-endian CPU architectures and ARGB on
|
||||
* big-endian CPUs.
|
||||
*
|
||||
* @note
|
||||
* If the resolution is not a multiple of the chroma subsampling factor
|
||||
* then the chroma plane resolution must be rounded up.
|
||||
*
|
||||
* @par
|
||||
* When the pixel format is palettized RGB32 (AV_PIX_FMT_PAL8), the palettized
|
||||
* image data is stored in AVFrame.data[0]. The palette is transported in
|
||||
|
|
|
|||
144
media/ffvpx/libavutil/random_seed.c
Normal file
144
media/ffvpx/libavutil/random_seed.c
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
#if HAVE_CRYPTGENRANDOM
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include "avassert.h"
|
||||
#include "internal.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "timer.h"
|
||||
#include "ff_random_seed.h"
|
||||
#include "sha.h"
|
||||
|
||||
#ifndef TEST
|
||||
#define TEST 0
|
||||
#endif
|
||||
|
||||
static int read_random(uint32_t *dst, const char *file)
|
||||
{
|
||||
#if HAVE_UNISTD_H
|
||||
int fd = avpriv_open(file, O_RDONLY);
|
||||
int err = -1;
|
||||
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
err = read(fd, dst, sizeof(*dst));
|
||||
close(fd);
|
||||
|
||||
return err;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t get_generic_seed(void)
|
||||
{
|
||||
uint64_t tmp[120/8];
|
||||
struct AVSHA *sha = (void*)tmp;
|
||||
clock_t last_t = 0;
|
||||
clock_t last_td = 0;
|
||||
clock_t init_t = 0;
|
||||
static uint64_t i = 0;
|
||||
static uint32_t buffer[512] = { 0 };
|
||||
unsigned char digest[20];
|
||||
uint64_t last_i = i;
|
||||
|
||||
av_assert0(sizeof(tmp) >= av_sha_size);
|
||||
|
||||
if(TEST){
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
last_i = i = 0;
|
||||
}else{
|
||||
#ifdef AV_READ_TIME
|
||||
buffer[13] ^= AV_READ_TIME();
|
||||
buffer[41] ^= AV_READ_TIME()>>32;
|
||||
#endif
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
clock_t t = clock();
|
||||
if (last_t + 2*last_td + (CLOCKS_PER_SEC > 1000) >= t) {
|
||||
last_td = t - last_t;
|
||||
buffer[i & 511] = 1664525*buffer[i & 511] + 1013904223 + (last_td % 3294638521U);
|
||||
} else {
|
||||
last_td = t - last_t;
|
||||
buffer[++i & 511] += last_td % 3294638521U;
|
||||
if ((t - init_t) >= CLOCKS_PER_SEC>>5)
|
||||
if (last_i && i - last_i > 4 || i - last_i > 64 || TEST && i - last_i > 8)
|
||||
break;
|
||||
}
|
||||
last_t = t;
|
||||
if (!init_t)
|
||||
init_t = t;
|
||||
}
|
||||
|
||||
if(TEST) {
|
||||
buffer[0] = buffer[1] = 0;
|
||||
} else {
|
||||
#ifdef AV_READ_TIME
|
||||
buffer[111] += AV_READ_TIME();
|
||||
#endif
|
||||
}
|
||||
|
||||
av_sha_init(sha, 160);
|
||||
av_sha_update(sha, (const uint8_t *)buffer, sizeof(buffer));
|
||||
av_sha_final(sha, digest);
|
||||
return AV_RB32(digest) + AV_RB32(digest + 16);
|
||||
}
|
||||
|
||||
uint32_t av_get_random_seed(void)
|
||||
{
|
||||
uint32_t seed;
|
||||
|
||||
#if HAVE_CRYPTGENRANDOM
|
||||
HCRYPTPROV provider;
|
||||
if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL,
|
||||
CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
|
||||
BOOL ret = CryptGenRandom(provider, sizeof(seed), (PBYTE) &seed);
|
||||
CryptReleaseContext(provider, 0);
|
||||
if (ret)
|
||||
return seed;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_ARC4RANDOM
|
||||
return arc4random();
|
||||
#endif
|
||||
|
||||
if (read_random(&seed, "/dev/urandom") == sizeof(seed))
|
||||
return seed;
|
||||
if (read_random(&seed, "/dev/random") == sizeof(seed))
|
||||
return seed;
|
||||
return get_generic_seed();
|
||||
}
|
||||
65
media/ffvpx/libavutil/rc4.c
Normal file
65
media/ffvpx/libavutil/rc4.c
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* RC4 encryption/decryption/pseudo-random number generator
|
||||
* Copyright (c) 2007 Reimar Doeffinger
|
||||
*
|
||||
* loosely based on LibTomCrypt by Tom St Denis
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "avutil.h"
|
||||
#include "common.h"
|
||||
#include "mem.h"
|
||||
#include "rc4.h"
|
||||
|
||||
AVRC4 *av_rc4_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVRC4));
|
||||
}
|
||||
|
||||
int av_rc4_init(AVRC4 *r, const uint8_t *key, int key_bits, int decrypt) {
|
||||
int i, j;
|
||||
uint8_t y;
|
||||
uint8_t *state = r->state;
|
||||
int keylen = key_bits >> 3;
|
||||
if (key_bits & 7)
|
||||
return AVERROR(EINVAL);
|
||||
for (i = 0; i < 256; i++)
|
||||
state[i] = i;
|
||||
y = 0;
|
||||
// j is i % keylen
|
||||
for (j = 0, i = 0; i < 256; i++, j++) {
|
||||
if (j == keylen) j = 0;
|
||||
y += state[i] + key[j];
|
||||
FFSWAP(uint8_t, state[i], state[y]);
|
||||
}
|
||||
r->x = 1;
|
||||
r->y = state[1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_rc4_crypt(AVRC4 *r, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt) {
|
||||
uint8_t x = r->x, y = r->y;
|
||||
uint8_t *state = r->state;
|
||||
while (count-- > 0) {
|
||||
uint8_t sum = state[x] + state[y];
|
||||
FFSWAP(uint8_t, state[x], state[y]);
|
||||
*dst++ = src ? *src++ ^ state[sum] : state[sum];
|
||||
x++;
|
||||
y += state[x];
|
||||
}
|
||||
r->x = x; r->y = y;
|
||||
}
|
||||
66
media/ffvpx/libavutil/rc4.h
Normal file
66
media/ffvpx/libavutil/rc4.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* RC4 encryption/decryption/pseudo-random number generator
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_RC4_H
|
||||
#define AVUTIL_RC4_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_rc4 RC4
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef struct AVRC4 {
|
||||
uint8_t state[256];
|
||||
int x, y;
|
||||
} AVRC4;
|
||||
|
||||
/**
|
||||
* Allocate an AVRC4 context.
|
||||
*/
|
||||
AVRC4 *av_rc4_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Initializes an AVRC4 context.
|
||||
*
|
||||
* @param key_bits must be a multiple of 8
|
||||
* @param decrypt 0 for encryption, 1 for decryption, currently has no effect
|
||||
* @return zero on success, negative value otherwise
|
||||
*/
|
||||
int av_rc4_init(struct AVRC4 *d, const uint8_t *key, int key_bits, int decrypt);
|
||||
|
||||
/**
|
||||
* @brief Encrypts / decrypts using the RC4 algorithm.
|
||||
*
|
||||
* @param count number of bytes
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst, may be NULL
|
||||
* @param iv not (yet) used for RC4, should be NULL
|
||||
* @param decrypt 0 for encryption, 1 for decryption, not (yet) used
|
||||
*/
|
||||
void av_rc4_crypt(struct AVRC4 *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_RC4_H */
|
||||
551
media/ffvpx/libavutil/ripemd.c
Normal file
551
media/ffvpx/libavutil/ripemd.c
Normal file
|
|
@ -0,0 +1,551 @@
|
|||
/*
|
||||
* Copyright (C) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (C) 2013 James Almer
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "avutil.h"
|
||||
#include "bswap.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "ripemd.h"
|
||||
#include "mem.h"
|
||||
|
||||
/** hash context */
|
||||
typedef struct AVRIPEMD {
|
||||
uint8_t digest_len; ///< digest length in 32-bit words
|
||||
uint64_t count; ///< number of bytes in buffer
|
||||
uint8_t buffer[64]; ///< 512-bit buffer of input values used in hash updating
|
||||
uint32_t state[10]; ///< current hash value
|
||||
/** function used to update hash for 512-bit input block */
|
||||
void (*transform)(uint32_t *state, const uint8_t buffer[64]);
|
||||
} AVRIPEMD;
|
||||
|
||||
const int av_ripemd_size = sizeof(AVRIPEMD);
|
||||
|
||||
struct AVRIPEMD *av_ripemd_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVRIPEMD));
|
||||
}
|
||||
|
||||
static const uint32_t KA[4] = {
|
||||
0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e
|
||||
};
|
||||
|
||||
static const uint32_t KB[4] = {
|
||||
0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9
|
||||
};
|
||||
|
||||
static const int ROTA[80] = {
|
||||
11, 14, 15, 12, 5, 8, 7 , 9, 11, 13, 14, 15, 6, 7, 9, 8,
|
||||
7 , 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
|
||||
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
|
||||
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
|
||||
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
|
||||
};
|
||||
|
||||
static const int ROTB[80] = {
|
||||
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
|
||||
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
|
||||
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
|
||||
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
|
||||
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
|
||||
};
|
||||
|
||||
static const int WA[80] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
||||
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
|
||||
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
|
||||
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
|
||||
};
|
||||
|
||||
static const int WB[80] = {
|
||||
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
|
||||
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
|
||||
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
|
||||
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
|
||||
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
|
||||
};
|
||||
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
#define ROUND128_0_TO_15(a,b,c,d,e,f,g,h) \
|
||||
a = rol(a + (( b ^ c ^ d) + block[WA[n]]), ROTA[n]); \
|
||||
e = rol(e + ((((f ^ g) & h) ^ g) + block[WB[n]] + KB[0]), ROTB[n]); \
|
||||
n++
|
||||
|
||||
#define ROUND128_16_TO_31(a,b,c,d,e,f,g,h) \
|
||||
a = rol(a + ((((c ^ d) & b) ^ d) + block[WA[n]] + KA[0]), ROTA[n]); \
|
||||
e = rol(e + (((~g | f) ^ h) + block[WB[n]] + KB[1]), ROTB[n]); \
|
||||
n++
|
||||
|
||||
#define ROUND128_32_TO_47(a,b,c,d,e,f,g,h) \
|
||||
a = rol(a + (((~c | b) ^ d) + block[WA[n]] + KA[1]), ROTA[n]); \
|
||||
e = rol(e + ((((g ^ h) & f) ^ h) + block[WB[n]] + KB[2]), ROTB[n]); \
|
||||
n++
|
||||
|
||||
#define ROUND128_48_TO_63(a,b,c,d,e,f,g,h) \
|
||||
a = rol(a + ((((b ^ c) & d) ^ c) + block[WA[n]] + KA[2]), ROTA[n]); \
|
||||
e = rol(e + (( f ^ g ^ h) + block[WB[n]]), ROTB[n]); \
|
||||
n++
|
||||
|
||||
#define R128_0 \
|
||||
ROUND128_0_TO_15(a,b,c,d,e,f,g,h); \
|
||||
ROUND128_0_TO_15(d,a,b,c,h,e,f,g); \
|
||||
ROUND128_0_TO_15(c,d,a,b,g,h,e,f); \
|
||||
ROUND128_0_TO_15(b,c,d,a,f,g,h,e)
|
||||
|
||||
#define R128_16 \
|
||||
ROUND128_16_TO_31(a,b,c,d,e,f,g,h); \
|
||||
ROUND128_16_TO_31(d,a,b,c,h,e,f,g); \
|
||||
ROUND128_16_TO_31(c,d,a,b,g,h,e,f); \
|
||||
ROUND128_16_TO_31(b,c,d,a,f,g,h,e)
|
||||
|
||||
#define R128_32 \
|
||||
ROUND128_32_TO_47(a,b,c,d,e,f,g,h); \
|
||||
ROUND128_32_TO_47(d,a,b,c,h,e,f,g); \
|
||||
ROUND128_32_TO_47(c,d,a,b,g,h,e,f); \
|
||||
ROUND128_32_TO_47(b,c,d,a,f,g,h,e)
|
||||
|
||||
#define R128_48 \
|
||||
ROUND128_48_TO_63(a,b,c,d,e,f,g,h); \
|
||||
ROUND128_48_TO_63(d,a,b,c,h,e,f,g); \
|
||||
ROUND128_48_TO_63(c,d,a,b,g,h,e,f); \
|
||||
ROUND128_48_TO_63(b,c,d,a,f,g,h,e)
|
||||
|
||||
static void ripemd128_transform(uint32_t *state, const uint8_t buffer[64])
|
||||
{
|
||||
uint32_t a, b, c, d, e, f, g, h, av_unused t;
|
||||
uint32_t block[16];
|
||||
int n;
|
||||
|
||||
a = e = state[0];
|
||||
b = f = state[1];
|
||||
c = g = state[2];
|
||||
d = h = state[3];
|
||||
|
||||
for (n = 0; n < 16; n++)
|
||||
block[n] = AV_RL32(buffer + 4 * n);
|
||||
n = 0;
|
||||
|
||||
#if CONFIG_SMALL
|
||||
for (; n < 16;) {
|
||||
ROUND128_0_TO_15(a,b,c,d,e,f,g,h);
|
||||
t = d; d = c; c = b; b = a; a = t;
|
||||
t = h; h = g; g = f; f = e; e = t;
|
||||
}
|
||||
|
||||
for (; n < 32;) {
|
||||
ROUND128_16_TO_31(a,b,c,d,e,f,g,h);
|
||||
t = d; d = c; c = b; b = a; a = t;
|
||||
t = h; h = g; g = f; f = e; e = t;
|
||||
}
|
||||
|
||||
for (; n < 48;) {
|
||||
ROUND128_32_TO_47(a,b,c,d,e,f,g,h);
|
||||
t = d; d = c; c = b; b = a; a = t;
|
||||
t = h; h = g; g = f; f = e; e = t;
|
||||
}
|
||||
|
||||
for (; n < 64;) {
|
||||
ROUND128_48_TO_63(a,b,c,d,e,f,g,h);
|
||||
t = d; d = c; c = b; b = a; a = t;
|
||||
t = h; h = g; g = f; f = e; e = t;
|
||||
}
|
||||
#else
|
||||
|
||||
R128_0; R128_0; R128_0; R128_0;
|
||||
|
||||
R128_16; R128_16; R128_16; R128_16;
|
||||
|
||||
R128_32; R128_32; R128_32; R128_32;
|
||||
|
||||
R128_48; R128_48; R128_48; R128_48;
|
||||
#endif
|
||||
|
||||
h += c + state[1];
|
||||
state[1] = state[2] + d + e;
|
||||
state[2] = state[3] + a + f;
|
||||
state[3] = state[0] + b + g;
|
||||
state[0] = h;
|
||||
}
|
||||
|
||||
static void ripemd256_transform(uint32_t *state, const uint8_t buffer[64])
|
||||
{
|
||||
uint32_t a, b, c, d, e, f, g, h, av_unused t;
|
||||
uint32_t block[16];
|
||||
int n;
|
||||
|
||||
a = state[0]; b = state[1]; c = state[2]; d = state[3];
|
||||
e = state[4]; f = state[5]; g = state[6]; h = state[7];
|
||||
|
||||
for (n = 0; n < 16; n++)
|
||||
block[n] = AV_RL32(buffer + 4 * n);
|
||||
n = 0;
|
||||
|
||||
#if CONFIG_SMALL
|
||||
for (; n < 16;) {
|
||||
ROUND128_0_TO_15(a,b,c,d,e,f,g,h);
|
||||
t = d; d = c; c = b; b = a; a = t;
|
||||
t = h; h = g; g = f; f = e; e = t;
|
||||
}
|
||||
FFSWAP(uint32_t, a, e);
|
||||
|
||||
for (; n < 32;) {
|
||||
ROUND128_16_TO_31(a,b,c,d,e,f,g,h);
|
||||
t = d; d = c; c = b; b = a; a = t;
|
||||
t = h; h = g; g = f; f = e; e = t;
|
||||
}
|
||||
FFSWAP(uint32_t, b, f);
|
||||
|
||||
for (; n < 48;) {
|
||||
ROUND128_32_TO_47(a,b,c,d,e,f,g,h);
|
||||
t = d; d = c; c = b; b = a; a = t;
|
||||
t = h; h = g; g = f; f = e; e = t;
|
||||
}
|
||||
FFSWAP(uint32_t, c, g);
|
||||
|
||||
for (; n < 64;) {
|
||||
ROUND128_48_TO_63(a,b,c,d,e,f,g,h);
|
||||
t = d; d = c; c = b; b = a; a = t;
|
||||
t = h; h = g; g = f; f = e; e = t;
|
||||
}
|
||||
FFSWAP(uint32_t, d, h);
|
||||
#else
|
||||
|
||||
R128_0; R128_0; R128_0; R128_0;
|
||||
FFSWAP(uint32_t, a, e);
|
||||
|
||||
R128_16; R128_16; R128_16; R128_16;
|
||||
FFSWAP(uint32_t, b, f);
|
||||
|
||||
R128_32; R128_32; R128_32; R128_32;
|
||||
FFSWAP(uint32_t, c, g);
|
||||
|
||||
R128_48; R128_48; R128_48; R128_48;
|
||||
FFSWAP(uint32_t, d, h);
|
||||
#endif
|
||||
|
||||
state[0] += a; state[1] += b; state[2] += c; state[3] += d;
|
||||
state[4] += e; state[5] += f; state[6] += g; state[7] += h;
|
||||
}
|
||||
|
||||
#define ROTATE(x,y) \
|
||||
x = rol(x, 10); \
|
||||
y = rol(y, 10); \
|
||||
n++
|
||||
|
||||
#define ROUND160_0_TO_15(a,b,c,d,e,f,g,h,i,j) \
|
||||
a = rol(a + (( b ^ c ^ d) + block[WA[n]]), ROTA[n]) + e; \
|
||||
f = rol(f + (((~i | h) ^ g) + block[WB[n]] + KB[0]), ROTB[n]) + j; \
|
||||
ROTATE(c,h)
|
||||
|
||||
#define ROUND160_16_TO_31(a,b,c,d,e,f,g,h,i,j) \
|
||||
a = rol(a + ((((c ^ d) & b) ^ d) + block[WA[n]] + KA[0]), ROTA[n]) + e; \
|
||||
f = rol(f + ((((g ^ h) & i) ^ h) + block[WB[n]] + KB[1]), ROTB[n]) + j; \
|
||||
ROTATE(c,h)
|
||||
|
||||
#define ROUND160_32_TO_47(a,b,c,d,e,f,g,h,i,j) \
|
||||
a = rol(a + (((~c | b) ^ d) + block[WA[n]] + KA[1]), ROTA[n]) + e; \
|
||||
f = rol(f + (((~h | g) ^ i) + block[WB[n]] + KB[2]), ROTB[n]) + j; \
|
||||
ROTATE(c,h)
|
||||
|
||||
#define ROUND160_48_TO_63(a,b,c,d,e,f,g,h,i,j) \
|
||||
a = rol(a + ((((b ^ c) & d) ^ c) + block[WA[n]] + KA[2]), ROTA[n]) + e; \
|
||||
f = rol(f + ((((h ^ i) & g) ^ i) + block[WB[n]] + KB[3]), ROTB[n]) + j; \
|
||||
ROTATE(c,h)
|
||||
|
||||
#define ROUND160_64_TO_79(a,b,c,d,e,f,g,h,i,j) \
|
||||
a = rol(a + (((~d | c) ^ b) + block[WA[n]] + KA[3]), ROTA[n]) + e; \
|
||||
f = rol(f + (( g ^ h ^ i) + block[WB[n]]), ROTB[n]) + j; \
|
||||
ROTATE(c,h)
|
||||
|
||||
#define R160_0 \
|
||||
ROUND160_0_TO_15(a,b,c,d,e,f,g,h,i,j); \
|
||||
ROUND160_0_TO_15(e,a,b,c,d,j,f,g,h,i); \
|
||||
ROUND160_0_TO_15(d,e,a,b,c,i,j,f,g,h); \
|
||||
ROUND160_0_TO_15(c,d,e,a,b,h,i,j,f,g); \
|
||||
ROUND160_0_TO_15(b,c,d,e,a,g,h,i,j,f)
|
||||
|
||||
#define R160_16 \
|
||||
ROUND160_16_TO_31(e,a,b,c,d,j,f,g,h,i); \
|
||||
ROUND160_16_TO_31(d,e,a,b,c,i,j,f,g,h); \
|
||||
ROUND160_16_TO_31(c,d,e,a,b,h,i,j,f,g); \
|
||||
ROUND160_16_TO_31(b,c,d,e,a,g,h,i,j,f); \
|
||||
ROUND160_16_TO_31(a,b,c,d,e,f,g,h,i,j)
|
||||
|
||||
#define R160_32 \
|
||||
ROUND160_32_TO_47(d,e,a,b,c,i,j,f,g,h); \
|
||||
ROUND160_32_TO_47(c,d,e,a,b,h,i,j,f,g); \
|
||||
ROUND160_32_TO_47(b,c,d,e,a,g,h,i,j,f); \
|
||||
ROUND160_32_TO_47(a,b,c,d,e,f,g,h,i,j); \
|
||||
ROUND160_32_TO_47(e,a,b,c,d,j,f,g,h,i)
|
||||
|
||||
#define R160_48 \
|
||||
ROUND160_48_TO_63(c,d,e,a,b,h,i,j,f,g); \
|
||||
ROUND160_48_TO_63(b,c,d,e,a,g,h,i,j,f); \
|
||||
ROUND160_48_TO_63(a,b,c,d,e,f,g,h,i,j); \
|
||||
ROUND160_48_TO_63(e,a,b,c,d,j,f,g,h,i); \
|
||||
ROUND160_48_TO_63(d,e,a,b,c,i,j,f,g,h)
|
||||
|
||||
#define R160_64 \
|
||||
ROUND160_64_TO_79(b,c,d,e,a,g,h,i,j,f); \
|
||||
ROUND160_64_TO_79(a,b,c,d,e,f,g,h,i,j); \
|
||||
ROUND160_64_TO_79(e,a,b,c,d,j,f,g,h,i); \
|
||||
ROUND160_64_TO_79(d,e,a,b,c,i,j,f,g,h); \
|
||||
ROUND160_64_TO_79(c,d,e,a,b,h,i,j,f,g)
|
||||
|
||||
static void ripemd160_transform(uint32_t *state, const uint8_t buffer[64])
|
||||
{
|
||||
uint32_t a, b, c, d, e, f, g, h, i, j, av_unused t;
|
||||
uint32_t block[16];
|
||||
int n;
|
||||
|
||||
a = f = state[0];
|
||||
b = g = state[1];
|
||||
c = h = state[2];
|
||||
d = i = state[3];
|
||||
e = j = state[4];
|
||||
|
||||
for (n = 0; n < 16; n++)
|
||||
block[n] = AV_RL32(buffer + 4 * n);
|
||||
n = 0;
|
||||
|
||||
#if CONFIG_SMALL
|
||||
for (; n < 16;) {
|
||||
ROUND160_0_TO_15(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
|
||||
for (; n < 32;) {
|
||||
ROUND160_16_TO_31(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
|
||||
for (; n < 48;) {
|
||||
ROUND160_32_TO_47(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
|
||||
for (; n < 64;) {
|
||||
ROUND160_48_TO_63(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
|
||||
for (; n < 80;) {
|
||||
ROUND160_64_TO_79(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
#else
|
||||
|
||||
R160_0; R160_0; R160_0;
|
||||
ROUND160_0_TO_15(a,b,c,d,e,f,g,h,i,j);
|
||||
|
||||
R160_16; R160_16; R160_16;
|
||||
ROUND160_16_TO_31(e,a,b,c,d,j,f,g,h,i);
|
||||
|
||||
R160_32; R160_32; R160_32;
|
||||
ROUND160_32_TO_47(d,e,a,b,c,i,j,f,g,h);
|
||||
|
||||
R160_48; R160_48; R160_48;
|
||||
ROUND160_48_TO_63(c,d,e,a,b,h,i,j,f,g);
|
||||
|
||||
R160_64; R160_64; R160_64;
|
||||
ROUND160_64_TO_79(b,c,d,e,a,g,h,i,j,f);
|
||||
#endif
|
||||
|
||||
i += c + state[1];
|
||||
state[1] = state[2] + d + j;
|
||||
state[2] = state[3] + e + f;
|
||||
state[3] = state[4] + a + g;
|
||||
state[4] = state[0] + b + h;
|
||||
state[0] = i;
|
||||
}
|
||||
|
||||
static void ripemd320_transform(uint32_t *state, const uint8_t buffer[64])
|
||||
{
|
||||
uint32_t a, b, c, d, e, f, g, h, i, j, av_unused t;
|
||||
uint32_t block[16];
|
||||
int n;
|
||||
|
||||
a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4];
|
||||
f = state[5]; g = state[6]; h = state[7]; i = state[8]; j = state[9];
|
||||
|
||||
for (n = 0; n < 16; n++)
|
||||
block[n] = AV_RL32(buffer + 4 * n);
|
||||
n = 0;
|
||||
|
||||
#if CONFIG_SMALL
|
||||
for (; n < 16;) {
|
||||
ROUND160_0_TO_15(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
FFSWAP(uint32_t, b, g);
|
||||
|
||||
for (; n < 32;) {
|
||||
ROUND160_16_TO_31(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
FFSWAP(uint32_t, d, i);
|
||||
|
||||
for (; n < 48;) {
|
||||
ROUND160_32_TO_47(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
FFSWAP(uint32_t, a, f);
|
||||
|
||||
for (; n < 64;) {
|
||||
ROUND160_48_TO_63(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
FFSWAP(uint32_t, c, h);
|
||||
|
||||
for (; n < 80;) {
|
||||
ROUND160_64_TO_79(a,b,c,d,e,f,g,h,i,j);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
t = j; j = i; i = h; h = g; g = f; f = t;
|
||||
}
|
||||
FFSWAP(uint32_t, e, j);
|
||||
#else
|
||||
|
||||
R160_0; R160_0; R160_0;
|
||||
ROUND160_0_TO_15(a,b,c,d,e,f,g,h,i,j);
|
||||
FFSWAP(uint32_t, a, f);
|
||||
|
||||
R160_16; R160_16; R160_16;
|
||||
ROUND160_16_TO_31(e,a,b,c,d,j,f,g,h,i);
|
||||
FFSWAP(uint32_t, b, g);
|
||||
|
||||
R160_32; R160_32; R160_32;
|
||||
ROUND160_32_TO_47(d,e,a,b,c,i,j,f,g,h);
|
||||
FFSWAP(uint32_t, c, h);
|
||||
|
||||
R160_48; R160_48; R160_48;
|
||||
ROUND160_48_TO_63(c,d,e,a,b,h,i,j,f,g);
|
||||
FFSWAP(uint32_t, d, i);
|
||||
|
||||
R160_64; R160_64; R160_64;
|
||||
ROUND160_64_TO_79(b,c,d,e,a,g,h,i,j,f);
|
||||
FFSWAP(uint32_t, e, j);
|
||||
#endif
|
||||
|
||||
state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e;
|
||||
state[5] += f; state[6] += g; state[7] += h; state[8] += i; state[9] += j;
|
||||
}
|
||||
|
||||
av_cold int av_ripemd_init(AVRIPEMD *ctx, int bits)
|
||||
{
|
||||
ctx->digest_len = bits >> 5;
|
||||
switch (bits) {
|
||||
case 128: // RIPEMD-128
|
||||
ctx->state[0] = 0x67452301;
|
||||
ctx->state[1] = 0xEFCDAB89;
|
||||
ctx->state[2] = 0x98BADCFE;
|
||||
ctx->state[3] = 0x10325476;
|
||||
ctx->transform = ripemd128_transform;
|
||||
break;
|
||||
case 160: // RIPEMD-160
|
||||
ctx->state[0] = 0x67452301;
|
||||
ctx->state[1] = 0xEFCDAB89;
|
||||
ctx->state[2] = 0x98BADCFE;
|
||||
ctx->state[3] = 0x10325476;
|
||||
ctx->state[4] = 0xC3D2E1F0;
|
||||
ctx->transform = ripemd160_transform;
|
||||
break;
|
||||
case 256: // RIPEMD-256
|
||||
ctx->state[0] = 0x67452301;
|
||||
ctx->state[1] = 0xEFCDAB89;
|
||||
ctx->state[2] = 0x98BADCFE;
|
||||
ctx->state[3] = 0x10325476;
|
||||
ctx->state[4] = 0x76543210;
|
||||
ctx->state[5] = 0xFEDCBA98;
|
||||
ctx->state[6] = 0x89ABCDEF;
|
||||
ctx->state[7] = 0x01234567;
|
||||
ctx->transform = ripemd256_transform;
|
||||
break;
|
||||
case 320: // RIPEMD-320
|
||||
ctx->state[0] = 0x67452301;
|
||||
ctx->state[1] = 0xEFCDAB89;
|
||||
ctx->state[2] = 0x98BADCFE;
|
||||
ctx->state[3] = 0x10325476;
|
||||
ctx->state[4] = 0xC3D2E1F0;
|
||||
ctx->state[5] = 0x76543210;
|
||||
ctx->state[6] = 0xFEDCBA98;
|
||||
ctx->state[7] = 0x89ABCDEF;
|
||||
ctx->state[8] = 0x01234567;
|
||||
ctx->state[9] = 0x3C2D1E0F;
|
||||
ctx->transform = ripemd320_transform;
|
||||
break;
|
||||
default:
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
ctx->count = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_ripemd_update(AVRIPEMD* ctx, const uint8_t* data, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
j = ctx->count & 63;
|
||||
ctx->count += len;
|
||||
#if CONFIG_SMALL
|
||||
for (i = 0; i < len; i++) {
|
||||
ctx->buffer[j++] = data[i];
|
||||
if (64 == j) {
|
||||
ctx->transform(ctx->state, ctx->buffer);
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if ((j + len) > 63) {
|
||||
memcpy(&ctx->buffer[j], data, (i = 64 - j));
|
||||
ctx->transform(ctx->state, ctx->buffer);
|
||||
for (; i + 63 < len; i += 64)
|
||||
ctx->transform(ctx->state, &data[i]);
|
||||
j = 0;
|
||||
} else
|
||||
i = 0;
|
||||
memcpy(&ctx->buffer[j], &data[i], len - i);
|
||||
#endif
|
||||
}
|
||||
|
||||
void av_ripemd_final(AVRIPEMD* ctx, uint8_t *digest)
|
||||
{
|
||||
int i;
|
||||
uint64_t finalcount = av_le2ne64(ctx->count << 3);
|
||||
|
||||
av_ripemd_update(ctx, "\200", 1);
|
||||
while ((ctx->count & 63) != 56)
|
||||
av_ripemd_update(ctx, "", 1);
|
||||
av_ripemd_update(ctx, (uint8_t *)&finalcount, 8); /* Should cause a transform() */
|
||||
for (i = 0; i < ctx->digest_len; i++)
|
||||
AV_WL32(digest + i*4, ctx->state[i]);
|
||||
}
|
||||
83
media/ffvpx/libavutil/ripemd.h
Normal file
83
media/ffvpx/libavutil/ripemd.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (C) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (C) 2013 James Almer <jamrial@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavu_ripemd
|
||||
* Public header for RIPEMD hash function implementation.
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_RIPEMD_H
|
||||
#define AVUTIL_RIPEMD_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_ripemd RIPEMD
|
||||
* @ingroup lavu_hash
|
||||
* RIPEMD hash function implementation.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_ripemd_size;
|
||||
|
||||
struct AVRIPEMD;
|
||||
|
||||
/**
|
||||
* Allocate an AVRIPEMD context.
|
||||
*/
|
||||
struct AVRIPEMD *av_ripemd_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize RIPEMD hashing.
|
||||
*
|
||||
* @param context pointer to the function context (of size av_ripemd_size)
|
||||
* @param bits number of bits in digest (128, 160, 256 or 320 bits)
|
||||
* @return zero if initialization succeeded, -1 otherwise
|
||||
*/
|
||||
int av_ripemd_init(struct AVRIPEMD* context, int bits);
|
||||
|
||||
/**
|
||||
* Update hash value.
|
||||
*
|
||||
* @param context hash function context
|
||||
* @param data input data to update hash with
|
||||
* @param len input data length
|
||||
*/
|
||||
void av_ripemd_update(struct AVRIPEMD* context, const uint8_t* data, unsigned int len);
|
||||
|
||||
/**
|
||||
* Finish hashing and output digest value.
|
||||
*
|
||||
* @param context hash function context
|
||||
* @param digest buffer where output digest value is stored
|
||||
*/
|
||||
void av_ripemd_final(struct AVRIPEMD* context, uint8_t *digest);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_RIPEMD_H */
|
||||
356
media/ffvpx/libavutil/sha.c
Normal file
356
media/ffvpx/libavutil/sha.c
Normal file
|
|
@ -0,0 +1,356 @@
|
|||
/*
|
||||
* Copyright (C) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (C) 2009 Konstantin Shishkov
|
||||
* based on public domain SHA-1 code by Steve Reid <steve@edmweb.com>
|
||||
* and on BSD-licensed SHA-2 code by Aaron D. Gifford
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "avutil.h"
|
||||
#include "bswap.h"
|
||||
#include "sha.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "mem.h"
|
||||
|
||||
/** hash context */
|
||||
typedef struct AVSHA {
|
||||
uint8_t digest_len; ///< digest length in 32-bit words
|
||||
uint64_t count; ///< number of bytes in buffer
|
||||
uint8_t buffer[64]; ///< 512-bit buffer of input values used in hash updating
|
||||
uint32_t state[8]; ///< current hash value
|
||||
/** function used to update hash for 512-bit input block */
|
||||
void (*transform)(uint32_t *state, const uint8_t buffer[64]);
|
||||
} AVSHA;
|
||||
|
||||
const int av_sha_size = sizeof(AVSHA);
|
||||
|
||||
struct AVSHA *av_sha_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVSHA));
|
||||
}
|
||||
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
|
||||
#define blk0(i) (block[i] = AV_RB32(buffer + 4 * (i)))
|
||||
#define blk(i) (block[i] = rol(block[(i)-3] ^ block[(i)-8] ^ block[(i)-14] ^ block[(i)-16], 1))
|
||||
|
||||
#define R0(v,w,x,y,z,i) z += (((w)&((x)^(y)))^(y)) + blk0(i) + 0x5A827999 + rol(v, 5); w = rol(w, 30);
|
||||
#define R1(v,w,x,y,z,i) z += (((w)&((x)^(y)))^(y)) + blk (i) + 0x5A827999 + rol(v, 5); w = rol(w, 30);
|
||||
#define R2(v,w,x,y,z,i) z += ( (w)^(x) ^(y)) + blk (i) + 0x6ED9EBA1 + rol(v, 5); w = rol(w, 30);
|
||||
#define R3(v,w,x,y,z,i) z += ((((w)|(x))&(y))|((w)&(x))) + blk (i) + 0x8F1BBCDC + rol(v, 5); w = rol(w, 30);
|
||||
#define R4(v,w,x,y,z,i) z += ( (w)^(x) ^(y)) + blk (i) + 0xCA62C1D6 + rol(v, 5); w = rol(w, 30);
|
||||
|
||||
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
||||
|
||||
static void sha1_transform(uint32_t state[5], const uint8_t buffer[64])
|
||||
{
|
||||
uint32_t block[80];
|
||||
unsigned int i, a, b, c, d, e;
|
||||
|
||||
a = state[0];
|
||||
b = state[1];
|
||||
c = state[2];
|
||||
d = state[3];
|
||||
e = state[4];
|
||||
#if CONFIG_SMALL
|
||||
for (i = 0; i < 80; i++) {
|
||||
int t;
|
||||
if (i < 16)
|
||||
t = AV_RB32(buffer + 4 * i);
|
||||
else
|
||||
t = rol(block[i-3] ^ block[i-8] ^ block[i-14] ^ block[i-16], 1);
|
||||
block[i] = t;
|
||||
t += e + rol(a, 5);
|
||||
if (i < 40) {
|
||||
if (i < 20)
|
||||
t += ((b&(c^d))^d) + 0x5A827999;
|
||||
else
|
||||
t += ( b^c ^d) + 0x6ED9EBA1;
|
||||
} else {
|
||||
if (i < 60)
|
||||
t += (((b|c)&d)|(b&c)) + 0x8F1BBCDC;
|
||||
else
|
||||
t += ( b^c ^d) + 0xCA62C1D6;
|
||||
}
|
||||
e = d;
|
||||
d = c;
|
||||
c = rol(b, 30);
|
||||
b = a;
|
||||
a = t;
|
||||
}
|
||||
#else
|
||||
|
||||
#define R1_0 \
|
||||
R0(a, b, c, d, e, 0 + i); \
|
||||
R0(e, a, b, c, d, 1 + i); \
|
||||
R0(d, e, a, b, c, 2 + i); \
|
||||
R0(c, d, e, a, b, 3 + i); \
|
||||
R0(b, c, d, e, a, 4 + i); \
|
||||
i += 5
|
||||
|
||||
i = 0;
|
||||
R1_0; R1_0; R1_0;
|
||||
R0(a, b, c, d, e, 15);
|
||||
R1(e, a, b, c, d, 16);
|
||||
R1(d, e, a, b, c, 17);
|
||||
R1(c, d, e, a, b, 18);
|
||||
R1(b, c, d, e, a, 19);
|
||||
|
||||
#define R1_20 \
|
||||
R2(a, b, c, d, e, 0 + i); \
|
||||
R2(e, a, b, c, d, 1 + i); \
|
||||
R2(d, e, a, b, c, 2 + i); \
|
||||
R2(c, d, e, a, b, 3 + i); \
|
||||
R2(b, c, d, e, a, 4 + i); \
|
||||
i += 5
|
||||
|
||||
i = 20;
|
||||
R1_20; R1_20; R1_20; R1_20;
|
||||
|
||||
#define R1_40 \
|
||||
R3(a, b, c, d, e, 0 + i); \
|
||||
R3(e, a, b, c, d, 1 + i); \
|
||||
R3(d, e, a, b, c, 2 + i); \
|
||||
R3(c, d, e, a, b, 3 + i); \
|
||||
R3(b, c, d, e, a, 4 + i); \
|
||||
i += 5
|
||||
|
||||
R1_40; R1_40; R1_40; R1_40;
|
||||
|
||||
#define R1_60 \
|
||||
R4(a, b, c, d, e, 0 + i); \
|
||||
R4(e, a, b, c, d, 1 + i); \
|
||||
R4(d, e, a, b, c, 2 + i); \
|
||||
R4(c, d, e, a, b, 3 + i); \
|
||||
R4(b, c, d, e, a, 4 + i); \
|
||||
i += 5
|
||||
|
||||
R1_60; R1_60; R1_60; R1_60;
|
||||
#endif
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
}
|
||||
|
||||
static const uint32_t K256[64] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
||||
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
||||
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
|
||||
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
||||
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
|
||||
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
|
||||
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
||||
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
|
||||
|
||||
#define Ch(x,y,z) (((x) & ((y) ^ (z))) ^ (z))
|
||||
#define Maj(z,y,x) ((((x) | (y)) & (z)) | ((x) & (y)))
|
||||
|
||||
#define Sigma0_256(x) (rol((x), 30) ^ rol((x), 19) ^ rol((x), 10))
|
||||
#define Sigma1_256(x) (rol((x), 26) ^ rol((x), 21) ^ rol((x), 7))
|
||||
#define sigma0_256(x) (rol((x), 25) ^ rol((x), 14) ^ ((x) >> 3))
|
||||
#define sigma1_256(x) (rol((x), 15) ^ rol((x), 13) ^ ((x) >> 10))
|
||||
|
||||
#undef blk
|
||||
#define blk(i) (block[i] = block[i - 16] + sigma0_256(block[i - 15]) + \
|
||||
sigma1_256(block[i - 2]) + block[i - 7])
|
||||
|
||||
#define ROUND256(a,b,c,d,e,f,g,h) \
|
||||
T1 += (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[i]; \
|
||||
(d) += T1; \
|
||||
(h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
|
||||
i++
|
||||
|
||||
#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
|
||||
T1 = blk0(i); \
|
||||
ROUND256(a,b,c,d,e,f,g,h)
|
||||
|
||||
#define ROUND256_16_TO_63(a,b,c,d,e,f,g,h) \
|
||||
T1 = blk(i); \
|
||||
ROUND256(a,b,c,d,e,f,g,h)
|
||||
|
||||
static void sha256_transform(uint32_t *state, const uint8_t buffer[64])
|
||||
{
|
||||
unsigned int i, a, b, c, d, e, f, g, h;
|
||||
uint32_t block[64];
|
||||
uint32_t T1;
|
||||
|
||||
a = state[0];
|
||||
b = state[1];
|
||||
c = state[2];
|
||||
d = state[3];
|
||||
e = state[4];
|
||||
f = state[5];
|
||||
g = state[6];
|
||||
h = state[7];
|
||||
#if CONFIG_SMALL
|
||||
for (i = 0; i < 64; i++) {
|
||||
uint32_t T2;
|
||||
if (i < 16)
|
||||
T1 = blk0(i);
|
||||
else
|
||||
T1 = blk(i);
|
||||
T1 += h + Sigma1_256(e) + Ch(e, f, g) + K256[i];
|
||||
T2 = Sigma0_256(a) + Maj(a, b, c);
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = d + T1;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = T1 + T2;
|
||||
}
|
||||
#else
|
||||
|
||||
i = 0;
|
||||
#define R256_0 \
|
||||
ROUND256_0_TO_15(a, b, c, d, e, f, g, h); \
|
||||
ROUND256_0_TO_15(h, a, b, c, d, e, f, g); \
|
||||
ROUND256_0_TO_15(g, h, a, b, c, d, e, f); \
|
||||
ROUND256_0_TO_15(f, g, h, a, b, c, d, e); \
|
||||
ROUND256_0_TO_15(e, f, g, h, a, b, c, d); \
|
||||
ROUND256_0_TO_15(d, e, f, g, h, a, b, c); \
|
||||
ROUND256_0_TO_15(c, d, e, f, g, h, a, b); \
|
||||
ROUND256_0_TO_15(b, c, d, e, f, g, h, a)
|
||||
|
||||
R256_0; R256_0;
|
||||
|
||||
#define R256_16 \
|
||||
ROUND256_16_TO_63(a, b, c, d, e, f, g, h); \
|
||||
ROUND256_16_TO_63(h, a, b, c, d, e, f, g); \
|
||||
ROUND256_16_TO_63(g, h, a, b, c, d, e, f); \
|
||||
ROUND256_16_TO_63(f, g, h, a, b, c, d, e); \
|
||||
ROUND256_16_TO_63(e, f, g, h, a, b, c, d); \
|
||||
ROUND256_16_TO_63(d, e, f, g, h, a, b, c); \
|
||||
ROUND256_16_TO_63(c, d, e, f, g, h, a, b); \
|
||||
ROUND256_16_TO_63(b, c, d, e, f, g, h, a)
|
||||
|
||||
R256_16; R256_16; R256_16;
|
||||
R256_16; R256_16; R256_16;
|
||||
#endif
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
state[5] += f;
|
||||
state[6] += g;
|
||||
state[7] += h;
|
||||
}
|
||||
|
||||
|
||||
av_cold int av_sha_init(AVSHA *ctx, int bits)
|
||||
{
|
||||
ctx->digest_len = bits >> 5;
|
||||
switch (bits) {
|
||||
case 160: // SHA-1
|
||||
ctx->state[0] = 0x67452301;
|
||||
ctx->state[1] = 0xEFCDAB89;
|
||||
ctx->state[2] = 0x98BADCFE;
|
||||
ctx->state[3] = 0x10325476;
|
||||
ctx->state[4] = 0xC3D2E1F0;
|
||||
ctx->transform = sha1_transform;
|
||||
break;
|
||||
case 224: // SHA-224
|
||||
ctx->state[0] = 0xC1059ED8;
|
||||
ctx->state[1] = 0x367CD507;
|
||||
ctx->state[2] = 0x3070DD17;
|
||||
ctx->state[3] = 0xF70E5939;
|
||||
ctx->state[4] = 0xFFC00B31;
|
||||
ctx->state[5] = 0x68581511;
|
||||
ctx->state[6] = 0x64F98FA7;
|
||||
ctx->state[7] = 0xBEFA4FA4;
|
||||
ctx->transform = sha256_transform;
|
||||
break;
|
||||
case 256: // SHA-256
|
||||
ctx->state[0] = 0x6A09E667;
|
||||
ctx->state[1] = 0xBB67AE85;
|
||||
ctx->state[2] = 0x3C6EF372;
|
||||
ctx->state[3] = 0xA54FF53A;
|
||||
ctx->state[4] = 0x510E527F;
|
||||
ctx->state[5] = 0x9B05688C;
|
||||
ctx->state[6] = 0x1F83D9AB;
|
||||
ctx->state[7] = 0x5BE0CD19;
|
||||
ctx->transform = sha256_transform;
|
||||
break;
|
||||
default:
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
ctx->count = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if FF_API_CRYPTO_SIZE_T
|
||||
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len)
|
||||
#else
|
||||
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len)
|
||||
#endif
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
j = ctx->count & 63;
|
||||
ctx->count += len;
|
||||
#if CONFIG_SMALL
|
||||
for (i = 0; i < len; i++) {
|
||||
ctx->buffer[j++] = data[i];
|
||||
if (64 == j) {
|
||||
ctx->transform(ctx->state, ctx->buffer);
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if ((j + len) > 63) {
|
||||
memcpy(&ctx->buffer[j], data, (i = 64 - j));
|
||||
ctx->transform(ctx->state, ctx->buffer);
|
||||
for (; i + 63 < len; i += 64)
|
||||
ctx->transform(ctx->state, &data[i]);
|
||||
j = 0;
|
||||
} else
|
||||
i = 0;
|
||||
memcpy(&ctx->buffer[j], &data[i], len - i);
|
||||
#endif
|
||||
}
|
||||
|
||||
void av_sha_final(AVSHA* ctx, uint8_t *digest)
|
||||
{
|
||||
int i;
|
||||
uint64_t finalcount = av_be2ne64(ctx->count << 3);
|
||||
|
||||
av_sha_update(ctx, "\200", 1);
|
||||
while ((ctx->count & 63) != 56)
|
||||
av_sha_update(ctx, "", 1);
|
||||
av_sha_update(ctx, (uint8_t *)&finalcount, 8); /* Should cause a transform() */
|
||||
for (i = 0; i < ctx->digest_len; i++)
|
||||
AV_WB32(digest + i*4, ctx->state[i]);
|
||||
}
|
||||
95
media/ffvpx/libavutil/sha.h
Normal file
95
media/ffvpx/libavutil/sha.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright (C) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavu_sha
|
||||
* Public header for SHA-1 & SHA-256 hash function implementations.
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_SHA_H
|
||||
#define AVUTIL_SHA_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_sha SHA
|
||||
* @ingroup lavu_hash
|
||||
* SHA-1 and SHA-256 (Secure Hash Algorithm) hash function implementations.
|
||||
*
|
||||
* This module supports the following SHA hash functions:
|
||||
*
|
||||
* - SHA-1: 160 bits
|
||||
* - SHA-224: 224 bits, as a variant of SHA-2
|
||||
* - SHA-256: 256 bits, as a variant of SHA-2
|
||||
*
|
||||
* @see For SHA-384, SHA-512, and variants thereof, see @ref lavu_sha512.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_sha_size;
|
||||
|
||||
struct AVSHA;
|
||||
|
||||
/**
|
||||
* Allocate an AVSHA context.
|
||||
*/
|
||||
struct AVSHA *av_sha_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize SHA-1 or SHA-2 hashing.
|
||||
*
|
||||
* @param context pointer to the function context (of size av_sha_size)
|
||||
* @param bits number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits)
|
||||
* @return zero if initialization succeeded, -1 otherwise
|
||||
*/
|
||||
int av_sha_init(struct AVSHA* context, int bits);
|
||||
|
||||
/**
|
||||
* Update hash value.
|
||||
*
|
||||
* @param ctx hash function context
|
||||
* @param data input data to update hash with
|
||||
* @param len input data length
|
||||
*/
|
||||
#if FF_API_CRYPTO_SIZE_T
|
||||
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len);
|
||||
#else
|
||||
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Finish hashing and output digest value.
|
||||
*
|
||||
* @param context hash function context
|
||||
* @param digest buffer where output digest value is stored
|
||||
*/
|
||||
void av_sha_final(struct AVSHA* context, uint8_t *digest);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_SHA_H */
|
||||
287
media/ffvpx/libavutil/sha512.c
Normal file
287
media/ffvpx/libavutil/sha512.c
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
/*
|
||||
* Copyright (C) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (C) 2009 Konstantin Shishkov
|
||||
* Copyright (C) 2013 James Almer
|
||||
* based on BSD-licensed SHA-2 code by Aaron D. Gifford
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "avutil.h"
|
||||
#include "bswap.h"
|
||||
#include "sha512.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "mem.h"
|
||||
|
||||
/** hash context */
|
||||
typedef struct AVSHA512 {
|
||||
uint8_t digest_len; ///< digest length in 64-bit words
|
||||
uint64_t count; ///< number of bytes in buffer
|
||||
uint8_t buffer[128]; ///< 1024-bit buffer of input values used in hash updating
|
||||
uint64_t state[8]; ///< current hash value
|
||||
} AVSHA512;
|
||||
|
||||
const int av_sha512_size = sizeof(AVSHA512);
|
||||
|
||||
struct AVSHA512 *av_sha512_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVSHA512));
|
||||
}
|
||||
|
||||
static const uint64_t K512[80] = {
|
||||
UINT64_C(0x428a2f98d728ae22), UINT64_C(0x7137449123ef65cd),
|
||||
UINT64_C(0xb5c0fbcfec4d3b2f), UINT64_C(0xe9b5dba58189dbbc),
|
||||
UINT64_C(0x3956c25bf348b538), UINT64_C(0x59f111f1b605d019),
|
||||
UINT64_C(0x923f82a4af194f9b), UINT64_C(0xab1c5ed5da6d8118),
|
||||
UINT64_C(0xd807aa98a3030242), UINT64_C(0x12835b0145706fbe),
|
||||
UINT64_C(0x243185be4ee4b28c), UINT64_C(0x550c7dc3d5ffb4e2),
|
||||
UINT64_C(0x72be5d74f27b896f), UINT64_C(0x80deb1fe3b1696b1),
|
||||
UINT64_C(0x9bdc06a725c71235), UINT64_C(0xc19bf174cf692694),
|
||||
UINT64_C(0xe49b69c19ef14ad2), UINT64_C(0xefbe4786384f25e3),
|
||||
UINT64_C(0x0fc19dc68b8cd5b5), UINT64_C(0x240ca1cc77ac9c65),
|
||||
UINT64_C(0x2de92c6f592b0275), UINT64_C(0x4a7484aa6ea6e483),
|
||||
UINT64_C(0x5cb0a9dcbd41fbd4), UINT64_C(0x76f988da831153b5),
|
||||
UINT64_C(0x983e5152ee66dfab), UINT64_C(0xa831c66d2db43210),
|
||||
UINT64_C(0xb00327c898fb213f), UINT64_C(0xbf597fc7beef0ee4),
|
||||
UINT64_C(0xc6e00bf33da88fc2), UINT64_C(0xd5a79147930aa725),
|
||||
UINT64_C(0x06ca6351e003826f), UINT64_C(0x142929670a0e6e70),
|
||||
UINT64_C(0x27b70a8546d22ffc), UINT64_C(0x2e1b21385c26c926),
|
||||
UINT64_C(0x4d2c6dfc5ac42aed), UINT64_C(0x53380d139d95b3df),
|
||||
UINT64_C(0x650a73548baf63de), UINT64_C(0x766a0abb3c77b2a8),
|
||||
UINT64_C(0x81c2c92e47edaee6), UINT64_C(0x92722c851482353b),
|
||||
UINT64_C(0xa2bfe8a14cf10364), UINT64_C(0xa81a664bbc423001),
|
||||
UINT64_C(0xc24b8b70d0f89791), UINT64_C(0xc76c51a30654be30),
|
||||
UINT64_C(0xd192e819d6ef5218), UINT64_C(0xd69906245565a910),
|
||||
UINT64_C(0xf40e35855771202a), UINT64_C(0x106aa07032bbd1b8),
|
||||
UINT64_C(0x19a4c116b8d2d0c8), UINT64_C(0x1e376c085141ab53),
|
||||
UINT64_C(0x2748774cdf8eeb99), UINT64_C(0x34b0bcb5e19b48a8),
|
||||
UINT64_C(0x391c0cb3c5c95a63), UINT64_C(0x4ed8aa4ae3418acb),
|
||||
UINT64_C(0x5b9cca4f7763e373), UINT64_C(0x682e6ff3d6b2b8a3),
|
||||
UINT64_C(0x748f82ee5defb2fc), UINT64_C(0x78a5636f43172f60),
|
||||
UINT64_C(0x84c87814a1f0ab72), UINT64_C(0x8cc702081a6439ec),
|
||||
UINT64_C(0x90befffa23631e28), UINT64_C(0xa4506cebde82bde9),
|
||||
UINT64_C(0xbef9a3f7b2c67915), UINT64_C(0xc67178f2e372532b),
|
||||
UINT64_C(0xca273eceea26619c), UINT64_C(0xd186b8c721c0c207),
|
||||
UINT64_C(0xeada7dd6cde0eb1e), UINT64_C(0xf57d4f7fee6ed178),
|
||||
UINT64_C(0x06f067aa72176fba), UINT64_C(0x0a637dc5a2c898a6),
|
||||
UINT64_C(0x113f9804bef90dae), UINT64_C(0x1b710b35131c471b),
|
||||
UINT64_C(0x28db77f523047d84), UINT64_C(0x32caab7b40c72493),
|
||||
UINT64_C(0x3c9ebe0a15c9bebc), UINT64_C(0x431d67c49c100d4c),
|
||||
UINT64_C(0x4cc5d4becb3e42b6), UINT64_C(0x597f299cfc657e2a),
|
||||
UINT64_C(0x5fcb6fab3ad6faec), UINT64_C(0x6c44198c4a475817),
|
||||
};
|
||||
|
||||
#define ror(value, bits) (((value) >> (bits)) | ((value) << (64 - (bits))))
|
||||
|
||||
#define Ch(x,y,z) (((x) & ((y) ^ (z))) ^ (z))
|
||||
#define Maj(z,y,x) ((((x) | (y)) & (z)) | ((x) & (y)))
|
||||
|
||||
#define Sigma0_512(x) (ror((x), 28) ^ ror((x), 34) ^ ror((x), 39))
|
||||
#define Sigma1_512(x) (ror((x), 14) ^ ror((x), 18) ^ ror((x), 41))
|
||||
#define sigma0_512(x) (ror((x), 1) ^ ror((x), 8) ^ ((x) >> 7))
|
||||
#define sigma1_512(x) (ror((x), 19) ^ ror((x), 61) ^ ((x) >> 6))
|
||||
|
||||
#define blk0(i) (block[i] = AV_RB64(buffer + 8 * (i)))
|
||||
#define blk(i) (block[i] = block[i - 16] + sigma0_512(block[i - 15]) + \
|
||||
sigma1_512(block[i - 2]) + block[i - 7])
|
||||
|
||||
#define ROUND512(a,b,c,d,e,f,g,h) \
|
||||
T1 += (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[i]; \
|
||||
(d) += T1; \
|
||||
(h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
|
||||
i++
|
||||
|
||||
#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
|
||||
T1 = blk0(i); \
|
||||
ROUND512(a,b,c,d,e,f,g,h)
|
||||
|
||||
#define ROUND512_16_TO_80(a,b,c,d,e,f,g,h) \
|
||||
T1 = blk(i); \
|
||||
ROUND512(a,b,c,d,e,f,g,h)
|
||||
|
||||
static void sha512_transform(uint64_t *state, const uint8_t buffer[128])
|
||||
{
|
||||
uint64_t a, b, c, d, e, f, g, h;
|
||||
uint64_t block[80];
|
||||
uint64_t T1;
|
||||
int i;
|
||||
|
||||
a = state[0];
|
||||
b = state[1];
|
||||
c = state[2];
|
||||
d = state[3];
|
||||
e = state[4];
|
||||
f = state[5];
|
||||
g = state[6];
|
||||
h = state[7];
|
||||
#if CONFIG_SMALL
|
||||
for (i = 0; i < 80; i++) {
|
||||
uint64_t T2;
|
||||
if (i < 16)
|
||||
T1 = blk0(i);
|
||||
else
|
||||
T1 = blk(i);
|
||||
T1 += h + Sigma1_512(e) + Ch(e, f, g) + K512[i];
|
||||
T2 = Sigma0_512(a) + Maj(a, b, c);
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = d + T1;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = T1 + T2;
|
||||
}
|
||||
#else
|
||||
|
||||
#define R512_0 \
|
||||
ROUND512_0_TO_15(a, b, c, d, e, f, g, h); \
|
||||
ROUND512_0_TO_15(h, a, b, c, d, e, f, g); \
|
||||
ROUND512_0_TO_15(g, h, a, b, c, d, e, f); \
|
||||
ROUND512_0_TO_15(f, g, h, a, b, c, d, e); \
|
||||
ROUND512_0_TO_15(e, f, g, h, a, b, c, d); \
|
||||
ROUND512_0_TO_15(d, e, f, g, h, a, b, c); \
|
||||
ROUND512_0_TO_15(c, d, e, f, g, h, a, b); \
|
||||
ROUND512_0_TO_15(b, c, d, e, f, g, h, a)
|
||||
|
||||
i = 0;
|
||||
R512_0; R512_0;
|
||||
|
||||
#define R512_16 \
|
||||
ROUND512_16_TO_80(a, b, c, d, e, f, g, h); \
|
||||
ROUND512_16_TO_80(h, a, b, c, d, e, f, g); \
|
||||
ROUND512_16_TO_80(g, h, a, b, c, d, e, f); \
|
||||
ROUND512_16_TO_80(f, g, h, a, b, c, d, e); \
|
||||
ROUND512_16_TO_80(e, f, g, h, a, b, c, d); \
|
||||
ROUND512_16_TO_80(d, e, f, g, h, a, b, c); \
|
||||
ROUND512_16_TO_80(c, d, e, f, g, h, a, b); \
|
||||
ROUND512_16_TO_80(b, c, d, e, f, g, h, a)
|
||||
|
||||
R512_16; R512_16; R512_16; R512_16;
|
||||
R512_16; R512_16; R512_16; R512_16;
|
||||
#endif
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
state[5] += f;
|
||||
state[6] += g;
|
||||
state[7] += h;
|
||||
}
|
||||
|
||||
|
||||
av_cold int av_sha512_init(AVSHA512 *ctx, int bits)
|
||||
{
|
||||
ctx->digest_len = bits >> 6;
|
||||
switch (bits) {
|
||||
case 224: // SHA-512/224
|
||||
ctx->state[0] = UINT64_C(0x8C3D37C819544DA2);
|
||||
ctx->state[1] = UINT64_C(0x73E1996689DCD4D6);
|
||||
ctx->state[2] = UINT64_C(0x1DFAB7AE32FF9C82);
|
||||
ctx->state[3] = UINT64_C(0x679DD514582F9FCF);
|
||||
ctx->state[4] = UINT64_C(0x0F6D2B697BD44DA8);
|
||||
ctx->state[5] = UINT64_C(0x77E36F7304C48942);
|
||||
ctx->state[6] = UINT64_C(0x3F9D85A86A1D36C8);
|
||||
ctx->state[7] = UINT64_C(0x1112E6AD91D692A1);
|
||||
break;
|
||||
case 256: // SHA-512/256
|
||||
ctx->state[0] = UINT64_C(0x22312194FC2BF72C);
|
||||
ctx->state[1] = UINT64_C(0x9F555FA3C84C64C2);
|
||||
ctx->state[2] = UINT64_C(0x2393B86B6F53B151);
|
||||
ctx->state[3] = UINT64_C(0x963877195940EABD);
|
||||
ctx->state[4] = UINT64_C(0x96283EE2A88EFFE3);
|
||||
ctx->state[5] = UINT64_C(0xBE5E1E2553863992);
|
||||
ctx->state[6] = UINT64_C(0x2B0199FC2C85B8AA);
|
||||
ctx->state[7] = UINT64_C(0x0EB72DDC81C52CA2);
|
||||
break;
|
||||
case 384: // SHA-384
|
||||
ctx->state[0] = UINT64_C(0xCBBB9D5DC1059ED8);
|
||||
ctx->state[1] = UINT64_C(0x629A292A367CD507);
|
||||
ctx->state[2] = UINT64_C(0x9159015A3070DD17);
|
||||
ctx->state[3] = UINT64_C(0x152FECD8F70E5939);
|
||||
ctx->state[4] = UINT64_C(0x67332667FFC00B31);
|
||||
ctx->state[5] = UINT64_C(0x8EB44A8768581511);
|
||||
ctx->state[6] = UINT64_C(0xDB0C2E0D64F98FA7);
|
||||
ctx->state[7] = UINT64_C(0x47B5481DBEFA4FA4);
|
||||
break;
|
||||
case 512: // SHA-512
|
||||
ctx->state[0] = UINT64_C(0x6A09E667F3BCC908);
|
||||
ctx->state[1] = UINT64_C(0xBB67AE8584CAA73B);
|
||||
ctx->state[2] = UINT64_C(0x3C6EF372FE94F82B);
|
||||
ctx->state[3] = UINT64_C(0xA54FF53A5F1D36F1);
|
||||
ctx->state[4] = UINT64_C(0x510E527FADE682D1);
|
||||
ctx->state[5] = UINT64_C(0x9B05688C2B3E6C1F);
|
||||
ctx->state[6] = UINT64_C(0x1F83D9ABFB41BD6B);
|
||||
ctx->state[7] = UINT64_C(0x5BE0CD19137E2179);
|
||||
break;
|
||||
default:
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
ctx->count = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if FF_API_CRYPTO_SIZE_T
|
||||
void av_sha512_update(AVSHA512* ctx, const uint8_t* data, unsigned int len)
|
||||
#else
|
||||
void av_sha512_update(AVSHA512* ctx, const uint8_t* data, size_t len)
|
||||
#endif
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
j = ctx->count & 127;
|
||||
ctx->count += len;
|
||||
#if CONFIG_SMALL
|
||||
for (i = 0; i < len; i++) {
|
||||
ctx->buffer[j++] = data[i];
|
||||
if (128 == j) {
|
||||
sha512_transform(ctx->state, ctx->buffer);
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if ((j + len) > 127) {
|
||||
memcpy(&ctx->buffer[j], data, (i = 128 - j));
|
||||
sha512_transform(ctx->state, ctx->buffer);
|
||||
for (; i + 127 < len; i += 128)
|
||||
sha512_transform(ctx->state, &data[i]);
|
||||
j = 0;
|
||||
} else
|
||||
i = 0;
|
||||
memcpy(&ctx->buffer[j], &data[i], len - i);
|
||||
#endif
|
||||
}
|
||||
|
||||
void av_sha512_final(AVSHA512* ctx, uint8_t *digest)
|
||||
{
|
||||
uint64_t i = 0;
|
||||
uint64_t finalcount = av_be2ne64(ctx->count << 3);
|
||||
|
||||
av_sha512_update(ctx, "\200", 1);
|
||||
while ((ctx->count & 127) != 112)
|
||||
av_sha512_update(ctx, "", 1);
|
||||
av_sha512_update(ctx, (uint8_t *)&i, 8);
|
||||
av_sha512_update(ctx, (uint8_t *)&finalcount, 8); /* Should cause a transform() */
|
||||
for (i = 0; i < ctx->digest_len; i++)
|
||||
AV_WB64(digest + i*8, ctx->state[i]);
|
||||
if (ctx->digest_len & 1) /* SHA512/224 is 28 bytes, and is not divisible by 8. */
|
||||
AV_WB32(digest + i*8, ctx->state[i] >> 32);
|
||||
}
|
||||
97
media/ffvpx/libavutil/sha512.h
Normal file
97
media/ffvpx/libavutil/sha512.h
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Copyright (C) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (C) 2013 James Almer <jamrial@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavu_sha512
|
||||
* Public header for SHA-512 implementation.
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_SHA512_H
|
||||
#define AVUTIL_SHA512_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_sha512 SHA-512
|
||||
* @ingroup lavu_hash
|
||||
* SHA-512 (Secure Hash Algorithm) hash function implementations.
|
||||
*
|
||||
* This module supports the following SHA-2 hash functions:
|
||||
*
|
||||
* - SHA-512/224: 224 bits
|
||||
* - SHA-512/256: 256 bits
|
||||
* - SHA-384: 384 bits
|
||||
* - SHA-512: 512 bits
|
||||
*
|
||||
* @see For SHA-1, SHA-256, and variants thereof, see @ref lavu_sha.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_sha512_size;
|
||||
|
||||
struct AVSHA512;
|
||||
|
||||
/**
|
||||
* Allocate an AVSHA512 context.
|
||||
*/
|
||||
struct AVSHA512 *av_sha512_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize SHA-2 512 hashing.
|
||||
*
|
||||
* @param context pointer to the function context (of size av_sha512_size)
|
||||
* @param bits number of bits in digest (224, 256, 384 or 512 bits)
|
||||
* @return zero if initialization succeeded, -1 otherwise
|
||||
*/
|
||||
int av_sha512_init(struct AVSHA512* context, int bits);
|
||||
|
||||
/**
|
||||
* Update hash value.
|
||||
*
|
||||
* @param context hash function context
|
||||
* @param data input data to update hash with
|
||||
* @param len input data length
|
||||
*/
|
||||
#if FF_API_CRYPTO_SIZE_T
|
||||
void av_sha512_update(struct AVSHA512* context, const uint8_t* data, unsigned int len);
|
||||
#else
|
||||
void av_sha512_update(struct AVSHA512* context, const uint8_t* data, size_t len);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Finish hashing and output digest value.
|
||||
*
|
||||
* @param context hash function context
|
||||
* @param digest buffer where output digest value is stored
|
||||
*/
|
||||
void av_sha512_final(struct AVSHA512* context, uint8_t *digest);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_SHA512_H */
|
||||
289
media/ffvpx/libavutil/softfloat.h
Normal file
289
media/ffvpx/libavutil/softfloat.h
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
/*
|
||||
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_SOFTFLOAT_H
|
||||
#define AVUTIL_SOFTFLOAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
|
||||
#include "avassert.h"
|
||||
#include "softfloat_tables.h"
|
||||
|
||||
#define MIN_EXP -149
|
||||
#define MAX_EXP 126
|
||||
#define ONE_BITS 29
|
||||
|
||||
typedef struct SoftFloat{
|
||||
int32_t mant;
|
||||
int32_t exp;
|
||||
}SoftFloat;
|
||||
|
||||
static const SoftFloat FLOAT_0 = { 0, MIN_EXP}; ///< 0.0
|
||||
static const SoftFloat FLOAT_05 = { 0x20000000, 0}; ///< 0.5
|
||||
static const SoftFloat FLOAT_1 = { 0x20000000, 1}; ///< 1.0
|
||||
static const SoftFloat FLOAT_EPSILON = { 0x29F16B12, -16}; ///< A small value
|
||||
static const SoftFloat FLOAT_1584893192 = { 0x32B771ED, 1}; ///< 1.584893192 (10^.2)
|
||||
static const SoftFloat FLOAT_100000 = { 0x30D40000, 17}; ///< 100000
|
||||
static const SoftFloat FLOAT_0999999 = { 0x3FFFFBCE, 0}; ///< 0.999999
|
||||
static const SoftFloat FLOAT_MIN = { 0x20000000, MIN_EXP};
|
||||
|
||||
|
||||
/**
|
||||
* Convert a SoftFloat to a double precision float.
|
||||
*/
|
||||
static inline av_const double av_sf2double(SoftFloat v) {
|
||||
v.exp -= ONE_BITS +1;
|
||||
return ldexp(v.mant, v.exp);
|
||||
}
|
||||
|
||||
static av_const SoftFloat av_normalize_sf(SoftFloat a){
|
||||
if(a.mant){
|
||||
#if 1
|
||||
while((a.mant + 0x1FFFFFFFU)<0x3FFFFFFFU){
|
||||
a.mant += a.mant;
|
||||
a.exp -= 1;
|
||||
}
|
||||
#else
|
||||
int s=ONE_BITS - av_log2(FFABS(a.mant));
|
||||
a.exp -= s;
|
||||
a.mant <<= s;
|
||||
#endif
|
||||
if(a.exp < MIN_EXP){
|
||||
a.exp = MIN_EXP;
|
||||
a.mant= 0;
|
||||
}
|
||||
}else{
|
||||
a.exp= MIN_EXP;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
static inline av_const SoftFloat av_normalize1_sf(SoftFloat a){
|
||||
#if 1
|
||||
if((int32_t)(a.mant + 0x40000000U) <= 0){
|
||||
a.exp++;
|
||||
a.mant>>=1;
|
||||
}
|
||||
av_assert2(a.mant < 0x40000000 && a.mant > -0x40000000);
|
||||
av_assert2(a.exp <= MAX_EXP);
|
||||
return a;
|
||||
#elif 1
|
||||
int t= a.mant + 0x40000000 < 0;
|
||||
return (SoftFloat){ a.mant>>t, a.exp+t};
|
||||
#else
|
||||
int t= (a.mant + 0x3FFFFFFFU)>>31;
|
||||
return (SoftFloat){a.mant>>t, a.exp+t};
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Will not be more denormalized than a*b. So if either input is
|
||||
* normalized, then the output will not be worse then the other input.
|
||||
* If both are normalized, then the output will be normalized.
|
||||
*/
|
||||
static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){
|
||||
a.exp += b.exp;
|
||||
av_assert2((int32_t)((a.mant * (int64_t)b.mant) >> ONE_BITS) == (a.mant * (int64_t)b.mant) >> ONE_BITS);
|
||||
a.mant = (a.mant * (int64_t)b.mant) >> ONE_BITS;
|
||||
a = av_normalize1_sf((SoftFloat){a.mant, a.exp - 1});
|
||||
if (!a.mant || a.exp < MIN_EXP)
|
||||
return FLOAT_0;
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* b has to be normalized and not zero.
|
||||
* @return Will not be more denormalized than a.
|
||||
*/
|
||||
static inline av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){
|
||||
int64_t temp = (int64_t)a.mant * (1<<(ONE_BITS+1));
|
||||
temp /= b.mant;
|
||||
a.exp -= b.exp;
|
||||
a.mant = temp;
|
||||
while (a.mant != temp) {
|
||||
temp /= 2;
|
||||
a.exp--;
|
||||
a.mant = temp;
|
||||
}
|
||||
a = av_normalize1_sf(a);
|
||||
if (!a.mant || a.exp < MIN_EXP)
|
||||
return FLOAT_0;
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two SoftFloats.
|
||||
* @returns < 0 if the first is less
|
||||
* > 0 if the first is greater
|
||||
* 0 if they are equal
|
||||
*/
|
||||
static inline av_const int av_cmp_sf(SoftFloat a, SoftFloat b){
|
||||
int t= a.exp - b.exp;
|
||||
if (t <-31) return - b.mant ;
|
||||
else if (t < 0) return (a.mant >> (-t)) - b.mant ;
|
||||
else if (t < 32) return a.mant - (b.mant >> t);
|
||||
else return a.mant ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two SoftFloats.
|
||||
* @returns 1 if a is greater than b, 0 otherwise
|
||||
*/
|
||||
static inline av_const int av_gt_sf(SoftFloat a, SoftFloat b)
|
||||
{
|
||||
int t= a.exp - b.exp;
|
||||
if (t <-31) return 0 > b.mant ;
|
||||
else if (t < 0) return (a.mant >> (-t)) > b.mant ;
|
||||
else if (t < 32) return a.mant > (b.mant >> t);
|
||||
else return a.mant > 0 ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the sum of 2 SoftFloats.
|
||||
*/
|
||||
static inline av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b){
|
||||
int t= a.exp - b.exp;
|
||||
if (t <-31) return b;
|
||||
else if (t < 0) return av_normalize_sf(av_normalize1_sf((SoftFloat){ b.mant + (a.mant >> (-t)), b.exp}));
|
||||
else if (t < 32) return av_normalize_sf(av_normalize1_sf((SoftFloat){ a.mant + (b.mant >> t ), a.exp}));
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the difference of 2 SoftFloats.
|
||||
*/
|
||||
static inline av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b){
|
||||
return av_add_sf(a, (SoftFloat){ -b.mant, b.exp});
|
||||
}
|
||||
|
||||
//FIXME log, exp, pow
|
||||
|
||||
/**
|
||||
* Converts a mantisse and exponent to a SoftFloat.
|
||||
* This converts a fixed point value v with frac_bits fractional bits to a
|
||||
* SoftFloat.
|
||||
* @returns a SoftFloat with value v * 2^-frac_bits
|
||||
*/
|
||||
static inline av_const SoftFloat av_int2sf(int v, int frac_bits){
|
||||
int exp_offset = 0;
|
||||
if(v <= INT_MIN + 1){
|
||||
exp_offset = 1;
|
||||
v>>=1;
|
||||
}
|
||||
return av_normalize_sf(av_normalize1_sf((SoftFloat){v, ONE_BITS + 1 - frac_bits + exp_offset}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a SoftFloat to an integer.
|
||||
* Rounding is to -inf.
|
||||
*/
|
||||
static inline av_const int av_sf2int(SoftFloat v, int frac_bits){
|
||||
v.exp += frac_bits - (ONE_BITS + 1);
|
||||
if(v.exp >= 0) return v.mant << v.exp ;
|
||||
else return v.mant >>(-v.exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounding-to-nearest used.
|
||||
*/
|
||||
static av_always_inline SoftFloat av_sqrt_sf(SoftFloat val)
|
||||
{
|
||||
int tabIndex, rem;
|
||||
|
||||
if (val.mant == 0)
|
||||
val.exp = MIN_EXP;
|
||||
else if (val.mant < 0)
|
||||
abort();
|
||||
else
|
||||
{
|
||||
tabIndex = (val.mant - 0x20000000) >> 20;
|
||||
|
||||
rem = val.mant & 0xFFFFF;
|
||||
val.mant = (int)(((int64_t)av_sqrttbl_sf[tabIndex] * (0x100000 - rem) +
|
||||
(int64_t)av_sqrttbl_sf[tabIndex + 1] * rem +
|
||||
0x80000) >> 20);
|
||||
val.mant = (int)(((int64_t)av_sqr_exp_multbl_sf[val.exp & 1] * val.mant +
|
||||
0x10000000) >> 29);
|
||||
|
||||
if (val.mant < 0x40000000)
|
||||
val.exp -= 2;
|
||||
else
|
||||
val.mant >>= 1;
|
||||
|
||||
val.exp = (val.exp >> 1) + 1;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounding-to-nearest used.
|
||||
*/
|
||||
static av_unused void av_sincos_sf(int a, int *s, int *c)
|
||||
{
|
||||
int idx, sign;
|
||||
int sv, cv;
|
||||
int st, ct;
|
||||
|
||||
idx = a >> 26;
|
||||
sign = (int32_t)((unsigned)idx << 27) >> 31;
|
||||
cv = av_costbl_1_sf[idx & 0xf];
|
||||
cv = (cv ^ sign) - sign;
|
||||
|
||||
idx -= 8;
|
||||
sign = (int32_t)((unsigned)idx << 27) >> 31;
|
||||
sv = av_costbl_1_sf[idx & 0xf];
|
||||
sv = (sv ^ sign) - sign;
|
||||
|
||||
idx = a >> 21;
|
||||
ct = av_costbl_2_sf[idx & 0x1f];
|
||||
st = av_sintbl_2_sf[idx & 0x1f];
|
||||
|
||||
idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30);
|
||||
|
||||
sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30);
|
||||
|
||||
cv = idx;
|
||||
|
||||
idx = a >> 16;
|
||||
ct = av_costbl_3_sf[idx & 0x1f];
|
||||
st = av_sintbl_3_sf[idx & 0x1f];
|
||||
|
||||
idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30);
|
||||
|
||||
sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30);
|
||||
cv = idx;
|
||||
|
||||
idx = a >> 11;
|
||||
|
||||
ct = (int)(((int64_t)av_costbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) +
|
||||
(int64_t)av_costbl_4_sf[(idx & 0x1f)+1]*(a & 0x7ff) +
|
||||
0x400) >> 11);
|
||||
st = (int)(((int64_t)av_sintbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) +
|
||||
(int64_t)av_sintbl_4_sf[(idx & 0x1f) + 1] * (a & 0x7ff) +
|
||||
0x400) >> 11);
|
||||
|
||||
*c = (int)(((int64_t)cv * ct + (int64_t)sv * st + 0x20000000) >> 30);
|
||||
|
||||
*s = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30);
|
||||
}
|
||||
|
||||
#endif /* AVUTIL_SOFTFLOAT_H */
|
||||
115
media/ffvpx/libavutil/softfloat_ieee754.h
Normal file
115
media/ffvpx/libavutil/softfloat_ieee754.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Umair Khan <omerjerk@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_SOFTFLOAT_IEEE754_H
|
||||
#define AVUTIL_SOFTFLOAT_IEEE754_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define EXP_BIAS 127
|
||||
#define MANT_BITS 23
|
||||
|
||||
typedef struct SoftFloat_IEEE754 {
|
||||
int32_t sign;
|
||||
uint64_t mant;
|
||||
int32_t exp;
|
||||
} SoftFloat_IEEE754;
|
||||
|
||||
static const SoftFloat_IEEE754 FLOAT_0 = {0, 0, -126};
|
||||
static const SoftFloat_IEEE754 FLOAT_1 = {0, 0, 0};
|
||||
|
||||
/** Normalize the softfloat as defined by IEEE 754 single-recision floating
|
||||
* point specification
|
||||
*/
|
||||
static inline SoftFloat_IEEE754 av_normalize_sf_ieee754(SoftFloat_IEEE754 sf) {
|
||||
while( sf.mant >= 0x1000000UL ) {
|
||||
sf.exp++;
|
||||
sf.mant >>= 1;
|
||||
}
|
||||
sf.mant &= 0x007fffffUL;
|
||||
return sf;
|
||||
}
|
||||
|
||||
/** Convert integer to softfloat.
|
||||
* @return softfloat with value n * 2^e
|
||||
*/
|
||||
static inline SoftFloat_IEEE754 av_int2sf_ieee754(int64_t n, int e) {
|
||||
int sign = 0;
|
||||
|
||||
if (n < 0) {
|
||||
sign = 1;
|
||||
n *= -1;
|
||||
}
|
||||
return av_normalize_sf_ieee754((SoftFloat_IEEE754) {sign, n << MANT_BITS, 0 + e});
|
||||
}
|
||||
|
||||
/** Make a softfloat out of the bitstream. Assumes the bits are in the form as defined
|
||||
* by the IEEE 754 spec.
|
||||
*/
|
||||
static inline SoftFloat_IEEE754 av_bits2sf_ieee754(uint32_t n) {
|
||||
return ((SoftFloat_IEEE754) { (n & 0x80000000UL), (n & 0x7FFFFFUL), (n & 0x7F800000UL) });
|
||||
}
|
||||
|
||||
/** Convert the softfloat to integer
|
||||
*/
|
||||
static inline int av_sf2int_ieee754(SoftFloat_IEEE754 a) {
|
||||
if(a.exp >= 0) return a.mant << a.exp ;
|
||||
else return a.mant >>(-a.exp);
|
||||
}
|
||||
|
||||
/** Divide a by b. b should not be zero.
|
||||
* @return normalized result
|
||||
*/
|
||||
static inline SoftFloat_IEEE754 av_div_sf_ieee754(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b) {
|
||||
int32_t mant, exp, sign;
|
||||
a = av_normalize_sf_ieee754(a);
|
||||
b = av_normalize_sf_ieee754(b);
|
||||
sign = a.sign ^ b.sign;
|
||||
mant = ((((uint64_t) (a.mant | 0x00800000UL)) << MANT_BITS) / (b.mant| 0x00800000UL));
|
||||
exp = a.exp - b.exp;
|
||||
return av_normalize_sf_ieee754((SoftFloat_IEEE754) {sign, mant, exp});
|
||||
}
|
||||
|
||||
/** Multiply a with b
|
||||
* #return normalized result
|
||||
*/
|
||||
static inline SoftFloat_IEEE754 av_mul_sf_ieee754(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b) {
|
||||
int32_t sign, mant, exp;
|
||||
a = av_normalize_sf_ieee754(a);
|
||||
b = av_normalize_sf_ieee754(b);
|
||||
sign = a.sign ^ b.sign;
|
||||
mant = (((uint64_t)(a.mant|0x00800000UL) * (uint64_t)(b.mant|0x00800000UL))>>MANT_BITS);
|
||||
exp = a.exp + b.exp;
|
||||
return av_normalize_sf_ieee754((SoftFloat_IEEE754) {sign, mant, exp});
|
||||
}
|
||||
|
||||
/** Compare a with b strictly
|
||||
* @returns 1 if the a and b are equal, 0 otherwise.
|
||||
*/
|
||||
static inline int av_cmp_sf_ieee754(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b) {
|
||||
a = av_normalize_sf_ieee754(a);
|
||||
b = av_normalize_sf_ieee754(b);
|
||||
if (a.sign != b.sign) return 0;
|
||||
if (a.mant != b.mant) return 0;
|
||||
if (a.exp != b.exp ) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /*AVUTIL_SOFTFLOAT_IEEE754_H*/
|
||||
262
media/ffvpx/libavutil/softfloat_tables.h
Normal file
262
media/ffvpx/libavutil/softfloat_tables.h
Normal file
|
|
@ -0,0 +1,262 @@
|
|||
/*
|
||||
* Copyright (c) 2012
|
||||
* MIPS Technologies, Inc., California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the MIPS Technologies, Inc., nor the names of is
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Author: Stanislav Ocovaj (stanislav.ocovaj imgtec com)
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef AVUTIL_SOFTFLOAT_TABLES_H
|
||||
#define AVUTIL_SOFTFLOAT_TABLES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static const int32_t av_sqrttbl_sf[512+1] = { /* sqrt(x), 0.5<=x<1 */
|
||||
0x2d413ccd,0x2d4c8bb3,0x2d57d7c6,0x2d63210a,
|
||||
0x2d6e677f,0x2d79ab2a,0x2d84ec0b,0x2d902a23,
|
||||
0x2d9b6578,0x2da69e08,0x2db1d3d6,0x2dbd06e6,
|
||||
0x2dc83738,0x2dd364ce,0x2dde8fac,0x2de9b7d2,
|
||||
0x2df4dd43,0x2e000000,0x2e0b200c,0x2e163d68,
|
||||
0x2e215816,0x2e2c701a,0x2e378573,0x2e429824,
|
||||
0x2e4da830,0x2e58b598,0x2e63c05d,0x2e6ec883,
|
||||
0x2e79ce0a,0x2e84d0f5,0x2e8fd144,0x2e9acefb,
|
||||
0x2ea5ca1b,0x2eb0c2a7,0x2ebbb89e,0x2ec6ac04,
|
||||
0x2ed19cda,0x2edc8b23,0x2ee776df,0x2ef26012,
|
||||
0x2efd46bb,0x2f082add,0x2f130c7b,0x2f1deb95,
|
||||
0x2f28c82e,0x2f33a246,0x2f3e79e1,0x2f494eff,
|
||||
0x2f5421a3,0x2f5ef1ce,0x2f69bf81,0x2f748abe,
|
||||
0x2f7f5388,0x2f8a19e0,0x2f94ddc7,0x2f9f9f3e,
|
||||
0x2faa5e48,0x2fb51ae8,0x2fbfd51c,0x2fca8ce9,
|
||||
0x2fd5424e,0x2fdff54e,0x2feaa5eb,0x2ff55426,
|
||||
0x30000000,0x300aa97b,0x3015509a,0x301ff55c,
|
||||
0x302a97c5,0x303537d5,0x303fd58e,0x304a70f2,
|
||||
0x30550a01,0x305fa0be,0x306a352a,0x3074c747,
|
||||
0x307f5716,0x3089e499,0x30946fd2,0x309ef8c0,
|
||||
0x30a97f67,0x30b403c7,0x30be85e2,0x30c905bb,
|
||||
0x30d38351,0x30ddfea6,0x30e877bc,0x30f2ee96,
|
||||
0x30fd6332,0x3107d594,0x311245bc,0x311cb3ad,
|
||||
0x31271f67,0x313188ec,0x313bf03d,0x3146555c,
|
||||
0x3150b84a,0x315b1909,0x31657798,0x316fd3fc,
|
||||
0x317a2e34,0x31848642,0x318edc28,0x31992fe5,
|
||||
0x31a3817d,0x31add0f0,0x31b81e40,0x31c2696e,
|
||||
0x31ccb27b,0x31d6f969,0x31e13e38,0x31eb80eb,
|
||||
0x31f5c182,0x32000000,0x320a3c65,0x321476b1,
|
||||
0x321eaee8,0x3228e50a,0x32331917,0x323d4b13,
|
||||
0x32477afc,0x3251a8d6,0x325bd4a2,0x3265fe5f,
|
||||
0x32702611,0x327a4bb8,0x32846f55,0x328e90e9,
|
||||
0x3298b076,0x32a2cdfd,0x32ace97e,0x32b702fd,
|
||||
0x32c11a79,0x32cb2ff3,0x32d5436d,0x32df54e9,
|
||||
0x32e96466,0x32f371e8,0x32fd7d6d,0x330786f9,
|
||||
0x33118e8c,0x331b9426,0x332597cb,0x332f9979,
|
||||
0x33399933,0x334396fa,0x334d92cf,0x33578cb2,
|
||||
0x336184a6,0x336b7aab,0x33756ec3,0x337f60ed,
|
||||
0x3389512d,0x33933f83,0x339d2bef,0x33a71672,
|
||||
0x33b0ff10,0x33bae5c7,0x33c4ca99,0x33cead88,
|
||||
0x33d88e95,0x33e26dbf,0x33ec4b09,0x33f62673,
|
||||
0x34000000,0x3409d7af,0x3413ad82,0x341d817a,
|
||||
0x34275397,0x343123db,0x343af248,0x3444bedd,
|
||||
0x344e899d,0x34585288,0x3462199f,0x346bdee3,
|
||||
0x3475a254,0x347f63f5,0x348923c6,0x3492e1c9,
|
||||
0x349c9dfe,0x34a65865,0x34b01101,0x34b9c7d2,
|
||||
0x34c37cda,0x34cd3018,0x34d6e18f,0x34e0913f,
|
||||
0x34ea3f29,0x34f3eb4d,0x34fd95ae,0x35073e4c,
|
||||
0x3510e528,0x351a8a43,0x35242d9d,0x352dcf39,
|
||||
0x35376f16,0x35410d36,0x354aa99a,0x35544442,
|
||||
0x355ddd2f,0x35677463,0x357109df,0x357a9da2,
|
||||
0x35842fb0,0x358dc007,0x35974ea9,0x35a0db98,
|
||||
0x35aa66d3,0x35b3f05c,0x35bd7833,0x35c6fe5a,
|
||||
0x35d082d3,0x35da059c,0x35e386b7,0x35ed0626,
|
||||
0x35f683e8,0x36000000,0x36097a6e,0x3612f331,
|
||||
0x361c6a4d,0x3625dfc1,0x362f538f,0x3638c5b7,
|
||||
0x36423639,0x364ba518,0x36551252,0x365e7deb,
|
||||
0x3667e7e2,0x36715039,0x367ab6f0,0x36841c07,
|
||||
0x368d7f81,0x3696e15d,0x36a0419d,0x36a9a040,
|
||||
0x36b2fd49,0x36bc58b8,0x36c5b28e,0x36cf0acb,
|
||||
0x36d86170,0x36e1b680,0x36eb09f8,0x36f45bdc,
|
||||
0x36fdac2b,0x3706fae7,0x37104810,0x371993a7,
|
||||
0x3722ddad,0x372c2622,0x37356d08,0x373eb25f,
|
||||
0x3747f629,0x37513865,0x375a7914,0x3763b838,
|
||||
0x376cf5d0,0x377631e0,0x377f6c64,0x3788a561,
|
||||
0x3791dcd6,0x379b12c4,0x37a4472c,0x37ad7a0e,
|
||||
0x37b6ab6a,0x37bfdb44,0x37c90999,0x37d2366d,
|
||||
0x37db61be,0x37e48b8e,0x37edb3de,0x37f6daae,
|
||||
0x38000000,0x380923d3,0x3812462a,0x381b6703,
|
||||
0x38248660,0x382da442,0x3836c0aa,0x383fdb97,
|
||||
0x3848f50c,0x38520d09,0x385b238d,0x3864389b,
|
||||
0x386d4c33,0x38765e55,0x387f6f01,0x38887e3b,
|
||||
0x38918c00,0x389a9853,0x38a3a334,0x38acaca3,
|
||||
0x38b5b4a3,0x38bebb32,0x38c7c051,0x38d0c402,
|
||||
0x38d9c645,0x38e2c71b,0x38ebc685,0x38f4c482,
|
||||
0x38fdc114,0x3906bc3c,0x390fb5fa,0x3918ae4f,
|
||||
0x3921a53a,0x392a9abe,0x39338edb,0x393c8192,
|
||||
0x394572e2,0x394e62ce,0x39575155,0x39603e77,
|
||||
0x39692a36,0x39721494,0x397afd8f,0x3983e527,
|
||||
0x398ccb60,0x3995b039,0x399e93b2,0x39a775cc,
|
||||
0x39b05689,0x39b935e8,0x39c213e9,0x39caf08e,
|
||||
0x39d3cbd9,0x39dca5c7,0x39e57e5b,0x39ee5596,
|
||||
0x39f72b77,0x3a000000,0x3a08d331,0x3a11a50a,
|
||||
0x3a1a758d,0x3a2344ba,0x3a2c1291,0x3a34df13,
|
||||
0x3a3daa41,0x3a46741b,0x3a4f3ca3,0x3a5803d7,
|
||||
0x3a60c9ba,0x3a698e4b,0x3a72518b,0x3a7b137c,
|
||||
0x3a83d41d,0x3a8c936f,0x3a955173,0x3a9e0e29,
|
||||
0x3aa6c992,0x3aaf83ae,0x3ab83c7e,0x3ac0f403,
|
||||
0x3ac9aa3c,0x3ad25f2c,0x3adb12d1,0x3ae3c52d,
|
||||
0x3aec7642,0x3af5260e,0x3afdd492,0x3b0681d0,
|
||||
0x3b0f2dc6,0x3b17d878,0x3b2081e4,0x3b292a0c,
|
||||
0x3b31d0f0,0x3b3a7690,0x3b431aec,0x3b4bbe06,
|
||||
0x3b545fdf,0x3b5d0077,0x3b659fcd,0x3b6e3de4,
|
||||
0x3b76daba,0x3b7f7651,0x3b8810aa,0x3b90a9c4,
|
||||
0x3b9941a1,0x3ba1d842,0x3baa6da5,0x3bb301cd,
|
||||
0x3bbb94b9,0x3bc4266a,0x3bccb6e2,0x3bd5461f,
|
||||
0x3bddd423,0x3be660ee,0x3beeec81,0x3bf776dc,
|
||||
0x3c000000,0x3c0887ed,0x3c110ea4,0x3c199426,
|
||||
0x3c221872,0x3c2a9b8a,0x3c331d6e,0x3c3b9e1d,
|
||||
0x3c441d9a,0x3c4c9be5,0x3c5518fd,0x3c5d94e3,
|
||||
0x3c660f98,0x3c6e891d,0x3c770172,0x3c7f7898,
|
||||
0x3c87ee8e,0x3c906356,0x3c98d6ef,0x3ca1495b,
|
||||
0x3ca9ba9a,0x3cb22aac,0x3cba9992,0x3cc3074c,
|
||||
0x3ccb73dc,0x3cd3df41,0x3cdc497b,0x3ce4b28c,
|
||||
0x3ced1a73,0x3cf58132,0x3cfde6c8,0x3d064b37,
|
||||
0x3d0eae7f,0x3d17109f,0x3d1f719a,0x3d27d16e,
|
||||
0x3d30301d,0x3d388da8,0x3d40ea0d,0x3d49454f,
|
||||
0x3d519f6d,0x3d59f867,0x3d625040,0x3d6aa6f6,
|
||||
0x3d72fc8b,0x3d7b50fe,0x3d83a451,0x3d8bf683,
|
||||
0x3d944796,0x3d9c9788,0x3da4e65c,0x3dad3412,
|
||||
0x3db580a9,0x3dbdcc24,0x3dc61680,0x3dce5fc0,
|
||||
0x3dd6a7e4,0x3ddeeeed,0x3de734d9,0x3def79ab,
|
||||
0x3df7bd62,0x3e000000,0x3e084184,0x3e1081ee,
|
||||
0x3e18c140,0x3e20ff7a,0x3e293c9c,0x3e3178a7,
|
||||
0x3e39b39a,0x3e41ed77,0x3e4a263d,0x3e525def,
|
||||
0x3e5a948b,0x3e62ca12,0x3e6afe85,0x3e7331e4,
|
||||
0x3e7b642f,0x3e839567,0x3e8bc58c,0x3e93f49f,
|
||||
0x3e9c22a1,0x3ea44f91,0x3eac7b6f,0x3eb4a63e,
|
||||
0x3ebccffb,0x3ec4f8aa,0x3ecd2049,0x3ed546d9,
|
||||
0x3edd6c5a,0x3ee590cd,0x3eedb433,0x3ef5d68c,
|
||||
0x3efdf7d7,0x3f061816,0x3f0e3749,0x3f165570,
|
||||
0x3f1e728c,0x3f268e9d,0x3f2ea9a4,0x3f36c3a0,
|
||||
0x3f3edc93,0x3f46f47c,0x3f4f0b5d,0x3f572135,
|
||||
0x3f5f3606,0x3f6749cf,0x3f6f5c90,0x3f776e4a,
|
||||
0x3f7f7efe,0x3f878eab,0x3f8f9d53,0x3f97aaf6,
|
||||
0x3f9fb793,0x3fa7c32c,0x3fafcdc1,0x3fb7d752,
|
||||
0x3fbfdfe0,0x3fc7e76b,0x3fcfedf3,0x3fd7f378,
|
||||
0x3fdff7fc,0x3fe7fb7f,0x3feffe00,0x3ff7ff80,
|
||||
0x3fffffff,
|
||||
};
|
||||
|
||||
static const int32_t av_sqr_exp_multbl_sf[2] = {
|
||||
0x20000000,0x2d413ccd,
|
||||
};
|
||||
|
||||
static const int32_t av_costbl_1_sf[16] = {
|
||||
0x40000000,0x3ec52fa0,0x3b20d79e,0x3536cc52,
|
||||
0x2d413ccd,0x238e7673,0x187de2a7,0x0c7c5c1e,
|
||||
0x00000000,0xf383a3e3,0xe7821d5a,0xdc71898e,
|
||||
0xd2bec334,0xcac933af,0xc4df2863,0xc13ad061,
|
||||
};
|
||||
|
||||
static const int32_t av_costbl_2_sf[32] = {
|
||||
0x40000000,0x3fffb10b,0x3ffec42d,0x3ffd3969,
|
||||
0x3ffb10c1,0x3ff84a3c,0x3ff4e5e0,0x3ff0e3b6,
|
||||
0x3fec43c7,0x3fe7061f,0x3fe12acb,0x3fdab1d9,
|
||||
0x3fd39b5a,0x3fcbe75e,0x3fc395f9,0x3fbaa740,
|
||||
0x3fb11b48,0x3fa6f228,0x3f9c2bfb,0x3f90c8da,
|
||||
0x3f84c8e2,0x3f782c30,0x3f6af2e3,0x3f5d1d1d,
|
||||
0x3f4eaafe,0x3f3f9cab,0x3f2ff24a,0x3f1fabff,
|
||||
0x3f0ec9f5,0x3efd4c54,0x3eeb3347,0x3ed87efc,
|
||||
};
|
||||
|
||||
static const int32_t av_sintbl_2_sf[32] = {
|
||||
0x00000000,0x006487c4,0x00c90e90,0x012d936c,
|
||||
0x0192155f,0x01f69373,0x025b0caf,0x02bf801a,
|
||||
0x0323ecbe,0x038851a2,0x03ecadcf,0x0451004d,
|
||||
0x04b54825,0x0519845e,0x057db403,0x05e1d61b,
|
||||
0x0645e9af,0x06a9edc9,0x070de172,0x0771c3b3,
|
||||
0x07d59396,0x08395024,0x089cf867,0x09008b6a,
|
||||
0x09640837,0x09c76dd8,0x0a2abb59,0x0a8defc3,
|
||||
0x0af10a22,0x0b540982,0x0bb6ecef,0x0c19b374,
|
||||
};
|
||||
|
||||
static const int32_t av_costbl_3_sf[32] = {
|
||||
0x40000000,0x3fffffec,0x3fffffb1,0x3fffff4e,
|
||||
0x3ffffec4,0x3ffffe13,0x3ffffd39,0x3ffffc39,
|
||||
0x3ffffb11,0x3ffff9c1,0x3ffff84a,0x3ffff6ac,
|
||||
0x3ffff4e6,0x3ffff2f8,0x3ffff0e3,0x3fffeea7,
|
||||
0x3fffec43,0x3fffe9b7,0x3fffe705,0x3fffe42a,
|
||||
0x3fffe128,0x3fffddff,0x3fffdaae,0x3fffd736,
|
||||
0x3fffd396,0x3fffcfcf,0x3fffcbe0,0x3fffc7ca,
|
||||
0x3fffc38c,0x3fffbf27,0x3fffba9b,0x3fffb5e7,
|
||||
};
|
||||
|
||||
static const int32_t av_sintbl_3_sf[32] = {
|
||||
0x00000000,0x0003243f,0x0006487f,0x00096cbe,
|
||||
0x000c90fe,0x000fb53d,0x0012d97c,0x0015fdbb,
|
||||
0x001921fb,0x001c463a,0x001f6a79,0x00228eb8,
|
||||
0x0025b2f7,0x0028d736,0x002bfb74,0x002f1fb3,
|
||||
0x003243f1,0x00356830,0x00388c6e,0x003bb0ac,
|
||||
0x003ed4ea,0x0041f928,0x00451d66,0x004841a3,
|
||||
0x004b65e1,0x004e8a1e,0x0051ae5b,0x0054d297,
|
||||
0x0057f6d4,0x005b1b10,0x005e3f4c,0x00616388,
|
||||
};
|
||||
|
||||
static const int32_t av_costbl_4_sf[33] = {
|
||||
0x40000000,0x40000000,0x40000000,0x40000000,
|
||||
0x40000000,0x40000000,0x3fffffff,0x3fffffff,
|
||||
0x3fffffff,0x3ffffffe,0x3ffffffe,0x3ffffffe,
|
||||
0x3ffffffd,0x3ffffffd,0x3ffffffc,0x3ffffffc,
|
||||
0x3ffffffb,0x3ffffffa,0x3ffffffa,0x3ffffff9,
|
||||
0x3ffffff8,0x3ffffff7,0x3ffffff7,0x3ffffff6,
|
||||
0x3ffffff5,0x3ffffff4,0x3ffffff3,0x3ffffff2,
|
||||
0x3ffffff1,0x3ffffff0,0x3fffffef,0x3fffffed,
|
||||
0x3fffffec,
|
||||
};
|
||||
|
||||
static const int32_t av_sintbl_4_sf[33] = {
|
||||
0x00000000,0x00001922,0x00003244,0x00004b66,
|
||||
0x00006488,0x00007daa,0x000096cc,0x0000afee,
|
||||
0x0000c910,0x0000e232,0x0000fb54,0x00011476,
|
||||
0x00012d98,0x000146ba,0x00015fdc,0x000178fe,
|
||||
0x00019220,0x0001ab42,0x0001c464,0x0001dd86,
|
||||
0x0001f6a8,0x00020fca,0x000228ec,0x0002420e,
|
||||
0x00025b30,0x00027452,0x00028d74,0x0002a696,
|
||||
0x0002bfb7,0x0002d8d9,0x0002f1fb,0x00030b1d,
|
||||
0x0003243f,
|
||||
};
|
||||
#endif /* AVUTIL_SOFTFLOAT_TABLES_H */
|
||||
79
media/ffvpx/libavutil/spherical.c
Normal file
79
media/ffvpx/libavutil/spherical.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Vittorio Giovara <vittorio.giovara@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "mem.h"
|
||||
#include "spherical.h"
|
||||
|
||||
AVSphericalMapping *av_spherical_alloc(size_t *size)
|
||||
{
|
||||
AVSphericalMapping *spherical = av_mallocz(sizeof(AVSphericalMapping));
|
||||
if (!spherical)
|
||||
return NULL;
|
||||
|
||||
if (size)
|
||||
*size = sizeof(*spherical);
|
||||
|
||||
return spherical;
|
||||
}
|
||||
|
||||
void av_spherical_tile_bounds(const AVSphericalMapping *map,
|
||||
size_t width, size_t height,
|
||||
size_t *left, size_t *top,
|
||||
size_t *right, size_t *bottom)
|
||||
{
|
||||
/* conversion from 0.32 coordinates to pixels */
|
||||
uint64_t orig_width = (uint64_t) width * UINT32_MAX /
|
||||
(UINT32_MAX - map->bound_right - map->bound_left);
|
||||
uint64_t orig_height = (uint64_t) height * UINT32_MAX /
|
||||
(UINT32_MAX - map->bound_bottom - map->bound_top);
|
||||
|
||||
/* add a (UINT32_MAX - 1) to round up integer division */
|
||||
*left = (orig_width * map->bound_left + UINT32_MAX - 1) / UINT32_MAX;
|
||||
*top = (orig_height * map->bound_top + UINT32_MAX - 1) / UINT32_MAX;
|
||||
*right = orig_width - width - *left;
|
||||
*bottom = orig_height - height - *top;
|
||||
}
|
||||
|
||||
static const char *spherical_projection_names[] = {
|
||||
[AV_SPHERICAL_EQUIRECTANGULAR] = "equirectangular",
|
||||
[AV_SPHERICAL_CUBEMAP] = "cubemap",
|
||||
[AV_SPHERICAL_EQUIRECTANGULAR_TILE] = "tiled equirectangular",
|
||||
};
|
||||
|
||||
const char *av_spherical_projection_name(enum AVSphericalProjection projection)
|
||||
{
|
||||
if ((unsigned)projection >= FF_ARRAY_ELEMS(spherical_projection_names))
|
||||
return "unknown";
|
||||
|
||||
return spherical_projection_names[projection];
|
||||
}
|
||||
|
||||
int av_spherical_from_name(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(spherical_projection_names); i++) {
|
||||
size_t len = strlen(spherical_projection_names[i]);
|
||||
if (!strncmp(spherical_projection_names[i], name, len))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
232
media/ffvpx/libavutil/spherical.h
Normal file
232
media/ffvpx/libavutil/spherical.h
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Vittorio Giovara <vittorio.giovara@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Spherical video
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_SPHERICAL_H
|
||||
#define AVUTIL_SPHERICAL_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_video
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_video_spherical Spherical video mapping
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_video_spherical
|
||||
* A spherical video file contains surfaces that need to be mapped onto a
|
||||
* sphere. Depending on how the frame was converted, a different distortion
|
||||
* transformation or surface recomposition function needs to be applied before
|
||||
* the video should be mapped and displayed.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Projection of the video surface(s) on a sphere.
|
||||
*/
|
||||
enum AVSphericalProjection {
|
||||
/**
|
||||
* Video represents a sphere mapped on a flat surface using
|
||||
* equirectangular projection.
|
||||
*/
|
||||
AV_SPHERICAL_EQUIRECTANGULAR,
|
||||
|
||||
/**
|
||||
* Video frame is split into 6 faces of a cube, and arranged on a
|
||||
* 3x2 layout. Faces are oriented upwards for the front, left, right,
|
||||
* and back faces. The up face is oriented so the top of the face is
|
||||
* forwards and the down face is oriented so the top of the face is
|
||||
* to the back.
|
||||
*/
|
||||
AV_SPHERICAL_CUBEMAP,
|
||||
|
||||
/**
|
||||
* Video represents a portion of a sphere mapped on a flat surface
|
||||
* using equirectangular projection. The @ref bounding fields indicate
|
||||
* the position of the current video in a larger surface.
|
||||
*/
|
||||
AV_SPHERICAL_EQUIRECTANGULAR_TILE,
|
||||
};
|
||||
|
||||
/**
|
||||
* This structure describes how to handle spherical videos, outlining
|
||||
* information about projection, initial layout, and any other view modifier.
|
||||
*
|
||||
* @note The struct must be allocated with av_spherical_alloc() and
|
||||
* its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVSphericalMapping {
|
||||
/**
|
||||
* Projection type.
|
||||
*/
|
||||
enum AVSphericalProjection projection;
|
||||
|
||||
/**
|
||||
* @name Initial orientation
|
||||
* @{
|
||||
* There fields describe additional rotations applied to the sphere after
|
||||
* the video frame is mapped onto it. The sphere is rotated around the
|
||||
* viewer, who remains stationary. The order of transformation is always
|
||||
* yaw, followed by pitch, and finally by roll.
|
||||
*
|
||||
* The coordinate system matches the one defined in OpenGL, where the
|
||||
* forward vector (z) is coming out of screen, and it is equivalent to
|
||||
* a rotation matrix of R = r_y(yaw) * r_x(pitch) * r_z(roll).
|
||||
*
|
||||
* A positive yaw rotates the portion of the sphere in front of the viewer
|
||||
* toward their right. A positive pitch rotates the portion of the sphere
|
||||
* in front of the viewer upwards. A positive roll tilts the portion of
|
||||
* the sphere in front of the viewer to the viewer's right.
|
||||
*
|
||||
* These values are exported as 16.16 fixed point.
|
||||
*
|
||||
* See this equirectangular projection as example:
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* Yaw
|
||||
* -180 0 180
|
||||
* 90 +-------------+-------------+ 180
|
||||
* | | | up
|
||||
* P | | | y| forward
|
||||
* i | ^ | | /z
|
||||
* t 0 +-------------X-------------+ 0 Roll | /
|
||||
* c | | | | /
|
||||
* h | | | 0|/_____right
|
||||
* | | | x
|
||||
* -90 +-------------+-------------+ -180
|
||||
*
|
||||
* X - the default camera center
|
||||
* ^ - the default up vector
|
||||
* @endcode
|
||||
*/
|
||||
int32_t yaw; ///< Rotation around the up vector [-180, 180].
|
||||
int32_t pitch; ///< Rotation around the right vector [-90, 90].
|
||||
int32_t roll; ///< Rotation around the forward vector [-180, 180].
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name Bounding rectangle
|
||||
* @anchor bounding
|
||||
* @{
|
||||
* These fields indicate the location of the current tile, and where
|
||||
* it should be mapped relative to the original surface. They are
|
||||
* exported as 0.32 fixed point, and can be converted to classic
|
||||
* pixel values with av_spherical_bounds().
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* +----------------+----------+
|
||||
* | |bound_top |
|
||||
* | +--------+ |
|
||||
* | bound_left |tile | |
|
||||
* +<---------->| |<--->+bound_right
|
||||
* | +--------+ |
|
||||
* | | |
|
||||
* | bound_bottom| |
|
||||
* +----------------+----------+
|
||||
* @endcode
|
||||
*
|
||||
* If needed, the original video surface dimensions can be derived
|
||||
* by adding the current stream or frame size to the related bounds,
|
||||
* like in the following example:
|
||||
*
|
||||
* @code{c}
|
||||
* original_width = tile->width + bound_left + bound_right;
|
||||
* original_height = tile->height + bound_top + bound_bottom;
|
||||
* @endcode
|
||||
*
|
||||
* @note These values are valid only for the tiled equirectangular
|
||||
* projection type (@ref AV_SPHERICAL_EQUIRECTANGULAR_TILE),
|
||||
* and should be ignored in all other cases.
|
||||
*/
|
||||
uint32_t bound_left; ///< Distance from the left edge
|
||||
uint32_t bound_top; ///< Distance from the top edge
|
||||
uint32_t bound_right; ///< Distance from the right edge
|
||||
uint32_t bound_bottom; ///< Distance from the bottom edge
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Number of pixels to pad from the edge of each cube face.
|
||||
*
|
||||
* @note This value is valid for only for the cubemap projection type
|
||||
* (@ref AV_SPHERICAL_CUBEMAP), and should be ignored in all other
|
||||
* cases.
|
||||
*/
|
||||
uint32_t padding;
|
||||
} AVSphericalMapping;
|
||||
|
||||
/**
|
||||
* Allocate a AVSphericalVideo structure and initialize its fields to default
|
||||
* values.
|
||||
*
|
||||
* @return the newly allocated struct or NULL on failure
|
||||
*/
|
||||
AVSphericalMapping *av_spherical_alloc(size_t *size);
|
||||
|
||||
/**
|
||||
* Convert the @ref bounding fields from an AVSphericalVideo
|
||||
* from 0.32 fixed point to pixels.
|
||||
*
|
||||
* @param map The AVSphericalVideo map to read bound values from.
|
||||
* @param width Width of the current frame or stream.
|
||||
* @param height Height of the current frame or stream.
|
||||
* @param left Pixels from the left edge.
|
||||
* @param top Pixels from the top edge.
|
||||
* @param right Pixels from the right edge.
|
||||
* @param bottom Pixels from the bottom edge.
|
||||
*/
|
||||
void av_spherical_tile_bounds(const AVSphericalMapping *map,
|
||||
size_t width, size_t height,
|
||||
size_t *left, size_t *top,
|
||||
size_t *right, size_t *bottom);
|
||||
|
||||
/**
|
||||
* Provide a human-readable name of a given AVSphericalProjection.
|
||||
*
|
||||
* @param projection The input AVSphericalProjection.
|
||||
*
|
||||
* @return The name of the AVSphericalProjection, or "unknown".
|
||||
*/
|
||||
const char *av_spherical_projection_name(enum AVSphericalProjection projection);
|
||||
|
||||
/**
|
||||
* Get the AVSphericalProjection form a human-readable name.
|
||||
*
|
||||
* @param name The input string.
|
||||
*
|
||||
* @return The AVSphericalProjection value, or -1 if not found.
|
||||
*/
|
||||
int av_spherical_from_name(const char *name);
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_SPHERICAL_H */
|
||||
76
media/ffvpx/libavutil/stereo3d.c
Normal file
76
media/ffvpx/libavutil/stereo3d.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Vittorio Giovara <vittorio.giovara@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "mem.h"
|
||||
#include "stereo3d.h"
|
||||
|
||||
AVStereo3D *av_stereo3d_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(AVStereo3D));
|
||||
}
|
||||
|
||||
AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame)
|
||||
{
|
||||
AVFrameSideData *side_data = av_frame_new_side_data(frame,
|
||||
AV_FRAME_DATA_STEREO3D,
|
||||
sizeof(AVStereo3D));
|
||||
if (!side_data)
|
||||
return NULL;
|
||||
|
||||
memset(side_data->data, 0, sizeof(AVStereo3D));
|
||||
|
||||
return (AVStereo3D *)side_data->data;
|
||||
}
|
||||
|
||||
static const char * const stereo3d_type_names[] = {
|
||||
[AV_STEREO3D_2D] = "2D",
|
||||
[AV_STEREO3D_SIDEBYSIDE] = "side by side",
|
||||
[AV_STEREO3D_TOPBOTTOM] = "top and bottom",
|
||||
[AV_STEREO3D_FRAMESEQUENCE] = "frame alternate",
|
||||
[AV_STEREO3D_CHECKERBOARD] = "checkerboard",
|
||||
[AV_STEREO3D_SIDEBYSIDE_QUINCUNX] = "side by side (quincunx subsampling)",
|
||||
[AV_STEREO3D_LINES] = "interleaved lines",
|
||||
[AV_STEREO3D_COLUMNS] = "interleaved columns",
|
||||
};
|
||||
|
||||
const char *av_stereo3d_type_name(unsigned int type)
|
||||
{
|
||||
if (type >= FF_ARRAY_ELEMS(stereo3d_type_names))
|
||||
return "unknown";
|
||||
|
||||
return stereo3d_type_names[type];
|
||||
}
|
||||
|
||||
int av_stereo3d_from_name(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(stereo3d_type_names); i++) {
|
||||
size_t len = strlen(stereo3d_type_names[i]);
|
||||
if (!strncmp(stereo3d_type_names[i], name, len))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
209
media/ffvpx/libavutil/stereo3d.h
Normal file
209
media/ffvpx/libavutil/stereo3d.h
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Vittorio Giovara <vittorio.giovara@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Stereoscopic video
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_STEREO3D_H
|
||||
#define AVUTIL_STEREO3D_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "frame.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_video
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_video_stereo3d Stereo3D types and functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_video_stereo3d
|
||||
* A stereoscopic video file consists in multiple views embedded in a single
|
||||
* frame, usually describing two views of a scene. This file describes all
|
||||
* possible codec-independent view arrangements.
|
||||
* */
|
||||
|
||||
/**
|
||||
* List of possible 3D Types
|
||||
*/
|
||||
enum AVStereo3DType {
|
||||
/**
|
||||
* Video is not stereoscopic (and metadata has to be there).
|
||||
*/
|
||||
AV_STEREO3D_2D,
|
||||
|
||||
/**
|
||||
* Views are next to each other.
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* LLLLRRRR
|
||||
* LLLLRRRR
|
||||
* LLLLRRRR
|
||||
* ...
|
||||
* @endcode
|
||||
*/
|
||||
AV_STEREO3D_SIDEBYSIDE,
|
||||
|
||||
/**
|
||||
* Views are on top of each other.
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* LLLLLLLL
|
||||
* LLLLLLLL
|
||||
* RRRRRRRR
|
||||
* RRRRRRRR
|
||||
* @endcode
|
||||
*/
|
||||
AV_STEREO3D_TOPBOTTOM,
|
||||
|
||||
/**
|
||||
* Views are alternated temporally.
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* frame0 frame1 frame2 ...
|
||||
* LLLLLLLL RRRRRRRR LLLLLLLL
|
||||
* LLLLLLLL RRRRRRRR LLLLLLLL
|
||||
* LLLLLLLL RRRRRRRR LLLLLLLL
|
||||
* ... ... ...
|
||||
* @endcode
|
||||
*/
|
||||
AV_STEREO3D_FRAMESEQUENCE,
|
||||
|
||||
/**
|
||||
* Views are packed in a checkerboard-like structure per pixel.
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* LRLRLRLR
|
||||
* RLRLRLRL
|
||||
* LRLRLRLR
|
||||
* ...
|
||||
* @endcode
|
||||
*/
|
||||
AV_STEREO3D_CHECKERBOARD,
|
||||
|
||||
/**
|
||||
* Views are next to each other, but when upscaling
|
||||
* apply a checkerboard pattern.
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* LLLLRRRR L L L L R R R R
|
||||
* LLLLRRRR => L L L L R R R R
|
||||
* LLLLRRRR L L L L R R R R
|
||||
* LLLLRRRR L L L L R R R R
|
||||
* @endcode
|
||||
*/
|
||||
AV_STEREO3D_SIDEBYSIDE_QUINCUNX,
|
||||
|
||||
/**
|
||||
* Views are packed per line, as if interlaced.
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* LLLLLLLL
|
||||
* RRRRRRRR
|
||||
* LLLLLLLL
|
||||
* ...
|
||||
* @endcode
|
||||
*/
|
||||
AV_STEREO3D_LINES,
|
||||
|
||||
/**
|
||||
* Views are packed per column.
|
||||
*
|
||||
* @code{.unparsed}
|
||||
* LRLRLRLR
|
||||
* LRLRLRLR
|
||||
* LRLRLRLR
|
||||
* ...
|
||||
* @endcode
|
||||
*/
|
||||
AV_STEREO3D_COLUMNS,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Inverted views, Right/Bottom represents the left view.
|
||||
*/
|
||||
#define AV_STEREO3D_FLAG_INVERT (1 << 0)
|
||||
|
||||
/**
|
||||
* Stereo 3D type: this structure describes how two videos are packed
|
||||
* within a single video surface, with additional information as needed.
|
||||
*
|
||||
* @note The struct must be allocated with av_stereo3d_alloc() and
|
||||
* its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVStereo3D {
|
||||
/**
|
||||
* How views are packed within the video.
|
||||
*/
|
||||
enum AVStereo3DType type;
|
||||
|
||||
/**
|
||||
* Additional information about the frame packing.
|
||||
*/
|
||||
int flags;
|
||||
} AVStereo3D;
|
||||
|
||||
/**
|
||||
* Allocate an AVStereo3D structure and set its fields to default values.
|
||||
* The resulting struct can be freed using av_freep().
|
||||
*
|
||||
* @return An AVStereo3D filled with default values or NULL on failure.
|
||||
*/
|
||||
AVStereo3D *av_stereo3d_alloc(void);
|
||||
|
||||
/**
|
||||
* Allocate a complete AVFrameSideData and add it to the frame.
|
||||
*
|
||||
* @param frame The frame which side data is added to.
|
||||
*
|
||||
* @return The AVStereo3D structure to be filled by caller.
|
||||
*/
|
||||
AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Provide a human-readable name of a given stereo3d type.
|
||||
*
|
||||
* @param type The input stereo3d type value.
|
||||
*
|
||||
* @return The name of the stereo3d value, or "unknown".
|
||||
*/
|
||||
const char *av_stereo3d_type_name(unsigned int type);
|
||||
|
||||
/**
|
||||
* Get the AVStereo3DType form a human-readable name.
|
||||
*
|
||||
* @param name The input string.
|
||||
*
|
||||
* @return The AVStereo3DType value, or -1 if not found.
|
||||
*/
|
||||
int av_stereo3d_from_name(const char *name);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_STEREO3D_H */
|
||||
121
media/ffvpx/libavutil/tea.c
Normal file
121
media/ffvpx/libavutil/tea.c
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* A 32-bit implementation of the TEA algorithm
|
||||
* Copyright (c) 2015 Vesselin Bontchev
|
||||
*
|
||||
* Loosely based on the implementation of David Wheeler and Roger Needham,
|
||||
* https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm#Reference_code
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "avutil.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "tea.h"
|
||||
|
||||
typedef struct AVTEA {
|
||||
uint32_t key[16];
|
||||
int rounds;
|
||||
} AVTEA;
|
||||
|
||||
struct AVTEA *av_tea_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVTEA));
|
||||
}
|
||||
|
||||
const int av_tea_size = sizeof(AVTEA);
|
||||
|
||||
void av_tea_init(AVTEA *ctx, const uint8_t key[16], int rounds)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
ctx->key[i] = AV_RB32(key + (i << 2));
|
||||
|
||||
ctx->rounds = rounds;
|
||||
}
|
||||
|
||||
static void tea_crypt_ecb(AVTEA *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int decrypt, uint8_t *iv)
|
||||
{
|
||||
uint32_t v0, v1;
|
||||
int rounds = ctx->rounds;
|
||||
uint32_t k0, k1, k2, k3;
|
||||
k0 = ctx->key[0];
|
||||
k1 = ctx->key[1];
|
||||
k2 = ctx->key[2];
|
||||
k3 = ctx->key[3];
|
||||
|
||||
v0 = AV_RB32(src);
|
||||
v1 = AV_RB32(src + 4);
|
||||
|
||||
if (decrypt) {
|
||||
int i;
|
||||
uint32_t delta = 0x9E3779B9U, sum = delta * (rounds / 2);
|
||||
|
||||
for (i = 0; i < rounds / 2; i++) {
|
||||
v1 -= ((v0 << 4) + k2) ^ (v0 + sum) ^ ((v0 >> 5) + k3);
|
||||
v0 -= ((v1 << 4) + k0) ^ (v1 + sum) ^ ((v1 >> 5) + k1);
|
||||
sum -= delta;
|
||||
}
|
||||
if (iv) {
|
||||
v0 ^= AV_RB32(iv);
|
||||
v1 ^= AV_RB32(iv + 4);
|
||||
memcpy(iv, src, 8);
|
||||
}
|
||||
} else {
|
||||
int i;
|
||||
uint32_t sum = 0, delta = 0x9E3779B9U;
|
||||
|
||||
for (i = 0; i < rounds / 2; i++) {
|
||||
sum += delta;
|
||||
v0 += ((v1 << 4) + k0) ^ (v1 + sum) ^ ((v1 >> 5) + k1);
|
||||
v1 += ((v0 << 4) + k2) ^ (v0 + sum) ^ ((v0 >> 5) + k3);
|
||||
}
|
||||
}
|
||||
|
||||
AV_WB32(dst, v0);
|
||||
AV_WB32(dst + 4, v1);
|
||||
}
|
||||
|
||||
void av_tea_crypt(AVTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
|
||||
uint8_t *iv, int decrypt)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (decrypt) {
|
||||
while (count--) {
|
||||
tea_crypt_ecb(ctx, dst, src, decrypt, iv);
|
||||
|
||||
src += 8;
|
||||
dst += 8;
|
||||
}
|
||||
} else {
|
||||
while (count--) {
|
||||
if (iv) {
|
||||
for (i = 0; i < 8; i++)
|
||||
dst[i] = src[i] ^ iv[i];
|
||||
tea_crypt_ecb(ctx, dst, dst, decrypt, NULL);
|
||||
memcpy(iv, dst, 8);
|
||||
} else {
|
||||
tea_crypt_ecb(ctx, dst, src, decrypt, NULL);
|
||||
}
|
||||
src += 8;
|
||||
dst += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
71
media/ffvpx/libavutil/tea.h
Normal file
71
media/ffvpx/libavutil/tea.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* A 32-bit implementation of the TEA algorithm
|
||||
* Copyright (c) 2015 Vesselin Bontchev
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_TEA_H
|
||||
#define AVUTIL_TEA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Public header for libavutil TEA algorithm
|
||||
* @defgroup lavu_tea TEA
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_tea_size;
|
||||
|
||||
struct AVTEA;
|
||||
|
||||
/**
|
||||
* Allocate an AVTEA context
|
||||
* To free the struct: av_free(ptr)
|
||||
*/
|
||||
struct AVTEA *av_tea_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVTEA context.
|
||||
*
|
||||
* @param ctx an AVTEA context
|
||||
* @param key a key of 16 bytes used for encryption/decryption
|
||||
* @param rounds the number of rounds in TEA (64 is the "standard")
|
||||
*/
|
||||
void av_tea_init(struct AVTEA *ctx, const uint8_t key[16], int rounds);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
*
|
||||
* @param ctx an AVTEA context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 8 byte blocks
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_tea_crypt(struct AVTEA *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_TEA_H */
|
||||
168
media/ffvpx/libavutil/tree.c
Normal file
168
media/ffvpx/libavutil/tree.c
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "error.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
#include "tree.h"
|
||||
|
||||
typedef struct AVTreeNode {
|
||||
struct AVTreeNode *child[2];
|
||||
void *elem;
|
||||
int state;
|
||||
} AVTreeNode;
|
||||
|
||||
const int av_tree_node_size = sizeof(AVTreeNode);
|
||||
|
||||
struct AVTreeNode *av_tree_node_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVTreeNode));
|
||||
}
|
||||
|
||||
void *av_tree_find(const AVTreeNode *t, void *key,
|
||||
int (*cmp)(const void *key, const void *b), void *next[2])
|
||||
{
|
||||
if (t) {
|
||||
unsigned int v = cmp(key, t->elem);
|
||||
if (v) {
|
||||
if (next)
|
||||
next[v >> 31] = t->elem;
|
||||
return av_tree_find(t->child[(v >> 31) ^ 1], key, cmp, next);
|
||||
} else {
|
||||
if (next) {
|
||||
av_tree_find(t->child[0], key, cmp, next);
|
||||
av_tree_find(t->child[1], key, cmp, next);
|
||||
}
|
||||
return t->elem;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *av_tree_insert(AVTreeNode **tp, void *key,
|
||||
int (*cmp)(const void *key, const void *b), AVTreeNode **next)
|
||||
{
|
||||
AVTreeNode *t = *tp;
|
||||
if (t) {
|
||||
unsigned int v = cmp(t->elem, key);
|
||||
void *ret;
|
||||
if (!v) {
|
||||
if (*next)
|
||||
return t->elem;
|
||||
else if (t->child[0] || t->child[1]) {
|
||||
int i = !t->child[0];
|
||||
void *next_elem[2];
|
||||
av_tree_find(t->child[i], key, cmp, next_elem);
|
||||
key = t->elem = next_elem[i];
|
||||
v = -i;
|
||||
} else {
|
||||
*next = t;
|
||||
*tp = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
ret = av_tree_insert(&t->child[v >> 31], key, cmp, next);
|
||||
if (!ret) {
|
||||
int i = (v >> 31) ^ !!*next;
|
||||
AVTreeNode **child = &t->child[i];
|
||||
t->state += 2 * i - 1;
|
||||
|
||||
if (!(t->state & 1)) {
|
||||
if (t->state) {
|
||||
/* The following code is equivalent to
|
||||
* if ((*child)->state * 2 == -t->state)
|
||||
* rotate(child, i ^ 1);
|
||||
* rotate(tp, i);
|
||||
*
|
||||
* with rotate():
|
||||
* static void rotate(AVTreeNode **tp, int i)
|
||||
* {
|
||||
* AVTreeNode *t= *tp;
|
||||
*
|
||||
* *tp = t->child[i];
|
||||
* t->child[i] = t->child[i]->child[i ^ 1];
|
||||
* (*tp)->child[i ^ 1] = t;
|
||||
* i = 4 * t->state + 2 * (*tp)->state + 12;
|
||||
* t->state = ((0x614586 >> i) & 3) - 1;
|
||||
* (*tp)->state = ((0x400EEA >> i) & 3) - 1 +
|
||||
* ((*tp)->state >> 1);
|
||||
* }
|
||||
* but such a rotate function is both bigger and slower
|
||||
*/
|
||||
if ((*child)->state * 2 == -t->state) {
|
||||
*tp = (*child)->child[i ^ 1];
|
||||
(*child)->child[i ^ 1] = (*tp)->child[i];
|
||||
(*tp)->child[i] = *child;
|
||||
*child = (*tp)->child[i ^ 1];
|
||||
(*tp)->child[i ^ 1] = t;
|
||||
|
||||
(*tp)->child[0]->state = -((*tp)->state > 0);
|
||||
(*tp)->child[1]->state = (*tp)->state < 0;
|
||||
(*tp)->state = 0;
|
||||
} else {
|
||||
*tp = *child;
|
||||
*child = (*child)->child[i ^ 1];
|
||||
(*tp)->child[i ^ 1] = t;
|
||||
if ((*tp)->state)
|
||||
t->state = 0;
|
||||
else
|
||||
t->state >>= 1;
|
||||
(*tp)->state = -t->state;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(*tp)->state ^ !!*next)
|
||||
return key;
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
*tp = *next;
|
||||
*next = NULL;
|
||||
if (*tp) {
|
||||
(*tp)->elem = key;
|
||||
return NULL;
|
||||
} else
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
void av_tree_destroy(AVTreeNode *t)
|
||||
{
|
||||
if (t) {
|
||||
av_tree_destroy(t->child[0]);
|
||||
av_tree_destroy(t->child[1]);
|
||||
av_free(t);
|
||||
}
|
||||
}
|
||||
|
||||
void av_tree_enumerate(AVTreeNode *t, void *opaque,
|
||||
int (*cmp)(void *opaque, void *elem),
|
||||
int (*enu)(void *opaque, void *elem))
|
||||
{
|
||||
if (t) {
|
||||
int v = cmp ? cmp(opaque, t->elem) : 0;
|
||||
if (v >= 0)
|
||||
av_tree_enumerate(t->child[0], opaque, cmp, enu);
|
||||
if (v == 0)
|
||||
enu(opaque, t->elem);
|
||||
if (v <= 0)
|
||||
av_tree_enumerate(t->child[1], opaque, cmp, enu);
|
||||
}
|
||||
}
|
||||
138
media/ffvpx/libavutil/tree.h
Normal file
138
media/ffvpx/libavutil/tree.h
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* A tree container.
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_TREE_H
|
||||
#define AVUTIL_TREE_H
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_tree AVTree
|
||||
* @ingroup lavu_data
|
||||
*
|
||||
* Low-complexity tree container
|
||||
*
|
||||
* Insertion, removal, finding equal, largest which is smaller than and
|
||||
* smallest which is larger than, all have O(log n) worst-case complexity.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
struct AVTreeNode;
|
||||
extern const int av_tree_node_size;
|
||||
|
||||
/**
|
||||
* Allocate an AVTreeNode.
|
||||
*/
|
||||
struct AVTreeNode *av_tree_node_alloc(void);
|
||||
|
||||
/**
|
||||
* Find an element.
|
||||
* @param root a pointer to the root node of the tree
|
||||
* @param next If next is not NULL, then next[0] will contain the previous
|
||||
* element and next[1] the next element. If either does not exist,
|
||||
* then the corresponding entry in next is unchanged.
|
||||
* @param cmp compare function used to compare elements in the tree,
|
||||
* API identical to that of Standard C's qsort
|
||||
* It is guaranteed that the first and only the first argument to cmp()
|
||||
* will be the key parameter to av_tree_find(), thus it could if the
|
||||
* user wants, be a different type (like an opaque context).
|
||||
* @return An element with cmp(key, elem) == 0 or NULL if no such element
|
||||
* exists in the tree.
|
||||
*/
|
||||
void *av_tree_find(const struct AVTreeNode *root, void *key,
|
||||
int (*cmp)(const void *key, const void *b), void *next[2]);
|
||||
|
||||
/**
|
||||
* Insert or remove an element.
|
||||
*
|
||||
* If *next is NULL, then the supplied element will be removed if it exists.
|
||||
* If *next is non-NULL, then the supplied element will be inserted, unless
|
||||
* it already exists in the tree.
|
||||
*
|
||||
* @param rootp A pointer to a pointer to the root node of the tree; note that
|
||||
* the root node can change during insertions, this is required
|
||||
* to keep the tree balanced.
|
||||
* @param key pointer to the element key to insert in the tree
|
||||
* @param next Used to allocate and free AVTreeNodes. For insertion the user
|
||||
* must set it to an allocated and zeroed object of at least
|
||||
* av_tree_node_size bytes size. av_tree_insert() will set it to
|
||||
* NULL if it has been consumed.
|
||||
* For deleting elements *next is set to NULL by the user and
|
||||
* av_tree_insert() will set it to the AVTreeNode which was
|
||||
* used for the removed element.
|
||||
* This allows the use of flat arrays, which have
|
||||
* lower overhead compared to many malloced elements.
|
||||
* You might want to define a function like:
|
||||
* @code
|
||||
* void *tree_insert(struct AVTreeNode **rootp, void *key,
|
||||
* int (*cmp)(void *key, const void *b),
|
||||
* AVTreeNode **next)
|
||||
* {
|
||||
* if (!*next)
|
||||
* *next = av_mallocz(av_tree_node_size);
|
||||
* return av_tree_insert(rootp, key, cmp, next);
|
||||
* }
|
||||
* void *tree_remove(struct AVTreeNode **rootp, void *key,
|
||||
* int (*cmp)(void *key, const void *b, AVTreeNode **next))
|
||||
* {
|
||||
* av_freep(next);
|
||||
* return av_tree_insert(rootp, key, cmp, next);
|
||||
* }
|
||||
* @endcode
|
||||
* @param cmp compare function used to compare elements in the tree, API identical
|
||||
* to that of Standard C's qsort
|
||||
* @return If no insertion happened, the found element; if an insertion or
|
||||
* removal happened, then either key or NULL will be returned.
|
||||
* Which one it is depends on the tree state and the implementation. You
|
||||
* should make no assumptions that it's one or the other in the code.
|
||||
*/
|
||||
void *av_tree_insert(struct AVTreeNode **rootp, void *key,
|
||||
int (*cmp)(const void *key, const void *b),
|
||||
struct AVTreeNode **next);
|
||||
|
||||
void av_tree_destroy(struct AVTreeNode *t);
|
||||
|
||||
/**
|
||||
* Apply enu(opaque, &elem) to all the elements in the tree in a given range.
|
||||
*
|
||||
* @param cmp a comparison function that returns < 0 for an element below the
|
||||
* range, > 0 for an element above the range and == 0 for an
|
||||
* element inside the range
|
||||
*
|
||||
* @note The cmp function should use the same ordering used to construct the
|
||||
* tree.
|
||||
*/
|
||||
void av_tree_enumerate(struct AVTreeNode *t, void *opaque,
|
||||
int (*cmp)(void *opaque, void *elem),
|
||||
int (*enu)(void *opaque, void *elem));
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_TREE_H */
|
||||
331
media/ffvpx/libavutil/twofish.c
Normal file
331
media/ffvpx/libavutil/twofish.c
Normal file
|
|
@ -0,0 +1,331 @@
|
|||
/*
|
||||
* An implementation of the TwoFish algorithm
|
||||
* Copyright (c) 2015 Supraja Meedinti
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "twofish.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "attributes.h"
|
||||
|
||||
#define LR(x, n) ((x) << (n) | (x) >> (32 - (n)))
|
||||
#define RR(x, n) ((x) >> (n) | (x) << (32 - (n)))
|
||||
|
||||
typedef struct AVTWOFISH {
|
||||
uint32_t K[40];
|
||||
uint32_t S[4];
|
||||
int ksize;
|
||||
uint32_t MDS1[256];
|
||||
uint32_t MDS2[256];
|
||||
uint32_t MDS3[256];
|
||||
uint32_t MDS4[256];
|
||||
} AVTWOFISH;
|
||||
|
||||
static const uint8_t MD1[256] = {
|
||||
0x00, 0x5b, 0xb6, 0xed, 0x05, 0x5e, 0xb3, 0xe8, 0x0a, 0x51, 0xbc, 0xe7, 0x0f, 0x54, 0xb9, 0xe2,
|
||||
0x14, 0x4f, 0xa2, 0xf9, 0x11, 0x4a, 0xa7, 0xfc, 0x1e, 0x45, 0xa8, 0xf3, 0x1b, 0x40, 0xad, 0xf6,
|
||||
0x28, 0x73, 0x9e, 0xc5, 0x2d, 0x76, 0x9b, 0xc0, 0x22, 0x79, 0x94, 0xcf, 0x27, 0x7c, 0x91, 0xca,
|
||||
0x3c, 0x67, 0x8a, 0xd1, 0x39, 0x62, 0x8f, 0xd4, 0x36, 0x6d, 0x80, 0xdb, 0x33, 0x68, 0x85, 0xde,
|
||||
0x50, 0x0b, 0xe6, 0xbd, 0x55, 0x0e, 0xe3, 0xb8, 0x5a, 0x01, 0xec, 0xb7, 0x5f, 0x04, 0xe9, 0xb2,
|
||||
0x44, 0x1f, 0xf2, 0xa9, 0x41, 0x1a, 0xf7, 0xac, 0x4e, 0x15, 0xf8, 0xa3, 0x4b, 0x10, 0xfd, 0xa6,
|
||||
0x78, 0x23, 0xce, 0x95, 0x7d, 0x26, 0xcb, 0x90, 0x72, 0x29, 0xc4, 0x9f, 0x77, 0x2c, 0xc1, 0x9a,
|
||||
0x6c, 0x37, 0xda, 0x81, 0x69, 0x32, 0xdf, 0x84, 0x66, 0x3d, 0xd0, 0x8b, 0x63, 0x38, 0xd5, 0x8e,
|
||||
0xa0, 0xfb, 0x16, 0x4d, 0xa5, 0xfe, 0x13, 0x48, 0xaa, 0xf1, 0x1c, 0x47, 0xaf, 0xf4, 0x19, 0x42,
|
||||
0xb4, 0xef, 0x02, 0x59, 0xb1, 0xea, 0x07, 0x5c, 0xbe, 0xe5, 0x08, 0x53, 0xbb, 0xe0, 0x0d, 0x56,
|
||||
0x88, 0xd3, 0x3e, 0x65, 0x8d, 0xd6, 0x3b, 0x60, 0x82, 0xd9, 0x34, 0x6f, 0x87, 0xdc, 0x31, 0x6a,
|
||||
0x9c, 0xc7, 0x2a, 0x71, 0x99, 0xc2, 0x2f, 0x74, 0x96, 0xcd, 0x20, 0x7b, 0x93, 0xc8, 0x25, 0x7e,
|
||||
0xf0, 0xab, 0x46, 0x1d, 0xf5, 0xae, 0x43, 0x18, 0xfa, 0xa1, 0x4c, 0x17, 0xff, 0xa4, 0x49, 0x12,
|
||||
0xe4, 0xbf, 0x52, 0x09, 0xe1, 0xba, 0x57, 0x0c, 0xee, 0xb5, 0x58, 0x03, 0xeb, 0xb0, 0x5d, 0x06,
|
||||
0xd8, 0x83, 0x6e, 0x35, 0xdd, 0x86, 0x6b, 0x30, 0xd2, 0x89, 0x64, 0x3f, 0xd7, 0x8c, 0x61, 0x3a,
|
||||
0xcc, 0x97, 0x7a, 0x21, 0xc9, 0x92, 0x7f, 0x24, 0xc6, 0x9d, 0x70, 0x2b, 0xc3, 0x98, 0x75, 0x2e
|
||||
};
|
||||
|
||||
static const uint8_t MD2[256] = {
|
||||
0x00, 0xef, 0xb7, 0x58, 0x07, 0xe8, 0xb0, 0x5f, 0x0e, 0xe1, 0xb9, 0x56, 0x09, 0xe6, 0xbe, 0x51,
|
||||
0x1c, 0xf3, 0xab, 0x44, 0x1b, 0xf4, 0xac, 0x43, 0x12, 0xfd, 0xa5, 0x4a, 0x15, 0xfa, 0xa2, 0x4d,
|
||||
0x38, 0xd7, 0x8f, 0x60, 0x3f, 0xd0, 0x88, 0x67, 0x36, 0xd9, 0x81, 0x6e, 0x31, 0xde, 0x86, 0x69,
|
||||
0x24, 0xcb, 0x93, 0x7c, 0x23, 0xcc, 0x94, 0x7b, 0x2a, 0xc5, 0x9d, 0x72, 0x2d, 0xc2, 0x9a, 0x75,
|
||||
0x70, 0x9f, 0xc7, 0x28, 0x77, 0x98, 0xc0, 0x2f, 0x7e, 0x91, 0xc9, 0x26, 0x79, 0x96, 0xce, 0x21,
|
||||
0x6c, 0x83, 0xdb, 0x34, 0x6b, 0x84, 0xdc, 0x33, 0x62, 0x8d, 0xd5, 0x3a, 0x65, 0x8a, 0xd2, 0x3d,
|
||||
0x48, 0xa7, 0xff, 0x10, 0x4f, 0xa0, 0xf8, 0x17, 0x46, 0xa9, 0xf1, 0x1e, 0x41, 0xae, 0xf6, 0x19,
|
||||
0x54, 0xbb, 0xe3, 0x0c, 0x53, 0xbc, 0xe4, 0x0b, 0x5a, 0xb5, 0xed, 0x02, 0x5d, 0xb2, 0xea, 0x05,
|
||||
0xe0, 0x0f, 0x57, 0xb8, 0xe7, 0x08, 0x50, 0xbf, 0xee, 0x01, 0x59, 0xb6, 0xe9, 0x06, 0x5e, 0xb1,
|
||||
0xfc, 0x13, 0x4b, 0xa4, 0xfb, 0x14, 0x4c, 0xa3, 0xf2, 0x1d, 0x45, 0xaa, 0xf5, 0x1a, 0x42, 0xad,
|
||||
0xd8, 0x37, 0x6f, 0x80, 0xdf, 0x30, 0x68, 0x87, 0xd6, 0x39, 0x61, 0x8e, 0xd1, 0x3e, 0x66, 0x89,
|
||||
0xc4, 0x2b, 0x73, 0x9c, 0xc3, 0x2c, 0x74, 0x9b, 0xca, 0x25, 0x7d, 0x92, 0xcd, 0x22, 0x7a, 0x95,
|
||||
0x90, 0x7f, 0x27, 0xc8, 0x97, 0x78, 0x20, 0xcf, 0x9e, 0x71, 0x29, 0xc6, 0x99, 0x76, 0x2e, 0xc1,
|
||||
0x8c, 0x63, 0x3b, 0xd4, 0x8b, 0x64, 0x3c, 0xd3, 0x82, 0x6d, 0x35, 0xda, 0x85, 0x6a, 0x32, 0xdd,
|
||||
0xa8, 0x47, 0x1f, 0xf0, 0xaf, 0x40, 0x18, 0xf7, 0xa6, 0x49, 0x11, 0xfe, 0xa1, 0x4e, 0x16, 0xf9,
|
||||
0xb4, 0x5b, 0x03, 0xec, 0xb3, 0x5c, 0x04, 0xeb, 0xba, 0x55, 0x0d, 0xe2, 0xbd, 0x52, 0x0a, 0xe5
|
||||
};
|
||||
|
||||
static const uint8_t q0[256] = {
|
||||
0xa9, 0x67, 0xb3, 0xe8, 0x04, 0xfd, 0xa3, 0x76, 0x9a, 0x92, 0x80, 0x78, 0xe4, 0xdd, 0xd1, 0x38,
|
||||
0x0d, 0xc6, 0x35, 0x98, 0x18, 0xf7, 0xec, 0x6c, 0x43, 0x75, 0x37, 0x26, 0xfa, 0x13, 0x94, 0x48,
|
||||
0xf2, 0xd0, 0x8b, 0x30, 0x84, 0x54, 0xdf, 0x23, 0x19, 0x5b, 0x3d, 0x59, 0xf3, 0xae, 0xa2, 0x82,
|
||||
0x63, 0x01, 0x83, 0x2e, 0xd9, 0x51, 0x9b, 0x7c, 0xa6, 0xeb, 0xa5, 0xbe, 0x16, 0x0c, 0xe3, 0x61,
|
||||
0xc0, 0x8c, 0x3a, 0xf5, 0x73, 0x2c, 0x25, 0x0b, 0xbb, 0x4e, 0x89, 0x6b, 0x53, 0x6a, 0xb4, 0xf1,
|
||||
0xe1, 0xe6, 0xbd, 0x45, 0xe2, 0xf4, 0xb6, 0x66, 0xcc, 0x95, 0x03, 0x56, 0xd4, 0x1c, 0x1e, 0xd7,
|
||||
0xfb, 0xc3, 0x8e, 0xb5, 0xe9, 0xcf, 0xbf, 0xba, 0xea, 0x77, 0x39, 0xaf, 0x33, 0xc9, 0x62, 0x71,
|
||||
0x81, 0x79, 0x09, 0xad, 0x24, 0xcd, 0xf9, 0xd8, 0xe5, 0xc5, 0xb9, 0x4d, 0x44, 0x08, 0x86, 0xe7,
|
||||
0xa1, 0x1d, 0xaa, 0xed, 0x06, 0x70, 0xb2, 0xd2, 0x41, 0x7b, 0xa0, 0x11, 0x31, 0xc2, 0x27, 0x90,
|
||||
0x20, 0xf6, 0x60, 0xff, 0x96, 0x5c, 0xb1, 0xab, 0x9e, 0x9c, 0x52, 0x1b, 0x5f, 0x93, 0x0a, 0xef,
|
||||
0x91, 0x85, 0x49, 0xee, 0x2d, 0x4f, 0x8f, 0x3b, 0x47, 0x87, 0x6d, 0x46, 0xd6, 0x3e, 0x69, 0x64,
|
||||
0x2a, 0xce, 0xcb, 0x2f, 0xfc, 0x97, 0x05, 0x7a, 0xac, 0x7f, 0xd5, 0x1a, 0x4b, 0x0e, 0xa7, 0x5a,
|
||||
0x28, 0x14, 0x3f, 0x29, 0x88, 0x3c, 0x4c, 0x02, 0xb8, 0xda, 0xb0, 0x17, 0x55, 0x1f, 0x8a, 0x7d,
|
||||
0x57, 0xc7, 0x8d, 0x74, 0xb7, 0xc4, 0x9f, 0x72, 0x7e, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34,
|
||||
0x6e, 0x50, 0xde, 0x68, 0x65, 0xbc, 0xdb, 0xf8, 0xc8, 0xa8, 0x2b, 0x40, 0xdc, 0xfe, 0x32, 0xa4,
|
||||
0xca, 0x10, 0x21, 0xf0, 0xd3, 0x5d, 0x0f, 0x00, 0x6f, 0x9d, 0x36, 0x42, 0x4a, 0x5e, 0xc1, 0xe0
|
||||
};
|
||||
|
||||
static const uint8_t q1[256] = {
|
||||
0x75, 0xf3, 0xc6, 0xf4, 0xdb, 0x7b, 0xfb, 0xc8, 0x4a, 0xd3, 0xe6, 0x6b, 0x45, 0x7d, 0xe8, 0x4b,
|
||||
0xd6, 0x32, 0xd8, 0xfd, 0x37, 0x71, 0xf1, 0xe1, 0x30, 0x0f, 0xf8, 0x1b, 0x87, 0xfa, 0x06, 0x3f,
|
||||
0x5e, 0xba, 0xae, 0x5b, 0x8a, 0x00, 0xbc, 0x9d, 0x6d, 0xc1, 0xb1, 0x0e, 0x80, 0x5d, 0xd2, 0xd5,
|
||||
0xa0, 0x84, 0x07, 0x14, 0xb5, 0x90, 0x2c, 0xa3, 0xb2, 0x73, 0x4c, 0x54, 0x92, 0x74, 0x36, 0x51,
|
||||
0x38, 0xb0, 0xbd, 0x5a, 0xfc, 0x60, 0x62, 0x96, 0x6c, 0x42, 0xf7, 0x10, 0x7c, 0x28, 0x27, 0x8c,
|
||||
0x13, 0x95, 0x9c, 0xc7, 0x24, 0x46, 0x3b, 0x70, 0xca, 0xe3, 0x85, 0xcb, 0x11, 0xd0, 0x93, 0xb8,
|
||||
0xa6, 0x83, 0x20, 0xff, 0x9f, 0x77, 0xc3, 0xcc, 0x03, 0x6f, 0x08, 0xbf, 0x40, 0xe7, 0x2b, 0xe2,
|
||||
0x79, 0x0c, 0xaa, 0x82, 0x41, 0x3a, 0xea, 0xb9, 0xe4, 0x9a, 0xa4, 0x97, 0x7e, 0xda, 0x7a, 0x17,
|
||||
0x66, 0x94, 0xa1, 0x1d, 0x3d, 0xf0, 0xde, 0xb3, 0x0b, 0x72, 0xa7, 0x1c, 0xef, 0xd1, 0x53, 0x3e,
|
||||
0x8f, 0x33, 0x26, 0x5f, 0xec, 0x76, 0x2a, 0x49, 0x81, 0x88, 0xee, 0x21, 0xc4, 0x1a, 0xeb, 0xd9,
|
||||
0xc5, 0x39, 0x99, 0xcd, 0xad, 0x31, 0x8b, 0x01, 0x18, 0x23, 0xdd, 0x1f, 0x4e, 0x2d, 0xf9, 0x48,
|
||||
0x4f, 0xf2, 0x65, 0x8e, 0x78, 0x5c, 0x58, 0x19, 0x8d, 0xe5, 0x98, 0x57, 0x67, 0x7f, 0x05, 0x64,
|
||||
0xaf, 0x63, 0xb6, 0xfe, 0xf5, 0xb7, 0x3c, 0xa5, 0xce, 0xe9, 0x68, 0x44, 0xe0, 0x4d, 0x43, 0x69,
|
||||
0x29, 0x2e, 0xac, 0x15, 0x59, 0xa8, 0x0a, 0x9e, 0x6e, 0x47, 0xdf, 0x34, 0x35, 0x6a, 0xcf, 0xdc,
|
||||
0x22, 0xc9, 0xc0, 0x9b, 0x89, 0xd4, 0xed, 0xab, 0x12, 0xa2, 0x0d, 0x52, 0xbb, 0x02, 0x2f, 0xa9,
|
||||
0xd7, 0x61, 0x1e, 0xb4, 0x50, 0x04, 0xf6, 0xc2, 0x16, 0x25, 0x86, 0x56, 0x55, 0x09, 0xbe, 0x91
|
||||
};
|
||||
|
||||
struct AVTWOFISH *av_twofish_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVTWOFISH));
|
||||
}
|
||||
|
||||
const int av_twofish_size = sizeof(AVTWOFISH);
|
||||
|
||||
static uint8_t gfmul(uint8_t a, uint8_t b)
|
||||
{
|
||||
uint8_t r = 0, t;
|
||||
while (a && b) {
|
||||
if (a & 1)
|
||||
r = r ^ b;
|
||||
t = b & 0x80;
|
||||
b = b << 1;
|
||||
if (t)
|
||||
b = b ^ 0x4d;
|
||||
a = a >> 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
static uint32_t tf_RS(uint32_t k0, uint32_t k1)
|
||||
{
|
||||
uint8_t s[4], m[8];
|
||||
AV_WL32(m, k0);
|
||||
AV_WL32(m + 4, k1);
|
||||
s[0] = gfmul(0x01, m[0]) ^ gfmul(0xa4, m[1]) ^ gfmul(0x55, m[2]) ^ gfmul(0x87, m[3]) ^ gfmul(0x5a, m[4]) ^ gfmul(0x58, m[5]) ^ gfmul(0xdb, m[6]) ^ gfmul(0x9e, m[7]);
|
||||
s[1] = gfmul(0xa4, m[0]) ^ gfmul(0x56, m[1]) ^ gfmul(0x82, m[2]) ^ gfmul(0xf3, m[3]) ^ gfmul(0x1e, m[4]) ^ gfmul(0xc6, m[5]) ^ gfmul(0x68, m[6]) ^ gfmul(0xe5, m[7]);
|
||||
s[2] = gfmul(0x02, m[0]) ^ gfmul(0xa1, m[1]) ^ gfmul(0xfc, m[2]) ^ gfmul(0xc1, m[3]) ^ gfmul(0x47, m[4]) ^ gfmul(0xae, m[5]) ^ gfmul(0x3d, m[6]) ^ gfmul(0x19, m[7]);
|
||||
s[3] = gfmul(0xa4, m[0]) ^ gfmul(0x55, m[1]) ^ gfmul(0x87, m[2]) ^ gfmul(0x5a, m[3]) ^ gfmul(0x58, m[4]) ^ gfmul(0xdb, m[5]) ^ gfmul(0x9e, m[6]) ^ gfmul(0x03, m[7]);
|
||||
return AV_RL32(s);
|
||||
}
|
||||
|
||||
static void tf_h0(uint8_t y[4], uint32_t L[4], int k)
|
||||
{
|
||||
uint8_t l[4];
|
||||
if (k == 4) {
|
||||
AV_WL32(l, L[3]);
|
||||
y[0] = q1[y[0]] ^ l[0];
|
||||
y[1] = q0[y[1]] ^ l[1];
|
||||
y[2] = q0[y[2]] ^ l[2];
|
||||
y[3] = q1[y[3]] ^ l[3];
|
||||
}
|
||||
if (k >= 3) {
|
||||
AV_WL32(l, L[2]);
|
||||
y[0] = q1[y[0]] ^ l[0];
|
||||
y[1] = q1[y[1]] ^ l[1];
|
||||
y[2] = q0[y[2]] ^ l[2];
|
||||
y[3] = q0[y[3]] ^ l[3];
|
||||
}
|
||||
AV_WL32(l, L[1]);
|
||||
y[0] = q1[q0[q0[y[0]] ^ l[0]] ^ (L[0] & 0xff)];
|
||||
y[1] = q0[q0[q1[y[1]] ^ l[1]] ^ ((L[0] >> 8) & 0xff)];
|
||||
y[2] = q1[q1[q0[y[2]] ^ l[2]] ^ ((L[0] >> 16) & 0xff)];
|
||||
y[3] = q0[q1[q1[y[3]] ^ l[3]] ^ (L[0] >> 24)];
|
||||
}
|
||||
|
||||
static uint32_t tf_h(uint32_t X, uint32_t L[4], int k)
|
||||
{
|
||||
uint8_t y[4], l[4];
|
||||
AV_WL32(y, X);
|
||||
tf_h0(y, L, k);
|
||||
|
||||
l[0] = y[0] ^ MD2[y[1]] ^ MD1[y[2]] ^ MD1[y[3]];
|
||||
l[1] = MD1[y[0]] ^ MD2[y[1]] ^ MD2[y[2]] ^ y[3];
|
||||
l[2] = MD2[y[0]] ^ MD1[y[1]] ^ y[2] ^ MD2[y[3]];
|
||||
l[3] = MD2[y[0]] ^ y[1] ^ MD2[y[2]] ^ MD1[y[3]];
|
||||
|
||||
return AV_RL32(l);
|
||||
}
|
||||
|
||||
static uint32_t MDS_mul(AVTWOFISH *cs, uint32_t X)
|
||||
{
|
||||
return cs->MDS1[(X) & 0xff] ^ cs->MDS2[((X) >> 8) & 0xff] ^ cs->MDS3[((X) >> 16) & 0xff] ^ cs->MDS4[(X) >> 24];
|
||||
}
|
||||
|
||||
static void precomputeMDS(AVTWOFISH *cs)
|
||||
{
|
||||
uint8_t y[4];
|
||||
int i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
y[0] = y[1] = y[2] = y[3] = i;
|
||||
tf_h0(y, cs->S, cs->ksize);
|
||||
cs->MDS1[i] = ((uint32_t)y[0]) ^ ((uint32_t)MD1[y[0]] << 8) ^ ((uint32_t)MD2[y[0]] << 16) ^ ((uint32_t)MD2[y[0]] << 24);
|
||||
cs->MDS2[i] = ((uint32_t)MD2[y[1]]) ^ ((uint32_t)MD2[y[1]] << 8) ^ ((uint32_t)MD1[y[1]] << 16) ^ ((uint32_t)y[1] << 24);
|
||||
cs->MDS3[i] = ((uint32_t)MD1[y[2]]) ^ ((uint32_t)MD2[y[2]] << 8) ^ ((uint32_t)y[2] << 16) ^ ((uint32_t)MD2[y[2]] << 24);
|
||||
cs->MDS4[i] = ((uint32_t)MD1[y[3]]) ^ ((uint32_t)y[3] << 8) ^ ((uint32_t)MD2[y[3]] << 16) ^ ((uint32_t)MD1[y[3]] << 24);
|
||||
}
|
||||
}
|
||||
|
||||
static void twofish_encrypt(AVTWOFISH *cs, uint8_t *dst, const uint8_t *src)
|
||||
{
|
||||
uint32_t P[4], t0, t1;
|
||||
int i;
|
||||
P[0] = AV_RL32(src) ^ cs->K[0];
|
||||
P[1] = AV_RL32(src + 4) ^ cs->K[1];
|
||||
P[2] = AV_RL32(src + 8) ^ cs->K[2];
|
||||
P[3] = AV_RL32(src + 12) ^ cs->K[3];
|
||||
for (i = 0; i < 16; i += 2) {
|
||||
t0 = MDS_mul(cs, P[0]);
|
||||
t1 = MDS_mul(cs, LR(P[1], 8));
|
||||
P[2] = RR(P[2] ^ (t0 + t1 + cs->K[2 * i + 8]), 1);
|
||||
P[3] = LR(P[3], 1) ^ (t0 + 2 * t1 + cs->K[2 * i + 9]);
|
||||
t0 = MDS_mul(cs, P[2]);
|
||||
t1 = MDS_mul(cs, LR(P[3], 8));
|
||||
P[0] = RR(P[0] ^ (t0 + t1 + cs->K[2 * i + 10]), 1);
|
||||
P[1] = LR(P[1], 1) ^ (t0 + 2 * t1 + cs->K[2 * i + 11]);
|
||||
}
|
||||
P[2] ^= cs->K[4];
|
||||
P[3] ^= cs->K[5];
|
||||
P[0] ^= cs->K[6];
|
||||
P[1] ^= cs->K[7];
|
||||
AV_WL32(dst, P[2]);
|
||||
AV_WL32(dst + 4, P[3]);
|
||||
AV_WL32(dst + 8, P[0]);
|
||||
AV_WL32(dst + 12, P[1]);
|
||||
}
|
||||
|
||||
static void twofish_decrypt(AVTWOFISH *cs, uint8_t *dst, const uint8_t *src, uint8_t *iv)
|
||||
{
|
||||
uint32_t P[4], t0, t1;
|
||||
int i;
|
||||
P[2] = AV_RL32(src) ^ cs->K[4];
|
||||
P[3] = AV_RL32(src + 4) ^ cs->K[5];
|
||||
P[0] = AV_RL32(src + 8) ^ cs->K[6];
|
||||
P[1] = AV_RL32(src + 12) ^ cs->K[7];
|
||||
for (i = 15; i >= 0; i -= 2) {
|
||||
t0 = MDS_mul(cs, P[2]);
|
||||
t1 = MDS_mul(cs, LR(P[3], 8));
|
||||
P[0] = LR(P[0], 1) ^ (t0 + t1 + cs->K[2 * i + 8]);
|
||||
P[1] = RR(P[1] ^ (t0 + 2 * t1 + cs->K[2 * i + 9]), 1);
|
||||
t0 = MDS_mul(cs, P[0]);
|
||||
t1 = MDS_mul(cs, LR(P[1], 8));
|
||||
P[2] = LR(P[2], 1) ^ (t0 + t1 + cs->K[2 * i + 6]);
|
||||
P[3] = RR(P[3] ^ (t0 + 2 * t1 + cs->K[2 * i + 7]), 1);
|
||||
}
|
||||
P[0] ^= cs->K[0];
|
||||
P[1] ^= cs->K[1];
|
||||
P[2] ^= cs->K[2];
|
||||
P[3] ^= cs->K[3];
|
||||
if (iv) {
|
||||
P[0] ^= AV_RL32(iv);
|
||||
P[1] ^= AV_RL32(iv + 4);
|
||||
P[2] ^= AV_RL32(iv + 8);
|
||||
P[3] ^= AV_RL32(iv + 12);
|
||||
memcpy(iv, src, 16);
|
||||
}
|
||||
AV_WL32(dst, P[2]);
|
||||
AV_WL32(dst + 4, P[3]);
|
||||
AV_WL32(dst + 8, P[0]);
|
||||
AV_WL32(dst + 12, P[1]);
|
||||
}
|
||||
|
||||
av_cold int av_twofish_init(AVTWOFISH *cs, const uint8_t *key, int key_bits)
|
||||
{
|
||||
int i;
|
||||
uint8_t keypad[32];
|
||||
uint32_t Key[8], Me[4], Mo[4], A, B;
|
||||
const uint32_t rho = 0x01010101;
|
||||
if (key_bits < 0)
|
||||
return AVERROR(EINVAL);
|
||||
if (key_bits <= 128) {
|
||||
cs->ksize = 2;
|
||||
} else if (key_bits <= 192) {
|
||||
cs->ksize = 3;
|
||||
} else {
|
||||
cs->ksize = 4;
|
||||
}
|
||||
memset(keypad, 0, sizeof(keypad));
|
||||
if (key_bits <= 256) {
|
||||
memcpy(keypad, key, key_bits >> 3);
|
||||
} else {
|
||||
memcpy(keypad, key, 32);
|
||||
}
|
||||
for (i = 0; i < 2 * cs->ksize ; i++)
|
||||
Key[i] = AV_RL32(keypad + 4 * i);
|
||||
for (i = 0; i < cs->ksize; i++) {
|
||||
Me[i] = Key[2 * i];
|
||||
Mo[i] = Key[2 * i + 1];
|
||||
cs->S[cs->ksize - i - 1] = tf_RS(Me[i], Mo[i]);
|
||||
}
|
||||
precomputeMDS(cs);
|
||||
for (i = 0; i < 20; i++) {
|
||||
A = tf_h((2 * i) * rho, Me, cs->ksize);
|
||||
B = tf_h((2 * i + 1) * rho, Mo, cs->ksize);
|
||||
B = LR(B, 8);
|
||||
cs->K[2 * i] = A + B;
|
||||
cs->K[2 * i + 1] = LR((A + (2 * B)), 9);
|
||||
}
|
||||
if (cs->ksize << 6 != key_bits) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void av_twofish_crypt(AVTWOFISH *cs, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
|
||||
{
|
||||
int i;
|
||||
while (count--) {
|
||||
if (decrypt) {
|
||||
twofish_decrypt(cs, dst, src, iv);
|
||||
} else {
|
||||
if (iv) {
|
||||
for (i = 0; i < 16; i++)
|
||||
dst[i] = src[i] ^ iv[i];
|
||||
twofish_encrypt(cs, dst, dst);
|
||||
memcpy(iv, dst, 16);
|
||||
} else {
|
||||
twofish_encrypt(cs, dst, src);
|
||||
}
|
||||
}
|
||||
src = src + 16;
|
||||
dst = dst + 16;
|
||||
}
|
||||
}
|
||||
70
media/ffvpx/libavutil/twofish.h
Normal file
70
media/ffvpx/libavutil/twofish.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* An implementation of the TwoFish algorithm
|
||||
* Copyright (c) 2015 Supraja Meedinti
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_TWOFISH_H
|
||||
#define AVUTIL_TWOFISH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Public header for libavutil TWOFISH algorithm
|
||||
* @defgroup lavu_twofish TWOFISH
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_twofish_size;
|
||||
|
||||
struct AVTWOFISH;
|
||||
|
||||
/**
|
||||
* Allocate an AVTWOFISH context
|
||||
* To free the struct: av_free(ptr)
|
||||
*/
|
||||
struct AVTWOFISH *av_twofish_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVTWOFISH context.
|
||||
*
|
||||
* @param ctx an AVTWOFISH context
|
||||
* @param key a key of size ranging from 1 to 32 bytes used for encryption/decryption
|
||||
* @param key_bits number of keybits: 128, 192, 256 If less than the required, padded with zeroes to nearest valid value; return value is 0 if key_bits is 128/192/256, -1 if less than 0, 1 otherwise
|
||||
*/
|
||||
int av_twofish_init(struct AVTWOFISH *ctx, const uint8_t *key, int key_bits);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context
|
||||
*
|
||||
* @param ctx an AVTWOFISH context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 16 byte blocks
|
||||
* @paran iv initialization vector for CBC mode, NULL for ECB mode
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_twofish_crypt(struct AVTWOFISH *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* AVUTIL_TWOFISH_H */
|
||||
45
media/ffvpx/libavutil/wchar_filename.h
Normal file
45
media/ffvpx/libavutil/wchar_filename.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_WCHAR_FILENAME_H
|
||||
#define AVUTIL_WCHAR_FILENAME_H
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32CE__)
|
||||
#include <windows.h>
|
||||
#include "mem.h"
|
||||
|
||||
av_warn_unused_result
|
||||
static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w)
|
||||
{
|
||||
int num_chars;
|
||||
num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename_utf8, -1, NULL, 0);
|
||||
if (num_chars <= 0) {
|
||||
*filename_w = NULL;
|
||||
return 0;
|
||||
}
|
||||
*filename_w = (wchar_t *)av_mallocz_array(num_chars, sizeof(wchar_t));
|
||||
if (!*filename_w) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_WCHAR_FILENAME_H */
|
||||
417
media/ffvpx/libavutil/xga_font_data.c
Normal file
417
media/ffvpx/libavutil/xga_font_data.c
Normal file
|
|
@ -0,0 +1,417 @@
|
|||
/*
|
||||
* CGA/EGA/VGA ROM font data
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CGA/EGA/VGA ROM font data
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "xga_font_data.h"
|
||||
|
||||
const uint8_t avpriv_cga_font[2048] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
|
||||
0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00,
|
||||
0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x7c, 0x38, 0x7c,
|
||||
0x10, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00,
|
||||
0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00,
|
||||
0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78,
|
||||
0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0,
|
||||
0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0, 0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99,
|
||||
0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00, 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00,
|
||||
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00,
|
||||
0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00, 0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff,
|
||||
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00,
|
||||
0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00,
|
||||
0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00,
|
||||
0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
|
||||
0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, 0x00, 0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00,
|
||||
0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00,
|
||||
0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00,
|
||||
0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0x7c, 0x00, 0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00,
|
||||
0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0xfc, 0x00, 0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00,
|
||||
0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00, 0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00,
|
||||
0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00, 0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00,
|
||||
0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00,
|
||||
0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60,
|
||||
0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00,
|
||||
0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00,
|
||||
0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00, 0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00,
|
||||
0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, 0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00,
|
||||
0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00,
|
||||
0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00, 0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3e, 0x00,
|
||||
0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00, 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00,
|
||||
0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00,
|
||||
0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00,
|
||||
0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xdc, 0x78, 0x1c, 0x00,
|
||||
0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00, 0x78, 0xcc, 0xe0, 0x70, 0x1c, 0xcc, 0x78, 0x00,
|
||||
0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00,
|
||||
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00,
|
||||
0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00,
|
||||
0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00,
|
||||
0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00,
|
||||
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
|
||||
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
|
||||
0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00,
|
||||
0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00,
|
||||
0x38, 0x6c, 0x60, 0xf0, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
|
||||
0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00, 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00,
|
||||
0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, 0x00,
|
||||
0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00,
|
||||
0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e,
|
||||
0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x00,
|
||||
0x10, 0x30, 0x7c, 0x30, 0x30, 0x34, 0x18, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
|
||||
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, 0x00, 0x00, 0xc6, 0xd6, 0xfe, 0xfe, 0x6c, 0x00,
|
||||
0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
|
||||
0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00, 0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00,
|
||||
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, 0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00,
|
||||
0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00,
|
||||
0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x18, 0x0c, 0x78, 0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00,
|
||||
0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0x7e, 0xc3, 0x3c, 0x06, 0x3e, 0x66, 0x3f, 0x00,
|
||||
0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00,
|
||||
0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0x00, 0x00, 0x78, 0xc0, 0xc0, 0x78, 0x0c, 0x38,
|
||||
0x7e, 0xc3, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00, 0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00,
|
||||
0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0x7c, 0xc6, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, 0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00, 0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0xcc, 0x00,
|
||||
0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00, 0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0x7f, 0x00,
|
||||
0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00, 0x78, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00,
|
||||
0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00,
|
||||
0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00, 0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00,
|
||||
0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, 0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18, 0x00,
|
||||
0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18,
|
||||
0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0xfc, 0x00, 0xcc, 0xcc, 0x78, 0xfc, 0x30, 0xfc, 0x30, 0x30,
|
||||
0xf8, 0xcc, 0xcc, 0xfa, 0xc6, 0xcf, 0xc6, 0xc7, 0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0xd8, 0x70,
|
||||
0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00,
|
||||
0x00, 0xf8, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0x00, 0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0xcc, 0x00,
|
||||
0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00,
|
||||
0x30, 0x00, 0x30, 0x60, 0xc0, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xc0, 0xc0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xde, 0x33, 0x66, 0xcc, 0x0f,
|
||||
0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6f, 0xcf, 0x03, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00,
|
||||
0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00, 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00,
|
||||
0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
|
||||
0xdb, 0x77, 0xdb, 0xee, 0xdb, 0x77, 0xdb, 0xee, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18,
|
||||
0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36,
|
||||
0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
|
||||
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x76, 0xdc, 0xc8, 0xdc, 0x76, 0x00, 0x00, 0x78, 0xcc, 0xf8, 0xcc, 0xf8, 0xc0, 0xc0,
|
||||
0x00, 0xfc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00,
|
||||
0xfc, 0xcc, 0x60, 0x30, 0x60, 0xcc, 0xfc, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0x70, 0x00,
|
||||
0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xc0, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x00,
|
||||
0xfc, 0x30, 0x78, 0xcc, 0xcc, 0x78, 0x30, 0xfc, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x6c, 0x38, 0x00,
|
||||
0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x6c, 0xee, 0x00, 0x1c, 0x30, 0x18, 0x7c, 0xcc, 0xcc, 0x78, 0x00,
|
||||
0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x06, 0x0c, 0x7e, 0xdb, 0xdb, 0x7e, 0x60, 0xc0,
|
||||
0x38, 0x60, 0xc0, 0xf8, 0xc0, 0x60, 0x38, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00,
|
||||
0x00, 0xfc, 0x00, 0xfc, 0x00, 0xfc, 0x00, 0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0xfc, 0x00,
|
||||
0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xfc, 0x00, 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xfc, 0x00,
|
||||
0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0x70,
|
||||
0x30, 0x30, 0x00, 0xfc, 0x00, 0x30, 0x30, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00,
|
||||
0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x3c, 0x1c,
|
||||
0x78, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x70, 0x18, 0x30, 0x60, 0x78, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
const uint8_t avpriv_vga16_font[4096] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x66, 0xc3, 0xc3, 0xdb, 0xdb, 0xc3, 0xc3, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00,
|
||||
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff, 0xdb, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff, 0xc3, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc1, 0xc3, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
|
||||
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00,
|
||||
0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00,
|
||||
0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xff, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00,
|
||||
0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x3b, 0x1b, 0x7e, 0xd8, 0xdc, 0x77, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc6, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00,
|
||||
0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x18, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xfc, 0x66, 0x66, 0x7c, 0x62, 0x66, 0x6f, 0x66, 0x66, 0x66, 0xf3, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00,
|
||||
0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
|
||||
0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xce, 0x9b, 0x06, 0x0c, 0x1f, 0x00, 0x00,
|
||||
0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xce, 0x96, 0x3e, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44,
|
||||
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
|
||||
0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
|
||||
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x70, 0xd8, 0x30, 0x60, 0xc8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
35
media/ffvpx/libavutil/xga_font_data.h
Normal file
35
media/ffvpx/libavutil/xga_font_data.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* CGA/EGA/VGA ROM font data
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CGA/EGA/VGA ROM font data
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_XGA_FONT_DATA_H
|
||||
#define AVUTIL_XGA_FONT_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "internal.h"
|
||||
|
||||
extern av_export const uint8_t avpriv_cga_font[2048];
|
||||
extern av_export const uint8_t avpriv_vga16_font[4096];
|
||||
|
||||
#endif /* AVUTIL_XGA_FONT_DATA_H */
|
||||
253
media/ffvpx/libavutil/xtea.c
Normal file
253
media/ffvpx/libavutil/xtea.c
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
* A 32-bit implementation of the XTEA algorithm
|
||||
* Copyright (c) 2012 Samuel Pitoiset
|
||||
*
|
||||
* loosely based on the implementation of David Wheeler and Roger Needham
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief XTEA 32-bit implementation
|
||||
* @author Samuel Pitoiset
|
||||
* @ingroup lavu_xtea
|
||||
*/
|
||||
|
||||
#include "avutil.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "mem.h"
|
||||
#include "xtea.h"
|
||||
|
||||
AVXTEA *av_xtea_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVXTEA));
|
||||
}
|
||||
|
||||
void av_xtea_init(AVXTEA *ctx, const uint8_t key[16])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
ctx->key[i] = AV_RB32(key + (i << 2));
|
||||
}
|
||||
|
||||
void av_xtea_le_init(AVXTEA *ctx, const uint8_t key[16])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
ctx->key[i] = AV_RL32(key + (i << 2));
|
||||
}
|
||||
|
||||
static void xtea_crypt_ecb(AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int decrypt, uint8_t *iv)
|
||||
{
|
||||
uint32_t v0, v1;
|
||||
#if !CONFIG_SMALL
|
||||
uint32_t k0 = ctx->key[0];
|
||||
uint32_t k1 = ctx->key[1];
|
||||
uint32_t k2 = ctx->key[2];
|
||||
uint32_t k3 = ctx->key[3];
|
||||
#endif
|
||||
|
||||
v0 = AV_RB32(src);
|
||||
v1 = AV_RB32(src + 4);
|
||||
|
||||
if (decrypt) {
|
||||
#if CONFIG_SMALL
|
||||
int i;
|
||||
uint32_t delta = 0x9E3779B9U, sum = delta * 32;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + ctx->key[(sum >> 11) & 3]);
|
||||
sum -= delta;
|
||||
v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + ctx->key[sum & 3]);
|
||||
}
|
||||
#else
|
||||
#define DSTEP(SUM, K0, K1) \
|
||||
v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (SUM + K0); \
|
||||
v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (SUM - 0x9E3779B9U + K1)
|
||||
|
||||
DSTEP(0xC6EF3720U, k2, k3);
|
||||
DSTEP(0x28B7BD67U, k3, k2);
|
||||
DSTEP(0x8A8043AEU, k0, k1);
|
||||
DSTEP(0xEC48C9F5U, k1, k0);
|
||||
DSTEP(0x4E11503CU, k2, k3);
|
||||
DSTEP(0xAFD9D683U, k2, k2);
|
||||
DSTEP(0x11A25CCAU, k3, k1);
|
||||
DSTEP(0x736AE311U, k0, k0);
|
||||
DSTEP(0xD5336958U, k1, k3);
|
||||
DSTEP(0x36FBEF9FU, k1, k2);
|
||||
DSTEP(0x98C475E6U, k2, k1);
|
||||
DSTEP(0xFA8CFC2DU, k3, k0);
|
||||
DSTEP(0x5C558274U, k0, k3);
|
||||
DSTEP(0xBE1E08BBU, k1, k2);
|
||||
DSTEP(0x1FE68F02U, k1, k1);
|
||||
DSTEP(0x81AF1549U, k2, k0);
|
||||
DSTEP(0xE3779B90U, k3, k3);
|
||||
DSTEP(0x454021D7U, k0, k2);
|
||||
DSTEP(0xA708A81EU, k1, k1);
|
||||
DSTEP(0x08D12E65U, k1, k0);
|
||||
DSTEP(0x6A99B4ACU, k2, k3);
|
||||
DSTEP(0xCC623AF3U, k3, k2);
|
||||
DSTEP(0x2E2AC13AU, k0, k1);
|
||||
DSTEP(0x8FF34781U, k0, k0);
|
||||
DSTEP(0xF1BBCDC8U, k1, k3);
|
||||
DSTEP(0x5384540FU, k2, k2);
|
||||
DSTEP(0xB54CDA56U, k3, k1);
|
||||
DSTEP(0x1715609DU, k0, k0);
|
||||
DSTEP(0x78DDE6E4U, k0, k3);
|
||||
DSTEP(0xDAA66D2BU, k1, k2);
|
||||
DSTEP(0x3C6EF372U, k2, k1);
|
||||
DSTEP(0x9E3779B9U, k3, k0);
|
||||
#endif
|
||||
if (iv) {
|
||||
v0 ^= AV_RB32(iv);
|
||||
v1 ^= AV_RB32(iv + 4);
|
||||
memcpy(iv, src, 8);
|
||||
}
|
||||
} else {
|
||||
#if CONFIG_SMALL
|
||||
int i;
|
||||
uint32_t sum = 0, delta = 0x9E3779B9U;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + ctx->key[sum & 3]);
|
||||
sum += delta;
|
||||
v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + ctx->key[(sum >> 11) & 3]);
|
||||
}
|
||||
#else
|
||||
#define ESTEP(SUM, K0, K1) \
|
||||
v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (SUM + K0);\
|
||||
v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (SUM + 0x9E3779B9U + K1)
|
||||
ESTEP(0x00000000U, k0, k3);
|
||||
ESTEP(0x9E3779B9U, k1, k2);
|
||||
ESTEP(0x3C6EF372U, k2, k1);
|
||||
ESTEP(0xDAA66D2BU, k3, k0);
|
||||
ESTEP(0x78DDE6E4U, k0, k0);
|
||||
ESTEP(0x1715609DU, k1, k3);
|
||||
ESTEP(0xB54CDA56U, k2, k2);
|
||||
ESTEP(0x5384540FU, k3, k1);
|
||||
ESTEP(0xF1BBCDC8U, k0, k0);
|
||||
ESTEP(0x8FF34781U, k1, k0);
|
||||
ESTEP(0x2E2AC13AU, k2, k3);
|
||||
ESTEP(0xCC623AF3U, k3, k2);
|
||||
ESTEP(0x6A99B4ACU, k0, k1);
|
||||
ESTEP(0x08D12E65U, k1, k1);
|
||||
ESTEP(0xA708A81EU, k2, k0);
|
||||
ESTEP(0x454021D7U, k3, k3);
|
||||
ESTEP(0xE3779B90U, k0, k2);
|
||||
ESTEP(0x81AF1549U, k1, k1);
|
||||
ESTEP(0x1FE68F02U, k2, k1);
|
||||
ESTEP(0xBE1E08BBU, k3, k0);
|
||||
ESTEP(0x5C558274U, k0, k3);
|
||||
ESTEP(0xFA8CFC2DU, k1, k2);
|
||||
ESTEP(0x98C475E6U, k2, k1);
|
||||
ESTEP(0x36FBEF9FU, k3, k1);
|
||||
ESTEP(0xD5336958U, k0, k0);
|
||||
ESTEP(0x736AE311U, k1, k3);
|
||||
ESTEP(0x11A25CCAU, k2, k2);
|
||||
ESTEP(0xAFD9D683U, k3, k2);
|
||||
ESTEP(0x4E11503CU, k0, k1);
|
||||
ESTEP(0xEC48C9F5U, k1, k0);
|
||||
ESTEP(0x8A8043AEU, k2, k3);
|
||||
ESTEP(0x28B7BD67U, k3, k2);
|
||||
#endif
|
||||
}
|
||||
|
||||
AV_WB32(dst, v0);
|
||||
AV_WB32(dst + 4, v1);
|
||||
}
|
||||
|
||||
static void xtea_le_crypt_ecb(AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int decrypt, uint8_t *iv)
|
||||
{
|
||||
uint32_t v0, v1;
|
||||
int i;
|
||||
|
||||
v0 = AV_RL32(src);
|
||||
v1 = AV_RL32(src + 4);
|
||||
|
||||
if (decrypt) {
|
||||
uint32_t delta = 0x9E3779B9, sum = delta * 32;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + ctx->key[(sum >> 11) & 3]);
|
||||
sum -= delta;
|
||||
v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + ctx->key[sum & 3]);
|
||||
}
|
||||
if (iv) {
|
||||
v0 ^= AV_RL32(iv);
|
||||
v1 ^= AV_RL32(iv + 4);
|
||||
memcpy(iv, src, 8);
|
||||
}
|
||||
} else {
|
||||
uint32_t sum = 0, delta = 0x9E3779B9;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + ctx->key[sum & 3]);
|
||||
sum += delta;
|
||||
v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + ctx->key[(sum >> 11) & 3]);
|
||||
}
|
||||
}
|
||||
|
||||
AV_WL32(dst, v0);
|
||||
AV_WL32(dst + 4, v1);
|
||||
}
|
||||
|
||||
static void xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
|
||||
uint8_t *iv, int decrypt,
|
||||
void (*crypt)(AVXTEA *, uint8_t *, const uint8_t *, int, uint8_t *))
|
||||
{
|
||||
int i;
|
||||
|
||||
if (decrypt) {
|
||||
while (count--) {
|
||||
crypt(ctx, dst, src, decrypt, iv);
|
||||
|
||||
src += 8;
|
||||
dst += 8;
|
||||
}
|
||||
} else {
|
||||
while (count--) {
|
||||
if (iv) {
|
||||
for (i = 0; i < 8; i++)
|
||||
dst[i] = src[i] ^ iv[i];
|
||||
crypt(ctx, dst, dst, decrypt, NULL);
|
||||
memcpy(iv, dst, 8);
|
||||
} else {
|
||||
crypt(ctx, dst, src, decrypt, NULL);
|
||||
}
|
||||
src += 8;
|
||||
dst += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
|
||||
uint8_t *iv, int decrypt)
|
||||
{
|
||||
xtea_crypt(ctx, dst, src, count, iv, decrypt, xtea_crypt_ecb);
|
||||
}
|
||||
|
||||
void av_xtea_le_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
|
||||
uint8_t *iv, int decrypt)
|
||||
{
|
||||
xtea_crypt(ctx, dst, src, count, iv, decrypt, xtea_le_crypt_ecb);
|
||||
}
|
||||
94
media/ffvpx/libavutil/xtea.h
Normal file
94
media/ffvpx/libavutil/xtea.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* A 32-bit implementation of the XTEA algorithm
|
||||
* Copyright (c) 2012 Samuel Pitoiset
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_XTEA_H
|
||||
#define AVUTIL_XTEA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Public header for libavutil XTEA algorithm
|
||||
* @defgroup lavu_xtea XTEA
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef struct AVXTEA {
|
||||
uint32_t key[16];
|
||||
} AVXTEA;
|
||||
|
||||
/**
|
||||
* Allocate an AVXTEA context.
|
||||
*/
|
||||
AVXTEA *av_xtea_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVXTEA context.
|
||||
*
|
||||
* @param ctx an AVXTEA context
|
||||
* @param key a key of 16 bytes used for encryption/decryption,
|
||||
* interpreted as big endian 32 bit numbers
|
||||
*/
|
||||
void av_xtea_init(struct AVXTEA *ctx, const uint8_t key[16]);
|
||||
|
||||
/**
|
||||
* Initialize an AVXTEA context.
|
||||
*
|
||||
* @param ctx an AVXTEA context
|
||||
* @param key a key of 16 bytes used for encryption/decryption,
|
||||
* interpreted as little endian 32 bit numbers
|
||||
*/
|
||||
void av_xtea_le_init(struct AVXTEA *ctx, const uint8_t key[16]);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context,
|
||||
* in big endian format.
|
||||
*
|
||||
* @param ctx an AVXTEA context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 8 byte blocks
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_xtea_crypt(struct AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context,
|
||||
* in little endian format.
|
||||
*
|
||||
* @param ctx an AVXTEA context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 8 byte blocks
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_xtea_le_crypt(struct AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_XTEA_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue