avcodec/hevc/dsp_template: Add restrict to add_residual functions

Allows the compiler to optimize the the aliasing checks away
and saves 5376B here (GCC 15, -O3).
Also, avoid converting the stride to uint16_t for >8bpp:
stride /= sizeof(pixel) will use an unsigned division
(i.e. a logical right shift)*, which is not what is intended here.

*: If size_t is the corresponding unsigned type to ptrdiff_t

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2026-04-02 13:20:01 +02:00
parent 72058ccdf8
commit da59f288c6

View File

@@ -43,20 +43,18 @@ static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t stride, int width, int height
}
}
static av_always_inline void FUNC(add_residual)(uint8_t *_dst, const int16_t *res,
static av_always_inline void FUNC(add_residual)(uint8_t *restrict dst8, const int16_t *restrict res,
ptrdiff_t stride, int size)
{
int x, y;
pixel *dst = (pixel *)_dst;
stride /= sizeof(pixel);
for (y = 0; y < size; y++) {
pixel *restrict dst = (pixel *)dst8;
for (x = 0; x < size; x++) {
dst[x] = av_clip_pixel(dst[x] + *res);
res++;
}
dst += stride;
dst8 += stride;
}
}