Commit 0706d0ab1f for ffmpeg
commit 0706d0ab1fadddf4a32fe7e589b2cff623475274
Author: lusoris <lusoris@proton.me>
Date: Tue Oct 27 17:06:28 2026 +0100
avcodec/vvc/intra_template: bound reference corner extension
The corner extension uses at most four samples before the top and left
origins. Those origins have MAX_TB_SIZE + 3 samples of headroom, so the
negative indices are valid. However, the ref_line range is not visible
to the compiler in this loop, and gcc 15.2 and gcc 16.2 with
-march=x86-64-v3 report vector stores before the edge object.
Assume ref_line >= -4 before the loop. ref_idx is at most 3, so the
assumption always holds, and the compiler can bound every corner index
to [-4, -1] without an extra loop condition. With assert-level > 0 the
assumption is checked at runtime.
Suggested-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: lusoris <lusoris@proton.me>
diff --git a/libavcodec/vvc/intra_template.c b/libavcodec/vvc/intra_template.c
index 3ec6c72213..0e8da24ac1 100644
--- a/libavcodec/vvc/intra_template.c
+++ b/libavcodec/vvc/intra_template.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/avassert.h"
#include "libavcodec/bit_depth_template.c"
#include "intra.h"
@@ -526,6 +527,8 @@ do { \
top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx);
memcpy(top, src + ref_line * stride, top_available * sizeof(pixel));
+ av_assume(ref_line >= -4);
+
for (int i = -1; i >= ref_line; i--) {
if (cand_up_left) {
left[i] = POS(ref_line, i);