[FFmpeg-devel] [PATCH 3/3] swscale/x86/yuv2yuvX: Process tails by jumping back into the main loop.
Alan Kelly
alankelly at google.com
Mon Jul 17 12:30:09 EEST 2023
---
libswscale/x86/swscale.c | 11 ++++-------
libswscale/x86/yuv2yuvX.asm | 24 ++++++++++++++++++------
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 600c7d6c91..6980002e9e 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -202,17 +202,14 @@ static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, \
const int16_t **src, uint8_t *dest, int dstW, \
const uint8_t *dither, int offset) \
{ \
- int remainder = (dstW % step); \
- int pixelsProcessed = dstW - remainder; \
if(((uintptr_t)dest) & 15){ \
yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset); \
return; \
} \
- if(pixelsProcessed > 0) \
- ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, pixelsProcessed + offset, dither, offset); \
- if(remainder > 0){ \
- yuv2yuvX_ ##tail(filter, filterSize, src, dest, dstW, dither, offset); \
- } \
+ if (dstW >= step) \
+ ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, dstW + offset, dither, offset); \
+ else \
+ yuv2yuvX_ ##tail(filter, filterSize, src, dest, dstW, dither, offset); \
return; \
}
diff --git a/libswscale/x86/yuv2yuvX.asm b/libswscale/x86/yuv2yuvX.asm
index 57bfa09d66..03bfd6ad1d 100644
--- a/libswscale/x86/yuv2yuvX.asm
+++ b/libswscale/x86/yuv2yuvX.asm
@@ -54,6 +54,8 @@ cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, dstW, dither, offset
%else
movq xm3, [ditherq]
%endif ; avx2
+ mov ditherq, dstWq
+ sub dstWq, mmsize * unroll
%if cpuflag(avx512)
mova m15, [permutation]
@@ -92,13 +94,17 @@ cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, dstW, dither, offset
%else
mova m0, [filterSizeq + 8]
%endif
- pmulhw m2, m0, [srcq + offsetq * 2]
- pmulhw m5, m0, [srcq + offsetq * 2 + mmsize]
+ movu m2, [srcq + offsetq * 2]
+ movu m5, [srcq + offsetq * 2 + mmsize]
+ pmulhw m2, m0, m2
+ pmulhw m5, m0, m5
paddw m3, m3, m2
paddw m4, m4, m5
%if cpuflag(sse3)
- pmulhw m2, m0, [srcq + offsetq * 2 + 2 * mmsize]
- pmulhw m5, m0, [srcq + offsetq * 2 + 3 * mmsize]
+ movu m2, [srcq + offsetq * 2 + 2 * mmsize]
+ movu m5, [srcq + offsetq * 2 + 3 * mmsize]
+ pmulhw m2, m0, m2
+ pmulhw m5, m0, m5
paddw m6, m6, m2
paddw m1, m1, m5
%endif
@@ -131,8 +137,14 @@ cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, dstW, dither, offset
add offsetq, mmsize * unroll
mov filterSizeq, filterq
cmp offsetq, dstWq
- jb .outerloop
- RET
+ jb .outerloop
+
+ mov dstWq, offsetq
+ mov offsetq, ditherq
+ sub offsetq, mmsize * unroll
+ cmp dstWq, ditherq
+ jb .outerloop
+ REP_RET
%endmacro
INIT_MMX mmxext
--
2.41.0.255.g8b1d071c50-goog
More information about the ffmpeg-devel
mailing list