static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx)

{

    if (hc->current + 1 >= hc->length) {

        av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");

        return AVERROR_INVALIDDATA;

    }

    if(!get_bits1(gb)){ //Leaf

        int val, i1, i2;

        i1 = ctx->v1->table ? get_vlc2(gb, ctx->v1->table, SMKTREE_BITS, 3) : 0;

        i2 = ctx->v2->table ? get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3) : 0;

        if (i1 < 0 || i2 < 0)

            return AVERROR_INVALIDDATA;

        val = ctx->recode1[i1] | (ctx->recode2[i2] << 8);

        if(val == ctx->escapes[0]) {

            ctx->last[0] = hc->current;

            val = 0;

        } else if(val == ctx->escapes[1]) {

            ctx->last[1] = hc->current;

            val = 0;

        } else if(val == ctx->escapes[2]) {

            ctx->last[2] = hc->current;

            val = 0;

        }



        hc->values[hc->current++] = val;

        return 1;

    } else { //Node

        int r = 0, r_new, t;



        t = hc->current++;

        r = smacker_decode_bigtree(gb, hc, ctx);

        if(r < 0)

            return r;

        hc->values[t] = SMK_NODE | r;

        r++;

        r_new = smacker_decode_bigtree(gb, hc, ctx);

        if (r_new < 0)

            return r_new;

        return r + r_new;

    }

}

static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx)

{

    if (hc->current + 1 >= hc->length) {

        av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");

        return AVERROR_INVALIDDATA;

    }

    if(!get_bits1(gb)){ 

        int val, i1, i2;

        i1 = ctx->v1->table ? get_vlc2(gb, ctx->v1->table, SMKTREE_BITS, 3) : 0;

        i2 = ctx->v2->table ? get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3) : 0;

        if (i1 < 0 || i2 < 0)

            return AVERROR_INVALIDDATA;

        val = ctx->recode1[i1] | (ctx->recode2[i2] << 8);

        if(val == ctx->escapes[0]) {

            ctx->last[0] = hc->current;

            val = 0;

        } else if(val == ctx->escapes[1]) {

            ctx->last[1] = hc->current;

            val = 0;

        } else if(val == ctx->escapes[2]) {

            ctx->last[2] = hc->current;

            val = 0;

        }



        hc->values[hc->current++] = val;

        return 1;

    } else { 

        int r = 0, r_new, t;



        t = hc->current++;

        r = smacker_decode_bigtree(gb, hc, ctx);

        if(r < 0)

            return r;

        hc->values[t] = SMK_NODE | r;

        r++;

        r_new = smacker_decode_bigtree(gb, hc, ctx);

        if (r_new < 0)

            return r_new;

        return r + r_new;

    }

}

static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx)         r = smacker_decode_bigtree(gb, hc, ctx);         r_new = smacker_decode_bigtree(gb, hc, ctx);
static int FUNC_0(GetBitContext *VAR_0, HuffContext *VAR_1, DBCtx *VAR_2)

{

    if (VAR_1->current + 1 >= VAR_1->length) {

        av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");

        return AVERROR_INVALIDDATA;

    }

    if(!get_bits1(VAR_0)){ 

        int VAR_3, VAR_4, VAR_5;

        VAR_4 = VAR_2->v1->table ? get_vlc2(VAR_0, VAR_2->v1->table, SMKTREE_BITS, 3) : 0;

        VAR_5 = VAR_2->v2->table ? get_vlc2(VAR_0, VAR_2->v2->table, SMKTREE_BITS, 3) : 0;

        if (VAR_4 < 0 || VAR_5 < 0)

            return AVERROR_INVALIDDATA;

        VAR_3 = VAR_2->recode1[VAR_4] | (VAR_2->recode2[VAR_5] << 8);

        if(VAR_3 == VAR_2->escapes[0]) {

            VAR_2->last[0] = VAR_1->current;

            VAR_3 = 0;

        } else if(VAR_3 == VAR_2->escapes[1]) {

            VAR_2->last[1] = VAR_1->current;

            VAR_3 = 0;

        } else if(VAR_3 == VAR_2->escapes[2]) {

            VAR_2->last[2] = VAR_1->current;

            VAR_3 = 0;

        }



        VAR_1->values[VAR_1->current++] = VAR_3;

        return 1;

    } else { 

        int VAR_6 = 0, VAR_7, VAR_8;



        VAR_8 = VAR_1->current++;

        VAR_6 = FUNC_0(VAR_0, VAR_1, VAR_2);

        if(VAR_6 < 0)

            return VAR_6;

        VAR_1->values[VAR_8] = SMK_NODE | VAR_6;

        VAR_6++;

        VAR_7 = FUNC_0(VAR_0, VAR_1, VAR_2);

        if (VAR_7 < 0)

            return VAR_7;

        return VAR_6 + VAR_7;

    }

}

static int FUNC_0(GetBitContext *VAR_0, HuffContext *VAR_1, DBCtx *VAR_2)
{ if (VAR_1->current + 1 >= VAR_1->length) { av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n"); return AVERROR_INVALIDDATA; } if(!get_bits1(VAR_0)){ int VAR_3, VAR_4, VAR_5; VAR_4 = VAR_2->v1->table ? get_vlc2(VAR_0, VAR_2->v1->table, SMKTREE_BITS, 3) : 0; VAR_5 = VAR_2->v2->table ? get_vlc2(VAR_0, VAR_2->v2->table, SMKTREE_BITS, 3) : 0; if (VAR_4 < 0 || VAR_5 < 0)
return AVERROR_INVALIDDATA; VAR_3 = VAR_2->recode1[VAR_4] | (VAR_2->recode2[VAR_5] << 8); if(VAR_3 == VAR_2->escapes[0]) { VAR_2->last[0] = VAR_1->current; VAR_3 = 0; } else if(VAR_3 == VAR_2->escapes[1]) { VAR_2->last[1] = VAR_1->current; VAR_3 = 0; } else if(VAR_3 == VAR_2->escapes[2]) { VAR_2->last[2] = VAR_1->current; VAR_3 = 0; } VAR_1->values[VAR_1->current++] = VAR_3; return 1; } else { int VAR_6 = 0, VAR_7, VAR_8; VAR_8 = VAR_1->current++; VAR_6 = FUNC_0(VAR_0, VAR_1, VAR_2); if(VAR_6 < 0)
return VAR_6; VAR_1->values[VAR_8] = SMK_NODE | VAR_6; VAR_6++; VAR_7 = FUNC_0(VAR_0, VAR_1, VAR_2); if (VAR_7 < 0)
return VAR_7; return VAR_6 + VAR_7; } }