* [FFmpeg-devel] [PATCH] lavc/exrdsp: unroll predictor
@ 2023-11-11 15:27 Rémi Denis-Courmont
0 siblings, 0 replies; only message in thread
From: Rémi Denis-Courmont @ 2023-11-11 15:27 UTC (permalink / raw)
To: ffmpeg-devel
With explicit unrolling, we can skip half of the sign bit flips, and
the compiler is then better able to optimise the scalar loop:
predictor_c: 31376.0 (before)
predictor_c: 23703.0 (after)
---
libavcodec/exrdsp.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/libavcodec/exrdsp.c b/libavcodec/exrdsp.c
index 752e1eb553..248cb93c5a 100644
--- a/libavcodec/exrdsp.c
+++ b/libavcodec/exrdsp.c
@@ -40,10 +40,20 @@ static void reorder_pixels_scalar(uint8_t *dst, const uint8_t *src, ptrdiff_t si
static void predictor_scalar(uint8_t *src, ptrdiff_t size)
{
- ptrdiff_t i;
+ /* Unrolled: `src[i + 1] += src[i] - 128;` */
+ if ((size & 1) == 0) {
+ src[1] += src[0] ^ 0x80;
+ src++;
+ size--;
+ }
+
+ for (ptrdiff_t i = 1; i < size; i += 2) {
+ uint8_t a = src[i] + src[i - 1];
- for (i = 1; i < size; i++)
- src[i] += src[i-1] - 128;
+ src[i] = a;
+ src[i + 1] += a;
+ src[i] ^= 0x80;
+ }
}
av_cold void ff_exrdsp_init(ExrDSPContext *c)
--
2.42.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-11 15:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-11 15:27 [FFmpeg-devel] [PATCH] lavc/exrdsp: unroll predictor Rémi Denis-Courmont
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