[FFmpeg-devel] [PATCH 1/1] avcodec/pcm: fix build warning by replacing deprecated method with avcodec_get_supported_config.
joneyao6 at gmail.com
joneyao6 at gmail.com
Tue Mar 11 11:25:11 EET 2025
From: Jingwei Yao <joneyao6 at gmail.com>
Signed-off-by: Jingwei Yao <joneyao6 at gmail.com>
---
libavcodec/pcm.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index a23293dca2..e04ca78101 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -252,8 +252,10 @@ typedef struct PCMDecode {
static av_cold int pcm_decode_init(AVCodecContext *avctx)
{
PCMDecode *s = avctx->priv_data;
+ const enum AVSampleFormat *sample_fmts;
AVFloatDSPContext *fdsp;
- int i;
+ int num_sample_fmts;
+ int i, ret;
switch (avctx->codec_id) {
case AV_CODEC_ID_PCM_ALAW:
@@ -284,7 +286,13 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
break;
}
- avctx->sample_fmt = avctx->codec->sample_fmts[0];
+ ret = avcodec_get_supported_config(avctx, NULL, AV_CODEC_CONFIG_SAMPLE_FORMAT,
+ 0, (const void**)&sample_fmts, &num_sample_fmts);
+ if (ret < 0)
+ return ret;
+
+ if (sample_fmts)
+ avctx->sample_fmt = sample_fmts[0];
if (avctx->sample_fmt == AV_SAMPLE_FMT_S32)
avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec_id);
--
2.25.1
More information about the ffmpeg-devel
mailing list