[FFmpeg-devel] [PATCH 271/279] lavc: drop temporary compat wrappers for channel layout API change

James Almer jamrial at gmail.com
Wed Dec 8 03:06:41 EET 2021


From: Anton Khirnov <anton at khirnov.net>

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/aacdec_template.c |  7 -------
 libavcodec/avcodec.c         | 29 -----------------------------
 libavcodec/dca_lbr.c         |  7 -------
 libavcodec/dcadec.c          |  8 --------
 libavcodec/decode.c          | 20 --------------------
 libavcodec/encode.c          | 15 ---------------
 6 files changed, 86 deletions(-)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 387a4acfce..349ecdefb3 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -592,13 +592,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
     }
 
     av_channel_layout_copy(&avctx->ch_layout, &ac->oc[1].ch_layout);
-#if FF_API_OLD_CHANNEL_LAYOUT
-FF_DISABLE_DEPRECATION_WARNINGS
-    avctx->channels = avctx->ch_layout.nb_channels;
-    avctx->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ?
-                            avctx->ch_layout.u.mask : 0;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
     ac->oc[1].status = oc_type;
 
     if (get_new_frame) {
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 4c576a848c..35a6bf9bfe 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -137,8 +137,6 @@ static int64_t get_bit_rate(AVCodecContext *ctx)
 int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
 {
     int ret = 0;
-    int orig_channels;
-    uint64_t orig_channel_layout;
     AVCodecInternal *avci;
 
     if (avcodec_is_open(avctx))
@@ -275,14 +273,6 @@ FF_DISABLE_DEPRECATION_WARNINGS
             avctx->ch_layout.nb_channels = avctx->channels;
         }
     }
-
-    /* temporary compat wrapper for new-style callers and old-style codecs;
-     * to be removed once all the codecs have been converted */
-    if (avctx->ch_layout.nb_channels) {
-        avctx->channels = avctx->ch_layout.nb_channels;
-        avctx->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ?
-                                avctx->ch_layout.u.mask : 0;
-    }
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
@@ -345,13 +335,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
     if (!HAVE_THREADS && !(codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS))
         avctx->thread_count = 1;
 
-#if FF_API_OLD_CHANNEL_LAYOUT
-FF_DISABLE_DEPRECATION_WARNINGS
-    orig_channels = avctx->channels;
-    orig_channel_layout = avctx->channel_layout;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     if (!(avctx->active_thread_type & FF_THREAD_FRAME) ||
         avci->frame_thread_encoder) {
         if (avctx->codec->init) {
@@ -372,18 +355,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 #if FF_API_OLD_CHANNEL_LAYOUT
 FF_DISABLE_DEPRECATION_WARNINGS
-        /* decoder setting the old-style fields */
-        if (avctx->channels != orig_channels ||
-            avctx->channel_layout != orig_channel_layout) {
-            av_channel_layout_uninit(&avctx->ch_layout);
-            if (avctx->channel_layout) {
-                av_channel_layout_from_mask(&avctx->ch_layout, avctx->channel_layout);
-            } else {
-                avctx->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
-                avctx->ch_layout.nb_channels = avctx->channels;
-            }
-        }
-
         /* update the deprecated fields for old-style callers */
         avctx->channels = avctx->ch_layout.nb_channels;
         avctx->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ?
diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c
index c11f2f7e18..527bc8b7c0 100644
--- a/libavcodec/dca_lbr.c
+++ b/libavcodec/dca_lbr.c
@@ -1744,13 +1744,6 @@ int ff_dca_lbr_filter_frame(DCALbrDecoder *s, AVFrame *frame)
 
     av_channel_layout_uninit(&avctx->ch_layout);
     av_channel_layout_from_mask(&avctx->ch_layout, channel_mask);
-#if FF_API_OLD_CHANNEL_LAYOUT
-FF_DISABLE_DEPRECATION_WARNINGS
-    avctx->channels = avctx->ch_layout.nb_channels;
-    avctx->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ?
-                            avctx->ch_layout.u.mask : 0;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 
     frame->nb_samples = 1024 << s->freq_range;
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
index 239ed9ac91..9f40da20fc 100644
--- a/libavcodec/dcadec.c
+++ b/libavcodec/dcadec.c
@@ -78,14 +78,6 @@ int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask
         av_channel_layout_from_mask(&avctx->ch_layout, wav_mask);
     }
 
-#if FF_API_OLD_CHANNEL_LAYOUT
-FF_DISABLE_DEPRECATION_WARNINGS
-    avctx->channels = avctx->ch_layout.nb_channels;
-    avctx->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ?
-                            avctx->ch_layout.u.mask : 0;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
     return nchannels;
 }
 
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index aa74c677ef..24357a4d09 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1690,26 +1690,6 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
     } else if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
 #if FF_API_OLD_CHANNEL_LAYOUT
 FF_DISABLE_DEPRECATION_WARNINGS
-        /* temporary compat layer for decoders setting the old-style channel
-         * layout fields; shall be removed after all the decoders are converted
-         * to the new API */
-        if ((avctx->channels > 0 && avctx->ch_layout.nb_channels != avctx->channels) ||
-            (avctx->channel_layout && (avctx->ch_layout.order != AV_CHANNEL_ORDER_NATIVE ||
-                                       avctx->ch_layout.u.mask != avctx->channel_layout))) {
-            av_channel_layout_uninit(&avctx->ch_layout);
-            if (avctx->channel_layout) {
-                if (av_popcount64(avctx->channel_layout) != avctx->channels) {
-                    av_log(avctx, AV_LOG_ERROR, "Inconsistent channel layout/channels\n");
-                    ret = AVERROR(EINVAL);
-                    goto fail;
-                }
-                av_channel_layout_from_mask(&avctx->ch_layout, avctx->channel_layout);
-            } else {
-                avctx->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
-                avctx->ch_layout.nb_channels = avctx->channels;
-            }
-        }
-
         /* compat layer for old-style get_buffer() implementations */
         avctx->channels = avctx->ch_layout.nb_channels;
         avctx->channel_layout = (avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE) ?
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 0dd5e3fdd1..af274a5cc5 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -490,21 +490,6 @@ int ff_encode_preinit(AVCodecContext *avctx)
 FF_DISABLE_DEPRECATION_WARNINGS
     }
 #if FF_API_OLD_CHANNEL_LAYOUT
-    else if (avctx->codec->channel_layouts) {
-        if (!avctx->channel_layout) {
-            av_log(avctx, AV_LOG_WARNING, "Channel layout not specified\n");
-        } else {
-            for (i = 0; avctx->codec->channel_layouts[i] != 0; i++)
-                if (avctx->channel_layout == avctx->codec->channel_layouts[i])
-                    break;
-            if (avctx->codec->channel_layouts[i] == 0) {
-                char buf[512];
-                av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
-                av_log(avctx, AV_LOG_ERROR, "Specified channel layout '%s' is not supported\n", buf);
-                return AVERROR(EINVAL);
-            }
-        }
-    }
     if (avctx->channel_layout && avctx->channels) {
         int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
         if (channels != avctx->channels) {
-- 
2.34.1



More information about the ffmpeg-devel mailing list