From 8b700fad94a7521c958f72da88b04b924277a2f8 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 30 Mar 2026 10:56:43 +0200 Subject: [PATCH] avcodec/mpegvideoencdsp: Add restrict to shrink Makes GCC avoid creating the aliasing fallback path and saves 1280B of .text here. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideoencdsp.c | 16 ++++++++-------- libavcodec/mpegvideoencdsp.h | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c index 3b4a57d58a..a9a905c8bb 100644 --- a/libavcodec/mpegvideoencdsp.c +++ b/libavcodec/mpegvideoencdsp.c @@ -179,16 +179,16 @@ static void draw_edges_8_c(uint8_t *buf, ptrdiff_t wrap, int width, int height, /* This wrapper function only serves to convert the stride parameters * from ptrdiff_t to int for av_image_copy_plane(). */ -static void copy_plane_wrapper(uint8_t *dst, ptrdiff_t dst_wrap, - const uint8_t *src, ptrdiff_t src_wrap, +static void copy_plane_wrapper(uint8_t *restrict dst, ptrdiff_t dst_wrap, + const uint8_t *restrict src, ptrdiff_t src_wrap, int width, int height) { av_image_copy_plane(dst, dst_wrap, src, src_wrap, width, height); } /* 2x2 -> 1x1 */ -static void shrink22(uint8_t *dst, ptrdiff_t dst_wrap, - const uint8_t *src, ptrdiff_t src_wrap, +static void shrink22(uint8_t *restrict dst, ptrdiff_t dst_wrap, + const uint8_t *restrict src, ptrdiff_t src_wrap, int width, int height) { int w; @@ -220,8 +220,8 @@ static void shrink22(uint8_t *dst, ptrdiff_t dst_wrap, } /* 4x4 -> 1x1 */ -static void shrink44(uint8_t *dst, ptrdiff_t dst_wrap, - const uint8_t *src, ptrdiff_t src_wrap, +static void shrink44(uint8_t *restrict dst, ptrdiff_t dst_wrap, + const uint8_t *restrict src, ptrdiff_t src_wrap, int width, int height) { int w; @@ -251,8 +251,8 @@ static void shrink44(uint8_t *dst, ptrdiff_t dst_wrap, } /* 8x8 -> 1x1 */ -static void shrink88(uint8_t *dst, ptrdiff_t dst_wrap, - const uint8_t *src, ptrdiff_t src_wrap, +static void shrink88(uint8_t *restrict dst, ptrdiff_t dst_wrap, + const uint8_t *restrict src, ptrdiff_t src_wrap, int width, int height) { int w, i; diff --git a/libavcodec/mpegvideoencdsp.h b/libavcodec/mpegvideoencdsp.h index 989503f25f..4d205e1f9a 100644 --- a/libavcodec/mpegvideoencdsp.h +++ b/libavcodec/mpegvideoencdsp.h @@ -40,8 +40,9 @@ typedef struct MpegvideoEncDSPContext { int (*pix_sum)(const uint8_t *pix, ptrdiff_t line_size); int (*pix_norm1)(const uint8_t *pix, ptrdiff_t line_size); - void (*shrink[4])(uint8_t *dst, ptrdiff_t dst_wrap, const uint8_t *src, - ptrdiff_t src_wrap, int width, int height); + void (*shrink[4])(uint8_t *restrict dst, ptrdiff_t dst_wrap, + const uint8_t *restrict src, ptrdiff_t src_wrap, + int width, int height); void (*draw_edges)(uint8_t *buf, ptrdiff_t wrap, int width, int height, int w, int h, int sides);