diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 09dd0dda7f5519ea2c275aa46084ceef7bec6fe9..a32f0d415ed3d3647daa72fa848321e9d2f3af05 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -822,7 +822,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
         goto fail;
     s->psypp = ff_psy_preprocess_init(avctx);
     s->coder = &ff_aac_coders[s->options.aac_coder];
-    ff_lpc_init(&s->lpc, avctx->frame_size, TNS_MAX_ORDER, FF_LPC_TYPE_LEVINSON);
+    ff_lpc_init(&s->lpc, avctx->frame_size, MAX_LPC_ORDER, FF_LPC_TYPE_LEVINSON);
 
     if (HAVE_MIPSDSPR1)
         ff_aac_coder_init_mips(s);
diff --git a/libavcodec/aacenc_tns.c b/libavcodec/aacenc_tns.c
index e948b32ba88859e591476f6123c069d19f6b109e..5e02c4fb44ba93a28d4e5bc717bdfb8c49d632a2 100644
--- a/libavcodec/aacenc_tns.c
+++ b/libavcodec/aacenc_tns.c
@@ -205,7 +205,7 @@ void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce)
 
         if (sfb_len <= 0 || coef_len <= 0)
             continue;
-        if (coef_start + coef_len > 1024)
+        if (coef_start + coef_len >= 1024)
             coef_len = 1024 - coef_start;
 
         /* LPC */