PR #24043 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24043 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24043.patch
Also change strides from int to ptrdiff_t in h264qpel and qpeldsp. >From 64b2734c20a558dd58bede622acf246ff6ffc0d6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 15:25:28 +0200 Subject: [PATCH 01/11] avcodec/x86/diracdsp: Properly sign-extend strides Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/x86/diracdsp.asm | 4 +++- libavcodec/x86/diracdsp_init.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/x86/diracdsp.asm b/libavcodec/x86/diracdsp.asm index 1844aaf89a..d3194416e4 100644 --- a/libavcodec/x86/diracdsp.asm +++ b/libavcodec/x86/diracdsp.asm @@ -46,7 +46,7 @@ SECTION .text %endmacro %macro HPEL_FILTER 1 -; dirac_hpel_filter_v_sse2(uint8_t *dst, uint8_t *src, int stride, int width); +; ff_dirac_hpel_filter_v_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int width); cglobal dirac_hpel_filter_v_%1, 4,6,8, dst, src, stride, width, src0, stridex3 mov src0q, srcq lea stridex3q, [3*strideq] @@ -317,6 +317,8 @@ INIT_XMM sse4 ; void put_signed_rect_clamped_10(uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height) %if ARCH_X86_64 cglobal put_signed_rect_clamped_10, 6, 8, 5, dst, dst_stride, src, src_stride, w, h, t1, t2 + movsxd dst_strideq, dst_strided + movsxd src_strideq, src_strided %else cglobal put_signed_rect_clamped_10, 5, 7, 5, dst, dst_stride, src, src_stride, w, t1, t2 %define hd r5mp diff --git a/libavcodec/x86/diracdsp_init.c b/libavcodec/x86/diracdsp_init.c index 4f27e1fc2b..c156bb3fb9 100644 --- a/libavcodec/x86/diracdsp_init.c +++ b/libavcodec/x86/diracdsp_init.c @@ -35,7 +35,8 @@ void ff_put_signed_rect_clamped_10_sse4(uint8_t *dst, int dst_stride, const uint void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, ptrdiff_t stride, const int qf, const int qs, int tot_v, int tot_h); #define HPEL_FILTER(MMSIZE, EXT) \ - void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *, const uint8_t *, int, int); \ + void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *dst, const uint8_t *src, \ + ptrdiff_t stride, int width); \ void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *, const uint8_t *, int); \ \ static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \ -- 2.52.0 >From c24460a66e827d2f6aa4ffab4dd5701167409c63 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 16:13:01 +0200 Subject: [PATCH 02/11] avcodec/diracdsp: Use ptrdiff_t for stride Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/diracdec.c | 6 +++--- libavcodec/diracdsp.c | 29 +++++++++++++++++------------ libavcodec/diracdsp.h | 33 +++++++++++++++++++++------------ libavcodec/qpeldsp.c | 18 +++++++++--------- libavcodec/x86/diracdsp.asm | 23 +++++++++++------------ libavcodec/x86/diracdsp_init.c | 28 ++++++++++++++++++---------- tests/checkasm/diracdsp.c | 3 ++- 7 files changed, 81 insertions(+), 59 deletions(-) diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index a4a719aa8e..6a5980601f 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -227,9 +227,9 @@ typedef struct DiracContext { DECLARE_ALIGNED(16, uint8_t, obmc_weight)[3][MAX_BLOCKSIZE*MAX_BLOCKSIZE]; - void (*put_pixels_tab[4])(uint8_t *dst, const uint8_t *src[5], int stride, int h); - void (*avg_pixels_tab[4])(uint8_t *dst, const uint8_t *src[5], int stride, int h); - void (*add_obmc)(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); + void (*put_pixels_tab[4])(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h); + void (*avg_pixels_tab[4])(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h); + void (*add_obmc)(uint16_t *dst, const uint8_t *src, ptrdiff_t stride, const uint8_t *obmc_weight, int yblen); dirac_weight_func weight_func; dirac_biweight_func biweight_func; diff --git a/libavcodec/diracdsp.c b/libavcodec/diracdsp.c index a02a23974b..ccd7c03de6 100644 --- a/libavcodec/diracdsp.c +++ b/libavcodec/diracdsp.c @@ -29,8 +29,8 @@ +3*((src)[-2*stride] + (src)[3*stride]) \ -1*((src)[-3*stride] + (src)[4*stride]) + 16) >> 5) -static void dirac_hpel_filter(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, const uint8_t *src, - int stride, int width, int height) +static void dirac_hpel_filter(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, + const uint8_t *src, ptrdiff_t stride, int width, int height) { int x, y; @@ -52,7 +52,7 @@ static void dirac_hpel_filter(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, const } #define PIXOP_BILINEAR(PFX, OP, WIDTH) \ - static void ff_ ## PFX ## _dirac_pixels ## WIDTH ## _bilinear_c(uint8_t *dst, const uint8_t *src[5], int stride, int h) \ + static void ff_ ## PFX ## _dirac_pixels ## WIDTH ## _bilinear_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h) \ { \ int x; \ const uint8_t *s0 = src[0]; \ @@ -88,8 +88,9 @@ PIXOP_BILINEAR(avg, OP_AVG, 32) #define op_scale2(x) dst[x] = av_clip_uint8( (src[x]*weights + dst[x]*weightd + (1<<(log2_denom-1))) >> log2_denom) #define DIRAC_WEIGHT(W) \ - static void weight_dirac_pixels ## W ## _c(uint8_t *block, int stride, int log2_denom, \ - int weight, int h) { \ + static void weight_dirac_pixels ## W ## _c(uint8_t *block, ptrdiff_t stride, \ + int log2_denom, int weight, int h) \ + { \ int x; \ while (h--) { \ for (x = 0; x < W; x++) { \ @@ -99,7 +100,8 @@ PIXOP_BILINEAR(avg, OP_AVG, 32) block += stride; \ } \ } \ - static void biweight_dirac_pixels ## W ## _c(uint8_t *dst, const uint8_t *src, int stride, int log2_denom, \ + static void biweight_dirac_pixels ## W ## _c(uint8_t *dst, const uint8_t *src, \ + ptrdiff_t stride, int log2_denom, \ int weightd, int weights, int h) { \ int x; \ while (h--) { \ @@ -117,7 +119,7 @@ DIRAC_WEIGHT(16) DIRAC_WEIGHT(32) #define ADD_OBMC(xblen) \ - static void add_obmc ## xblen ## _c(uint16_t *dst, const uint8_t *src, int stride, \ + static void add_obmc ## xblen ## _c(uint16_t *dst, const uint8_t *src, ptrdiff_t stride, \ const uint8_t *obmc_weight, int yblen) \ { \ int x; \ @@ -136,7 +138,9 @@ ADD_OBMC(8) ADD_OBMC(16) ADD_OBMC(32) -static void put_signed_rect_clamped_8bit_c(uint8_t *dst, int dst_stride, const uint8_t *_src, int src_stride, int width, int height) +static void put_signed_rect_clamped_8bit_c(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *_src, ptrdiff_t src_stride, + int width, int height) { int x, y; const int16_t *src = (const int16_t *)_src; @@ -153,8 +157,9 @@ static void put_signed_rect_clamped_8bit_c(uint8_t *dst, int dst_stride, const u } #define PUT_SIGNED_RECT_CLAMPED(PX) \ -static void put_signed_rect_clamped_ ## PX ## bit_c(uint8_t *_dst, int dst_stride, const uint8_t *_src, \ - int src_stride, int width, int height) \ +static void put_signed_rect_clamped_ ## PX ## bit_c(uint8_t *_dst, ptrdiff_t dst_stride, \ + const uint8_t *_src, ptrdiff_t src_stride, \ + int width, int height) \ { \ int x, y; \ uint16_t *dst = (uint16_t *)_dst; \ @@ -174,8 +179,8 @@ static void put_signed_rect_clamped_ ## PX ## bit_c(uint8_t *_dst, int dst_strid PUT_SIGNED_RECT_CLAMPED(10) PUT_SIGNED_RECT_CLAMPED(12) -static void add_rect_clamped_c(uint8_t *dst, const uint16_t *src, int stride, - const int16_t *idwt, int idwt_stride, +static void add_rect_clamped_c(uint8_t *dst, const uint16_t *src, ptrdiff_t stride, + const int16_t *idwt, ptrdiff_t idwt_stride, int width, int height) { int x, y; diff --git a/libavcodec/diracdsp.h b/libavcodec/diracdsp.h index 224828d880..317bcb0bf2 100644 --- a/libavcodec/diracdsp.h +++ b/libavcodec/diracdsp.h @@ -24,11 +24,13 @@ #include <stdint.h> #include <stddef.h> -typedef void (*dirac_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int h); -typedef void (*dirac_biweight_func)(uint8_t *dst, const uint8_t *src, int stride, int log2_denom, int weightd, int weights, int h); +typedef void (*dirac_weight_func)(uint8_t *block, ptrdiff_t stride, int log2_denom, int weight, int h); +typedef void (*dirac_biweight_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, + int log2_denom, int weightd, int weights, int h); typedef struct { - void (*dirac_hpel_filter)(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, const uint8_t *src, int stride, int width, int height); + void (*dirac_hpel_filter)(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, + const uint8_t *src, ptrdiff_t stride, int width, int height); /** * dirac_pixels_tab[width][subpel] * width is 2 for 32, 1 for 16, 0 for 8 @@ -39,13 +41,20 @@ typedef struct { * src[0-3] is each of the hpel planes * src[4] is the 1/8 pel weights if needed */ - void (*put_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], int stride, int h); - void (*avg_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], int stride, int h); + void (*put_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h); + void (*avg_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h); - void (*put_signed_rect_clamped[3])(uint8_t *dst/*align 16*/, int dst_stride, const uint8_t *src/*align 16*/, int src_stride, int width, int height/*mod 2*/); - void (*put_rect_clamped)(uint8_t *dst/*align 16*/, int dst_stride, const uint8_t *src/*align 16*/, int src_stride, int width, int height/*mod 2*/); - void (*add_rect_clamped)(uint8_t *dst/*align 16*/, const uint16_t *src/*align 16*/, int stride, const int16_t *idwt/*align 16*/, int idwt_stride, int width, int height/*mod 2*/); - void (*add_dirac_obmc[3])(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); + void (*put_signed_rect_clamped[3])(uint8_t *dst/*align 16*/, ptrdiff_t dst_stride, + const uint8_t *src/*align 16*/, ptrdiff_t src_stride, + int width, int height/*mod 2*/); + void (*put_rect_clamped)(uint8_t *dst/*align 16*/, ptrdiff_t dst_stride, + const uint8_t *src/*align 16*/, ptrdiff_t src_stride, + int width, int height/*mod 2*/); + void (*add_rect_clamped)(uint8_t *dst/*align 16*/, const uint16_t *src/*align 16*/, + ptrdiff_t stride, const int16_t *idwt/*align 16*/, + ptrdiff_t idwt_stride, int width, int height/*mod 2*/); + void (*add_dirac_obmc[3])(uint16_t *dst, const uint8_t *src, ptrdiff_t stride, + const uint8_t *obmc_weight, int yblen); /* 0-1: int16_t and int32_t asm/c, 2-3: int16 and int32_t, C only */ void (*dequant_subband[4])(uint8_t *src, uint8_t *dst, ptrdiff_t stride, const int qf, const int qs, int tot_v, int tot_h); @@ -55,9 +64,9 @@ typedef struct { } DiracDSPContext; #define DECL_DIRAC_PIXOP(PFX, EXT) \ - void ff_ ## PFX ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h); \ - void ff_ ## PFX ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h); \ - void ff_ ## PFX ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h) + void ff_ ## PFX ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h); \ + void ff_ ## PFX ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h); \ + void ff_ ## PFX ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h) DECL_DIRAC_PIXOP(put, c); DECL_DIRAC_PIXOP(avg, c); diff --git a/libavcodec/qpeldsp.c b/libavcodec/qpeldsp.c index 33a5eccd0b..f965d6d86d 100644 --- a/libavcodec/qpeldsp.c +++ b/libavcodec/qpeldsp.c @@ -738,41 +738,41 @@ void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, #if CONFIG_DIRAC_DECODER #define DIRAC_MC(OPNAME)\ -void ff_ ## OPNAME ## _dirac_pixels8_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +void ff_ ## OPNAME ## _dirac_pixels8_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h)\ {\ OPNAME ## _pixels8_8_c(dst, src[0], stride, h);\ }\ -void ff_ ## OPNAME ## _dirac_pixels16_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +void ff_ ## OPNAME ## _dirac_pixels16_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h)\ {\ OPNAME ## _pixels16_8_c(dst, src[0], stride, h);\ }\ -void ff_ ## OPNAME ## _dirac_pixels32_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +void ff_ ## OPNAME ## _dirac_pixels32_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h)\ {\ OPNAME ## _pixels16_8_c(dst , src[0] , stride, h);\ OPNAME ## _pixels16_8_c(dst+16, src[0]+16, stride, h);\ }\ -void ff_ ## OPNAME ## _dirac_pixels8_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +void ff_ ## OPNAME ## _dirac_pixels8_l2_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h)\ {\ OPNAME ## _pixels8_l2_8(dst, src[0], src[1], stride, stride, stride, h);\ }\ -void ff_ ## OPNAME ## _dirac_pixels16_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +void ff_ ## OPNAME ## _dirac_pixels16_l2_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h)\ {\ OPNAME ## _pixels16_l2_8(dst, src[0], src[1], stride, stride, stride, h);\ }\ -void ff_ ## OPNAME ## _dirac_pixels32_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +void ff_ ## OPNAME ## _dirac_pixels32_l2_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h)\ {\ OPNAME ## _pixels16_l2_8(dst , src[0] , src[1] , stride, stride, stride, h);\ OPNAME ## _pixels16_l2_8(dst+16, src[0]+16, src[1]+16, stride, stride, stride, h);\ }\ -void ff_ ## OPNAME ## _dirac_pixels8_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +void ff_ ## OPNAME ## _dirac_pixels8_l4_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h)\ {\ OPNAME ## _pixels8_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\ }\ -void ff_ ## OPNAME ## _dirac_pixels16_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +void ff_ ## OPNAME ## _dirac_pixels16_l4_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h)\ {\ OPNAME ## _pixels16_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\ }\ -void ff_ ## OPNAME ## _dirac_pixels32_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +void ff_ ## OPNAME ## _dirac_pixels32_l4_c(uint8_t *dst, const uint8_t *src[5], ptrdiff_t stride, int h)\ {\ OPNAME ## _pixels16_l4_8(dst , src[0] , src[1] , src[2] , src[3] , stride, stride, stride, stride, stride, h);\ OPNAME ## _pixels16_l4_8(dst+16, src[0]+16, src[1]+16, src[2]+16, src[3]+16, stride, stride, stride, stride, stride, h);\ diff --git a/libavcodec/x86/diracdsp.asm b/libavcodec/x86/diracdsp.asm index d3194416e4..69cdf0f8a5 100644 --- a/libavcodec/x86/diracdsp.asm +++ b/libavcodec/x86/diracdsp.asm @@ -132,15 +132,15 @@ cglobal dirac_hpel_filter_h_%1, 3,3,8, dst, src, width %endmacro %macro PUT_RECT 1 -; void put_rect_clamped(uint8_t *dst, int dst_stride, int16_t *src, int src_stride, int width, int height) +; void ff_put_signed_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, +; const int16_t *src, ptrdiff_t src_stride, +; int width, int height) cglobal put_signed_rect_clamped_%1, 5,9,3, dst, dst_stride, src, src_stride, w, dst2, src2 mova m0, [pb_80] add wd, (mmsize-1) and wd, ~(mmsize-1) %if ARCH_X86_64 - movsxd dst_strideq, dst_strided - movsxd src_strideq, src_strided mov r7d, r5m mov r8d, wd %define wspill r8d @@ -175,15 +175,15 @@ cglobal put_signed_rect_clamped_%1, 5,9,3, dst, dst_stride, src, src_stride, w, %endm %macro ADD_RECT 1 -; void add_rect_clamped(uint8_t *dst, uint16_t *src, int stride, int16_t *idwt, int idwt_stride, int width, int height) +; void ff_add_rect_clamped_sse2(uint8_t *dst, const uint16_t *src, ptrdiff_t stride, +; const int16_t *idwt, ptrdiff_t idwt_stride, +; int width, int height) cglobal add_rect_clamped_%1, 7,9,3, dst, src, stride, idwt, idwt_stride, w, h mova m0, [pw_32] add wd, (mmsize-1) and wd, ~(mmsize-1) %if ARCH_X86_64 - movsxd strideq, strided - movsxd idwt_strideq, idwt_strided mov r8d, wd %define wspill r8d %else @@ -215,10 +215,10 @@ cglobal add_rect_clamped_%1, 7,9,3, dst, src, stride, idwt, idwt_stride, w, h %endm %macro ADD_OBMC 2 -; void add_obmc(uint16_t *dst, uint8_t *src, int stride, uint8_t *obmc_weight, int yblen) +; void ff_add_dirac_obmc16/32_sse2(uint16_t *dst, const uint8_t *src, +; ptrdiff_t stride, const uint8_t *obmc_weight, int yblen) cglobal add_dirac_obmc%1_%2, 5,5,5, dst, src, stride, obmc, yblen pxor m4, m4 - movsxdifnidn strideq, strided .loop: %assign i 0 %rep %1 / mmsize @@ -258,7 +258,6 @@ ADD_OBMC 16, sse2 cglobal add_dirac_obmc8_sse2, 5,5,4, dst, src, stride, obmc, yblen pxor m3, m3 - movsxdifnidn strideq, strided .loop: movh m0, [srcq] punpcklbw m0, m3 @@ -314,11 +313,11 @@ cglobal dequant_subband_32, 7, 7, 4, src, dst, stride, qf, qs, tot_v, tot_h RET INIT_XMM sse4 -; void put_signed_rect_clamped_10(uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height) +; void ff_put_signed_rect_clamped_10_sse4(uint8_t *dst, ptrdiff_t dst_stride, +; const uint8_t *src, ptrdiff_t src_stride, +; int width, int height) %if ARCH_X86_64 cglobal put_signed_rect_clamped_10, 6, 8, 5, dst, dst_stride, src, src_stride, w, h, t1, t2 - movsxd dst_strideq, dst_strided - movsxd src_strideq, src_strided %else cglobal put_signed_rect_clamped_10, 5, 7, 5, dst, dst_stride, src, src_stride, w, t1, t2 %define hd r5mp diff --git a/libavcodec/x86/diracdsp_init.c b/libavcodec/x86/diracdsp_init.c index c156bb3fb9..a661788386 100644 --- a/libavcodec/x86/diracdsp_init.c +++ b/libavcodec/x86/diracdsp_init.c @@ -22,15 +22,23 @@ #include "libavcodec/diracdsp.h" #include "fpel.h" -void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int); +void ff_add_rect_clamped_sse2(uint8_t *dst, const uint16_t *src, ptrdiff_t stride, + const int16_t *idwt, ptrdiff_t idwt_stride, + int width, int height); -void ff_add_dirac_obmc8_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); -void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); -void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); +void ff_add_dirac_obmc8_sse2(uint16_t *dst, const uint8_t *src, ptrdiff_t stride, + const uint8_t *obmc_weight, int yblen); +void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, ptrdiff_t stride, + const uint8_t *obmc_weight, int yblen); +void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, ptrdiff_t stride, + const uint8_t *obmc_weight, int yblen); -void ff_put_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height); -void ff_put_signed_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height); -void ff_put_signed_rect_clamped_10_sse4(uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height); +void ff_put_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src, + ptrdiff_t src_stride, int width, int height); +void ff_put_signed_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src, + ptrdiff_t src_stride, int width, int height); +void ff_put_signed_rect_clamped_10_sse4(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, + ptrdiff_t src_stride, int width, int height); void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, ptrdiff_t stride, const int qf, const int qs, int tot_v, int tot_h); @@ -40,7 +48,7 @@ void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, ptrdiff_t stride, co void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *, const uint8_t *, int); \ \ static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \ - const uint8_t *src, int stride, int width, int height) \ + const uint8_t *src, ptrdiff_t stride, int width, int height) \ { \ while( height-- ) \ { \ @@ -57,7 +65,7 @@ void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, ptrdiff_t stride, co #define DIRAC_PIXOP(OPNAME, EXT)\ static void OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], \ - int stride, int h) \ + ptrdiff_t stride, int h) \ {\ if (h&3)\ ff_ ## OPNAME ## _dirac_pixels16_c(dst, src, stride, h);\ @@ -65,7 +73,7 @@ static void OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5 ff_ ## OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\ }\ static void OPNAME ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], \ - int stride, int h) \ + ptrdiff_t stride, int h) \ {\ if (h&3) {\ ff_ ## OPNAME ## _dirac_pixels32_c(dst, src, stride, h);\ diff --git a/tests/checkasm/diracdsp.c b/tests/checkasm/diracdsp.c index 47eaefc90b..7d0fec4db1 100644 --- a/tests/checkasm/diracdsp.c +++ b/tests/checkasm/diracdsp.c @@ -68,7 +68,8 @@ static void check_add_obmc(size_t func_index, int xblen) ff_diracdsp_init(&h); if (check_func(h.add_dirac_obmc[func_index], "diracdsp.add_dirac_obmc_%d", xblen)) { - declare_func(void, uint16_t*, const uint8_t*, int, const uint8_t *, int); + declare_func(void, uint16_t *dst, const uint8_t *src, ptrdiff_t stride, + const uint8_t *obmc_weight, int yblen); RANDOMIZE_BUFFER8(src, YBLEN_MAX * xblen); RANDOMIZE_DESTS(dst, YBLEN_MAX * xblen); -- 2.52.0 >From 710a09906cf0a807458670f28416daf8b2b9fc6c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 16:14:37 +0200 Subject: [PATCH 03/11] avcodec/diracdec: Fix shadowing Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/diracdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index 6a5980601f..4f2ddb5897 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -1924,7 +1924,7 @@ static int dirac_decode_frame_internal(DiracContext *s) select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen); for (i = 0; i < s->num_refs; i++) { - int ret = interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height); + ret = interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height); if (ret < 0) return ret; } -- 2.52.0 >From b53d90cdb7f0c967abd8ed192025f4dbb98343bf Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 16:31:58 +0200 Subject: [PATCH 04/11] avcodec/x86/diracdsp: Fix clipping packusdw saturates to uint16_t, yet CLIPW is designed for signed values. If any of the saturated unsigned values were >= 2^16*, the macro would return 0. Anyway, given that packusdw already saturates below, clipping from both sides again is simply wasteful. *: I don't know whether this can happen at all. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/x86/diracdsp.asm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/x86/diracdsp.asm b/libavcodec/x86/diracdsp.asm index 69cdf0f8a5..7cb6ee0664 100644 --- a/libavcodec/x86/diracdsp.asm +++ b/libavcodec/x86/diracdsp.asm @@ -327,7 +327,6 @@ cglobal put_signed_rect_clamped_10, 5, 7, 5, dst, dst_stride, src, src_stride, w neg wq mov t2q, dstq mov t1q, wq - pxor m2, m2 mova m3, [clip_10bit] mova m4, [convert_to_unsigned_10bit] @@ -342,7 +341,7 @@ cglobal put_signed_rect_clamped_10, 5, 7, 5, dst, dst_stride, src, src_stride, w paddd m0, m4 paddd m1, m4 packusdw m0, m0, m1 - CLIPW m0, m2, m3 ; packusdw saturates so it's fine + pminuw m0, m3 movu [dstq], m0 -- 2.52.0 >From 09a30e20cb300133461b6aee940e912e58cb350c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 17:01:03 +0200 Subject: [PATCH 05/11] avcodec/x86/diracdsp: Avoid useless macros, init cpuflags properly {ADD,PUT}_RECT was only used once since the removal of mmx functions in d29a9c2aa68fc3eb6d61ff95c698e29316037583. Furthermore, several of the INIT_XMM calls lacked the actual cpuflags. Therefore the cpu flag suffix has been manually added to the function names; furthermore, cpuflags() as well as the check for supported instructions wouldn't work. So add the cpu flags to INIT_XMM. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/x86/diracdsp.asm | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/libavcodec/x86/diracdsp.asm b/libavcodec/x86/diracdsp.asm index 7cb6ee0664..33e6e9f40d 100644 --- a/libavcodec/x86/diracdsp.asm +++ b/libavcodec/x86/diracdsp.asm @@ -45,9 +45,9 @@ SECTION .text paddw %2, m4 %endmacro -%macro HPEL_FILTER 1 +INIT_XMM sse2 ; ff_dirac_hpel_filter_v_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int width); -cglobal dirac_hpel_filter_v_%1, 4,6,8, dst, src, stride, width, src0, stridex3 +cglobal dirac_hpel_filter_v, 4,6,8, dst, src, stride, width, src0, stridex3 mov src0q, srcq lea stridex3q, [3*strideq] sub src0q, stridex3q @@ -91,7 +91,7 @@ cglobal dirac_hpel_filter_v_%1, 4,6,8, dst, src, stride, width, src0, stridex3 RET ; dirac_hpel_filter_h_sse2(uint8_t *dst, uint8_t *src, int width); -cglobal dirac_hpel_filter_h_%1, 3,3,8, dst, src, width +cglobal dirac_hpel_filter_h, 3,3,8, dst, src, width dec widthd pxor m7, m7 and widthd, ~(mmsize-1) @@ -129,13 +129,11 @@ cglobal dirac_hpel_filter_h_%1, 3,3,8, dst, src, width sub widthd, mmsize jge .loop RET -%endmacro -%macro PUT_RECT 1 ; void ff_put_signed_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, ; const int16_t *src, ptrdiff_t src_stride, ; int width, int height) -cglobal put_signed_rect_clamped_%1, 5,9,3, dst, dst_stride, src, src_stride, w, dst2, src2 +cglobal put_signed_rect_clamped, 5,9,3, dst, dst_stride, src, src_stride, w, dst2, src2 mova m0, [pb_80] add wd, (mmsize-1) and wd, ~(mmsize-1) @@ -172,13 +170,11 @@ cglobal put_signed_rect_clamped_%1, 5,9,3, dst, dst_stride, src, src_stride, w, mov wd, wspill jg .loopy RET -%endm -%macro ADD_RECT 1 ; void ff_add_rect_clamped_sse2(uint8_t *dst, const uint16_t *src, ptrdiff_t stride, ; const int16_t *idwt, ptrdiff_t idwt_stride, ; int width, int height) -cglobal add_rect_clamped_%1, 7,9,3, dst, src, stride, idwt, idwt_stride, w, h +cglobal add_rect_clamped, 7,9,3, dst, src, stride, idwt, idwt_stride, w, h mova m0, [pw_32] add wd, (mmsize-1) and wd, ~(mmsize-1) @@ -212,12 +208,11 @@ cglobal add_rect_clamped_%1, 7,9,3, dst, src, stride, idwt, idwt_stride, w, h mov wd, wspill jg .loop RET -%endm -%macro ADD_OBMC 2 +%macro ADD_OBMC 1 ; void ff_add_dirac_obmc16/32_sse2(uint16_t *dst, const uint8_t *src, ; ptrdiff_t stride, const uint8_t *obmc_weight, int yblen) -cglobal add_dirac_obmc%1_%2, 5,5,5, dst, src, stride, obmc, yblen +cglobal add_dirac_obmc%1, 5,5,5, dst, src, stride, obmc, yblen pxor m4, m4 .loop: %assign i 0 @@ -248,15 +243,10 @@ cglobal add_dirac_obmc%1_%2, 5,5,5, dst, src, stride, obmc, yblen RET %endm -INIT_XMM -PUT_RECT sse2 -ADD_RECT sse2 +ADD_OBMC 32 +ADD_OBMC 16 -HPEL_FILTER sse2 -ADD_OBMC 32, sse2 -ADD_OBMC 16, sse2 - -cglobal add_dirac_obmc8_sse2, 5,5,4, dst, src, stride, obmc, yblen +cglobal add_dirac_obmc8, 5,5,4, dst, src, stride, obmc, yblen pxor m3, m3 .loop: movh m0, [srcq] -- 2.52.0 >From fda89ac65bf5c5642a0f24e6b70f4e0380001bc7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 17:43:44 +0200 Subject: [PATCH 06/11] avcodec/x86/diracdsp_init: Name function parameters Also fix the comment of the same function in assembly. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/x86/diracdsp.asm | 2 +- libavcodec/x86/diracdsp_init.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/x86/diracdsp.asm b/libavcodec/x86/diracdsp.asm index 33e6e9f40d..1267cd6c98 100644 --- a/libavcodec/x86/diracdsp.asm +++ b/libavcodec/x86/diracdsp.asm @@ -90,7 +90,7 @@ cglobal dirac_hpel_filter_v, 4,6,8, dst, src, stride, width, src0, stridex3 jg .loop RET -; dirac_hpel_filter_h_sse2(uint8_t *dst, uint8_t *src, int width); +; ff_dirac_hpel_filter_h_sse2(uint8_t *dst, const uint8_t *src, int width); cglobal dirac_hpel_filter_h, 3,3,8, dst, src, width dec widthd pxor m7, m7 diff --git a/libavcodec/x86/diracdsp_init.c b/libavcodec/x86/diracdsp_init.c index a661788386..031a4b659d 100644 --- a/libavcodec/x86/diracdsp_init.c +++ b/libavcodec/x86/diracdsp_init.c @@ -45,7 +45,7 @@ void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, ptrdiff_t stride, co #define HPEL_FILTER(MMSIZE, EXT) \ void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *dst, const uint8_t *src, \ ptrdiff_t stride, int width); \ - void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *, const uint8_t *, int); \ + void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *dst, const uint8_t *src, int width); \ \ static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \ const uint8_t *src, ptrdiff_t stride, int width, int height) \ -- 2.52.0 >From 93498442239607ea418e00b208c730aafeae2b78 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 17:49:23 +0200 Subject: [PATCH 07/11] avcodec/x86/diracdsp: Avoid push+pop of xmm register Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/x86/diracdsp.asm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/x86/diracdsp.asm b/libavcodec/x86/diracdsp.asm index 1267cd6c98..9a6e1d4354 100644 --- a/libavcodec/x86/diracdsp.asm +++ b/libavcodec/x86/diracdsp.asm @@ -37,21 +37,21 @@ SECTION .text mov%6 m5, %4 mova m4, %1 mova %2, m5 - punpcklbw %1, m7 - punpcklbw m5, m7 - punpckhbw m4, m7 - punpckhbw %2, m7 + punpcklbw %1, m6 + punpcklbw m5, m6 + punpckhbw m4, m6 + punpckhbw %2, m6 paddw %1, m5 paddw %2, m4 %endmacro INIT_XMM sse2 ; ff_dirac_hpel_filter_v_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int width); -cglobal dirac_hpel_filter_v, 4,6,8, dst, src, stride, width, src0, stridex3 +cglobal dirac_hpel_filter_v, 4,6,7, dst, src, stride, width, src0, stridex3 mov src0q, srcq lea stridex3q, [3*strideq] sub src0q, stridex3q - pxor m7, m7 + pxor m6, m6 .loop: ; 7*(src[0] + src[1]) UNPACK_ADD m0, m1, [srcq], [srcq + strideq], a,a @@ -91,9 +91,9 @@ cglobal dirac_hpel_filter_v, 4,6,8, dst, src, stride, width, src0, stridex3 RET ; ff_dirac_hpel_filter_h_sse2(uint8_t *dst, const uint8_t *src, int width); -cglobal dirac_hpel_filter_h, 3,3,8, dst, src, width +cglobal dirac_hpel_filter_h, 3,3,7, dst, src, width dec widthd - pxor m7, m7 + pxor m6, m6 and widthd, ~(mmsize-1) .loop: ; 7*(src[0] + src[1]) -- 2.52.0 >From 052cae387a269b44fbe17eff34c7ab7e68328808 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 17:58:21 +0200 Subject: [PATCH 08/11] avcodec/x86/diracdsp_init: Avoid cast put_signed_rect_clamped uses different types for differnt 8bit and >8bit content. The 8bit SSE2 function used the real type in its function signature; this does not coincide with the array of function pointers it gets put into and therefore also not with how it is called which is UB. Also, casts of function pointers to void* like it is done here are not legal ISO-C as function pointers and object pointers need not be convertible. So just declare the function to have the required type for the function pointer array. Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/x86/diracdsp.asm | 3 ++- libavcodec/x86/diracdsp_init.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/diracdsp.asm b/libavcodec/x86/diracdsp.asm index 9a6e1d4354..43a3039476 100644 --- a/libavcodec/x86/diracdsp.asm +++ b/libavcodec/x86/diracdsp.asm @@ -131,8 +131,9 @@ cglobal dirac_hpel_filter_h, 3,3,7, dst, src, width RET ; void ff_put_signed_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, -; const int16_t *src, ptrdiff_t src_stride, +; const uint8_t *src, ptrdiff_t src_stride, ; int width, int height) +; note: src actually points to int16_t cglobal put_signed_rect_clamped, 5,9,3, dst, dst_stride, src, src_stride, w, dst2, src2 mova m0, [pb_80] add wd, (mmsize-1) diff --git a/libavcodec/x86/diracdsp_init.c b/libavcodec/x86/diracdsp_init.c index 031a4b659d..95fdcb02dc 100644 --- a/libavcodec/x86/diracdsp_init.c +++ b/libavcodec/x86/diracdsp_init.c @@ -35,7 +35,7 @@ void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, ptrdiff_t strid void ff_put_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src, ptrdiff_t src_stride, int width, int height); -void ff_put_signed_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src, +void ff_put_signed_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int width, int height); void ff_put_signed_rect_clamped_10_sse4(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int width, int height); @@ -95,7 +95,7 @@ void ff_diracdsp_init_x86(DiracDSPContext* c) if (EXTERNAL_SSE2(mm_flags)) { c->dirac_hpel_filter = dirac_hpel_filter_sse2; c->add_rect_clamped = ff_add_rect_clamped_sse2; - c->put_signed_rect_clamped[0] = (void *)ff_put_signed_rect_clamped_sse2; + c->put_signed_rect_clamped[0] = ff_put_signed_rect_clamped_sse2; c->add_dirac_obmc[0] = ff_add_dirac_obmc8_sse2; c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2; -- 2.52.0 >From 28a9789f29a9b6fdaea4a0006ae86c5e9946a295 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 16:51:29 +0200 Subject: [PATCH 09/11] avcodec/qpeldsp, qpel_template: Use ptrdiff_t for stride Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/qpel_template.c | 52 +++++++++++++++++++------------------- libavcodec/qpeldsp.c | 20 +++++++-------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/libavcodec/qpel_template.c b/libavcodec/qpel_template.c index e52a78cf22..2b1d52b15a 100644 --- a/libavcodec/qpel_template.c +++ b/libavcodec/qpel_template.c @@ -29,9 +29,9 @@ static inline void OPNAME ## _no_rnd_pixels8_l2_8(uint8_t *dst, \ const uint8_t *src1, \ const uint8_t *src2, \ - int dst_stride, \ - int src_stride1, \ - int src_stride2, \ + ptrdiff_t dst_stride, \ + ptrdiff_t src_stride1,\ + ptrdiff_t src_stride2,\ int h) \ { \ int i; \ @@ -52,9 +52,9 @@ static inline void OPNAME ## _no_rnd_pixels8_l2_8(uint8_t *dst, \ static inline void OPNAME ## _no_rnd_pixels16_l2_8(uint8_t *dst, \ const uint8_t *src1, \ const uint8_t *src2, \ - int dst_stride, \ - int src_stride1, \ - int src_stride2, \ + ptrdiff_t dst_stride,\ + ptrdiff_t src_stride1,\ + ptrdiff_t src_stride2,\ int h) \ { \ OPNAME ## _no_rnd_pixels8_l2_8(dst, src1, src2, dst_stride, \ @@ -71,11 +71,11 @@ static inline void OPNAME ## _pixels8_l4_8(uint8_t *dst, \ const uint8_t *src2, \ const uint8_t *src3, \ const uint8_t *src4, \ - int dst_stride, \ - int src_stride1, \ - int src_stride2, \ - int src_stride3, \ - int src_stride4, \ + ptrdiff_t dst_stride, \ + ptrdiff_t src_stride1, \ + ptrdiff_t src_stride2, \ + ptrdiff_t src_stride3, \ + ptrdiff_t src_stride4, \ int h) \ { \ /* FIXME HIGH BIT DEPTH */ \ @@ -121,11 +121,11 @@ static inline void OPNAME ## _no_rnd_pixels8_l4_8(uint8_t *dst, \ const uint8_t *src2, \ const uint8_t *src3, \ const uint8_t *src4, \ - int dst_stride, \ - int src_stride1, \ - int src_stride2, \ - int src_stride3, \ - int src_stride4, \ + ptrdiff_t dst_stride, \ + ptrdiff_t src_stride1,\ + ptrdiff_t src_stride2,\ + ptrdiff_t src_stride3,\ + ptrdiff_t src_stride4,\ int h) \ { \ /* FIXME HIGH BIT DEPTH */ \ @@ -171,11 +171,11 @@ static inline void OPNAME ## _pixels16_l4_8(uint8_t *dst, \ const uint8_t *src2, \ const uint8_t *src3, \ const uint8_t *src4, \ - int dst_stride, \ - int src_stride1, \ - int src_stride2, \ - int src_stride3, \ - int src_stride4, \ + ptrdiff_t dst_stride, \ + ptrdiff_t src_stride1, \ + ptrdiff_t src_stride2, \ + ptrdiff_t src_stride3, \ + ptrdiff_t src_stride4, \ int h) \ { \ OPNAME ## _pixels8_l4_8(dst, src1, src2, src3, src4, dst_stride, \ @@ -193,11 +193,11 @@ static inline void OPNAME ## _no_rnd_pixels16_l4_8(uint8_t *dst, \ const uint8_t *src2, \ const uint8_t *src3, \ const uint8_t *src4, \ - int dst_stride, \ - int src_stride1, \ - int src_stride2, \ - int src_stride3, \ - int src_stride4, \ + ptrdiff_t dst_stride,\ + ptrdiff_t src_stride1,\ + ptrdiff_t src_stride2,\ + ptrdiff_t src_stride3,\ + ptrdiff_t src_stride4,\ int h) \ { \ OPNAME ## _no_rnd_pixels8_l4_8(dst, src1, src2, src3, src4, \ diff --git a/libavcodec/qpeldsp.c b/libavcodec/qpeldsp.c index f965d6d86d..38021d69c0 100644 --- a/libavcodec/qpeldsp.c +++ b/libavcodec/qpeldsp.c @@ -42,8 +42,8 @@ #define QPEL_MC(r, OPNAME, RND, OP) \ static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, const uint8_t *src, \ - int dstStride, int srcStride, \ - int h) \ + ptrdiff_t dstStride, \ + ptrdiff_t srcStride, int h) \ { \ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \ int i; \ @@ -63,7 +63,8 @@ static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, const uint8_t *src, \ } \ \ static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, const uint8_t *src, \ - int dstStride, int srcStride) \ + ptrdiff_t dstStride, \ + ptrdiff_t srcStride) \ { \ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \ const int w = 8; \ @@ -92,10 +93,9 @@ static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, const uint8_t *src, \ } \ } \ \ -static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, \ - const uint8_t *src, \ - int dstStride, int srcStride, \ - int h) \ +static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, const uint8_t *src,\ + ptrdiff_t dstStride, \ + ptrdiff_t srcStride, int h) \ { \ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \ int i; \ @@ -122,9 +122,9 @@ static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, \ } \ } \ \ -static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, \ - const uint8_t *src, \ - int dstStride, int srcStride) \ +static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, const uint8_t *src,\ + ptrdiff_t dstStride, \ + ptrdiff_t srcStride) \ { \ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \ const int w = 16; \ -- 2.52.0 >From 50b0a8f333fec76d1ffb5fad3bffbe7e0a0051df Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 17:31:07 +0200 Subject: [PATCH 10/11] avcodec/dirac_dwt: Use ptrdiff_t for stride Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/dirac_dwt.c | 2 +- libavcodec/dirac_dwt.h | 7 ++++--- libavcodec/dirac_dwt_template.c | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/libavcodec/dirac_dwt.c b/libavcodec/dirac_dwt.c index 0d92ad06da..859e2234e7 100644 --- a/libavcodec/dirac_dwt.c +++ b/libavcodec/dirac_dwt.c @@ -73,7 +73,7 @@ void ff_spatial_idwt_slice2(DWTContext *d, int y) for (level = d->decomposition_count-1; level >= 0; level--) { int wl = d->width >> level; int hl = d->height >> level; - int stride_l = d->stride << level; + ptrdiff_t stride_l = d->stride << level; while (d->cs[level].y <= FFMIN((y>>level)+support, hl)) d->spatial_compose(d, level, wl, hl, stride_l); diff --git a/libavcodec/dirac_dwt.h b/libavcodec/dirac_dwt.h index 84f71d9120..909b18327a 100644 --- a/libavcodec/dirac_dwt.h +++ b/libavcodec/dirac_dwt.h @@ -21,6 +21,7 @@ #ifndef AVCODEC_DIRAC_DWT_H #define AVCODEC_DIRAC_DWT_H +#include <stddef.h> #include <stdint.h> typedef int DWTELEM; @@ -37,7 +38,7 @@ typedef struct DWTCompose { typedef struct DWTPlane { int width; int height; - int stride; + ptrdiff_t stride; uint8_t *buf; uint8_t *buf_base; uint8_t *tmp; @@ -56,11 +57,11 @@ typedef struct DWTContext { uint8_t *temp; int width; int height; - int stride; + ptrdiff_t stride; int decomposition_count; int support; - void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, int stride); + void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, ptrdiff_t stride); union { vertical_compose_3tap tap3; vertical_compose_5tap tap5; diff --git a/libavcodec/dirac_dwt_template.c b/libavcodec/dirac_dwt_template.c index 0d39754ed8..886d806f06 100644 --- a/libavcodec/dirac_dwt_template.c +++ b/libavcodec/dirac_dwt_template.c @@ -336,7 +336,7 @@ static void RENAME(vertical_compose_daub97iL1)(uint8_t *_b0, uint8_t *_b1, uint8 } } -static void RENAME(spatial_compose_dd97i_dy)(DWTContext *d, int level, int width, int height, int stride) +static void RENAME(spatial_compose_dd97i_dy)(DWTContext *d, int level, int width, int height, ptrdiff_t stride) { vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0.tap3; vertical_compose_5tap vertical_compose_h0 = d->vertical_compose_h0.tap5; @@ -360,7 +360,7 @@ static void RENAME(spatial_compose_dd97i_dy)(DWTContext *d, int level, int width cs->y += 2; } -static void RENAME(spatial_compose_dirac53i_dy)(DWTContext *d, int level, int width, int height, int stride) +static void RENAME(spatial_compose_dirac53i_dy)(DWTContext *d, int level, int width, int height, ptrdiff_t stride) { vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0.tap3; vertical_compose_3tap vertical_compose_h0 = d->vertical_compose_h0.tap3; @@ -382,7 +382,7 @@ static void RENAME(spatial_compose_dirac53i_dy)(DWTContext *d, int level, int wi cs->y += 2; } -static void RENAME(spatial_compose_dd137i_dy)(DWTContext *d, int level, int width, int height, int stride) +static void RENAME(spatial_compose_dd137i_dy)(DWTContext *d, int level, int width, int height, ptrdiff_t stride) { vertical_compose_5tap vertical_compose_l0 = d->vertical_compose_l0.tap5; vertical_compose_5tap vertical_compose_h0 = d->vertical_compose_h0.tap5; @@ -407,7 +407,7 @@ static void RENAME(spatial_compose_dd137i_dy)(DWTContext *d, int level, int widt } // haar makes the assumption that height is even (always true for dirac) -static void RENAME(spatial_compose_haari_dy)(DWTContext *d, int level, int width, int height, int stride) +static void RENAME(spatial_compose_haari_dy)(DWTContext *d, int level, int width, int height, ptrdiff_t stride) { vertical_compose_2tap vertical_compose = d->vertical_compose; int y = d->cs[level].y; @@ -423,7 +423,7 @@ static void RENAME(spatial_compose_haari_dy)(DWTContext *d, int level, int width // Don't do sliced idwt for fidelity; the 9 tap filter makes it a bit annoying // Fortunately, this filter isn't used in practice. -static void RENAME(spatial_compose_fidelity)(DWTContext *d, int level, int width, int height, int stride) +static void RENAME(spatial_compose_fidelity)(DWTContext *d, int level, int width, int height, ptrdiff_t stride) { vertical_compose_9tap vertical_compose_l0 = d->vertical_compose_l0.tap9; vertical_compose_9tap vertical_compose_h0 = d->vertical_compose_h0.tap9; @@ -448,7 +448,7 @@ static void RENAME(spatial_compose_fidelity)(DWTContext *d, int level, int width d->cs[level].y = height+1; } -static void RENAME(spatial_compose_daub97i_dy)(DWTContext *d, int level, int width, int height, int stride) +static void RENAME(spatial_compose_daub97i_dy)(DWTContext *d, int level, int width, int height, ptrdiff_t stride) { vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0.tap3; vertical_compose_3tap vertical_compose_h0 = d->vertical_compose_h0.tap3; @@ -476,7 +476,7 @@ static void RENAME(spatial_compose_daub97i_dy)(DWTContext *d, int level, int wid cs->y += 2; } -static void RENAME(spatial_compose97i_init)(DWTCompose *cs, uint8_t *buffer, int height, int stride) +static void RENAME(spatial_compose97i_init)(DWTCompose *cs, uint8_t *buffer, int height, ptrdiff_t stride) { cs->b[0] = buffer + avpriv_mirror(-3-1, height-1)*stride; cs->b[1] = buffer + avpriv_mirror(-3 , height-1)*stride; @@ -485,14 +485,14 @@ static void RENAME(spatial_compose97i_init)(DWTCompose *cs, uint8_t *buffer, int cs->y = -3; } -static void RENAME(spatial_compose53i_init)(DWTCompose *cs, uint8_t *buffer, int height, int stride) +static void RENAME(spatial_compose53i_init)(DWTCompose *cs, uint8_t *buffer, int height, ptrdiff_t stride) { cs->b[0] = buffer + avpriv_mirror(-1-1, height-1)*stride; cs->b[1] = buffer + avpriv_mirror(-1 , height-1)*stride; cs->y = -1; } -static void RENAME(spatial_compose_dd97i_init)(DWTCompose *cs, uint8_t *buffer, int height, int stride) +static void RENAME(spatial_compose_dd97i_init)(DWTCompose *cs, uint8_t *buffer, int height, ptrdiff_t stride) { cs->b[0] = buffer + av_clip(-5-1, 0, height-2)*stride; cs->b[1] = buffer + av_clip(-5 , 1, height-1)*stride; @@ -503,7 +503,7 @@ static void RENAME(spatial_compose_dd97i_init)(DWTCompose *cs, uint8_t *buffer, cs->y = -5; } -static void RENAME(spatial_compose_dd137i_init)(DWTCompose *cs, uint8_t *buffer, int height, int stride) +static void RENAME(spatial_compose_dd137i_init)(DWTCompose *cs, uint8_t *buffer, int height, ptrdiff_t stride) { cs->b[0] = buffer + av_clip(-5-1, 0, height-2)*stride; cs->b[1] = buffer + av_clip(-5 , 1, height-1)*stride; @@ -524,7 +524,7 @@ static int RENAME(spatial_idwt_init)(DWTContext *d, enum dwt_type type) for (level = d->decomposition_count - 1; level >= 0; level--){ int hl = d->height >> level; - int stride_l = d->stride << level; + ptrdiff_t stride_l = d->stride << level; switch(type){ case DWT_DIRAC_DD9_7: -- 2.52.0 >From c0677ce02dfa86d910533a8565bf207e1d9100ba Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <[email protected]> Date: Fri, 7 Aug 2026 17:35:52 +0200 Subject: [PATCH 11/11] avcodec/h264qpel_template: Use ptrdiff_t for stride Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/h264qpel_template.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libavcodec/h264qpel_template.c b/libavcodec/h264qpel_template.c index 875ac86d15..33df05475e 100644 --- a/libavcodec/h264qpel_template.c +++ b/libavcodec/h264qpel_template.c @@ -26,7 +26,7 @@ #include "hpel_template.c" #include "pel_template.c" -static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride, int h) +static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) { int i; for(i=0; i<h; i++) @@ -37,7 +37,7 @@ static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *restrict src, } } -static inline void FUNC(copy_block4)(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride, int h) +static inline void FUNC(copy_block4)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) { int i; for(i=0; i<h; i++) @@ -48,7 +48,7 @@ static inline void FUNC(copy_block4)(uint8_t *dst, const uint8_t *restrict src, } } -static inline void FUNC(copy_block8)(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride, int h) +static inline void FUNC(copy_block8)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) { int i; for(i=0; i<h; i++) @@ -60,7 +60,7 @@ static inline void FUNC(copy_block8)(uint8_t *dst, const uint8_t *restrict src, } } -static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride, int h) +static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) { int i; for(i=0; i<h; i++) @@ -75,7 +75,7 @@ static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *restrict src, } #define H264_LOWPASS(OPNAME, OP, OP2) \ -static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, ptrdiff_t dstStride, ptrdiff_t srcStride)\ {\ const int h=4;\ int i;\ @@ -94,7 +94,7 @@ static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *_dst, const uint8_t *r }\ }\ \ -static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, ptrdiff_t dstStride, ptrdiff_t srcStride)\ {\ const int w=4;\ int i;\ @@ -122,7 +122,7 @@ static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *_dst, const uint8_t *r }\ }\ \ -static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *_dst, pixeltmp *tmp, const uint8_t *restrict _src, int dstStride, int tmpStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *_dst, pixeltmp *tmp, const uint8_t *restrict _src, ptrdiff_t dstStride, ptrdiff_t tmpStride, ptrdiff_t srcStride)\ {\ const int h=4;\ const int w=4;\ @@ -163,7 +163,7 @@ static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *_dst, pixeltmp *tmp, }\ }\ \ -static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, ptrdiff_t dstStride, ptrdiff_t srcStride)\ {\ const int h=8;\ int i;\ @@ -186,7 +186,7 @@ static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *_dst, const uint8_t *r }\ }\ \ -static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, ptrdiff_t dstStride, ptrdiff_t srcStride)\ {\ const int w=8;\ int i;\ @@ -222,7 +222,7 @@ static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *_dst, const uint8_t *r }\ }\ \ -static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *_dst, pixeltmp *tmp, const uint8_t *restrict _src, int dstStride, int tmpStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *_dst, pixeltmp *tmp, const uint8_t *restrict _src, ptrdiff_t dstStride, ptrdiff_t tmpStride, ptrdiff_t srcStride)\ {\ const int h=8;\ const int w=8;\ @@ -275,7 +275,7 @@ static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *_dst, pixeltmp *tmp, }\ }\ \ -static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t dstStride, ptrdiff_t srcStride)\ {\ FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\ FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\ @@ -285,7 +285,7 @@ static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, const uint8_t *r FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\ }\ \ -static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t dstStride, ptrdiff_t srcStride)\ {\ FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\ FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\ @@ -295,7 +295,7 @@ static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, const uint8_t *r FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\ }\ \ -static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp, const uint8_t *restrict src, int dstStride, int tmpStride, int srcStride){\ +static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp, const uint8_t *restrict src, ptrdiff_t dstStride, ptrdiff_t tmpStride, ptrdiff_t srcStride){\ FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\ FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\ src += 8*srcStride;\ -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
