]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpc8huff.h
avcodec/mpc8: Reduce the size of the length tables to initialize VLCs
[ffmpeg] / libavcodec / mpc8huff.h
index 687c9f7e98700049919abfe63579741db642f00d..8838751fd68c75894803f1b5f42db3565807df97 100644 (file)
@@ -24,6 +24,8 @@
 
 #include <stdint.h>
 
+#define MPC8_MAX_VLC_SIZE 256
+
 #define MPC8_BANDS_SIZE 33
 #define MPC8_BANDS_BITS 9
 
@@ -31,9 +33,8 @@ static const uint8_t mpc8_bands_syms[MPC8_BANDS_SIZE] = {
     13, 19, 10, 11, 12, 14, 15, 16, 17, 18, 20, 21, 22,  9, 23, 24, 25,  8, 26,
     27,  7, 28,  5,  6, 29,  4,  3, 30,  2, 31,  1, 32,  0
 };
-static const uint8_t mpc8_bands_bits[MPC8_BANDS_SIZE] = {
-    13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10,
-    10,  9,  9,  8,  8,  8,  7,  6,  6,  5,  5,  3,  2,  1
+static const uint8_t mpc8_bands_len_counts[16] = {
+    1,  1,  1,  0,  2,  2,  1,  3,  2,  3,  4, 11,  2,  0,  0,  0
 };
 
 #define MPC8_SCFI0_SIZE 4
@@ -42,9 +43,6 @@ static const uint8_t mpc8_bands_bits[MPC8_BANDS_SIZE] = {
 static const uint8_t mpc8_scfi0_syms[MPC8_SCFI0_SIZE] = {
      0,  1,  3,  2
 };
-static const uint8_t mpc8_scfi0_bits[MPC8_SCFI0_SIZE] = {
-     3,  3,  2,  1
-};
 
 #define MPC8_SCFI1_SIZE 16
 #define MPC8_SCFI1_BITS 7
@@ -52,8 +50,10 @@ static const uint8_t mpc8_scfi0_bits[MPC8_SCFI0_SIZE] = {
 static const uint8_t mpc8_scfi1_syms[MPC8_SCFI1_SIZE] = {
      1,  4,  0,  2,  3,  8, 12,  5,  6,  7,  9, 13, 11, 14, 10, 15
 };
-static const uint8_t mpc8_scfi1_bits[MPC8_SCFI1_SIZE] = {
-     7,  7,  6,  6,  6,  6,  6,  5,  5,  5,  5,  5,  3,  3,  2,  2
+
+static const uint8_t mpc8_scfi_len_counts[2][16] = {
+    {  1,  1,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0  },
+    {  0,  2,  2,  0,  5,  5,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0  },
 };
 
 #define MPC8_DSCF0_SIZE 64
@@ -65,12 +65,6 @@ static const uint8_t mpc8_dscf0_syms[MPC8_DSCF0_SIZE] = {
     17, 18, 41, 42, 43, 19, 20, 21, 22, 40, 23, 24, 38, 39, 25, 28, 37, 26, 27,
     29, 30, 32, 36, 33, 34, 35,
 };
-static const uint8_t mpc8_dscf0_bits[MPC8_DSCF0_SIZE] = {
-    14, 14, 14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11,
-    11, 10, 10, 10, 10, 10, 10, 10, 10, 10,  9,  9,  9,  9,  9,  9,  9,  8,  8,
-     8,  8,  8,  8,  8,  7,  7,  7,  7,  7,  6,  6,  6,  6,  5,  5,  5,  4,  4,
-     4,  4,  4,  4,  3,  3,  3
-};
 
 #define MPC8_DSCF1_SIZE 65
 #define MPC8_DSCF1_BITS 9
@@ -81,11 +75,10 @@ static const uint8_t mpc8_dscf1_syms[MPC8_DSCF1_SIZE] = {
     44, 45, 18, 19, 20, 41, 42, 21, 22, 39, 40, 23, 24, 38, 25, 37, 26, 35, 36,
     27, 28, 34, 29, 30, 31, 32, 33,
 };
-static const uint8_t mpc8_dscf1_bits[MPC8_DSCF1_SIZE] = {
-    15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 12, 12,
-    12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10,
-    10, 10,  9,  9,  9,  9,  9,  8,  8,  8,  8,  7,  7,  7,  6,  6,  5,  5,  5,
-     4,  4,  4,  3,  3,  3,  3,  3
+
+static const uint8_t mpc8_dscf_len_counts[2][16] = {
+    {  0,  0,  3,  6,  3,  4,  5,  7,  7,  9,  6,  5,  3,  6,  0,  0  },
+    {  0,  0,  5,  3,  3,  2,  3,  4,  5,  7,  7,  9,  6,  5,  6,  0  },
 };
 
 #define MPC8_RES_SIZE 17
@@ -99,13 +92,10 @@ static const uint8_t mpc8_res_syms[2][MPC8_RES_SIZE] = {
      8,  9, 10, 11,  7, 12,  6, 13,  5,  4, 14,  3, 15,  2,  0,  1, 16,
   }
 };
-static const uint8_t mpc8_res_bits[2][MPC8_RES_SIZE] = {
-  {
-    16, 16, 15, 14, 13, 12, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1
-  },
-  {
-    14, 14, 14, 14, 12, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,  2,  2
-  }
+
+static const uint8_t mpc8_res_len_counts[2][16] = {
+    {  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2  },
+    {  0,  3,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  4,  0,  0  },
 };
 
 #define MPC8_Q1_SIZE 19
@@ -114,8 +104,9 @@ static const uint8_t mpc8_res_bits[2][MPC8_RES_SIZE] = {
 static const uint8_t mpc8_q1_syms[MPC8_Q1_SIZE] = {
      17, 18, 16, 15, 14, 13, 12,  0, 11,  1,  2,  8,  9, 10,  3,  4,  5,  6,  7,
 };
-static const uint8_t mpc8_q1_bits[MPC8_Q1_SIZE] = {
-    12, 12, 11, 10,  9,  8,  7,  6,  5,  4,  4,  4,  4,  4,  3,  3,  3,  3,  3
+
+static const uint8_t mpc8_q1_len_counts[16] = {
+    0,  0,  5,  5,  1,  1,  1,  1,  1,  1,  1,  2,  0,  0,  0,  0
 };
 
 #define MPC8_Q9UP_SIZE 256
@@ -141,21 +132,9 @@ static const uint8_t mpc8_q9up_syms[MPC8_Q9UP_SIZE] = {
     134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 127,
     128,
 };
-static const uint8_t mpc8_q9up_bits[MPC8_Q9UP_SIZE] = {
-    11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10,  9,  9,  9,  9,  9,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
-     7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
-     7,  7,  7,  7,  7,  7,  7,  6,  6
+
+static const uint8_t mpc8_q9up_len_counts[16] = {
+    0,  0,  0,  0,  0,  2, 38, 134, 71,  9,  2,  0,  0,  0,  0,  0
 };
 
 #define MPC8_Q2_SIZE 125
@@ -185,35 +164,18 @@ static const uint8_t mpc8_q2_syms[2][MPC8_Q2_SIZE] = {
      82,  86,  87,  92,  62,
 }
 };
-static const uint8_t mpc8_q2_bits[2][MPC8_Q2_SIZE] = {
-{
-    13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10,
-    10, 10, 10, 10, 10, 10,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  7,  7,  7,
-     7,  7,  7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
-     6,  6,  6,  6,  4,  4,  4,  4,  4,  4,  3
-},
-{
-    12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  7,  7,  7,
-     7,  7,  7,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  5,  5,  5,  5,  5,  5,
-     5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  4
-}
+
+static const uint8_t mpc8_q2_len_counts[2][16] = {
+    {  0,  0,  1,  6,  0, 17,  9, 24, 24,  9, 27,  4,  4,  0,  0,  0  },
+    {  0,  0,  0,  1, 16, 10,  6, 48,  9, 27,  4,  4,  0,  0,  0,  0  },
 };
 
 #define MPC8_Q3_SIZE 49
 #define MPC8_Q3_BITS 9
 #define MPC8_Q3_OFFSET -48
 
-static const uint8_t mpc8_q3_bits[MPC8_Q3_SIZE] = {
-    9,  9,  9,  9,  8,  8,  8,  8,  8,  8,  8,  8,  7,  7,  7,  7,  7,  7,  7,
-    7,  7,  7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  5,  5,
-    5,  5,  5,  5,  4,  4,  4,  4,  4,  4,  3,
+static const uint8_t mpc8_q3_len_counts[16] = {
+    0,  0,  1,  6,  6, 11, 13,  8,  4,  0,  0,  0,  0,  0,  0,  0
 };
 static const uint8_t mpc8_q3_syms[MPC8_Q3_SIZE] = {
      13,   3, 109,  99,  14,   2,  29,  19,  93,  83, 110,  98,  15,   0,   1,
@@ -226,12 +188,8 @@ static const uint8_t mpc8_q3_syms[MPC8_Q3_SIZE] = {
 #define MPC8_Q4_BITS 9
 #define MPC8_Q4_OFFSET -64
 
-static const uint8_t mpc8_q4_bits[MPC8_Q4_SIZE] = {
-    10, 10, 10, 10,  9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  7,  7,  7,  7,  7,  7,  7,
-     7,  7,  7,  7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
-     6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  5,  5,  5,  5,  5,  5,  5,  5,
-     5,  5,  5,  5,  4,
+static const uint8_t mpc8_q4_len_counts[16] = {
+    0,  0,  0,  1, 12, 23, 14, 19,  8,  4,  0,  0,  0,  0,  0,  0
 };
 static const uint8_t mpc8_q4_syms[MPC8_Q4_SIZE] = {
      12,   4, 140, 132,  13,   3,  28,  20, 124, 116, 141, 131,  14,   1,   2,
@@ -254,13 +212,10 @@ static const uint8_t mpc8_q5_syms[2][MPC8_Q5_SIZE] = {
      0,  1, 13, 14,  2, 12,  3,  4, 10, 11,  5,  6,  7,  8,  9,
 }
 };
-static const uint8_t mpc8_q5_bits[2][MPC8_Q5_SIZE] = {
-{
-    7,  7,  7,  7,  6,  6,  5,  5,  4,  4,  3,  3,  3,  3,  2
-},
-{
-    6,  6,  6,  6,  5,  5,  4,  4,  4,  4,  3,  3,  3,  3,  3
-}
+
+static const uint8_t mpc8_q5_len_counts[2][16] = {
+    {  0,  1,  4,  2,  2,  2,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0  },
+    {  0,  0,  5,  4,  2,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0  },
 };
 
 #define MPC8_Q6_SIZE 31
@@ -277,15 +232,10 @@ static const uint8_t mpc8_q6_syms[2][MPC8_Q6_SIZE] = {
      23, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
 }
 };
-static const uint8_t mpc8_q6_bits[2][MPC8_Q6_SIZE] = {
-{
-    9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8,  7,  7,  6,  6,  6,  6,  6,
-    6,  6,  5,  5,  5,  4,  4,  4,  4,  3,  3,  2
-},
-{
-    8,  8,  8,  8,  7,  7,  7,  7,  7,  7,  6,  6,  6,  6,  5,  5,  5,  5,  5,
-    5,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4
-}
+
+static const uint8_t mpc8_q6_len_counts[2][16] = {
+    {  0,  1,  2,  4,  3,  7,  2,  4,  8,  0,  0,  0,  0,  0,  0,  0  },
+    {  0,  0,  0, 11,  6,  4,  6,  4,  0,  0,  0,  0,  0,  0,  0,  0  },
 };
 
 #define MPC8_Q7_SIZE 63
@@ -306,19 +256,10 @@ static const uint8_t mpc8_q7_syms[2][MPC8_Q7_SIZE] = {
      36, 37, 38, 39, 40, 41,
 }
 };
-static const uint8_t mpc8_q7_bits[2][MPC8_Q7_SIZE] = {
-{
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  5,  5,  5,
-     5,  4,  4,  3,  3,  2
-},
-{
-     9,  9,  9,  9,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  7,
-     7,  7,  7,  7,  7,  7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
-     6,  6,  6,  6,  6,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
-     5,  5,  5,  5,  5,  5
-}
+
+static const uint8_t mpc8_q7_len_counts[2][MPC8_Q7_SIZE] = {
+    {  0,  1,  2,  2,  4,  6, 10, 10, 12, 16,  0,  0,  0,  0,  0,  0  },
+    {  0,  0,  0,  0, 20, 15, 10, 14,  4,  0,  0,  0,  0,  0,  0,  0  },
 };
 
 #define MPC8_Q8_SIZE 127
@@ -349,25 +290,10 @@ static const uint8_t mpc8_q8_syms[2][MPC8_Q8_SIZE] = {
      69,  70,  71,  72,  73,  74,  76,
 }
 };
-static const uint8_t mpc8_q8_bits[2][MPC8_Q8_SIZE] = {
-{
-    12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-    11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  7,  7,  7,  7,  7,  7,  7,  7,  6,  6,
-     6,  6,  6,  6,  6,  6,  5,  5,  5,  4,  3,  3,  2
-},
-{
-     9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
-     8,  8,  8,  8,  8,  8,  8,  8,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
-     7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
-     7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
-     7,  7,  7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
-     6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6
-}
+
+static const uint8_t mpc8_q8_len_counts[2][16] = {
+    {  0,  1,  2,  1,  3,  8,  8, 15, 24, 42, 17,  6,  0,  0,  0,  0  },
+    {  0,  0,  0,  0,  0, 26, 55, 38,  8,  0,  0,  0,  0,  0,  0,  0  },
 };
 
 #endif /* AVCODEC_MPC8HUFF_H */