diff mbox series

[FFmpeg-devel,03/17] avcodec/ac3enc: Remove redundant channel layout checks

Message ID GV1P250MB073767BA251045412751FCA88F012@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit b3d12fe200be1ddf8e48c8d5c94f8b22904f7165
Headers show
Series [FFmpeg-devel,01/17] avcodec/ac3enc: Don't presume ch_layout to be AV_CHANNEL_ORDER_NATIVE | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt April 7, 2024, 9:09 p.m. UTC
These are all checked generically via AVCodec.ch_layouts
in encode_preinit_audio().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ac3enc.c | 23 ++---------------------
 1 file changed, 2 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index f6456b2a22..1a65e35161 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2189,17 +2189,12 @@  av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
 /*
  * Set channel information during initialization.
  */
-static av_cold int set_channel_info(AVCodecContext *avctx)
+static av_cold void set_channel_info(AVCodecContext *avctx)
 {
     AC3EncodeContext *s = avctx->priv_data;
     uint64_t mask = av_channel_layout_subset(&avctx->ch_layout, ~(uint64_t)0);
     int channels = avctx->ch_layout.nb_channels;
 
-    if (channels < 1 || channels > AC3_MAX_CHANNELS)
-        return AVERROR(EINVAL);
-    if (mask > 0x7FF)
-        return AVERROR(EINVAL);
-
     s->lfe_on       = !!(mask & AV_CH_LOW_FREQUENCY);
     s->channels     = channels;
     s->fbw_channels = channels - s->lfe_on;
@@ -2217,15 +2212,11 @@  static av_cold int set_channel_info(AVCodecContext *avctx)
     case AV_CH_LAYOUT_2_2:            s->channel_mode = AC3_CHMODE_2F2R;   break;
     case AV_CH_LAYOUT_5POINT0:
     case AV_CH_LAYOUT_5POINT0_BACK:   s->channel_mode = AC3_CHMODE_3F2R;   break;
-    default:
-        return AVERROR(EINVAL);
     }
     s->has_center   = (s->channel_mode & 0x01) && s->channel_mode != AC3_CHMODE_MONO;
     s->has_surround =  s->channel_mode & 0x04;
 
     s->channel_map  = ac3_enc_channel_map[s->channel_mode][s->lfe_on];
-
-    return 0;
 }
 
 
@@ -2234,17 +2225,7 @@  static av_cold int validate_options(AC3EncodeContext *s)
     AVCodecContext *avctx = s->avctx;
     int i, ret, max_sr;
 
-    /* validate 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(avctx);
-    if (ret) {
-        av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n");
-        return ret;
-    }
+    set_channel_info(avctx);
 
     /* validate sample rate */
     /* note: max_sr could be changed from 2 to 5 for E-AC-3 once we find a