Commit bf743bb9e0 for ffmpeg
commit bf743bb9e066c0da08ea440ba438e5cf9617f59c
Author: Ramiro Polla <ramiro.polla@gmail.com>
Date: Tue Oct 27 19:55:14 2026 +0100
swscale/ops_memcpy: also use bulk memset/memcpy for negative strides
The operations themselves have already been generalized to support
this, so all we need to do is modify the base input/output pointers.
diff --git a/libswscale/ops_memcpy.c b/libswscale/ops_memcpy.c
index 64252ce4cd..7d7135079e 100644
--- a/libswscale/ops_memcpy.c
+++ b/libswscale/ops_memcpy.c
@@ -60,9 +60,16 @@ static void process_memcpy(const SwsOpExec *exec, const void *priv,
int lines = y_end - y_start;
/* Replace the per-line loop with a bulk memset/memcpy when possible. */
+ const size_t abs_stride = FFABS(out_stride);
if ((!in || out_stride == in_stride) &&
- out_stride >= 0 && (size_t) out_stride <= bytes + SWS_MAX_PADDING) {
- bytes += (size_t) (lines - 1) * out_stride;
+ abs_stride <= bytes + SWS_MAX_PADDING) {
+ if (out_stride < 0) {
+ const ptrdiff_t offset = (lines - 1) * out_stride;
+ out += offset;
+ if (in)
+ in += offset;
+ }
+ bytes += (lines - 1) * abs_stride;
lines = 1;
}