[FFmpeg-cvslog] avcodec/ac3enc: Remove disabled code for RealAudio variant of AC-3

Andreas Rheinhardt git at videolan.org
Thu Apr 11 14:00:16 EEST 2024


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Apr  7 15:45:12 2024 +0200| [fee093a5703e994169b04ffc99e6efa63d072b22] | committer: Andreas Rheinhardt

avcodec/ac3enc: Remove disabled code for RealAudio variant of AC-3

Implicitly disabled by 4679a474f06c229b10976d7f0b4eee0613c2715a.
Given that no one has ever complained about this, this commit
removes the now dead code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fee093a5703e994169b04ffc99e6efa63d072b22
---

 doc/encoders.texi    |  3 +--
 libavcodec/ac3enc.c  | 44 ++++++++++++++------------------------------
 libavcodec/ac3enc.h  |  2 --
 libavcodec/eac3enc.c |  9 ++-------
 4 files changed, 17 insertions(+), 41 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 8dd709186e..c08e40ee45 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -144,8 +144,7 @@ If this option is unspecified it is set to @samp{aac_low}.
 
 AC-3 audio encoders.
 
-These encoders implement part of ATSC A/52:2010 and ETSI TS 102 366, as well as
-the undocumented RealAudio 3 (a.k.a. dnet).
+These encoders implement part of ATSC A/52:2010 and ETSI TS 102 366.
 
 The @var{ac3} encoder uses floating-point math, while the @var{ac3_fixed}
 encoder only uses fixed-point integer math. This does not mean that one is
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 32aaf89ec1..d26b52e9b9 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -874,8 +874,8 @@ static av_cold void bit_alloc_init(AC3EncodeContext *s)
     /* compute real values */
     /* currently none of these values change during encoding, so we can just
        set them once at initialization */
-    s->bit_alloc.slow_decay = ff_ac3_slow_decay_tab[s->slow_decay_code] >> s->bit_alloc.sr_shift;
-    s->bit_alloc.fast_decay = ff_ac3_fast_decay_tab[s->fast_decay_code] >> s->bit_alloc.sr_shift;
+    s->bit_alloc.slow_decay = ff_ac3_slow_decay_tab[s->slow_decay_code];
+    s->bit_alloc.fast_decay = ff_ac3_fast_decay_tab[s->fast_decay_code];
     s->bit_alloc.slow_gain  = ff_ac3_slow_gain_tab[s->slow_gain_code];
     s->bit_alloc.db_per_bit = ff_ac3_db_per_bit_tab[s->db_per_bit_code];
     s->bit_alloc.floor      = ff_ac3_floor_tab[s->floor_code];
@@ -1812,8 +1812,6 @@ static void dprint_options(AC3EncodeContext *s)
     switch (s->bitstream_id) {
     case  6: msg = "AC-3 (alt syntax)";       break;
     case  8: msg = "AC-3 (standard)";         break;
-    case  9: msg = "AC-3 (dnet half-rate)";   break;
-    case 10: msg = "AC-3 (dnet quater-rate)"; break;
     case 16: msg = "E-AC-3 (enhanced)";       break;
     default: msg = "ERROR";
     }
@@ -2132,18 +2130,8 @@ int ff_ac3_validate_metadata(AC3EncodeContext *s)
     }
 
     /* set bitstream id for alternate bitstream syntax */
-    if (!s->eac3 && (opt->extended_bsi_1 || opt->extended_bsi_2)) {
-        if (s->bitstream_id > 8 && s->bitstream_id < 11) {
-            if (!s->warned_alternate_bitstream) {
-                av_log(avctx, AV_LOG_WARNING, "alternate bitstream syntax is "
-                       "not compatible with reduced samplerates. writing of "
-                       "extended bitstream information will be disabled.\n");
-                s->warned_alternate_bitstream = 1;
-            }
-        } else {
-            s->bitstream_id = 6;
-        }
-    }
+    if (!s->eac3 && (opt->extended_bsi_1 || opt->extended_bsi_2))
+        s->bitstream_id = 6;
 
     return 0;
 }
