Browse Source

xtea: invert branch and loop precedence

Should slightly improve performance depending on the compiler used.
tags/n1.0
Luca Barbato 13 years ago
parent
commit
f6687bf5f8
1 changed files with 12 additions and 7 deletions
  1. +12
    -7
      libavutil/xtea.c

+ 12
- 7
libavutil/xtea.c View File

@@ -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;
}
}



Loading…
Cancel
Save