summaryrefslogtreecommitdiff
path: root/libavutil/xtea.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2012-07-05 09:52:04 +0200
committerLuca Barbato <lu_zero@gentoo.org>2012-07-05 10:42:00 +0200
commitf6687bf5f8989d397cdef6d9d05bcb13a7ef8c4f (patch)
tree3c570a5f334d14d4d3f34a059a0d7a575c921723 /libavutil/xtea.c
parent669bbedfa863f8a1491a186fac4238baba407037 (diff)
xtea: invert branch and loop precedence
Should slightly improve performance depending on the compiler used.
Diffstat (limited to 'libavutil/xtea.c')
-rw-r--r--libavutil/xtea.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/libavutil/xtea.c b/libavutil/xtea.c
index 138657f88b..07a66e5666 100644
--- a/libavutil/xtea.c
+++ b/libavutil/xtea.c
@@ -71,8 +71,8 @@ void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
{
int i;
- while (count > 0) {
- if (decrypt) {
+ if (decrypt) {
+ while (count > 0) {
xtea_crypt_ecb(ctx, dst, src, decrypt);
if (iv) {
@@ -80,7 +80,13 @@ void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
dst[i] = dst[i] ^ iv[i];
memcpy(iv, src, 8);
}
- } else {
+
+ src += 8;
+ dst += 8;
+ count -= 8;
+ }
+ } else {
+ while (count > 0) {
if (iv) {
for (i = 0; i < 8; i++)
dst[i] = src[i] ^ iv[i];
@@ -89,11 +95,10 @@ void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
} else {
xtea_crypt_ecb(ctx, dst, src, decrypt);
}
+ src += 8;
+ dst += 8;
+ count -= 8;
}
-
- src += 8;
- dst += 8;
- count -= 8;
}
}