@@ -2233,23 +2221,19 @@ static av_cold void set_channel_info(AVCodecContext *avctx)
 static av_cold int validate_options(AC3EncodeContext *s)
 {
     AVCodecContext *avctx = s->avctx;
-    int i, ret, max_sr;
+    int 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
-             decoder that supports half sample rate so we can validate that
-             the generated files are correct. */
-    max_sr = s->eac3 ? 2 : 8;
-    for (i = 0; i <= max_sr; i++) {
-        if ((ff_ac3_sample_rate_tab[i % 3] >> (i / 3)) == avctx->sample_rate)
+    for (int i = 0;; i++) {
+        if (ff_ac3_sample_rate_tab[i] == avctx->sample_rate) {
+            s->bit_alloc.sr_code = i;
             break;
+        }
+        av_assert1(ff_ac3_sample_rate_tab[i] != 0);
     }
     s->sample_rate        = avctx->sample_rate;
-    s->bit_alloc.sr_shift = i / 3;
-    s->bit_alloc.sr_code  = i % 3;
-    s->bitstream_id       = s->eac3 ? 16 : 8 + s->bit_alloc.sr_shift;
+    s->bitstream_id       = s->eac3 ? 16 : 8;
 
     /* select a default bit rate if not set by the user */
     if (!avctx->bit_rate) {
@@ -2297,7 +2281,7 @@ static av_cold int validate_options(AC3EncodeContext *s)
            parameter selection */
         min_br_code = -1;
         min_br_dist = INT64_MAX;
-        for (i = 0; i < 19; i++) {
+        for (int i = 0; i < 19; i++) {
             long long br_dist = llabs(ff_ac3_bitrate_tab[i] * 1000 - avctx->bit_rate);
             if (br_dist < min_br_dist) {
                 min_br_dist = br_dist;
@@ -2313,8 +2297,8 @@ static av_cold int validate_options(AC3EncodeContext *s)
     } else {
         int best_br = 0, best_code = 0;
         long long best_diff = INT64_MAX;
-        for (i = 0; i < 19; i++) {
-            int br   = (ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift) * 1000;
+        for (int i = 0; i < 19; i++) {
+            int br   = ff_ac3_bitrate_tab[i] * 1000;
             long long diff = llabs(br - avctx->bit_rate);
             if (diff < best_diff) {
                 best_br   = br;
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index 1cb1aac4b2..dad53cc4bb 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -256,8 +256,6 @@ typedef struct AC3EncodeContext {
     uint8_t *ref_bap     [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap)
     int ref_bap_set;                                         ///< indicates if ref_bap pointers have been set
 
-    int warned_alternate_bitstream;
-
     /* fixed vs. float function pointers */
     int  (*mdct_init)(struct AC3EncodeContext *s);
 
diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c
index 527f77e33a..5deda083c3 100644
--- a/libavcodec/eac3enc.c
+++ b/libavcodec/eac3enc.c
@@ -134,13 +134,8 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s)
     put_bits(&s->pb,  2, 0);                        /* stream type = independent */
     put_bits(&s->pb,  3, 0);                        /* substream id = 0 */
     put_bits(&s->pb, 11, (s->frame_size / 2) - 1);  /* frame size */
-    if (s->bit_alloc.sr_shift) {
-        put_bits(&s->pb, 2, 0x3);                   /* fscod2 */
-        put_bits(&s->pb, 2, s->bit_alloc.sr_code);  /* sample rate code */
-    } else {
-        put_bits(&s->pb, 2, s->bit_alloc.sr_code);  /* sample rate code */
-        put_bits(&s->pb, 2, s->num_blks_code);      /* number of blocks */
-    }
+    put_bits(&s->pb, 2, s->bit_alloc.sr_code);      /* sample rate code */
+    put_bits(&s->pb, 2, s->num_blks_code);          /* number of blocks */
     put_bits(&s->pb, 3, s->channel_mode);           /* audio coding mode */
     put_bits(&s->pb, 1, s->lfe_on);                 /* LFE channel indicator */
     put_bits(&s->pb, 5, s->bitstream_id);           /* bitstream id (EAC3=16) */



More information about the ffmpeg-cvslog mailing list