xtea: invert branch and loop precedence

Should slightly improve performance depending on the compiler used.
pull/59/head
Luca Barbato 13 years ago
parent 669bbedfa8
commit f6687bf5f8
  1. 11
      libavutil/xtea.c

@ -71,8 +71,8 @@ void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
{ {
int i; int i;
while (count > 0) {
if (decrypt) { if (decrypt) {
while (count > 0) {
xtea_crypt_ecb(ctx, dst, src, decrypt); xtea_crypt_ecb(ctx, dst, src, decrypt);
if (iv) { 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]; dst[i] = dst[i] ^ iv[i];
memcpy(iv, src, 8); memcpy(iv, src, 8);
} }
src += 8;
dst += 8;
count -= 8;
}
} else { } else {
while (count > 0) {
if (iv) { if (iv) {
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
dst[i] = src[i] ^ iv[i]; dst[i] = src[i] ^ iv[i];
@ -89,12 +95,11 @@ void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
} else { } else {
xtea_crypt_ecb(ctx, dst, src, decrypt); xtea_crypt_ecb(ctx, dst, src, decrypt);
} }
}
src += 8; src += 8;
dst += 8; dst += 8;
count -= 8; count -= 8;
} }
}
} }
#ifdef TEST #ifdef TEST

Loading…
Cancel
Save