diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 24ea48e6d3350c29d0278cdbd489a91c61d4952d..88a78ea945597900f93df33fa05a74f394ddff6a 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -1081,11 +1081,6 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
     const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/120.f);
     const float thr_mult = NOISE_LAMBDA_NUMERATOR/lambda;
 
-    /* Coders !twoloop don't reset the band_types */
-    for (w = 0; w < 128; w++)
-        if (sce->band_type[w] == NOISE_BT)
-            sce->band_type[w] = 0;
-
     for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
         start = 0;
         for (g = 0;  g < sce->ics.num_swb; g++) {
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 8d48790745b37717c55f3757c35fb094017df6d1..eac2e92e7ab5c987b654a97bd656d648da47b4d8 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -560,8 +560,13 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
             memset(cpe->ms_mask, 0, sizeof(cpe->ms_mask));
             put_bits(&s->pb, 3, tag);
             put_bits(&s->pb, 4, chan_el_counter[tag]++);
-            for (ch = 0; ch < chans; ch++)
-                coeffs[ch] = cpe->ch[ch].coeffs;
+            for (ch = 0; ch < chans; ch++) {
+                sce = &cpe->ch[ch];
+                coeffs[ch] = sce->coeffs;
+                for (w = 0; w < 128; w++)
+                    if (sce->band_type[w] > RESERVED_BT)
+                        sce->band_type[w] = 0;
+            }
             s->psy.model->analyze(&s->psy, start_ch, coeffs, wi);
             for (ch = 0; ch < chans; ch++) {
                 s->cur_channel = start_ch + ch;