Browse code

Use new style static VLC tables for IMC decoder. Also fixes a memleak due to the previous in-context tables not being freed.

Originally committed as revision 14182 to svn://svn.ffmpeg.org/ffmpeg/trunk

Reimar Döffinger authored on 2008/07/13 00:02:40
Showing 1 changed files
... ...
@@ -79,7 +79,6 @@ typedef struct {
79 79
     int codewords[COEFFS];     ///< raw codewords read from bitstream
80 80
     float sqrt_tab[30];
81 81
     GetBitContext gb;
82
-    VLC huffman_vlc[4][4];
83 82
     int decoder_reset;
84 83
     float one_div_log2;
85 84
 
... ...
@@ -89,6 +88,15 @@ typedef struct {
89 89
     DECLARE_ALIGNED_16(float, out_samples[COEFFS]);
90 90
 } IMCContext;
91 91
 
92
+static VLC huffman_vlc[4][4];
93
+
94
+#define VLC_TABLES_SIZE 9512
95
+
96
+static const int vlc_offsets[17] = {
97
+    0,     640, 1156, 1732, 2308, 2852, 3396, 3924,
98
+    4452, 5220, 5860, 6628, 7268, 7908, 8424, 8936, VLC_TABLES_SIZE};
99
+
100
+static VLC_TYPE vlc_tables[VLC_TABLES_SIZE][2];
92 101
 
93 102
 static av_cold int imc_decode_init(AVCodecContext * avctx)
94 103
 {
... ...
@@ -135,9 +143,11 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
135 135
     /* initialize the VLC tables */
136 136
     for(i = 0; i < 4 ; i++) {
137 137
         for(j = 0; j < 4; j++) {
138
-            init_vlc (&q->huffman_vlc[i][j], 9, imc_huffman_sizes[i],
138
+            huffman_vlc[i][j].table = vlc_tables[vlc_offsets[i * 4 + j]];
139
+            huffman_vlc[i][j].table_allocated = vlc_offsets[i * 4 + j + 1] - vlc_offsets[i * 4 + j];
140
+            init_vlc(&huffman_vlc[i][j], 9, imc_huffman_sizes[i],
139 141
                      imc_huffman_lens[i][j], 1, 1,
140
-                     imc_huffman_bits[i][j], 2, 2, 1);
142
+                     imc_huffman_bits[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC);
141 143
         }
142 144
     }
143 145
     q->one_div_log2 = 1/log(2);
... ...
@@ -210,10 +220,10 @@ static void imc_read_level_coeffs(IMCContext* q, int stream_format_code, int* le
210 210
     int s;
211 211
 
212 212
     s = stream_format_code >> 1;
213
-    hufftab[0] = &q->huffman_vlc[s][0];
214
-    hufftab[1] = &q->huffman_vlc[s][1];
215
-    hufftab[2] = &q->huffman_vlc[s][2];
216
-    hufftab[3] = &q->huffman_vlc[s][3];
213
+    hufftab[0] = &huffman_vlc[s][0];
214
+    hufftab[1] = &huffman_vlc[s][1];
215
+    hufftab[2] = &huffman_vlc[s][2];
216
+    hufftab[3] = &huffman_vlc[s][3];
217 217
     cb_sel = imc_cb_select[s];
218 218
 
219 219
     if(stream_format_code & 4)