This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 0efac66e7e75aabd26ee63c16c6a198337334b0e
Author:     Lynne <[email protected]>
AuthorDate: Wed Jun 17 17:37:13 2026 +0900
Commit:     Lynne <[email protected]>
CommitDate: Wed Jul 1 21:05:27 2026 +0900

    aacenc: use the NMR coder by default
    
    The old coders will soon be removed.
---
 libavcodec/aaccoder.c | 43 ++++++++-----------------------------------
 libavcodec/aacenc.c   | 10 ++++++----
 2 files changed, 14 insertions(+), 39 deletions(-)

diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 18076bda78..7aead4d8b4 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -503,25 +503,12 @@ static void search_for_pns(AACEncContext *s, 
AVCodecContext *avctx, SingleChanne
     const float dist_bias = av_clipf(4.f * 120 / lambda, 0.25f, 4.0f);
     const float pns_transient_energy_r = FFMIN(0.7f, lambda / 140.f);
 
-    int refbits = avctx->bit_rate * 1024.0 / avctx->sample_rate
-        / ((avctx->flags & AV_CODEC_FLAG_QSCALE) ? 2.0f : 
avctx->ch_layout.nb_channels)
-        * (lambda / 120.f);
-
-    /** Keep this in sync with twoloop's cutoff selection */
-    float rate_bandwidth_multiplier = 1.5f;
     int prev = -1000, prev_sf = -1;
-    int frame_bit_rate = (avctx->flags & AV_CODEC_FLAG_QSCALE)
-        ? (refbits * rate_bandwidth_multiplier * avctx->sample_rate / 1024)
-        : (avctx->bit_rate / avctx->ch_layout.nb_channels);
-
-    frame_bit_rate *= 1.15f;
-
-    if (avctx->cutoff > 0) {
-        bandwidth = avctx->cutoff;
-    } else {
-        bandwidth = FFMAX(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, 
avctx->sample_rate));
-    }
 
+    /* PNS candidacy must use the coder's actual coding bandwidth 
(s->bandwidth,
+     * fixed at init), not a separate heuristic, or it evaluates a different 
band
+     * range than the coder later codes. */
+    bandwidth = s->bandwidth;
     cutoff = bandwidth * 2 * wlen / avctx->sample_rate;
 
     memcpy(sce->band_alt, sce->band_type, sizeof(sce->band_type));
@@ -640,24 +627,10 @@ static void mark_pns(AACEncContext *s, AVCodecContext 
*avctx, SingleChannelEleme
     const float spread_threshold = FFMIN(0.75f, 
NOISE_SPREAD_THRESHOLD*FFMAX(0.5f, lambda/100.f));
     const float pns_transient_energy_r = FFMIN(0.7f, lambda / 140.f);
 
-    int refbits = avctx->bit_rate * 1024.0 / avctx->sample_rate
-        / ((avctx->flags & AV_CODEC_FLAG_QSCALE) ? 2.0f : 
avctx->ch_layout.nb_channels)
-        * (lambda / 120.f);
-
-    /** Keep this in sync with twoloop's cutoff selection */
-    float rate_bandwidth_multiplier = 1.5f;
-    int frame_bit_rate = (avctx->flags & AV_CODEC_FLAG_QSCALE)
-        ? (refbits * rate_bandwidth_multiplier * avctx->sample_rate / 1024)
-        : (avctx->bit_rate / avctx->ch_layout.nb_channels);
-
-    frame_bit_rate *= 1.15f;
-
-    if (avctx->cutoff > 0) {
-        bandwidth = avctx->cutoff;
-    } else {
-        bandwidth = FFMAX(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, 
avctx->sample_rate));
-    }
-
+    /* PNS candidacy must use the coder's actual coding bandwidth 
(s->bandwidth,
+     * fixed at init), not a separate heuristic, or it evaluates a different 
band
+     * range than the coder later codes (NMR relies on this output directly). 
*/
+    bandwidth = s->bandwidth;
     cutoff = bandwidth * 2 * wlen / avctx->sample_rate;
 
     memcpy(sce->band_alt, sce->band_type, sizeof(sce->band_type));
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index eb57e4212a..468fdf222c 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -1591,9 +1591,11 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
         if (s->options.coder == AAC_CODER_NMR && frame_br >= 32000) {
             static const int rates[] = { 32000, 48000, 64000, 96000 };
             static const int bws[]   = { 14000, 15000, 18000, 20000 };
-            for (int i = 0; i < FF_ARRAY_ELEMS(rates) - 2 && frame_br > 
rates[i + 1]; i++);
-            s->bandwidth = bws[i] + (int)((int64_t)(bws[i + 1] - bws[i]) *
-                                          (frame_br - rates[i]) / (rates[i + 
1] - rates[i]));
+            int bw_i = 0;
+            for (; bw_i < FF_ARRAY_ELEMS(rates) - 2 && frame_br > rates[bw_i + 
1]; bw_i++)
+                ;
+            s->bandwidth = bws[bw_i] + (int)((int64_t)(bws[bw_i + 1] - 
bws[bw_i]) *
+                                             (frame_br - rates[bw_i]) / 
(rates[bw_i + 1] - rates[bw_i]));
             s->bandwidth = FFMIN3(s->bandwidth, 22000, avctx->sample_rate / 2);
         } else {
             if (s->options.pns || s->options.intensity_stereo)
@@ -1638,7 +1640,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
 
 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
 static const AVOption aacenc_options[] = {
-    {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.coder), 
AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, 0, AAC_CODER_NB-1, AACENC_FLAGS, 
.unit = "coder"},
+    {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.coder), 
AV_OPT_TYPE_INT, {.i64 = AAC_CODER_NMR}, 0, AAC_CODER_NB-1, AACENC_FLAGS, .unit 
= "coder"},
         {"twoloop",  "Two loop searching method", 0, AV_OPT_TYPE_CONST, {.i64 
= AAC_CODER_TWOLOOP}, INT_MIN, INT_MAX, AACENC_FLAGS, .unit = "coder"},
         {"fast",     "Fast search",               0, AV_OPT_TYPE_CONST, {.i64 
= AAC_CODER_FAST},    INT_MIN, INT_MAX, AACENC_FLAGS, .unit = "coder"},
         {"nmr",      "Noise-to-mask ratio scalefactor trellis", 0, 
AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_NMR}, INT_MIN, INT_MAX, AACENC_FLAGS, 
.unit = "coder"},

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to