From: Alan Kelly <alankelly-at-google.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Alan Kelly <alankelly@google.com>
Subject: [FFmpeg-devel] [PATCH 3/3] swscale/x86/yuv2yuvX: Process tails by jumping back into the main loop.
Date: Mon, 17 Jul 2023 11:30:09 +0200
Message-ID: <20230717093018.2076410-1-alankelly@google.com> (raw)
In-Reply-To: <CABaBdZoAqm7k=2o4RwjSsC3TY9LMpK07TD9z57pF-PzLMam48w@mail.gmail.com>
---
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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2023-07-17 9:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 10:08 Alan Kelly
2023-07-15 20:39 ` Michael Niedermayer
2023-07-17 9:29 ` Alan Kelly
2023-07-17 9:30 ` Alan Kelly [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230717093018.2076410-1-alankelly@google.com \
--to=alankelly-at-google.com@ffmpeg.org \
--cc=alankelly@google.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git