* Decode header tree */
| 125 | * Decode header tree |
| 126 | */ |
| 127 | static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx) |
| 128 | { |
| 129 | if(!get_bits1(gb)){ //Leaf |
| 130 | int val, i1, i2, b1, b2; |
| 131 | if(hc->current >= hc->length){ |
| 132 | av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n"); |
| 133 | return -1; |
| 134 | } |
| 135 | b1 = get_bits_count(gb); |
| 136 | i1 = get_vlc2(gb, ctx->v1->table, SMKTREE_BITS, 3); |
| 137 | b1 = get_bits_count(gb) - b1; |
| 138 | b2 = get_bits_count(gb); |
| 139 | i2 = get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3); |
| 140 | b2 = get_bits_count(gb) - b2; |
| 141 | val = ctx->recode1[i1] | (ctx->recode2[i2] << 8); |
| 142 | if(val == ctx->escapes[0]) { |
| 143 | ctx->last[0] = hc->current; |
| 144 | val = 0; |
| 145 | } else if(val == ctx->escapes[1]) { |
| 146 | ctx->last[1] = hc->current; |
| 147 | val = 0; |
| 148 | } else if(val == ctx->escapes[2]) { |
| 149 | ctx->last[2] = hc->current; |
| 150 | val = 0; |
| 151 | } |
| 152 | |
| 153 | hc->values[hc->current++] = val; |
| 154 | return 1; |
| 155 | } else { //Node |
| 156 | int r = 0, t; |
| 157 | |
| 158 | t = hc->current++; |
| 159 | r = smacker_decode_bigtree(gb, hc, ctx); |
| 160 | if(r < 0) |
| 161 | return r; |
| 162 | hc->values[t] = SMK_NODE | r; |
| 163 | r++; |
| 164 | r += smacker_decode_bigtree(gb, hc, ctx); |
| 165 | return r; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Store large tree as FFmpeg's vlc codes |
no test coverage detected