This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 72f751ef78e81c40aeb5f5f7e4e00f0d6e62fd80
Author:     Andreas Rheinhardt <[email protected]>
AuthorDate: Thu Jun 4 12:14:07 2026 +0200
Commit:     James Almer <[email protected]>
CommitDate: Thu Jun 4 19:39:32 2026 +0000

    doc/examples/encode_audio: Don't access deprecated AVCodec fields
    
    Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 doc/examples/encode_audio.c | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/doc/examples/encode_audio.c b/doc/examples/encode_audio.c
index 8be9e8a82a..a16c3a35c4 100644
--- a/doc/examples/encode_audio.c
+++ b/doc/examples/encode_audio.c
@@ -41,7 +41,17 @@
 /* check that a given sample format is supported by the encoder */
 static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat 
sample_fmt)
 {
-    const enum AVSampleFormat *p = codec->sample_fmts;
+    const void *out_config;
+    int ret = avcodec_get_supported_config(NULL, codec, 
AV_CODEC_CONFIG_SAMPLE_FORMAT,
+                                           0, &out_config, NULL);
+    if (ret < 0) {
+        fprintf(stderr, "Error getting supported sample formats\n");
+        exit(1);
+    }
+    const enum AVSampleFormat *p = out_config;
+
+    if (!p)
+        return 1;
 
     while (*p != AV_SAMPLE_FMT_NONE) {
         if (*p == sample_fmt)
@@ -54,13 +64,19 @@ static int check_sample_fmt(const AVCodec *codec, enum 
AVSampleFormat sample_fmt
 /* just pick the highest supported samplerate */
 static int select_sample_rate(const AVCodec *codec)
 {
-    const int *p;
+    const void *out_config;
+    int ret = avcodec_get_supported_config(NULL, codec, 
AV_CODEC_CONFIG_SAMPLE_RATE,
+                                           0, &out_config, NULL);
+    if (ret < 0) {
+        fprintf(stderr, "Error getting supported sample rates\n");
+        exit(1);
+    }
+    const int *p = out_config;
     int best_samplerate = 0;
 
-    if (!codec->supported_samplerates)
+    if (!p)
         return 44100;
 
-    p = codec->supported_samplerates;
     while (*p) {
         if (!best_samplerate || abs(44100 - *p) < abs(44100 - best_samplerate))
             best_samplerate = *p;
@@ -72,13 +88,19 @@ static int select_sample_rate(const AVCodec *codec)
 /* select layout with the highest channel count */
 static int select_channel_layout(const AVCodec *codec, AVChannelLayout *dst)
 {
-    const AVChannelLayout *p, *best_ch_layout;
+    const void *out_config;
+    int ret = avcodec_get_supported_config(NULL, codec, 
AV_CODEC_CONFIG_CHANNEL_LAYOUT,
+                                           0, &out_config, NULL);
+    if (ret < 0) {
+        fprintf(stderr, "Error getting supported channel layouts\n");
+        exit(1);
+    }
+    const AVChannelLayout *p = out_config, *best_ch_layout;
     int best_nb_channels   = 0;
 
-    if (!codec->ch_layouts)
+    if (!p)
         return av_channel_layout_copy(dst, 
&(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);
 
-    p = codec->ch_layouts;
     while (p->nb_channels) {
         int nb_channels = p->nb_channels;
 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to