summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-07-05 01:46:03 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-07-05 02:26:17 +0200
commit5d4fd1d1adf1ec17dd19548783f7f2eb0d64225f (patch)
tree0ed0d9be892e55bea47d777dcd78d7c1cf104adf /libavutil
parent96676e1abfece89e20bc962255b48cb2d9e417bd (diff)
parent3824ef08e0878aa9f100f33ef22b61daf68058c2 (diff)
downloadffmpeg-5d4fd1d1adf1ec17dd19548783f7f2eb0d64225f.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (36 commits) ARM: allow unaligned buffer in fixed-point NEON FFT4 fate: test more FFT etc sizes dca: set AVCodecContext frame_size for DTS audio YASM: Shut up unused variable compiler warning with --disable-yasm. x86_32: Fix build on x86_32 with --disable-yasm. iirfilter: add fate test doxygen: Add qmul docs. ogg: propagate return values and return more meaningful error values H.264: fix overreads of qscale_table Remove unused static tables and static inline functions. eval: clear Parser instances before using dct-test: remove 'ref' function pointer from tables build: Remove deleted 'check' target from .PHONY list. oggdec: Abort Ogg header parsing when encountering a data packet. Add LGPL license boilerplate to files lacking it. mxfenc: small typo fix doxygen: Fix documentation for some VP8 functions. sha: use AV_RB32() instead of assuming buffer can be cast to uint32_t* des: allow unaligned input and output buffers aes: allow unaligned input and output buffers ... Conflicts: libavcodec/dct-test.c libavcodec/libvpxenc.c libavcodec/x86/dsputil_mmx.c libavcodec/x86/h264_qpel_mmx.c libavfilter/x86/gradfun.c libavformat/oggdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/aes.c41
-rw-r--r--libavutil/des.c8
-rw-r--r--libavutil/eval.c17
-rw-r--r--libavutil/sha.c4
4 files changed, 43 insertions, 27 deletions
diff --git a/libavutil/aes.c b/libavutil/aes.c
index 7c92a2757f..49093efc53 100644
--- a/libavutil/aes.c
+++ b/libavutil/aes.c
@@ -22,6 +22,7 @@
#include "common.h"
#include "aes.h"
+#include "intreadwrite.h"
typedef union {
uint64_t u64[2];
@@ -67,6 +68,20 @@ static inline void addkey(av_aes_block *dst, const av_aes_block *src,
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);
@@ -119,32 +134,28 @@ static inline void crypt(AVAES *a, int s, const uint8_t *sbox,
subshift(&a->state[0], s, sbox);
}
-void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_,
- int count, uint8_t *iv_, int decrypt)
+void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src,
+ int count, uint8_t *iv, int decrypt)
{
- av_aes_block *dst = (av_aes_block *) dst_;
- const av_aes_block *src = (const av_aes_block *) src_;
- av_aes_block *iv = (av_aes_block *) iv_;
-
while (count--) {
- addkey(&a->state[1], src, &a->round_key[a->rounds]);
+ addkey_s(&a->state[1], src, &a->round_key[a->rounds]);
if (decrypt) {
crypt(a, 0, inv_sbox, dec_multbl);
if (iv) {
- addkey(&a->state[0], &a->state[0], iv);
- *iv = *src;
+ addkey_s(&a->state[0], iv, &a->state[0]);
+ memcpy(iv, src, 16);
}
- addkey(dst, &a->state[0], &a->round_key[0]);
+ addkey_d(dst, &a->state[0], &a->round_key[0]);
} else {
if (iv)
- addkey(&a->state[1], &a->state[1], iv);
+ addkey_s(&a->state[1], iv, &a->state[1]);
crypt(a, 2, sbox, enc_multbl);
- addkey(dst, &a->state[0], &a->round_key[0]);
+ addkey_d(dst, &a->state[0], &a->round_key[0]);
if (iv)
- *iv = *dst;
+ memcpy(iv, dst, 16);
}
- src++;
- dst++;
+ src += 16;
+ dst += 16;
}
}
diff --git a/libavutil/des.c b/libavutil/des.c
index 15ae503466..c473a5f68b 100644
--- a/libavutil/des.c
+++ b/libavutil/des.c
@@ -299,10 +299,10 @@ int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) {
}
void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt) {
- uint64_t iv_val = iv ? av_be2ne64(*(uint64_t *)iv) : 0;
+ uint64_t iv_val = iv ? AV_RB64(iv) : 0;
while (count-- > 0) {
uint64_t dst_val;
- uint64_t src_val = src ? av_be2ne64(*(const uint64_t *)src) : 0;
+ uint64_t src_val = src ? AV_RB64(src) : 0;
if (decrypt) {
uint64_t tmp = src_val;
if (d->triple_des) {
@@ -319,12 +319,12 @@ void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t
}
iv_val = iv ? dst_val : 0;
}
- *(uint64_t *)dst = av_be2ne64(dst_val);
+ AV_WB64(dst, dst_val);
src += 8;
dst += 8;
}
if (iv)
- *(uint64_t *)iv = av_be2ne64(iv_val);
+ AV_WB64(iv, iv_val);
}
#ifdef TEST
diff --git a/libavutil/eval.c b/libavutil/eval.c
index faa74a05fd..066bf7bab5 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -472,7 +472,7 @@ int av_expr_parse(AVExpr **expr, const char *s,
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
int log_offset, void *log_ctx)
{
- Parser p;
+ Parser p = { 0 };
AVExpr *e = NULL;
char *w = av_malloc(strlen(s) + 1);
char *wp = w;
@@ -517,7 +517,7 @@ end:
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
{
- Parser p;
+ Parser p = { 0 };
p.const_values = const_values;
p.opaque = opaque;
@@ -576,6 +576,8 @@ void av_free_expr(AVExpr *e)
#ifdef TEST
#undef printf
+#include <string.h>
+
static double const_values[] = {
M_PI,
M_E,
@@ -588,7 +590,7 @@ static const char *const_names[] = {
0
};
-int main(void)
+int main(int argc, char **argv)
{
int i;
double d;
@@ -669,13 +671,16 @@ int main(void)
NULL, NULL, NULL, NULL, NULL, 0, NULL);
printf("%f == 0.931322575\n", d);
- for (i=0; i<1050; i++) {
- START_TIMER
+ if (argc > 1 && !strcmp(argv[1], "-t")) {
+ for (i = 0; i < 1050; i++) {
+ START_TIMER;
av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
const_names, const_values,
NULL, NULL, NULL, NULL, NULL, 0, NULL);
- STOP_TIMER("av_expr_parse_and_eval")
+ STOP_TIMER("av_expr_parse_and_eval");
+ }
}
+
return 0;
}
#endif
diff --git a/libavutil/sha.c b/libavutil/sha.c
index ff9e55720f..301d1606b4 100644
--- a/libavutil/sha.c
+++ b/libavutil/sha.c
@@ -42,7 +42,7 @@ const int av_sha_size = sizeof(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_be2ne32(((const uint32_t*)buffer)[i]))
+#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);
@@ -67,7 +67,7 @@ static void sha1_transform(uint32_t state[5], const uint8_t buffer[64])
for (i = 0; i < 80; i++) {
int t;
if (i < 16)
- t = av_be2ne32(((uint32_t*)buffer)[i]);
+ 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;