Files
ffmpeg/libavfilter
Andreas Rheinhardt ea346a23de avfilter/blend_modes: Use stride in bytes
The blend functions currently convert strides from bytes to elements
of the type by using the stride /= sizeof(pixel) idiom. Yet this has
several drawbacks:
1. It invokes undefined behavior that happens to work when stride is
negative: size_t is typically the unsigned type of ptrdiff_t and
therefore the division will be performed as size_t, i.e. use logical
right shifts, making stride very big when sizeof(pixel) is > 1. This
works, because pointer to pixel for accesses entails an implicit
factor of sizeof(pixel) so that everything is correct modulo SIZE_MAX.
Yet this is UB and UBSan complains about it.
2. It makes the compiler emit actual shifts/ands to discard the low bits
shifted away.
3. There may be systems where alignof(uint16_t) or alignof(float) is
strictly smaller than their sizeof, so that the stride (in bytes) is
not guaranteed to be multiple of these sizeofs. In this case, dividing
by sizeof(pixel) is simply wrong.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 17:49:08 +02:00
..
2025-08-03 13:48:47 +02:00
2024-08-19 21:48:04 +02:00
2025-08-03 13:48:47 +02:00
2025-08-03 13:48:47 +02:00
2025-08-03 13:48:47 +02:00
2024-08-19 21:48:04 +02:00
2024-08-19 21:48:04 +02:00
2024-08-19 21:48:04 +02:00
2024-08-19 21:48:04 +02:00
2025-08-03 13:48:47 +02:00
2025-08-03 13:48:47 +02:00
2025-08-03 13:48:47 +02:00
2024-08-19 21:48:04 +02:00
2025-09-21 11:02:41 +00:00
2024-08-19 21:48:04 +02:00
2025-08-03 13:48:47 +02:00
2024-07-01 22:31:02 +02:00
2024-08-19 21:48:04 +02:00
2025-08-03 13:48:47 +02:00
2025-08-03 13:48:47 +02:00
2024-08-19 21:48:04 +02:00
2025-04-15 15:49:38 +02:00
2025-08-03 13:48:47 +02:00
2025-06-15 21:00:38 +05:30
2025-07-04 01:32:27 +02:00
2025-07-04 01:32:27 +02:00
2025-08-03 13:48:47 +02:00
2025-08-03 13:48:47 +02:00
2025-08-03 13:48:47 +02:00
2025-08-03 13:48:47 +02:00
2025-04-22 20:45:57 +02:00