Mercurial > libavcodec.hg
comparison vp3.c @ 11646:a69e24b73f3c libavcodec
theora: coeff huffman codes are allowed to be up to 32 bits long (for 32 tokens)
author | conrad |
---|---|
date | Wed, 21 Apr 2010 13:19:00 +0000 |
parents | 7dd2a45249a9 |
children | 7dff9c1061e1 |
comparison
equal
deleted
inserted
replaced
11645:69131e8f6614 | 11646:a69e24b73f3c |
---|---|
240 /* Huffman decode */ | 240 /* Huffman decode */ |
241 int hti; | 241 int hti; |
242 unsigned int hbits; | 242 unsigned int hbits; |
243 int entries; | 243 int entries; |
244 int huff_code_size; | 244 int huff_code_size; |
245 uint16_t huffman_table[80][32][2]; | 245 uint32_t huffman_table[80][32][2]; |
246 | 246 |
247 uint8_t filter_limit_values[64]; | 247 uint8_t filter_limit_values[64]; |
248 DECLARE_ALIGNED(8, int, bounding_values_array)[256+2]; | 248 DECLARE_ALIGNED(8, int, bounding_values_array)[256+2]; |
249 } Vp3DecodeContext; | 249 } Vp3DecodeContext; |
250 | 250 |
880 if (blocks_ended) | 880 if (blocks_ended) |
881 dct_tokens[j++] = blocks_ended << 2; | 881 dct_tokens[j++] = blocks_ended << 2; |
882 | 882 |
883 while (coeff_i < num_coeffs && get_bits_left(gb) > 0) { | 883 while (coeff_i < num_coeffs && get_bits_left(gb) > 0) { |
884 /* decode a VLC into a token */ | 884 /* decode a VLC into a token */ |
885 token = get_vlc2(gb, vlc_table, 5, 3); | 885 token = get_vlc2(gb, vlc_table, 11, 3); |
886 /* use the token to get a zero run, a coefficient, and an eob run */ | 886 /* use the token to get a zero run, a coefficient, and an eob run */ |
887 if (token <= 6) { | 887 if (token <= 6) { |
888 eob_run = eob_run_base[token]; | 888 eob_run = eob_run_base[token]; |
889 if (eob_run_get_bits[token]) | 889 if (eob_run_get_bits[token]) |
890 eob_run += get_bits(gb, eob_run_get_bits[token]); | 890 eob_run += get_bits(gb, eob_run_get_bits[token]); |
1604 | 1604 |
1605 /* init VLC tables */ | 1605 /* init VLC tables */ |
1606 for (i = 0; i < 16; i++) { | 1606 for (i = 0; i < 16; i++) { |
1607 | 1607 |
1608 /* DC histograms */ | 1608 /* DC histograms */ |
1609 init_vlc(&s->dc_vlc[i], 5, 32, | 1609 init_vlc(&s->dc_vlc[i], 11, 32, |
1610 &dc_bias[i][0][1], 4, 2, | 1610 &dc_bias[i][0][1], 4, 2, |
1611 &dc_bias[i][0][0], 4, 2, 0); | 1611 &dc_bias[i][0][0], 4, 2, 0); |
1612 | 1612 |
1613 /* group 1 AC histograms */ | 1613 /* group 1 AC histograms */ |
1614 init_vlc(&s->ac_vlc_1[i], 5, 32, | 1614 init_vlc(&s->ac_vlc_1[i], 11, 32, |
1615 &ac_bias_0[i][0][1], 4, 2, | 1615 &ac_bias_0[i][0][1], 4, 2, |
1616 &ac_bias_0[i][0][0], 4, 2, 0); | 1616 &ac_bias_0[i][0][0], 4, 2, 0); |
1617 | 1617 |
1618 /* group 2 AC histograms */ | 1618 /* group 2 AC histograms */ |
1619 init_vlc(&s->ac_vlc_2[i], 5, 32, | 1619 init_vlc(&s->ac_vlc_2[i], 11, 32, |
1620 &ac_bias_1[i][0][1], 4, 2, | 1620 &ac_bias_1[i][0][1], 4, 2, |
1621 &ac_bias_1[i][0][0], 4, 2, 0); | 1621 &ac_bias_1[i][0][0], 4, 2, 0); |
1622 | 1622 |
1623 /* group 3 AC histograms */ | 1623 /* group 3 AC histograms */ |
1624 init_vlc(&s->ac_vlc_3[i], 5, 32, | 1624 init_vlc(&s->ac_vlc_3[i], 11, 32, |
1625 &ac_bias_2[i][0][1], 4, 2, | 1625 &ac_bias_2[i][0][1], 4, 2, |
1626 &ac_bias_2[i][0][0], 4, 2, 0); | 1626 &ac_bias_2[i][0][0], 4, 2, 0); |
1627 | 1627 |
1628 /* group 4 AC histograms */ | 1628 /* group 4 AC histograms */ |
1629 init_vlc(&s->ac_vlc_4[i], 5, 32, | 1629 init_vlc(&s->ac_vlc_4[i], 11, 32, |
1630 &ac_bias_3[i][0][1], 4, 2, | 1630 &ac_bias_3[i][0][1], 4, 2, |
1631 &ac_bias_3[i][0][0], 4, 2, 0); | 1631 &ac_bias_3[i][0][0], 4, 2, 0); |
1632 } | 1632 } |
1633 } else { | 1633 } else { |
1634 | |
1634 for (i = 0; i < 16; i++) { | 1635 for (i = 0; i < 16; i++) { |
1635 | |
1636 /* DC histograms */ | 1636 /* DC histograms */ |
1637 if (init_vlc(&s->dc_vlc[i], 5, 32, | 1637 if (init_vlc(&s->dc_vlc[i], 11, 32, |
1638 &s->huffman_table[i][0][1], 4, 2, | 1638 &s->huffman_table[i][0][1], 8, 4, |
1639 &s->huffman_table[i][0][0], 4, 2, 0) < 0) | 1639 &s->huffman_table[i][0][0], 8, 4, 0) < 0) |
1640 goto vlc_fail; | 1640 goto vlc_fail; |
1641 | 1641 |
1642 /* group 1 AC histograms */ | 1642 /* group 1 AC histograms */ |
1643 if (init_vlc(&s->ac_vlc_1[i], 5, 32, | 1643 if (init_vlc(&s->ac_vlc_1[i], 11, 32, |
1644 &s->huffman_table[i+16][0][1], 4, 2, | 1644 &s->huffman_table[i+16][0][1], 8, 4, |
1645 &s->huffman_table[i+16][0][0], 4, 2, 0) < 0) | 1645 &s->huffman_table[i+16][0][0], 8, 4, 0) < 0) |
1646 goto vlc_fail; | 1646 goto vlc_fail; |
1647 | 1647 |
1648 /* group 2 AC histograms */ | 1648 /* group 2 AC histograms */ |
1649 if (init_vlc(&s->ac_vlc_2[i], 5, 32, | 1649 if (init_vlc(&s->ac_vlc_2[i], 11, 32, |
1650 &s->huffman_table[i+16*2][0][1], 4, 2, | 1650 &s->huffman_table[i+16*2][0][1], 8, 4, |
1651 &s->huffman_table[i+16*2][0][0], 4, 2, 0) < 0) | 1651 &s->huffman_table[i+16*2][0][0], 8, 4, 0) < 0) |
1652 goto vlc_fail; | 1652 goto vlc_fail; |
1653 | 1653 |
1654 /* group 3 AC histograms */ | 1654 /* group 3 AC histograms */ |
1655 if (init_vlc(&s->ac_vlc_3[i], 5, 32, | 1655 if (init_vlc(&s->ac_vlc_3[i], 11, 32, |
1656 &s->huffman_table[i+16*3][0][1], 4, 2, | 1656 &s->huffman_table[i+16*3][0][1], 8, 4, |
1657 &s->huffman_table[i+16*3][0][0], 4, 2, 0) < 0) | 1657 &s->huffman_table[i+16*3][0][0], 8, 4, 0) < 0) |
1658 goto vlc_fail; | 1658 goto vlc_fail; |
1659 | 1659 |
1660 /* group 4 AC histograms */ | 1660 /* group 4 AC histograms */ |
1661 if (init_vlc(&s->ac_vlc_4[i], 5, 32, | 1661 if (init_vlc(&s->ac_vlc_4[i], 11, 32, |
1662 &s->huffman_table[i+16*4][0][1], 4, 2, | 1662 &s->huffman_table[i+16*4][0][1], 8, 4, |
1663 &s->huffman_table[i+16*4][0][0], 4, 2, 0) < 0) | 1663 &s->huffman_table[i+16*4][0][0], 8, 4, 0) < 0) |
1664 goto vlc_fail; | 1664 goto vlc_fail; |
1665 } | 1665 } |
1666 } | 1666 } |
1667 | 1667 |
1668 init_vlc(&s->superblock_run_length_vlc, 6, 34, | 1668 init_vlc(&s->superblock_run_length_vlc, 6, 34, |