]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/atrac3plus.c
avcodec/avcodec: Remove unnecessary forward declaration
[ffmpeg] / libavcodec / atrac3plus.c
index 81799f72cb4e2821666912356619904d502e8f2f..3a0a0d5f360827d8bc1daf6bc3d4d84cd5557ace 100644 (file)
@@ -50,19 +50,18 @@ static VLC tone_vlc_tabs[7];
 static av_cold void build_canonical_huff(const uint8_t *cb, const uint8_t **xlat,
                                          int *tab_offset, VLC *out_vlc)
 {
-    int i, b;
+    int i, max_len;
     uint8_t bits[256];
     int index = 0;
-    int min_len = *cb++; // get shortest codeword length
-    int max_len = *cb++; // get longest  codeword length
 
-    for (b = min_len; b <= max_len; b++) {
+    for (int b = 1; b <= 12; b++) {
         for (i = *cb++; i > 0; i--) {
             av_assert0(index < 256);
             bits[index]  = b;
             index++;
         }
     }
+    max_len = bits[index - 1];
 
     out_vlc->table = &tables_data[*tab_offset];
     out_vlc->table_allocated = 1 << max_len;
@@ -79,91 +78,40 @@ av_cold void ff_atrac3p_init_vlcs(void)
     int i, tab_offset = 0;
     const uint8_t *xlats;
 
-    static const uint8_t wl_nb_bits[4]  = { 2, 3, 5, 5 };
-    static const uint8_t wl_nb_codes[4] = { 3, 5, 8, 8 };
-    static const uint8_t (*const wl_huffs[4])[2] = {
-        atrac3p_wl_huff1, atrac3p_wl_huff2,
-        atrac3p_wl_huff3, atrac3p_wl_huff4
-    };
-
-    static const uint8_t ct_nb_bits[4]  = { 3, 4, 4, 4 };
-    static const uint8_t ct_nb_codes[4] = { 4, 8, 8, 8 };
-    static const uint8_t (*const ct_huffs[4])[2]  = {
-        atrac3p_ct_huff1, atrac3p_ct_huff2,
-        atrac3p_ct_huff3, atrac3p_ct_huff4
-    };
-
-    static const uint8_t sf_nb_bits[8]  = {  9,  9,  9,  9,  6,  6,  7,  7 };
-    static const uint8_t sf_nb_codes[8] = { 64, 64, 64, 64, 15, 15, 15, 15 };
-    static const uint8_t  (*const sf_huffs[8])[2]  = {
-        atrac3p_sf_huff1, atrac3p_sf_huff2, atrac3p_sf_huff3,
-        atrac3p_sf_huff4, atrac3p_sf_huff5, atrac3p_sf_huff6,
-        atrac3p_sf_huff7, atrac3p_sf_huff8
-    };
-
-    static const uint8_t * const gain_cbs[11] = {
-        atrac3p_huff_gain_npoints1_cb, atrac3p_huff_gain_npoints1_cb,
-        atrac3p_huff_gain_lev1_cb, atrac3p_huff_gain_lev2_cb,
-        atrac3p_huff_gain_lev3_cb, atrac3p_huff_gain_lev4_cb,
-        atrac3p_huff_gain_loc3_cb, atrac3p_huff_gain_loc1_cb,
-        atrac3p_huff_gain_loc4_cb, atrac3p_huff_gain_loc2_cb,
-        atrac3p_huff_gain_loc5_cb
-    };
-
-    static const uint8_t * const tone_cbs[7] = {
-        atrac3p_huff_tonebands_cb,  atrac3p_huff_numwavs1_cb,
-        atrac3p_huff_numwavs2_cb,   atrac3p_huff_wav_ampsf1_cb,
-        atrac3p_huff_wav_ampsf2_cb, atrac3p_huff_wav_ampsf3_cb,
-        atrac3p_huff_freq_cb
-    };
-
+    xlats = atrac3p_wl_ct_xlats;
     for (int i = 0; i < 4; i++) {
-        wl_vlc_tabs[i].table = &tables_data[tab_offset];
-        wl_vlc_tabs[i].table_allocated = 1 << wl_nb_bits[i];
-        tab_offset                    += 1 << wl_nb_bits[i];
-        ff_init_vlc_from_lengths(&wl_vlc_tabs[i], wl_nb_bits[i], wl_nb_codes[i],
-                                 &wl_huffs[i][0][1], 2,
-                                 &wl_huffs[i][0][0], 2, 1,
-                                 0, INIT_VLC_USE_NEW_STATIC, NULL);
-
-        ct_vlc_tabs[i].table = &tables_data[tab_offset];
-        ct_vlc_tabs[i].table_allocated = 1 << ct_nb_bits[i];
-        tab_offset                    += 1 << ct_nb_bits[i];
-        ff_init_vlc_from_lengths(&ct_vlc_tabs[i], ct_nb_bits[i], ct_nb_codes[i],
-                                 &ct_huffs[i][0][1], 2,
-                                 &ct_huffs[i][0][0], 2, 1,
-                                 0, INIT_VLC_USE_NEW_STATIC, NULL);
+        build_canonical_huff(atrac3p_wl_cbs[i], &xlats,
+                             &tab_offset, &wl_vlc_tabs[i]);
+        build_canonical_huff(atrac3p_ct_cbs[i], &xlats,
+                             &tab_offset, &ct_vlc_tabs[i]);
     }
 
-    for (int i = 0; i < 8; i++) {
-        sf_vlc_tabs[i].table = &tables_data[tab_offset];
-        sf_vlc_tabs[i].table_allocated = 1 << sf_nb_bits[i];
-        tab_offset                    += 1 << sf_nb_bits[i];
-        ff_init_vlc_from_lengths(&sf_vlc_tabs[i], sf_nb_bits[i], sf_nb_codes[i],
-                                 &sf_huffs[i][0][1], 2,
-                                 &sf_huffs[i][0][0], 2, 1,
-                                 0, INIT_VLC_USE_NEW_STATIC, NULL);
-    }
+    xlats = atrac3p_sf_xlats;
+    for (int i = 0; i < 8; i++)
+        build_canonical_huff(atrac3p_sf_cbs[i], &xlats,
+                             &tab_offset, &sf_vlc_tabs[i]);
 
     /* build huffman tables for spectrum decoding */
     xlats = atrac3p_spectra_xlats;
     for (i = 0; i < 112; i++) {
-        if (atrac3p_spectra_tabs[i].redirect < 0)
-            build_canonical_huff(atrac3p_spectra_tabs[i].cb,
+        if (atrac3p_spectra_cbs[i][0] >= 0)
+            build_canonical_huff(atrac3p_spectra_cbs[i],
                                  &xlats, &tab_offset, &spec_vlc_tabs[i]);
         else /* Reuse already initialized VLC table */
-            spec_vlc_tabs[i] = spec_vlc_tabs[atrac3p_spectra_tabs[i].redirect];
+            spec_vlc_tabs[i] = spec_vlc_tabs[-atrac3p_spectra_cbs[i][0]];
     }
 
     /* build huffman tables for gain data decoding */
     xlats = atrac3p_gain_xlats;
     for (i = 0; i < 11; i++)
-        build_canonical_huff(gain_cbs[i], &xlats, &tab_offset, &gain_vlc_tabs[i]);
+        build_canonical_huff(atrac3p_gain_cbs[i], &xlats,
+                             &tab_offset, &gain_vlc_tabs[i]);
 
     /* build huffman tables for tone decoding */
     xlats = atrac3p_tone_xlats;
     for (i = 0; i < 7; i++)
-        build_canonical_huff(tone_cbs[i], &xlats, &tab_offset, &tone_vlc_tabs[i]);
+        build_canonical_huff(atrac3p_tone_cbs[i], &xlats,
+                             &tab_offset, &tone_vlc_tabs[i]);
 }
 
 /**