diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-06-23 02:02:54 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-07-03 18:17:56 +0200 |
commit | 589f1e5cc7286e76f196d27fb55dec94e83ff3ab (patch) | |
tree | e4b1a3e538826621b5cf06984f2824146b5d3b0e /libswresample/rematrix.c | |
parent | bdb4cd44e24c69ca8a0ad1cd8b3772c43a225e7f (diff) | |
download | ffmpeg-589f1e5cc7286e76f196d27fb55dec94e83ff3ab.tar.gz |
swresample/rematrix: Use correct function pointer types for calls
Calling a function via a different function pointer type is
undefined behavior (C11, 6.3.2.3 8); two pointer parameters
of different type are not equivalent in this regard, although
it happens to work in practice; the current code relies on this.
This patch brings the code in line with the spec. This fixes the
following FATE-tests when run with Clang-UBSan:
ac3-fixed-encode-2 audiomatch-afconvert-{16000,44100}-mono-he-{adts,m4a}
audiomatch-dolby-44100-mono-he-mp4 filter-metadata-avf-aphase-meter-mono
filter-pan-{downmix1,downmix2,mono2,stereo2,stereo3,stereo4,upmix1,upmix2}
lavf-dv_{pal,ntsc} matroska-encoding-delay
The error was something like
src/libswresample/rematrix.c:621:17: runtime error: call to function sum2_float through pointer to incorrect function type 'void (*)(void *, const void *, const void *, void *, int, int, int)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libswresample/rematrix.c')
-rw-r--r-- | libswresample/rematrix.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 5929ae4098..ed2d9fd883 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -494,13 +494,13 @@ av_cold int swri_rematrix_init(SwrContext *s){ } *((int*)s->native_one) = 32768; if (maxsum <= 32768) { - s->mix_1_1_f = (mix_1_1_func_type*)copy_s16; - s->mix_2_1_f = (mix_2_1_func_type*)sum2_s16; - s->mix_any_f = (mix_any_func_type*)get_mix_any_func_s16(s); + s->mix_1_1_f = copy_s16; + s->mix_2_1_f = sum2_s16; + s->mix_any_f = get_mix_any_func_s16(s); } else { - s->mix_1_1_f = (mix_1_1_func_type*)copy_clip_s16; - s->mix_2_1_f = (mix_2_1_func_type*)sum2_clip_s16; - s->mix_any_f = (mix_any_func_type*)get_mix_any_func_clip_s16(s); + s->mix_1_1_f = copy_clip_s16; + s->mix_2_1_f = sum2_clip_s16; + s->mix_any_f = get_mix_any_func_clip_s16(s); } }else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){ s->native_matrix = av_calloc(nb_in * nb_out, sizeof(float)); @@ -511,9 +511,9 @@ av_cold int swri_rematrix_init(SwrContext *s){ for (j = 0; j < nb_in; j++) ((float*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j]; *((float*)s->native_one) = 1.0; - s->mix_1_1_f = (mix_1_1_func_type*)copy_float; - s->mix_2_1_f = (mix_2_1_func_type*)sum2_float; - s->mix_any_f = (mix_any_func_type*)get_mix_any_func_float(s); + s->mix_1_1_f = copy_float; + s->mix_2_1_f = sum2_float; + s->mix_any_f = get_mix_any_func_float(s); }else if(s->midbuf.fmt == AV_SAMPLE_FMT_DBLP){ s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double)); s->native_one = av_mallocz(sizeof(double)); @@ -523,9 +523,9 @@ av_cold int swri_rematrix_init(SwrContext *s){ for (j = 0; j < nb_in; j++) ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j]; *((double*)s->native_one) = 1.0; - s->mix_1_1_f = (mix_1_1_func_type*)copy_double; - s->mix_2_1_f = (mix_2_1_func_type*)sum2_double; - s->mix_any_f = (mix_any_func_type*)get_mix_any_func_double(s); + s->mix_1_1_f = copy_double; + s->mix_2_1_f = sum2_double; + s->mix_any_f = get_mix_any_func_double(s); }else if(s->midbuf.fmt == AV_SAMPLE_FMT_S32P){ s->native_one = av_mallocz(sizeof(int)); if (!s->native_one) @@ -545,9 +545,9 @@ av_cold int swri_rematrix_init(SwrContext *s){ } } *((int*)s->native_one) = 32768; - s->mix_1_1_f = (mix_1_1_func_type*)copy_s32; - s->mix_2_1_f = (mix_2_1_func_type*)sum2_s32; - s->mix_any_f = (mix_any_func_type*)get_mix_any_func_s32(s); + s->mix_1_1_f = copy_s32; + s->mix_2_1_f = sum2_s32; + s->mix_any_f = get_mix_any_func_s32(s); }else av_assert0(0); //FIXME quantize for integeres |