Unified · Split
| @@ -246,7 +246,8 @@ static int8_t cavlc_level_tab[7][1<<LEVEL_TAB_BITS][2]; · 245 unmodified lines | ||
| 246 | 246 | #define RUN_VLC_BITS 3 |
| 247 | 247 | #define RUN7_VLC_BITS 6 |
| 248 | 248 | |
| 249 | −static const VLCElem *coeff_token_vlc[4]; | |
| 249 | +/// 17 pointers to only four different VLCs | |
| 250 | +static const VLCElem *coeff_token_vlc[17]; | |
| 250 | 251 | |
| 251 | 252 | static VLCElem chroma_dc_coeff_token_vlc_table[256]; |
| 252 | 253 | |
| @@ -313,6 +314,7 @@ static av_cold void init_cavlc_level_tab(void){ · 60 unmodified lines | ||
| 313 | 314 | |
| 314 | 315 | av_cold void ff_h264_decode_init_vlc(void) |
| 315 | 316 | { |
| 317 | + const VLCElem *coeff_token_vlc_original[4]; | |
| 316 | 318 | VLCInitState state = VLC_INIT_STATE(run7_vlc_table); |
| 317 | 319 | |
| 318 | 320 | VLC_INIT_STATIC_TABLE(chroma_dc_coeff_token_vlc_table, |
| @@ -336,11 +338,17 @@ av_cold void ff_h264_decode_init_vlc(void) · 17 unmodified lines | ||
| 336 | 338 | } |
| 337 | 339 | |
| 338 | 340 | for (int i = 0; i < 4; i++) { |
| 339 | − coeff_token_vlc[i] = | |
| 341 | + coeff_token_vlc_original[i] = | |
| 340 | 342 | ff_vlc_init_tables(&state, COEFF_TOKEN_VLC_BITS, 4*17, |
| 341 | 343 | &coeff_token_len [i][0], 1, 1, |
| 342 | 344 | &coeff_token_bits[i][0], 1, 1, 0); |
| 343 | 345 | } |
| 346 | + for (int i = 0; i < FF_ARRAY_ELEMS(coeff_token_vlc); i++) { | |
| 347 | + static const uint8_t coeff_token_table_index[17] = { | |
| 348 | + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 | |
| 349 | + }; | |
| 350 | + coeff_token_vlc[i] = coeff_token_vlc_original[coeff_token_table_index[i]]; | |
| 351 | + } | |
| 344 | 352 | |
| 345 | 353 | for (int i = 0; i < 3; i++) { |
| 346 | 354 | chroma_dc_total_zeros_vlc[i + 1] = |
| @@ -399,7 +407,6 @@ static int decode_residual(const H264Context *h, H264SliceContext *sl, · 52 unmodified lines | ||
| 399 | 407 | const uint8_t *scantable, const uint32_t *qmul, |
| 400 | 408 | int max_coeff) |
| 401 | 409 | { |
| 402 | − static const int coeff_token_table_index[17]= {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}; | |
| 403 | 410 | int level[16]; |
| 404 | 411 | int zeros_left, coeff_token, total_coeff, i, trailing_ones, run_before; |
| 405 | 412 | |
| @@ -416,12 +423,12 @@ static int decode_residual(const H264Context *h, H264SliceContext *sl, · 10 unmodified lines | ||
| 416 | 423 | }else{ |
| 417 | 424 | if(n >= LUMA_DC_BLOCK_INDEX){ |
| 418 | 425 | total_coeff= pred_non_zero_count(h, sl, (n - LUMA_DC_BLOCK_INDEX)*16); |
| 419 | − coeff_token = get_vlc2(gb, coeff_token_vlc[coeff_token_table_index[total_coeff]], | |
| 426 | + coeff_token = get_vlc2(gb, coeff_token_vlc[total_coeff], | |
| 420 | 427 | COEFF_TOKEN_VLC_BITS, 2); |
| 421 | 428 | total_coeff= coeff_token>>2; |
| 422 | 429 | }else{ |
| 423 | 430 | total_coeff= pred_non_zero_count(h, sl, n); |
| 424 | − coeff_token = get_vlc2(gb, coeff_token_vlc[coeff_token_table_index[total_coeff]], | |
| 431 | + coeff_token = get_vlc2(gb, coeff_token_vlc[total_coeff], | |
| 425 | 432 | COEFF_TOKEN_VLC_BITS, 2); |
| 426 | 433 | total_coeff= coeff_token>>2; |
| 427 | 434 | } |