*@brief Extract the coefficients from the bitstream. *@param s codec context *@param c current channel number *@return 0 on success, < 0 in case of bitstream errors */
| 763 | *@return 0 on success, < 0 in case of bitstream errors |
| 764 | */ |
| 765 | static int decode_coeffs(WMAProDecodeCtx *s, int c) |
| 766 | { |
| 767 | /* Integers 0..15 as single-precision floats. The table saves a |
| 768 | costly int to float conversion, and storing the values as |
| 769 | integers allows fast sign-flipping. */ |
| 770 | static const int fval_tab[16] = { |
| 771 | 0x00000000, 0x3f800000, 0x40000000, 0x40400000, |
| 772 | 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000, |
| 773 | 0x41000000, 0x41100000, 0x41200000, 0x41300000, |
| 774 | 0x41400000, 0x41500000, 0x41600000, 0x41700000, |
| 775 | }; |
| 776 | int vlctable; |
| 777 | VLC* vlc; |
| 778 | WMAProChannelCtx* ci = &s->channel[c]; |
| 779 | int rl_mode = 0; |
| 780 | int cur_coeff = 0; |
| 781 | int num_zeros = 0; |
| 782 | const uint16_t* run; |
| 783 | const float* level; |
| 784 | |
| 785 | dprintf(s->avctx, "decode coefficients for channel %i\n", c); |
| 786 | |
| 787 | vlctable = get_bits1(&s->gb); |
| 788 | vlc = &coef_vlc[vlctable]; |
| 789 | |
| 790 | if (vlctable) { |
| 791 | run = coef1_run; |
| 792 | level = coef1_level; |
| 793 | } else { |
| 794 | run = coef0_run; |
| 795 | level = coef0_level; |
| 796 | } |
| 797 | |
| 798 | /** decode vector coefficients (consumes up to 167 bits per iteration for |
| 799 | 4 vector coded large values) */ |
| 800 | while (!rl_mode && cur_coeff + 3 < s->subframe_len) { |
| 801 | int vals[4]; |
| 802 | int i; |
| 803 | unsigned int idx; |
| 804 | |
| 805 | idx = get_vlc2(&s->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH); |
| 806 | |
| 807 | if (idx == HUFF_VEC4_SIZE - 1) { |
| 808 | for (i = 0; i < 4; i += 2) { |
| 809 | idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH); |
| 810 | if (idx == HUFF_VEC2_SIZE - 1) { |
| 811 | int v0, v1; |
| 812 | v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); |
| 813 | if (v0 == HUFF_VEC1_SIZE - 1) |
| 814 | v0 += ff_wma_get_large_val(&s->gb); |
| 815 | v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); |
| 816 | if (v1 == HUFF_VEC1_SIZE - 1) |
| 817 | v1 += ff_wma_get_large_val(&s->gb); |
| 818 | ((float*)vals)[i ] = v0; |
| 819 | ((float*)vals)[i+1] = v1; |
| 820 | } else { |
| 821 | vals[i] = fval_tab[symbol_to_vec2[idx] >> 4 ]; |
| 822 | vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF]; |
no test coverage detected