From 06b0dae51bce088ec304771e25ab02c3846e169d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 12 Nov 2025 23:15:24 +0100 Subject: [PATCH] avfilter/vf_fsppdsp: Constify Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_fsppdsp.c | 30 +++++++++++++----------------- libavfilter/vf_fsppdsp.h | 12 ++++++------ libavfilter/x86/vf_fspp_init.c | 6 +++--- tests/checkasm/vf_fspp.c | 4 ++-- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/libavfilter/vf_fsppdsp.c b/libavfilter/vf_fsppdsp.c index e530bcd06b..7fdc5ece25 100644 --- a/libavfilter/vf_fsppdsp.c +++ b/libavfilter/vf_fsppdsp.c @@ -121,13 +121,13 @@ void ff_store_slice2_c(uint8_t *restrict dst, int16_t *restrict src, } } -void ff_mul_thrmat_c(int16_t *restrict thr_adr_noq, int16_t *restrict thr_adr, int q) +void ff_mul_thrmat_c(const int16_t *restrict thr_adr_noq, int16_t *restrict thr_adr, int q) { for (int a = 0; a < 64; a++) thr_adr[a] = q * thr_adr_noq[a]; } -void ff_column_fidct_c(int16_t *restrict thr_adr, int16_t *restrict data, +void ff_column_fidct_c(const int16_t *restrict thr_adr, const int16_t *restrict data, int16_t *restrict output, int cnt) { int_simd16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; @@ -135,28 +135,26 @@ void ff_column_fidct_c(int16_t *restrict thr_adr, int16_t *restrict data, int_simd16_t z1,z2,z3,z4,z5, z10, z11, z12, z13; int_simd16_t d0, d1, d2, d3, d4, d5, d6, d7; - int16_t *dataptr; int16_t *wsptr; int16_t *threshold; - dataptr = data; wsptr = output; for (; cnt > 0; cnt -= 2) { //start positions threshold = (int16_t *)thr_adr;//threshold_mtx for (int ctr = DCTSIZE; ctr > 0; ctr--) { // Process columns from input, add to output. - tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7]; - tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7]; + tmp0 = data[DCTSIZE * 0] + data[DCTSIZE * 7]; + tmp7 = data[DCTSIZE * 0] - data[DCTSIZE * 7]; - tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6]; - tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6]; + tmp1 = data[DCTSIZE * 1] + data[DCTSIZE * 6]; + tmp6 = data[DCTSIZE * 1] - data[DCTSIZE * 6]; - tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5]; - tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5]; + tmp2 = data[DCTSIZE * 2] + data[DCTSIZE * 5]; + tmp5 = data[DCTSIZE * 2] - data[DCTSIZE * 5]; - tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4]; - tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4]; + tmp3 = data[DCTSIZE * 3] + data[DCTSIZE * 4]; + tmp4 = data[DCTSIZE * 3] - data[DCTSIZE * 4]; // Even part of FDCT @@ -241,26 +239,24 @@ void ff_column_fidct_c(int16_t *restrict thr_adr, int16_t *restrict data, wsptr[DCTSIZE * 6] = (tmp1 - tmp6); wsptr[DCTSIZE * 7] = (tmp0 - tmp7); // - dataptr++; //next column + data++; //next column wsptr++; threshold++; } - dataptr += 8; //skip each second start pos + data += 8; //skip each second start pos wsptr += 8; } } -void ff_row_idct_c(int16_t *restrict workspace, int16_t *restrict output_adr, +void ff_row_idct_c(const int16_t *restrict wsptr, int16_t *restrict output_adr, ptrdiff_t output_stride, int cnt) { int_simd16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; int_simd16_t tmp10, tmp11, tmp12, tmp13; int_simd16_t z5, z10, z11, z12, z13; int16_t *outptr; - int16_t *wsptr; cnt *= 4; - wsptr = workspace; outptr = output_adr; for (; cnt > 0; cnt--) { // Even part diff --git a/libavfilter/vf_fsppdsp.h b/libavfilter/vf_fsppdsp.h index 66030da4b1..5a2f1af030 100644 --- a/libavfilter/vf_fsppdsp.h +++ b/libavfilter/vf_fsppdsp.h @@ -39,13 +39,13 @@ typedef struct FSPPDSPContext { ptrdiff_t dst_stride, ptrdiff_t src_stride, ptrdiff_t width, ptrdiff_t height, ptrdiff_t log2_scale); - void (*mul_thrmat)(int16_t *restrict thr_adr_noq /* align 16 */, + void (*mul_thrmat)(const int16_t *restrict thr_adr_noq /* align 16 */, int16_t *restrict thr_adr /* align 16 */, int q); - void (*column_fidct)(int16_t *restrict thr_adr, int16_t *data, + void (*column_fidct)(const int16_t *restrict thr_adr, const int16_t *restrict data, int16_t *restrict output, int cnt); - void (*row_idct)(int16_t *restrict workspace, int16_t *restrict output_adr, + void (*row_idct)(const int16_t *restrict workspace, int16_t *restrict output_adr, ptrdiff_t output_stride, int cnt); void (*row_fdct)(int16_t *restrict data, const uint8_t *restrict pixels, @@ -61,10 +61,10 @@ void ff_store_slice_c(uint8_t *restrict dst, int16_t *restrict src, void ff_store_slice2_c(uint8_t *restrict dst, int16_t *restrict src, ptrdiff_t dst_stride, ptrdiff_t src_stride, ptrdiff_t width, ptrdiff_t height, ptrdiff_t log2_scale); -void ff_mul_thrmat_c(int16_t *restrict thr_adr_noq, int16_t *restrict thr_adr, int q); -void ff_column_fidct_c(int16_t *restrict thr_adr, int16_t *restrict data, +void ff_mul_thrmat_c(const int16_t *restrict thr_adr_noq, int16_t *restrict thr_adr, int q); +void ff_column_fidct_c(const int16_t *restrict thr_adr, const int16_t *restrict data, int16_t *restrict output, int cnt); -void ff_row_idct_c(int16_t *restrict workspace, int16_t *restrict output_adr, +void ff_row_idct_c(const int16_t *restrict workspace, int16_t *restrict output_adr, ptrdiff_t output_stride, int cnt); void ff_row_fdct_c(int16_t *restrict data, const uint8_t *restrict pixels, ptrdiff_t line_size, int cnt); diff --git a/libavfilter/x86/vf_fspp_init.c b/libavfilter/x86/vf_fspp_init.c index c7a9b1799e..caf94b30d6 100644 --- a/libavfilter/x86/vf_fspp_init.c +++ b/libavfilter/x86/vf_fspp_init.c @@ -29,9 +29,9 @@ void ff_store_slice_sse2(uint8_t *dst, int16_t *src, void ff_store_slice2_sse2(uint8_t *dst, int16_t *src, ptrdiff_t dst_stride, ptrdiff_t src_stride, ptrdiff_t width, ptrdiff_t height, ptrdiff_t log2_scale); -void ff_mul_thrmat_sse2(int16_t *thr_adr_noq, int16_t *thr_adr, int q); -void ff_column_fidct_sse2(int16_t *thr_adr, int16_t *data, int16_t *output, int cnt); -void ff_row_idct_mmx(int16_t *workspace, int16_t *output_adr, ptrdiff_t output_stride, int cnt); +void ff_mul_thrmat_sse2(const int16_t *thr_adr_noq, int16_t *thr_adr, int q); +void ff_column_fidct_sse2(const int16_t *thr_adr, const int16_t *data, int16_t *output, int cnt); +void ff_row_idct_mmx(const int16_t *workspace, int16_t *output_adr, ptrdiff_t output_stride, int cnt); void ff_row_fdct_mmx(int16_t *data, const uint8_t *pixels, ptrdiff_t line_size, int cnt); av_cold void ff_fsppdsp_init_x86(FSPPDSPContext *s) diff --git a/tests/checkasm/vf_fspp.c b/tests/checkasm/vf_fspp.c index ccb9cd1e7d..496e859fe0 100644 --- a/tests/checkasm/vf_fspp.c +++ b/tests/checkasm/vf_fspp.c @@ -116,7 +116,7 @@ static void check_mul_thrmat(void) DECLARE_ALIGNED(16, int16_t, dst_ref)[64]; DECLARE_ALIGNED(16, int16_t, dst_new)[64]; const int q = (uint8_t)rnd(); - declare_func(void, int16_t *thr_adr_noq, int16_t *thr_adr, int q); + declare_func(void, const int16_t *thr_adr_noq, int16_t *thr_adr, int q); ff_fsppdsp_init(&fspp); @@ -136,7 +136,7 @@ static void check_column_fidct(void) NB_BLOCKS = 8, ///< arbitrary }; FSPPDSPContext fspp; - declare_func(void, int16_t *thr_adr, int16_t *data, + declare_func(void, const int16_t *thr_adr, const int16_t *data, int16_t *output, int cnt); ff_fsppdsp_init(&fspp);