diff options
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/blowfish.c | 18 | ||||
-rw-r--r-- | libavutil/x86/x86inc.asm | 4 | ||||
-rw-r--r-- | libavutil/x86/x86util.asm | 41 | ||||
-rw-r--r-- | libavutil/xtea.c | 17 |
4 files changed, 62 insertions, 18 deletions
diff --git a/libavutil/blowfish.c b/libavutil/blowfish.c index 2ef037c..fd894cd 100644 --- a/libavutil/blowfish.c +++ b/libavutil/blowfish.c @@ -381,8 +381,8 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src, uint32_t v0, v1; int i; - while (count > 0) { - if (decrypt) { + if (decrypt) { + while (count--) { v0 = AV_RB32(src); v1 = AV_RB32(src + 4); @@ -396,7 +396,12 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src, dst[i] = dst[i] ^ iv[i]; memcpy(iv, src, 8); } - } else { + + src += 8; + dst += 8; + } + } else { + while (count--) { if (iv) { for (i = 0; i < 8; i++) dst[i] = src[i] ^ iv[i]; @@ -414,11 +419,10 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src, if (iv) memcpy(iv, dst, 8); - } - src += 8; - dst += 8; - count -= 8; + src += 8; + dst += 8; + } } } diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm index 971d210..7d637a6 100644 --- a/libavutil/x86/x86inc.asm +++ b/libavutil/x86/x86inc.asm @@ -604,6 +604,7 @@ SECTION .note.GNU-stack noalloc noexec nowrite progbits ; All subsequent functions (up to the next INIT_CPUFLAGS) is built for the specified cpu. ; You shouldn't need to invoke this macro directly, it's a subroutine for INIT_MMX &co. %macro INIT_CPUFLAGS 0-2 + CPU amdnop %if %0 >= 1 %xdefine cpuname %1 %assign cpuflags cpuflags_%1 @@ -625,6 +626,9 @@ SECTION .note.GNU-stack noalloc noexec nowrite progbits %elifidn %1, sse3 %define movu lddqu %endif + %if notcpuflag(mmx2) + CPU basicnop + %endif %else %xdefine SUFFIX %undef cpuname diff --git a/libavutil/x86/x86util.asm b/libavutil/x86/x86util.asm index 34959f2..c5c72e3 100644 --- a/libavutil/x86/x86util.asm +++ b/libavutil/x86/x86util.asm @@ -256,15 +256,26 @@ %define ABSB ABSB_MMX %define ABSB2 ABSB2_MMX -%macro SPLATB_MMX 3 +%macro SPLATB_LOAD 3 +%if cpuflag(ssse3) + movd %1, [%2-3] + pshufb %1, %3 +%else movd %1, [%2-3] ;to avoid crossing a cacheline punpcklbw %1, %1 SPLATW %1, %1, 3 +%endif %endmacro -%macro SPLATB_SSSE3 3 - movd %1, [%2-3] +%macro SPLATB_REG 3 +%if cpuflag(ssse3) + movd %1, %2d pshufb %1, %3 +%else + movd %1, %2d + punpcklbw %1, %1 + SPLATW %1, %1, 0 +%endif %endmacro %macro PALIGNR_MMX 4-5 ; [dst,] src1, src2, imm, tmp @@ -296,6 +307,14 @@ %endif %endmacro +%macro PSHUFLW 1+ + %if mmsize == 8 + pshufw %1 + %else + pshuflw %1 + %endif +%endmacro + %macro DEINTB 5 ; mask, reg1, mask, reg2, optional src to fill masks from %ifnum %5 pand m%3, m%5, m%4 ; src .. y6 .. y4 @@ -521,8 +540,22 @@ %if mmsize == 16 pshuflw %1, %2, (%3)*0x55 punpcklqdq %1, %1 -%else +%elif cpuflag(mmx2) pshufw %1, %2, (%3)*0x55 +%else + %ifnidn %1, %2 + mova %1, %2 + %endif + %if %3 & 2 + punpckhwd %1, %1 + %else + punpcklwd %1, %1 + %endif + %if %3 & 1 + punpckhwd %1, %1 + %else + punpcklwd %1, %1 + %endif %endif %endmacro diff --git a/libavutil/xtea.c b/libavutil/xtea.c index 983cae9..0a5df1c 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--) { xtea_crypt_ecb(ctx, dst, src, decrypt); if (iv) { @@ -80,7 +80,12 @@ 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; + } + } else { + while (count--) { if (iv) { for (i = 0; i < 8; i++) dst[i] = src[i] ^ iv[i]; @@ -89,11 +94,9 @@ 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; } - - src += 8; - dst += 8; - count -= 8; } } |