| 348 | } |
| 349 | |
| 350 | static inline int parse_scale(DCACoreDecoder *s, int *scale_index, int sel) |
| 351 | { |
| 352 | const uint32_t *scale_table; |
| 353 | unsigned int scale_size; |
| 354 | |
| 355 | // Select the root square table |
| 356 | if (sel > 5) { |
| 357 | scale_table = ff_dca_scale_factor_quant7; |
| 358 | scale_size = FF_ARRAY_ELEMS(ff_dca_scale_factor_quant7); |
| 359 | } else { |
| 360 | scale_table = ff_dca_scale_factor_quant6; |
| 361 | scale_size = FF_ARRAY_ELEMS(ff_dca_scale_factor_quant6); |
| 362 | } |
| 363 | |
| 364 | // If Huffman code was used, the difference of scales was encoded |
| 365 | if (sel < 5) |
| 366 | *scale_index += get_vlc2(&s->gb, ff_dca_vlc_scale_factor[sel].table, |
| 367 | DCA_SCALES_VLC_BITS, 2); |
| 368 | else |
| 369 | *scale_index = get_bits(&s->gb, sel + 1); |
| 370 | |
| 371 | // Look up scale factor from the root square table |
| 372 | if ((unsigned int)*scale_index >= scale_size) { |
| 373 | av_log(s->avctx, AV_LOG_ERROR, "Invalid scale factor index\n"); |
| 374 | return AVERROR_INVALIDDATA; |
| 375 | } |
| 376 | |
| 377 | return scale_table[*scale_index]; |
| 378 | } |
| 379 | |
| 380 | static inline int parse_joint_scale(DCACoreDecoder *s, int sel) |
| 381 | { |
no test coverage detected