* [FFmpeg-devel] [PATCH 1/1] avcodec/pcm: fix build warning by replacing deprecated method with avcodec_get_supported_config.
@ 2025-03-11 9:25 joneyao6
2025-03-11 10:22 ` Zhao Zhili
0 siblings, 1 reply; 3+ messages in thread
From: joneyao6 @ 2025-03-11 9:25 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Jingwei Yao
From: Jingwei Yao <joneyao6@gmail.com>
Signed-off-by: Jingwei Yao <joneyao6@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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/1] avcodec/pcm: fix build warning by replacing deprecated method with avcodec_get_supported_config.
2025-03-11 9:25 [FFmpeg-devel] [PATCH 1/1] avcodec/pcm: fix build warning by replacing deprecated method with avcodec_get_supported_config joneyao6
@ 2025-03-11 10:22 ` Zhao Zhili
2025-03-13 5:50 ` Andreas Rheinhardt
0 siblings, 1 reply; 3+ messages in thread
From: Zhao Zhili @ 2025-03-11 10:22 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Jingwei Yao
> On Mar 11, 2025, at 17:25, joneyao6@gmail.com wrote:
>
> From: Jingwei Yao <joneyao6@gmail.com>
>
> Signed-off-by: Jingwei Yao <joneyao6@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];
How about just disable the warning with FF_DISABLE_DEPRECATION_WARNINGS?
sample_fmts should be moved to FFCodec finally. So we can fix it finally by
avctx->sample_fmt = ffcodec(avctx->codec)->sample_fmts[0];
It doesn’t worth the trouble and complexity to get some information which is only an array
in current translation unit.
>
> if (avctx->sample_fmt == AV_SAMPLE_FMT_S32)
> avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec_id);
> --
> 2.25.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/1] avcodec/pcm: fix build warning by replacing deprecated method with avcodec_get_supported_config.
2025-03-11 10:22 ` Zhao Zhili
@ 2025-03-13 5:50 ` Andreas Rheinhardt
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2025-03-13 5:50 UTC (permalink / raw)
To: ffmpeg-devel
Zhao Zhili:
>
>
>> On Mar 11, 2025, at 17:25, joneyao6@gmail.com wrote:
>>
>> From: Jingwei Yao <joneyao6@gmail.com>
>>
>> Signed-off-by: Jingwei Yao <joneyao6@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];
>
> How about just disable the warning with FF_DISABLE_DEPRECATION_WARNINGS?
>
> sample_fmts should be moved to FFCodec finally. So we can fix it finally by
>
> avctx->sample_fmt = ffcodec(avctx->codec)->sample_fmts[0];
Actually, sample_fmts and the other stuff should be encoder-only. I
therefore just sent a patchset that avoids using it here (by the decoders).
>
> It doesn’t worth the trouble and complexity to get some information which is only an array
> in current translation unit.
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-13 5:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-11 9:25 [FFmpeg-devel] [PATCH 1/1] avcodec/pcm: fix build warning by replacing deprecated method with avcodec_get_supported_config joneyao6
2025-03-11 10:22 ` Zhao Zhili
2025-03-13 5:50 ` Andreas Rheinhardt
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git