[FFmpeg-devel] [PATCH 16/17] avcodec/dcaenc: Remove dead checks for unspec channel layouts

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Sep 18 23:27:56 EEST 2022


This encoder has AVCodec.ch_layouts set, so ff_encode_preinit()
ensures that the used channel layout is equivalent to one of
these.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
The new channel layout API is more stricter wrt these checks than the
old one; the old one let you pass if channels was set and channel_layout
unset. If this was not intended (or only semi-intended), then setting
the channel layout based upon channel count should IMO be done
generically in ff_encode_preinit().

 libavcodec/dcaenc.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
index d0de6d3eee..0996296d8c 100644
--- a/libavcodec/dcaenc.c
+++ b/libavcodec/dcaenc.c
@@ -222,13 +222,6 @@ static int encode_init(AVCodecContext *avctx)
     if (ff_dcaadpcm_init(&c->adpcm_ctx))
         return AVERROR(ENOMEM);
 
-    if (layout.order == AV_CHANNEL_ORDER_UNSPEC) {
-        av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "
-                                      "encoder will guess the layout, but it "
-                                      "might be incorrect.\n");
-        av_channel_layout_default(&layout, layout.nb_channels);
-    }
-
     if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO))
         c->channel_config = 0;
     else if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO))
@@ -239,10 +232,6 @@ static int encode_init(AVCodecContext *avctx)
         c->channel_config = 9;
     else if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1))
         c->channel_config = 9;
-    else {
-        av_log(avctx, AV_LOG_ERROR, "Unsupported channel layout!\n");
-        return AVERROR_PATCHWELCOME;
-    }
 
     if (c->lfe_channel) {
         c->fullband_channels--;
-- 
2.34.1



More information about the ffmpeg-devel mailing list