* Decode local frame tree */
| 93 | * Decode local frame tree |
| 94 | */ |
| 95 | static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t prefix, int length) |
| 96 | { |
| 97 | if(!get_bits1(gb)){ //Leaf |
| 98 | if(hc->current >= 256){ |
| 99 | av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n"); |
| 100 | return -1; |
| 101 | } |
| 102 | if(length){ |
| 103 | hc->bits[hc->current] = prefix; |
| 104 | hc->lengths[hc->current] = length; |
| 105 | } else { |
| 106 | hc->bits[hc->current] = 0; |
| 107 | hc->lengths[hc->current] = 0; |
| 108 | } |
| 109 | hc->values[hc->current] = get_bits(gb, 8); |
| 110 | hc->current++; |
| 111 | if(hc->maxlength < length) |
| 112 | hc->maxlength = length; |
| 113 | return 0; |
| 114 | } else { //Node |
| 115 | int r; |
| 116 | length++; |
| 117 | r = smacker_decode_tree(gb, hc, prefix, length); |
| 118 | if(r) |
| 119 | return r; |
| 120 | return smacker_decode_tree(gb, hc, prefix | (1 << (length - 1)), length); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Decode header tree |
no test coverage detected