[FFmpeg-soc] [soc]: r3131 - mlp/mlpenc.c

ramiro subversion at mplayerhq.hu
Sun Aug 10 15:07:35 CEST 2008


Author: ramiro
Date: Sun Aug 10 15:07:34 2008
New Revision: 3131

Log:
Split huffman_tables into huffman_codes and huffman_bits.

Modified:
   mlp/mlpenc.c

Modified: mlp/mlpenc.c
==============================================================================
--- mlp/mlpenc.c	(original)
+++ mlp/mlpenc.c	Sun Aug 10 15:07:34 2008
@@ -625,20 +625,42 @@ static void apply_filter(MLPEncodeContex
     }
 }
 
-static const uint8_t huffman_tables[3][18][2] = {
-    {    /* huffman table 0, -7 - +10 */
-        {0x01, 9}, {0x01, 8}, {0x01, 7}, {0x01, 6}, {0x01, 5}, {0x01, 4}, {0x01, 3},
-        {0x04, 3}, {0x05, 3}, {0x06, 3}, {0x07, 3},
-        {0x03, 3}, {0x05, 4}, {0x09, 5}, {0x11, 6}, {0x21, 7}, {0x41, 8}, {0x81, 9},
-    }, { /* huffman table 1, -7 - +8 */
-        {0x01, 9}, {0x01, 8}, {0x01, 7}, {0x01, 6}, {0x01, 5}, {0x01, 4}, {0x01, 3},
-        {0x02, 2}, {0x03, 2},
-        {0x03, 3}, {0x05, 4}, {0x09, 5}, {0x11, 6}, {0x21, 7}, {0x41, 8}, {0x81, 9},
-    }, { /* huffman table 2, -7 - +7 */
-        {0x01, 9}, {0x01, 8}, {0x01, 7}, {0x01, 6}, {0x01, 5}, {0x01, 4}, {0x01, 3},
-        {0x01, 1},
-        {0x03, 3}, {0x05, 4}, {0x09, 5}, {0x11, 6}, {0x21, 7}, {0x41, 8}, {0x81, 9},
-    }
+static const uint8_t huffman_bits0[] = {
+    9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9,
+};
+
+static const uint8_t huffman_bits1[] = {
+    9, 8, 7, 6, 5, 4, 3,    2, 2,    3, 4, 5, 6, 7, 8, 9,
+};
+
+static const uint8_t huffman_bits2[] = {
+    9, 8, 7, 6, 5, 4, 3,      1,     3, 4, 5, 6, 7, 8, 9,
+};
+
+static const uint8_t *huffman_bits[] = {
+    huffman_bits0, huffman_bits1, huffman_bits2,
+};
+
+static const uint8_t huffman_codes0[] = {
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+    0x04, 0x05, 0x06, 0x07,
+    0x03, 0x05, 0x09, 0x11, 0x21, 0x41, 0x81,
+};
+
+static const uint8_t huffman_codes1[] = {
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+    0x02, 0x03,
+    0x03, 0x05, 0x09, 0x11, 0x21, 0x41, 0x81,
+};
+
+static const uint8_t huffman_codes2[] = {
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+    0x01,
+    0x03, 0x05, 0x09, 0x11, 0x21, 0x41, 0x81,
+};
+
+static const uint8_t *huffman_codes[] = {
+    huffman_codes0, huffman_codes1, huffman_codes2,
 };
 
 static int codebook_extremes[3][2] = {
@@ -741,7 +763,7 @@ static void codebook_bits_offset(MLPEnco
 
         sample >>= lsb_bits;
 
-        bitcount += huffman_tables[codebook][sample + codebook_offset][1];
+        bitcount += huffman_bits[codebook][sample + codebook_offset];
     }
 
     if (codebook == 2)
@@ -887,8 +909,8 @@ static void write_block_data(MLPEncodeCo
 
             if (codebook[ch] >= 0) {
                 int8_t vlc = (sample >> lsb_bits[ch]) + codebook_offset[ch];
-                put_bits(pb, huffman_tables[codebook[ch]][vlc][1],
-                             huffman_tables[codebook[ch]][vlc][0]);
+                put_bits(pb, huffman_bits [codebook[ch]][vlc],
+                             huffman_codes[codebook[ch]][vlc]);
             }
 
             put_sbits(pb, lsb_bits[ch], sample);



More information about the FFmpeg-soc mailing list