PR #25483 opened by Kilian (lusoris) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25483 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25483.patch
These patches address GCC 14.4.0 and 16.2.1 -Wunused-function, -Wunused-variable and -Wunused-but-set-variable diagnostics in libavcodec/adpcm.c when only some ADPCM decoders are enabled. Result: with a single ADPCM decoder enabled, warnings in libavcodec/adpcm.c go from 7–10 to 0 with GCC 14.4.0 and with GCC 16.2.1 (adpcm_ms 8 -> 0, adpcm_xa 9 -> 0, adpcm_swf 10 -> 0, adpcm_sanyo 7 -> 0, adpcm_ima_citrix 9 -> 0); the full configuration stays at 0 (0 -> 0). What the patches do: - `avcodec/adpcm: guard helpers with decoder configuration`: compiles the escape, hvqm2, hvqm4, circus, XA, SWF, Sanyo and Citrix helpers only when a decoder that uses them is enabled. - `avcodec/adpcm: mark conditionally used frame locals as unused`: marks `c`, `samples`, `samples_p` and `st` in `adpcm_decode_frame()` as `av_unused`, since their reads disappear with the CASE blocks of disabled decoders. Behaviour change: none; which helpers are compiled depends on the enabled decoders, and decoding with a given decoder enabled is unchanged. Base: FFmpeg master 46f23be8b1. Testing: - `--disable-everything --disable-doc --disable-programs --enable-decoder=<decoder>` for each of adpcm_ms, adpcm_xa, adpcm_swf, adpcm_sanyo and adpcm_ima_citrix, building libavcodec/adpcm.o with GCC 14.4.0 and GCC 16.2.1: the warning counts above on master, 0 with these patches. - GCC 14.4.0 (`--enable-gpl --enable-vulkan`) and GCC 16.2.1 (`--enable-gpl --enable-vulkan --enable-vaapi --enable-libdrm --enable-nvenc`), targets all, alltools, examples, testprogs and checkasm: libavcodec/adpcm.c is rebuilt and has no warnings on master and none with these patches, with each compiler. - FATE with GCC 16.2.1, the 85 tests whose name contains `adpcm`: all 85 ran and pass on master and with these patches. Split out of #25111 so that each part reaches the reviewers for its area. From 1063012b2534d805742754692b99ae09a0433f0f Mon Sep 17 00:00:00 2001 From: lusoris <[email protected]> Date: Thu, 15 Oct 2026 22:06:35 +0200 Subject: [PATCH 1/2] avcodec/adpcm: guard helpers with decoder configuration GCC 14.4.0 and 16.2.1 report -Wunused-function for decoder helpers left compiled when their users are disabled. Guard the escape, hvqm2, hvqm4, circus, XA, SWF, Sanyo and Citrix helpers with the configuration macros of the decoders that use them. This changes which helpers are compiled, without changing decoding when the corresponding decoder is enabled. Signed-off-by: lusoris <[email protected]> --- libavcodec/adpcm.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 3c294d9120a..d3d796fe189 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -455,6 +455,7 @@ static inline int16_t adpcm_agm_expand_nibble(ADPCMChannelStatus *c, int8_t nibb return pred; } +#if CONFIG_ADPCM_IMA_ESCAPE_DECODER static inline int16_t adpcm_ima_escape_expand_nibble(ADPCMChannelStatus *c, int8_t nibble) { int step_index; @@ -477,6 +478,7 @@ static inline int16_t adpcm_ima_escape_expand_nibble(ADPCMChannelStatus *c, int8 return (int16_t)c->predictor; } +#endif static inline int16_t adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift) { @@ -614,8 +616,10 @@ int16_t ff_adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble) return c->predictor; } -static void decode_adpcm_ima_hvqm2(AVCodecContext *avctx, int16_t *outbuf, int samples_to_do, - int frame_format, GetByteContext *gb) +#if CONFIG_ADPCM_IMA_HVQM2_DECODER +static void decode_adpcm_ima_hvqm2(AVCodecContext *avctx, int16_t *outbuf, + int samples_to_do, int frame_format, + GetByteContext *gb) { ADPCMDecodeContext *c = avctx->priv_data; int st = avctx->ch_layout.nb_channels == 2; @@ -650,9 +654,12 @@ static void decode_adpcm_ima_hvqm2(AVCodecContext *avctx, int16_t *outbuf, int s bytestream2_seek(gb, 0, SEEK_END); } +#endif -static void decode_adpcm_ima_hvqm4(AVCodecContext *avctx, int16_t *outbuf, int samples_to_do, - int frame_format, GetByteContext *gb) +#if CONFIG_ADPCM_IMA_HVQM4_DECODER +static void decode_adpcm_ima_hvqm4(AVCodecContext *avctx, int16_t *outbuf, + int samples_to_do, int frame_format, + GetByteContext *gb) { ADPCMDecodeContext *c = avctx->priv_data; int st = avctx->ch_layout.nb_channels == 2; @@ -693,6 +700,7 @@ static void decode_adpcm_ima_hvqm4(AVCodecContext *avctx, int16_t *outbuf, int s bytestream2_seek(gb, 0, SEEK_END); } +#endif static inline int16_t adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble) { @@ -826,6 +834,7 @@ static inline int16_t adpcm_mtaf_expand_nibble(ADPCMChannelStatus *c, uint8_t ni return c->predictor; } +#if CONFIG_ADPCM_CIRCUS_DECODER static inline int16_t adpcm_circus_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble) { int32_t sample = c->predictor; @@ -846,6 +855,7 @@ static inline int16_t adpcm_circus_expand_nibble(ADPCMChannelStatus *c, uint8_t return sample; } +#endif static inline int16_t adpcm_zork_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble) { @@ -882,6 +892,7 @@ static inline int16_t adpcm_zork_expand_nibble(ADPCMChannelStatus *c, uint8_t ni return sample; } +#if CONFIG_ADPCM_XA_DECODER static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, const uint8_t *in, ADPCMChannelStatus *left, ADPCMChannelStatus *right, int channels, int sample_offset) @@ -969,7 +980,9 @@ static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, return 0; } +#endif +#if CONFIG_ADPCM_SWF_DECODER static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int16_t *samples) { ADPCMDecodeContext *c = avctx->priv_data; @@ -1027,6 +1040,7 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_ } } } +#endif int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shift, int flag) { @@ -1045,6 +1059,7 @@ int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shif return sample; } +#if CONFIG_ADPCM_SANYO_DECODER static int adpcm_sanyo_expand3(ADPCMChannelStatus *c, int bits) { int sign, delta, add; @@ -1210,7 +1225,9 @@ static int adpcm_sanyo_expand5(ADPCMChannelStatus *c, int bits) c->step = av_clip(c->step, 1, 1024); return c->predictor; } +#endif +#if CONFIG_ADPCM_IMA_CITRIX_DECODER static int adpcm_citrix_expand(ADPCMChannelStatus *c, int bits) { int step = ff_adpcm_step_table[c->step_index]; @@ -1223,6 +1240,7 @@ static int adpcm_citrix_expand(ADPCMChannelStatus *c, int bits) c->predictor = av_clip_int16(c->predictor + add); return c->predictor; } +#endif /** * Get the number of samples (per channel) that will be decoded from the packet. -- 2.54.0 From 608b7057d9857ef5e471f4a8dffebb512172c502 Mon Sep 17 00:00:00 2001 From: lusoris <[email protected]> Date: Mon, 26 Oct 2026 11:58:37 +0100 Subject: [PATCH 2/2] avcodec/adpcm: mark conditionally used frame locals as unused GCC 14.4.0 and 16.2.1 report -Wunused-variable and -Wunused-but-set-variable warnings in adpcm_decode_frame with single-decoder configurations such as adpcm_xa, adpcm_swf, adpcm_sanyo and adpcm_ima_citrix. Reads of shared locals disappear when their CASE blocks are disabled. Mark c, samples, samples_p and st as av_unused to suppress both warnings for any subset of enabled decoders without changing behavior. Signed-off-by: lusoris <[email protected]> --- libavcodec/adpcm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index d3d796fe189..759a90aaf42 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -1545,11 +1545,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame, { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - ADPCMDecodeContext *c = avctx->priv_data; + av_unused ADPCMDecodeContext *c = avctx->priv_data; int channels = avctx->ch_layout.nb_channels; - int16_t *samples; - int16_t **samples_p; - int st; /* stereo */ + av_unused int16_t *samples; + av_unused int16_t **samples_p; + av_unused int st; /* stereo */ int nb_samples, coded_samples, approx_nb_samples, ret; GetByteContext gb; -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
