diff mbox series

[FFmpeg-devel,183/281] ac3: convert to new channel layout API

Message ID 20220113020242.661-4-jamrial@gmail.com
State New
Headers show
Series New channel layout API
Related show

Commit Message

James Almer Jan. 13, 2022, 2:02 a.m. UTC
From: Vittorio Giovara <vittorio.giovara@gmail.com>

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/aac_ac3_parser.c |  6 +++
 libavcodec/ac3dec.c         | 57 +++++++++++++++++----------
 libavcodec/ac3dec.h         |  2 +
 libavcodec/ac3dec_fixed.c   |  1 +
 libavcodec/ac3dec_float.c   |  2 +
 libavcodec/ac3enc.c         | 78 +++++++++++++++++++++++++++++--------
 libavcodec/ac3enc.h         |  4 +-
 libavcodec/ac3enc_fixed.c   |  5 +++
 libavcodec/ac3enc_float.c   |  5 +++
 libavcodec/eac3enc.c        |  5 +++
 tests/fate/ac3.mak          | 16 ++++----
 11 files changed, 135 insertions(+), 46 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index cd54a0a3e2..4ce7a73972 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -97,6 +97,12 @@  get_next:
                     avctx->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
                     avctx->ch_layout.nb_channels = s->channels;
                 }
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+                avctx->channels = avctx->ch_layout.nb_channels;
+                avctx->channel_layout = s->channel_layout;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
             }
             s1->duration = s->samples;
             avctx->audio_service_type = s->service_type;
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index ae00373dcb..70b35c170f 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -32,6 +32,7 @@ 
 #include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
 #include "libavutil/downmix_info.h"
