Of all these VLCs here, only VLC.table was really used after init, so use the ff_vlc_init_tables API to get rid of them.
Unified · Split
| @@ -45,12 +45,12 @@ · 44 unmodified lines | ||
| 45 | 45 | #include "svq1.h" |
| 46 | 46 | |
| 47 | 47 | #define SVQ1_BLOCK_TYPE_VLC_BITS 3 |
| 48 | −static VLC svq1_block_type; | |
| 49 | −static VLC svq1_motion_component; | |
| 50 | −static VLC svq1_intra_multistage[6]; | |
| 51 | −static VLC svq1_inter_multistage[6]; | |
| 52 | −static VLC svq1_intra_mean; | |
| 53 | −static VLC svq1_inter_mean; | |
| 48 | +static VLCElem svq1_block_type[8]; | |
| 49 | +static VLCElem svq1_motion_component[176]; | |
| 50 | +static const VLCElem *svq1_intra_multistage[6]; | |
| 51 | +static const VLCElem *svq1_inter_multistage[6]; | |
| 52 | +static VLCElem svq1_intra_mean[632]; | |
| 53 | +static VLCElem svq1_inter_mean[1434]; | |
| 54 | 54 | |
| 55 | 55 | /* motion vector (prediction) */ |
| 56 | 56 | typedef struct svq1_pmv_s { |
| @@ -190,7 +190,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels, · 133 unmodified lines | ||
| 190 | 190 | height = 1 << ((3 + level) / 2); |
| 191 | 191 | |
| 192 | 192 | /* get number of stages (-1 skips vector, 0 for mean only) */ |
| 193 | − stages = get_vlc2(bitbuf, svq1_intra_multistage[level].table, 3, 3) - 1; | |
| 193 | + stages = get_vlc2(bitbuf, svq1_intra_multistage[level], 3, 3) - 1; | |
| 194 | 194 | |
| 195 | 195 | if (stages == -1) { |
| 196 | 196 | for (y = 0; y < height; y++) |
| @@ -206,7 +206,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels, · 9 unmodified lines | ||
| 206 | 206 | } |
| 207 | 207 | av_assert0(stages >= 0); |
| 208 | 208 | |
| 209 | − mean = get_vlc2(bitbuf, svq1_intra_mean.table, 8, 3); | |
| 209 | + mean = get_vlc2(bitbuf, svq1_intra_mean, 8, 3); | |
| 210 | 210 | |
| 211 | 211 | if (stages == 0) { |
| 212 | 212 | for (y = 0; y < height; y++) |
| @@ -257,7 +257,7 @@ static int svq1_decode_block_non_intra(GetBitContext *bitbuf, uint8_t *pixels, · 44 unmodified lines | ||
| 257 | 257 | height = 1 << ((3 + level) / 2); |
| 258 | 258 | |
| 259 | 259 | /* get number of stages (-1 skips vector, 0 for mean only) */ |
| 260 | − stages = get_vlc2(bitbuf, svq1_inter_multistage[level].table, 3, 2) - 1; | |
| 260 | + stages = get_vlc2(bitbuf, svq1_inter_multistage[level], 3, 2) - 1; | |
| 261 | 261 | |
| 262 | 262 | if (stages == -1) |
| 263 | 263 | continue; /* skip vector */ |
| @@ -270,7 +270,7 @@ static int svq1_decode_block_non_intra(GetBitContext *bitbuf, uint8_t *pixels, · 6 unmodified lines | ||
| 270 | 270 | } |
| 271 | 271 | av_assert0(stages >= 0); |
| 272 | 272 | |
| 273 | − mean = get_vlc2(bitbuf, svq1_inter_mean.table, 9, 3) - 256; | |
| 273 | + mean = get_vlc2(bitbuf, svq1_inter_mean, 9, 3) - 256; | |
| 274 | 274 | |
| 275 | 275 | if (buggy) { |
| 276 | 276 | if (mean == -128) |
| @@ -307,7 +307,7 @@ static int svq1_decode_motion_vector(GetBitContext *bitbuf, svq1_pmv *mv, · 30 unmodified lines | ||
| 307 | 307 | |
| 308 | 308 | for (i = 0; i < 2; i++) { |
| 309 | 309 | /* get motion code */ |
| 310 | − diff = get_vlc2(bitbuf, svq1_motion_component.table, 7, 2); | |
| 310 | + diff = get_vlc2(bitbuf, svq1_motion_component, 7, 2); | |
| 311 | 311 | if (diff < 0) |
| 312 | 312 | return AVERROR_INVALIDDATA; |
| 313 | 313 | else if (diff) { |
| @@ -472,7 +472,7 @@ static int svq1_decode_delta_block(AVCodecContext *avctx, HpelDSPContext *hdsp, · 158 unmodified lines | ||
| 472 | 472 | int result = 0; |
| 473 | 473 | |
| 474 | 474 | /* get block type */ |
| 475 | − block_type = get_vlc2(bitbuf, svq1_block_type.table, | |
| 475 | + block_type = get_vlc2(bitbuf, svq1_block_type, | |
| 476 | 476 | SVQ1_BLOCK_TYPE_VLC_BITS, 1); |
| 477 | 477 | |
| 478 | 478 | /* reset motion vectors */ |
| @@ -779,41 +779,35 @@ static int svq1_decode_frame(AVCodecContext *avctx, AVFrame *cur, · 300 unmodified lines | ||
| 779 | 779 | |
| 780 | 780 | static av_cold void svq1_static_init(void) |
| 781 | 781 | { |
| 782 | − VLC_INIT_STATIC(&svq1_block_type, SVQ1_BLOCK_TYPE_VLC_BITS, 4, | |
| 783 | − &ff_svq1_block_type_vlc[0][1], 2, 1, | |
| 784 | − &ff_svq1_block_type_vlc[0][0], 2, 1, 8); | |
| 785 | − | |
| 786 | − VLC_INIT_STATIC(&svq1_motion_component, 7, 33, | |
| 787 | − &ff_mvtab[0][1], 2, 1, | |
| 788 | − &ff_mvtab[0][0], 2, 1, 176); | |
| 789 | − | |
| 790 | − for (int i = 0, offset = 0; i < 6; i++) { | |
| 791 | − static const uint8_t sizes[2][6] = { { 14, 10, 14, 18, 16, 18 }, | |
| 792 | − { 10, 10, 14, 14, 14, 16 } }; | |
| 793 | − static VLCElem table[168]; | |
| 794 | − svq1_intra_multistage[i].table = &table[offset]; | |
| 795 | − svq1_intra_multistage[i].table_allocated = sizes[0][i]; | |
| 796 | − offset += sizes[0][i]; | |
| 797 | − vlc_init(&svq1_intra_multistage[i], 3, 8, | |
| 798 | − &ff_svq1_intra_multistage_vlc[i][0][1], 2, 1, | |
| 799 | − &ff_svq1_intra_multistage_vlc[i][0][0], 2, 1, | |
| 800 | − VLC_INIT_USE_STATIC); | |
| 801 | − svq1_inter_multistage[i].table = &table[offset]; | |
| 802 | − svq1_inter_multistage[i].table_allocated = sizes[1][i]; | |
| 803 | − offset += sizes[1][i]; | |
| 804 | − vlc_init(&svq1_inter_multistage[i], 3, 8, | |
| 805 | − &ff_svq1_inter_multistage_vlc[i][0][1], 2, 1, | |
| 806 | − &ff_svq1_inter_multistage_vlc[i][0][0], 2, 1, | |
| 807 | − VLC_INIT_USE_STATIC); | |
| 782 | + static VLCElem table[168]; | |
| 783 | + VLCInitState state = VLC_INIT_STATE(table); | |
| 784 | + | |
| 785 | + VLC_INIT_STATIC_TABLE(svq1_block_type, SVQ1_BLOCK_TYPE_VLC_BITS, 4, | |
| 786 | + &ff_svq1_block_type_vlc[0][1], 2, 1, | |
| 787 | + &ff_svq1_block_type_vlc[0][0], 2, 1, 0); | |
| 788 | + | |
| 789 | + VLC_INIT_STATIC_TABLE(svq1_motion_component, 7, 33, | |
| 790 | + &ff_mvtab[0][1], 2, 1, | |
| 791 | + &ff_mvtab[0][0], 2, 1, 0); | |
| 792 | + | |
| 793 | + for (int i = 0; i < 6; i++) { | |
| 794 | + svq1_intra_multistage[i] = | |
| 795 | + ff_vlc_init_tables(&state, 3, 8, | |
| 796 | + &ff_svq1_intra_multistage_vlc[i][0][1], 2, 1, | |
| 797 | + &ff_svq1_intra_multistage_vlc[i][0][0], 2, 1, 0); | |
| 798 | + svq1_inter_multistage[i] = | |
| 799 | + ff_vlc_init_tables(&state, 3, 8, | |
| 800 | + &ff_svq1_inter_multistage_vlc[i][0][1], 2, 1, | |
| 801 | + &ff_svq1_inter_multistage_vlc[i][0][0], 2, 1, 0); | |
| 808 | 802 | } |
| 809 | 803 | |
| 810 | − VLC_INIT_STATIC(&svq1_intra_mean, 8, 256, | |
| 811 | − &ff_svq1_intra_mean_vlc[0][1], 4, 2, | |
| 812 | − &ff_svq1_intra_mean_vlc[0][0], 4, 2, 632); | |
| 804 | + VLC_INIT_STATIC_TABLE(svq1_intra_mean, 8, 256, | |
| 805 | + &ff_svq1_intra_mean_vlc[0][1], 4, 2, | |
| 806 | + &ff_svq1_intra_mean_vlc[0][0], 4, 2, 0); | |
| 813 | 807 | |
| 814 | − VLC_INIT_STATIC(&svq1_inter_mean, 9, 512, | |
| 815 | − &ff_svq1_inter_mean_vlc[0][1], 4, 2, | |
| 816 | − &ff_svq1_inter_mean_vlc[0][0], 4, 2, 1434); | |
| 808 | + VLC_INIT_STATIC_TABLE(svq1_inter_mean, 9, 512, | |
| 809 | + &ff_svq1_inter_mean_vlc[0][1], 4, 2, | |
| 810 | + &ff_svq1_inter_mean_vlc[0][0], 4, 2, 0); | |
| 817 | 811 | } |
| 818 | 812 | |
| 819 | 813 | static av_cold int svq1_decode_init(AVCodecContext *avctx) |