diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c
index 57c3301a1272cba31a3948aca9f10df64b54a3bd..814a0b081af2c6286a1b3acb9e5c106aaa9c22c1 100644
--- a/libavcodec/twinvq.c
+++ b/libavcodec/twinvq.c
@@ -1014,6 +1014,7 @@ static av_cold void init_bitstream_params(TwinContext *tctx)
     int bsize_no_main_cb[3];
     int bse_bits[3];
     int i;
+    enum FrameType frametype;
 
     for (i = 0; i < 3; i++)
         // +1 for history usage switch
@@ -1062,8 +1063,8 @@ static av_cold void init_bitstream_params(TwinContext *tctx)
         tctx->length_change[i] = num_rounded_up;
     }
 
-    for (i = 0; i < 4; i++)
-        construct_perm_table(tctx, i);
+    for (frametype = FT_SHORT; frametype <= FT_PPC; frametype++)
+        construct_perm_table(tctx, frametype);
 }
 
 static av_cold int twin_decode_init(AVCodecContext *avctx)