+#include "libavutil/intmath.h"
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "bswapdsp.h"
@@ -186,6 +187,8 @@  static av_cold int ac3_decode_init(AVCodecContext *avctx)
 {
     static AVOnce init_static_once = AV_ONCE_INIT;
     AC3DecodeContext *s = avctx->priv_data;
+    const AVChannelLayout mono   = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
+    const AVChannelLayout stereo = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
     int i, ret;
 
     s->avctx = avctx;
@@ -214,12 +217,23 @@  static av_cold int ac3_decode_init(AVCodecContext *avctx)
         avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
 
     /* allow downmixing to stereo or mono */
-    if (avctx->channels > 1 &&
-        avctx->request_channel_layout == AV_CH_LAYOUT_MONO)
-        avctx->channels = 1;
-    else if (avctx->channels > 2 &&
-             avctx->request_channel_layout == AV_CH_LAYOUT_STEREO)
-        avctx->channels = 2;
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+    if (avctx->request_channel_layout) {
+        av_channel_layout_uninit(&s->downmix_layout);
+        av_channel_layout_from_mask(&s->downmix_layout, avctx->request_channel_layout);
+    }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+    if (avctx->ch_layout.nb_channels > 1 &&
+        !av_channel_layout_compare(&s->downmix_layout, &mono)) {
+        av_channel_layout_uninit(&avctx->ch_layout);
+        avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
+    } else if (avctx->ch_layout.nb_channels > 2 &&
+             !av_channel_layout_compare(&s->downmix_layout, &stereo)) {
+        av_channel_layout_uninit(&avctx->ch_layout);
+        avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
+    }
     s->downmixed = 1;
 
     for (i = 0; i < AC3_MAX_CHANNELS; i++) {
@@ -1480,6 +1494,7 @@  static int ac3_decode_frame(AVCodecContext * avctx, void *data,
     const SHORTFLOAT *output[AC3_MAX_CHANNELS];
     enum AVMatrixEncoding matrix_encoding;
     AVDownmixInfo *downmix_info;
+    uint64_t mask;
 
     s->superframe_size = 0;
 
@@ -1590,11 +1605,11 @@  dependent_frame:
         if (s->lfe_on)
             s->output_mode |= AC3_OUTPUT_LFEON;
         if (s->channels > 1 &&
-            avctx->request_channel_layout == AV_CH_LAYOUT_MONO) {
+            !av_channel_layout_compare(&s->downmix_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO)) {
             s->out_channels = 1;
             s->output_mode  = AC3_CHMODE_MONO;
         } else if (s->channels > 2 &&
-                   avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
+                   !av_channel_layout_compare(&s->downmix_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) {
             s->out_channels = 2;
             s->output_mode  = AC3_CHMODE_STEREO;
         }
@@ -1615,10 +1630,13 @@  dependent_frame:
         av_log(avctx, AV_LOG_ERROR, "unable to determine channel mode\n");
         return AVERROR_INVALIDDATA;
     }
-    avctx->channels = s->out_channels;
-    avctx->channel_layout = ff_ac3_channel_layout_tab[s->output_mode & ~AC3_OUTPUT_LFEON];
+
+    mask = ff_ac3_channel_layout_tab[s->output_mode & ~AC3_OUTPUT_LFEON];
     if (s->output_mode & AC3_OUTPUT_LFEON)
-        avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
+        mask |= AV_CH_LOW_FREQUENCY;
+
+    av_channel_layout_uninit(&avctx->ch_layout);
+    av_channel_layout_from_mask(&avctx->ch_layout, mask);
 
     /* set audio service type based on bitstream mode for AC-3 */
     avctx->audio_service_type = s->bitstream_mode;
@@ -1714,20 +1732,20 @@  skip:
                 channel_layout |= ff_eac3_custom_channel_map_locations[ch][1];
             }
         }
-        if (av_get_channel_layout_nb_channels(channel_layout) > EAC3_MAX_CHANNELS) {
+        if (av_popcount64(channel_layout) > EAC3_MAX_CHANNELS) {
             av_log(avctx, AV_LOG_ERROR, "Too many channels (%d) coded\n",
-                   av_get_channel_layout_nb_channels(channel_layout));
+                   av_popcount64(channel_layout));
             return AVERROR_INVALIDDATA;
         }
 
-        avctx->channel_layout = channel_layout;
-        avctx->channels = av_get_channel_layout_nb_channels(channel_layout);
+        av_channel_layout_uninit(&avctx->ch_layout);
+        av_channel_layout_from_mask(&avctx->ch_layout, channel_layout);
 
         for (ch = 0; ch < EAC3_MAX_CHANNELS; ch++) {
             if (s->channel_map & (1 << (EAC3_MAX_CHANNELS - ch - 1))) {
                 if (ff_eac3_custom_channel_map_locations[ch][0]) {
-                    int index = av_get_channel_layout_channel_index(channel_layout,
-                                                                    ff_eac3_custom_channel_map_locations[ch][1]);
+                    int index = av_channel_layout_index_from_channel(&avctx->ch_layout,
+                                                                     ff_ctzll(ff_eac3_custom_channel_map_locations[ch][1]));
                     if (index < 0)
                         return AVERROR_INVALIDDATA;
                     if (extend >= channel_map_size)
@@ -1739,8 +1757,7 @@  skip:
 
                     for (i = 0; i < 64; i++) {
                         if ((1ULL << i) & ff_eac3_custom_channel_map_locations[ch][1]) {
-                            int index = av_get_channel_layout_channel_index(channel_layout,
-                                                                            1ULL << i);
+                            int index = av_channel_layout_index_from_channel(&avctx->ch_layout, i);
                             if (index < 0)
                                 return AVERROR_INVALIDDATA;
                             if (extend >= channel_map_size)
@@ -1759,7 +1776,7 @@  skip:
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
-    for (ch = 0; ch < avctx->channels; ch++) {
+    for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
         int map = extended_channel_map[ch];
         av_assert0(ch>=AV_NUM_DATA_POINTERS || frame->extended_data[ch] == frame->data[ch]);
         memcpy((SHORTFLOAT *)frame->extended_data[ch],
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 85653990cf..9444124974 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -251,6 +251,8 @@  typedef struct AC3DecodeContext {
     DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread
     DECLARE_ALIGNED(32, SHORTFLOAT, output_buffer)[EAC3_MAX_CHANNELS][AC3_BLOCK_SIZE * 6];  ///< final output buffer
 ///@}
+
+    AVChannelLayout downmix_layout;
 } AC3DecodeContext;
 
 /**
diff --git a/libavcodec/ac3dec_fixed.c b/libavcodec/ac3dec_fixed.c
index 8645952621..ae433c5cc7 100644
--- a/libavcodec/ac3dec_fixed.c
+++ b/libavcodec/ac3dec_fixed.c
@@ -157,6 +157,7 @@  static const AVOption options[] = {
     { "cons_noisegen", "enable consistent noise generation", OFFSET(consistent_noise_generation), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
     { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },
     { "heavy_compr", "enable heavy dynamic range compression", OFFSET(heavy_compression), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
+    { "downmix", "Request a specific channel layout from the decoder", OFFSET(downmix_layout), AV_OPT_TYPE_CHLAYOUT, {.str = NULL}, .flags = PAR },
     { NULL},
 };
 
diff --git a/libavcodec/ac3dec_float.c b/libavcodec/ac3dec_float.c
index 573fbe75b6..2b1b359a0c 100644
--- a/libavcodec/ac3dec_float.c
+++ b/libavcodec/ac3dec_float.c
@@ -43,6 +43,8 @@  static const AVOption options[] = {
 {"loro_cmixlev",   "Lo/Ro Center Mix Level",   OFFSET(loro_center_mix_level),    AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
 {"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level),  AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
 
+    { "downmix", "Request a specific channel layout from the decoder", OFFSET(downmix_layout), AV_OPT_TYPE_CHLAYOUT, {.str = NULL}, .flags = PAR },
+
     { NULL},
 };
 
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 034aa0beb9..30ba8bfecd 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -147,6 +147,7 @@  static uint8_t exponent_group_tab[2][3][256];
 /**
  * List of supported channel layouts.
  */
+#if FF_API_OLD_CHANNEL_LAYOUT
 const uint64_t ff_ac3_channel_layouts[19] = {
      AV_CH_LAYOUT_MONO,
      AV_CH_LAYOUT_STEREO,
@@ -168,6 +169,47 @@  const uint64_t ff_ac3_channel_layouts[19] = {
      AV_CH_LAYOUT_5POINT1_BACK,
      0
 };
+#endif
+
+const AVChannelLayout ff_ac3_ch_layouts[19] = {
+    AV_CHANNEL_LAYOUT_MONO,
+    AV_CHANNEL_LAYOUT_STEREO,
+    AV_CHANNEL_LAYOUT_2_1,
+    AV_CHANNEL_LAYOUT_SURROUND,
+    AV_CHANNEL_LAYOUT_2_2,
+    AV_CHANNEL_LAYOUT_QUAD,
+    AV_CHANNEL_LAYOUT_4POINT0,
+    AV_CHANNEL_LAYOUT_5POINT0,
+    AV_CHANNEL_LAYOUT_5POINT0_BACK,
+    {
+        .nb_channels = 2,
+        .order       = AV_CHANNEL_ORDER_NATIVE,
+        .u.mask      = AV_CH_LAYOUT_MONO | AV_CH_LOW_FREQUENCY,
+    },
+    {
+        .nb_channels = 3,
+        .order       = AV_CHANNEL_ORDER_NATIVE,
+        .u.mask      = AV_CH_LAYOUT_STEREO | AV_CH_LOW_FREQUENCY,
+    },
+    {
+        .nb_channels = 4,
+        .order       = AV_CHANNEL_ORDER_NATIVE,
+        .u.mask      = AV_CH_LAYOUT_2_1 | AV_CH_LOW_FREQUENCY,
+    },
+    {
+        .nb_channels = 4,
+        .order       = AV_CHANNEL_ORDER_NATIVE,
+        .u.mask      = AV_CH_LAYOUT_SURROUND | AV_CH_LOW_FREQUENCY,
+    },
+    {
+        .nb_channels = 5,
+        .order       = AV_CHANNEL_ORDER_NATIVE,
+        .u.mask      = AV_CH_LAYOUT_4POINT0 | AV_CH_LOW_FREQUENCY,
+    },
+    AV_CHANNEL_LAYOUT_5POINT1,
+    AV_CHANNEL_LAYOUT_5POINT1_BACK,
+    { 0 },
+};
 
 /**
  * Table to remap channels from SMPTE order to AC-3 order.
@@ -1797,7 +1839,7 @@  static void dprint_options(AC3EncodeContext *s)
     }
     ff_dlog(avctx, "bitstream_id: %s (%d)\n", strbuf, s->bitstream_id);
     ff_dlog(avctx, "sample_fmt: %s\n", av_get_sample_fmt_name(avctx->sample_fmt));
-    av_get_channel_layout_string(strbuf, 32, s->channels, avctx->channel_layout);
+    av_channel_layout_describe(&avctx->ch_layout, strbuf, sizeof(strbuf));
     ff_dlog(avctx, "channel_layout: %s\n", strbuf);
     ff_dlog(avctx, "sample_rate: %d\n", s->sample_rate);
     ff_dlog(avctx, "bit_rate: %d\n", s->bit_rate);
@@ -2041,11 +2083,11 @@  int ff_ac3_validate_metadata(AC3EncodeContext *s)
 
     /* validate audio service type / channels combination */
     if ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_KARAOKE &&
-         avctx->channels == 1) ||
+         avctx->ch_layout.nb_channels == 1) ||
         ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_COMMENTARY ||
           avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_EMERGENCY  ||
           avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_VOICE_OVER)
-         && avctx->channels > 1)) {
+         && avctx->ch_layout.nb_channels > 1)) {
         av_log(avctx, AV_LOG_ERROR, "invalid audio service type for the "
                                     "specified number of channels\n");
         return AVERROR(EINVAL);
@@ -2167,27 +2209,29 @@  av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
 /*
  * Set channel information during initialization.
  */
-static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
-                                    uint64_t *channel_layout)
+static av_cold int set_channel_info(AVCodecContext *avctx)
 {
-    int ch_layout;
+    AC3EncodeContext *s = avctx->priv_data;
+    int channels = avctx->ch_layout.nb_channels;
+    uint64_t mask = avctx->ch_layout.u.mask;
 
     if (channels < 1 || channels > AC3_MAX_CHANNELS)
         return AVERROR(EINVAL);
-    if (*channel_layout > 0x7FF)
+    if (mask > 0x7FF)
         return AVERROR(EINVAL);
-    ch_layout = *channel_layout;
-    if (!ch_layout)
-        ch_layout = av_get_default_channel_layout(channels);
 
-    s->lfe_on       = !!(ch_layout & AV_CH_LOW_FREQUENCY);
+    if (!mask)
+        av_channel_layout_default(&avctx->ch_layout, channels);
+    mask = avctx->ch_layout.u.mask;
+
+    s->lfe_on       = !!(mask & AV_CH_LOW_FREQUENCY);
     s->channels     = channels;
     s->fbw_channels = channels - s->lfe_on;
     s->lfe_channel  = s->lfe_on ? s->fbw_channels + 1 : -1;
     if (s->lfe_on)
-        ch_layout -= AV_CH_LOW_FREQUENCY;
+        mask -= AV_CH_LOW_FREQUENCY;
 
-    switch (ch_layout) {
+    switch (mask) {
     case AV_CH_LAYOUT_MONO:           s->channel_mode = AC3_CHMODE_MONO;   break;
     case AV_CH_LAYOUT_STEREO:         s->channel_mode = AC3_CHMODE_STEREO; break;
     case AV_CH_LAYOUT_SURROUND:       s->channel_mode = AC3_CHMODE_3F;     break;
@@ -2204,9 +2248,9 @@  static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
     s->has_surround =  s->channel_mode & 0x04;
 
     s->channel_map  = ac3_enc_channel_map[s->channel_mode][s->lfe_on];
-    *channel_layout = ch_layout;
     if (s->lfe_on)
-        *channel_layout |= AV_CH_LOW_FREQUENCY;
+        mask |= AV_CH_LOW_FREQUENCY;
+    av_channel_layout_from_mask(&avctx->ch_layout, mask);
 
     return 0;
 }
@@ -2218,12 +2262,12 @@  static av_cold int validate_options(AC3EncodeContext *s)
     int i, ret, max_sr;
 
     /* validate channel layout */
-    if (!avctx->channel_layout) {
+    if (!avctx->ch_layout.nb_channels) {
         av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "
                                       "encoder will guess the layout, but it "
                                       "might be incorrect.\n");
     }
-    ret = set_channel_info(s, avctx->channels, &avctx->channel_layout);
+    ret = set_channel_info(avctx);
     if (ret) {
         av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n");
         return ret;
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index 39a41fe0b0..647a7769ec 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -266,8 +266,10 @@  typedef struct AC3EncodeContext {
     void (*output_frame_header)(struct AC3EncodeContext *s);
 } AC3EncodeContext;
 
-
+#if FF_API_OLD_CHANNEL_LAYOUT
 extern const uint64_t ff_ac3_channel_layouts[19];
+#endif
+extern const AVChannelLayout ff_ac3_ch_layouts[19];
 extern const AVOption ff_ac3_enc_options[];
 extern const AVClass ff_ac3enc_class;
 extern const AVCodecDefault ff_ac3_enc_defaults[];
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index 80aa98c691..6e0abf4a26 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -119,6 +119,7 @@  static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx)
 }
 
 
+FF_DISABLE_DEPRECATION_WARNINGS
 const AVCodec ff_ac3_fixed_encoder = {
     .name            = "ac3_fixed",
     .long_name       = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
@@ -134,6 +135,10 @@  const AVCodec ff_ac3_fixed_encoder = {
     .priv_class      = &ff_ac3enc_class,
     .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .supported_samplerates = ff_ac3_sample_rate_tab,
+#if FF_API_OLD_CHANNEL_LAYOUT
     .channel_layouts = ff_ac3_channel_layouts,
+#endif
+    .ch_layouts      = ff_ac3_ch_layouts,
     .defaults        = ff_ac3_enc_defaults,
 };
+FF_ENABLE_DEPRECATION_WARNINGS
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index e4a3794dd8..0e605cdf2c 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -123,6 +123,7 @@  av_cold int ff_ac3_float_encode_init(AVCodecContext *avctx)
     return ff_ac3_encode_init(avctx);
 }
 
+FF_DISABLE_DEPRECATION_WARNINGS
 const AVCodec ff_ac3_encoder = {
     .name            = "ac3",
     .long_name       = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
@@ -137,7 +138,11 @@  const AVCodec ff_ac3_encoder = {
                                                       AV_SAMPLE_FMT_NONE },
     .priv_class      = &ff_ac3enc_class,
     .supported_samplerates = ff_ac3_sample_rate_tab,
+#if FF_API_OLD_CHANNEL_LAYOUT
     .channel_layouts = ff_ac3_channel_layouts,
+#endif
+    .ch_layouts      = ff_ac3_ch_layouts,
     .defaults        = ff_ac3_enc_defaults,
     .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
+FF_ENABLE_DEPRECATION_WARNINGS
diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c
index 96ef00ea4f..c959aec55c 100644
--- a/libavcodec/eac3enc.c
+++ b/libavcodec/eac3enc.c
@@ -248,6 +248,7 @@  void ff_eac3_output_frame_header(AC3EncodeContext *s)
 }
 
 
+FF_DISABLE_DEPRECATION_WARNINGS
 const AVCodec ff_eac3_encoder = {
     .name            = "eac3",
     .long_name       = NULL_IF_CONFIG_SMALL("ATSC A/52 E-AC-3"),
@@ -262,7 +263,11 @@  const AVCodec ff_eac3_encoder = {
                                                       AV_SAMPLE_FMT_NONE },
     .priv_class      = &eac3enc_class,
     .supported_samplerates = ff_ac3_sample_rate_tab,
+#if FF_API_OLD_CHANNEL_LAYOUT
     .channel_layouts = ff_ac3_channel_layouts,
+#endif
+    .ch_layouts      = ff_ac3_ch_layouts,
     .defaults        = ff_ac3_enc_defaults,
     .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
+FF_ENABLE_DEPRECATION_WARNINGS
diff --git a/tests/fate/ac3.mak b/tests/fate/ac3.mak
index 39b555161d..f0c3d18049 100644
--- a/tests/fate/ac3.mak
+++ b/tests/fate/ac3.mak
@@ -6,13 +6,13 @@  FATE_AC3 += fate-ac3-4.0
 fate-ac3-4.0: CMD = pcm -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3
 fate-ac3-4.0: REF = $(SAMPLES)/ac3/millers_crossing_4.0_v2.pcm
 
-#request_channel_layout 4 -> front channel
+#downmix 4.0 -> front channel
 FATE_AC3 += fate-ac3-4.0-downmix-mono
-fate-ac3-4.0-downmix-mono: CMD = pcm -request_channel_layout 4 -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3
+fate-ac3-4.0-downmix-mono: CMD = pcm -downmix mono -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3
 fate-ac3-4.0-downmix-mono: REF = $(SAMPLES)/ac3/millers_crossing_4.0_mono_v2.pcm
 
 FATE_AC3 += fate-ac3-4.0-downmix-stereo
-fate-ac3-4.0-downmix-stereo: CMD = pcm -request_channel_layout stereo -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3
+fate-ac3-4.0-downmix-stereo: CMD = pcm -downmix stereo -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3
 fate-ac3-4.0-downmix-stereo: REF = $(SAMPLES)/ac3/millers_crossing_4.0_stereo_v2.pcm
 
 FATE_AC3 += fate-ac3-5.1
@@ -20,11 +20,11 @@  fate-ac3-5.1: CMD = pcm -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3
 fate-ac3-5.1: REF = $(SAMPLES)/ac3/monsters_inc_5.1_448_small_v2.pcm
 
 FATE_AC3 += fate-ac3-5.1-downmix-mono
-fate-ac3-5.1-downmix-mono: CMD = pcm -request_channel_layout FC -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3
+fate-ac3-5.1-downmix-mono: CMD = pcm -downmix FC -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3
 fate-ac3-5.1-downmix-mono: REF = $(SAMPLES)/ac3/monsters_inc_5.1_448_small_mono_v2.pcm
 
 FATE_AC3 += fate-ac3-5.1-downmix-stereo
-fate-ac3-5.1-downmix-stereo: CMD = pcm -request_channel_layout 2c -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3
+fate-ac3-5.1-downmix-stereo: CMD = pcm -downmix stereo -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3
 fate-ac3-5.1-downmix-stereo: REF = $(SAMPLES)/ac3/monsters_inc_5.1_448_small_stereo_v2.pcm
 
 FATE_AC3 += fate-ac3-fixed-2.0
@@ -32,15 +32,15 @@  fate-ac3-fixed-2.0: CMD = pcm -c ac3_fixed -i $(TARGET_SAMPLES)/ac3/monsters_inc
 fate-ac3-fixed-2.0: REF = $(SAMPLES)/ac3/monsters_inc_2.0_192_small_v2.pcm
 
 FATE_AC3 += fate-ac3-fixed-4.0-downmix-mono
-fate-ac3-fixed-4.0-downmix-mono: CMD = pcm -c ac3_fixed -request_channel_layout mono -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3
+fate-ac3-fixed-4.0-downmix-mono: CMD = pcm -c ac3_fixed -downmix mono -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3
 fate-ac3-fixed-4.0-downmix-mono: REF = $(SAMPLES)/ac3/millers_crossing_4.0_mono_v2.pcm
 
 FATE_AC3 += fate-ac3-fixed-5.1-downmix-mono
-fate-ac3-fixed-5.1-downmix-mono: CMD = pcm -c ac3_fixed -request_channel_layout 4 -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3
+fate-ac3-fixed-5.1-downmix-mono: CMD = pcm -c ac3_fixed -downmix mono -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3
 fate-ac3-fixed-5.1-downmix-mono: REF = $(SAMPLES)/ac3/monsters_inc_5.1_448_small_mono_v2.pcm
 
 FATE_AC3 += fate-ac3-fixed-5.1-downmix-stereo
-fate-ac3-fixed-5.1-downmix-stereo: CMD = pcm -c ac3_fixed -request_channel_layout 3 -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3
+fate-ac3-fixed-5.1-downmix-stereo: CMD = pcm -c ac3_fixed -downmix stereo -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3
 fate-ac3-fixed-5.1-downmix-stereo: REF = $(SAMPLES)/ac3/monsters_inc_5.1_448_small_stereo_v2.pcm
 
 FATE_EAC3 += fate-eac3-1