static void decode_q_branch(SnowContext *s, int level, int x, int y){

    const int w= s->b_width << s->block_max_depth;

    const int rem_depth= s->block_max_depth - level;

    const int index= (x + y*w) << rem_depth;

    int trx= (x+1)<<rem_depth;

    const BlockNode *left  = x ? &s->block[index-1] : &null_block;

    const BlockNode *top   = y ? &s->block[index-w] : &null_block;

    const BlockNode *tl    = y && x ? &s->block[index-w-1] : left;

    const BlockNode *tr    = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt

    int s_context= 2*left->level + 2*top->level + tl->level + tr->level;



    if(s->keyframe){

        set_blocks(s, level, x, y, null_block.color[0], null_block.color[1], null_block.color[2], null_block.mx, null_block.my, null_block.ref, BLOCK_INTRA);

        return;

    }



    if(level==s->block_max_depth || get_rac(&s->c, &s->block_state[4 + s_context])){

        int type, mx, my;

        int l = left->color[0];

        int cb= left->color[1];

        int cr= left->color[2];

        int ref = 0;

        int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref);

        int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 0*av_log2(2*FFABS(tr->mx - top->mx));

        int my_context= av_log2(2*FFABS(left->my - top->my)) + 0*av_log2(2*FFABS(tr->my - top->my));



        type= get_rac(&s->c, &s->block_state[1 + left->type + top->type]) ? BLOCK_INTRA : 0;



        if(type){

            pred_mv(s, &mx, &my, 0, left, top, tr);

            l += get_symbol(&s->c, &s->block_state[32], 1);

            cb+= get_symbol(&s->c, &s->block_state[64], 1);

            cr+= get_symbol(&s->c, &s->block_state[96], 1);

        }else{

            if(s->ref_frames > 1)

                ref= get_symbol(&s->c, &s->block_state[128 + 1024 + 32*ref_context], 0);

            pred_mv(s, &mx, &my, ref, left, top, tr);

            mx+= get_symbol(&s->c, &s->block_state[128 + 32*(mx_context + 16*!!ref)], 1);

            my+= get_symbol(&s->c, &s->block_state[128 + 32*(my_context + 16*!!ref)], 1);

        }

        set_blocks(s, level, x, y, l, cb, cr, mx, my, ref, type);

    }else{

        decode_q_branch(s, level+1, 2*x+0, 2*y+0);

        decode_q_branch(s, level+1, 2*x+1, 2*y+0);

        decode_q_branch(s, level+1, 2*x+0, 2*y+1);

        decode_q_branch(s, level+1, 2*x+1, 2*y+1);

    }

}

static void decode_q_branch(SnowContext *s, int level, int x, int y){

    const int w= s->b_width << s->block_max_depth;

    const int rem_depth= s->block_max_depth - level;

    const int index= (x + y*w) << rem_depth;

    int trx= (x+1)<<rem_depth;

    const BlockNode *left  = x ? &s->block[index-1] : &null_block;

    const BlockNode *top   = y ? &s->block[index-w] : &null_block;

    const BlockNode *tl    = y && x ? &s->block[index-w-1] : left;

    const BlockNode *tr    = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; 

    int s_context= 2*left->level + 2*top->level + tl->level + tr->level;



    if(s->keyframe){

        set_blocks(s, level, x, y, null_block.color[0], null_block.color[1], null_block.color[2], null_block.mx, null_block.my, null_block.ref, BLOCK_INTRA);

        return;

    }



    if(level==s->block_max_depth || get_rac(&s->c, &s->block_state[4 + s_context])){

        int type, mx, my;

        int l = left->color[0];

        int cb= left->color[1];

        int cr= left->color[2];

        int ref = 0;

        int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref);

        int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 0*av_log2(2*FFABS(tr->mx - top->mx));

        int my_context= av_log2(2*FFABS(left->my - top->my)) + 0*av_log2(2*FFABS(tr->my - top->my));



        type= get_rac(&s->c, &s->block_state[1 + left->type + top->type]) ? BLOCK_INTRA : 0;



        if(type){

            pred_mv(s, &mx, &my, 0, left, top, tr);

            l += get_symbol(&s->c, &s->block_state[32], 1);

            cb+= get_symbol(&s->c, &s->block_state[64], 1);

            cr+= get_symbol(&s->c, &s->block_state[96], 1);

        }else{

            if(s->ref_frames > 1)

                ref= get_symbol(&s->c, &s->block_state[128 + 1024 + 32*ref_context], 0);

            pred_mv(s, &mx, &my, ref, left, top, tr);

            mx+= get_symbol(&s->c, &s->block_state[128 + 32*(mx_context + 16*!!ref)], 1);

            my+= get_symbol(&s->c, &s->block_state[128 + 32*(my_context + 16*!!ref)], 1);

        }

        set_blocks(s, level, x, y, l, cb, cr, mx, my, ref, type);

    }else{

        decode_q_branch(s, level+1, 2*x+0, 2*y+0);

        decode_q_branch(s, level+1, 2*x+1, 2*y+0);

        decode_q_branch(s, level+1, 2*x+0, 2*y+1);

        decode_q_branch(s, level+1, 2*x+1, 2*y+1);

    }

}

static void decode_q_branch(SnowContext *s, int level, int x, int y){         decode_q_branch(s, level+1, 2*x+0, 2*y+0);         decode_q_branch(s, level+1, 2*x+1, 2*y+0);         decode_q_branch(s, level+1, 2*x+0, 2*y+1);         decode_q_branch(s, level+1, 2*x+1, 2*y+1);
static void FUNC_0(SnowContext *VAR_0, int VAR_1, int VAR_2, int VAR_3){

    const int VAR_4= VAR_0->b_width << VAR_0->block_max_depth;

    const int VAR_5= VAR_0->block_max_depth - VAR_1;

    const int VAR_6= (VAR_2 + VAR_3*VAR_4) << VAR_5;

    int VAR_7= (VAR_2+1)<<VAR_5;

    const BlockNode *VAR_8  = VAR_2 ? &VAR_0->block[VAR_6-1] : &null_block;

    const BlockNode *VAR_9   = VAR_3 ? &VAR_0->block[VAR_6-VAR_4] : &null_block;

    const BlockNode *VAR_10    = VAR_3 && VAR_2 ? &VAR_0->block[VAR_6-VAR_4-1] : VAR_8;

    const BlockNode *VAR_11    = VAR_3 && VAR_7<VAR_4 && ((VAR_2&1)==0 || VAR_1==0) ? &VAR_0->block[VAR_6-VAR_4+(1<<VAR_5)] : VAR_10; 

    int VAR_12= 2*VAR_8->VAR_1 + 2*VAR_9->VAR_1 + VAR_10->VAR_1 + VAR_11->VAR_1;



    if(VAR_0->keyframe){

        set_blocks(VAR_0, VAR_1, VAR_2, VAR_3, null_block.color[0], null_block.color[1], null_block.color[2], null_block.VAR_14, null_block.VAR_15, null_block.VAR_19, BLOCK_INTRA);

        return;

    }



    if(VAR_1==VAR_0->block_max_depth || get_rac(&VAR_0->c, &VAR_0->block_state[4 + VAR_12])){

        int VAR_13, VAR_14, VAR_15;

        int VAR_16 = VAR_8->color[0];

        int VAR_17= VAR_8->color[1];

        int VAR_18= VAR_8->color[2];

        int VAR_19 = 0;

        int VAR_20= av_log2(2*VAR_8->VAR_19) + av_log2(2*VAR_9->VAR_19);

        int VAR_21= av_log2(2*FFABS(VAR_8->VAR_14 - VAR_9->VAR_14)) + 0*av_log2(2*FFABS(VAR_11->VAR_14 - VAR_9->VAR_14));

        int VAR_22= av_log2(2*FFABS(VAR_8->VAR_15 - VAR_9->VAR_15)) + 0*av_log2(2*FFABS(VAR_11->VAR_15 - VAR_9->VAR_15));



        VAR_13= get_rac(&VAR_0->c, &VAR_0->block_state[1 + VAR_8->VAR_13 + VAR_9->VAR_13]) ? BLOCK_INTRA : 0;



        if(VAR_13){

            pred_mv(VAR_0, &VAR_14, &VAR_15, 0, VAR_8, VAR_9, VAR_11);

            VAR_16 += get_symbol(&VAR_0->c, &VAR_0->block_state[32], 1);

            VAR_17+= get_symbol(&VAR_0->c, &VAR_0->block_state[64], 1);

            VAR_18+= get_symbol(&VAR_0->c, &VAR_0->block_state[96], 1);

        }else{

            if(VAR_0->ref_frames > 1)

                VAR_19= get_symbol(&VAR_0->c, &VAR_0->block_state[128 + 1024 + 32*VAR_20], 0);

            pred_mv(VAR_0, &VAR_14, &VAR_15, VAR_19, VAR_8, VAR_9, VAR_11);

            VAR_14+= get_symbol(&VAR_0->c, &VAR_0->block_state[128 + 32*(VAR_21 + 16*!!VAR_19)], 1);

            VAR_15+= get_symbol(&VAR_0->c, &VAR_0->block_state[128 + 32*(VAR_22 + 16*!!VAR_19)], 1);

        }

        set_blocks(VAR_0, VAR_1, VAR_2, VAR_3, VAR_16, VAR_17, VAR_18, VAR_14, VAR_15, VAR_19, VAR_13);

    }else{

        FUNC_0(VAR_0, VAR_1+1, 2*VAR_2+0, 2*VAR_3+0);

        FUNC_0(VAR_0, VAR_1+1, 2*VAR_2+1, 2*VAR_3+0);

        FUNC_0(VAR_0, VAR_1+1, 2*VAR_2+0, 2*VAR_3+1);

        FUNC_0(VAR_0, VAR_1+1, 2*VAR_2+1, 2*VAR_3+1);

    }

}

static void FUNC_0(SnowContext *VAR_0, int VAR_1, int VAR_2, int VAR_3){ const int VAR_4= VAR_0->b_width << VAR_0->block_max_depth; const int VAR_5= VAR_0->block_max_depth - VAR_1; const int VAR_6= (VAR_2 + VAR_3*VAR_4) << VAR_5; int VAR_7= (VAR_2+1)<<VAR_5; const BlockNode *VAR_8  = VAR_2 ? &VAR_0->block[VAR_6-1] : &null_block; const BlockNode *VAR_9   = VAR_3 ? &VAR_0->block[VAR_6-VAR_4] : &null_block; const BlockNode *VAR_10    = VAR_3 && VAR_2 ? &VAR_0->block[VAR_6-VAR_4-1] : VAR_8; const BlockNode *VAR_11    = VAR_3 && VAR_7<VAR_4 && ((VAR_2&1)==0 || VAR_1==0) ? &VAR_0->block[VAR_6-VAR_4+(1<<VAR_5)] : VAR_10; int VAR_12= 2*VAR_8->VAR_1 + 2*VAR_9->VAR_1 + VAR_10->VAR_1 + VAR_11->VAR_1; if(VAR_0->keyframe){ set_blocks(VAR_0, VAR_1, VAR_2, VAR_3, null_block.color[0], null_block.color[1], null_block.color[2], null_block.VAR_14, null_block.VAR_15, null_block.VAR_19, BLOCK_INTRA); return; } if(VAR_1==VAR_0->block_max_depth || get_rac(&VAR_0->c, &VAR_0->block_state[4 + VAR_12])){ int VAR_13, VAR_14, VAR_15; int VAR_16 = VAR_8->color[0]; int VAR_17= VAR_8->color[1]; int VAR_18= VAR_8->color[2]; int VAR_19 = 0; int VAR_20= av_log2(2*VAR_8->VAR_19) + av_log2(2*VAR_9->VAR_19); int VAR_21= av_log2(2*FFABS(VAR_8->VAR_14 - VAR_9->VAR_14)) + 0*av_log2(2*FFABS(VAR_11->VAR_14 - VAR_9->VAR_14)); int VAR_22= av_log2(2*FFABS(VAR_8->VAR_15 - VAR_9->VAR_15)) + 0*av_log2(2*FFABS(VAR_11->VAR_15 - VAR_9->VAR_15)); VAR_13= get_rac(&VAR_0->c, &VAR_0->block_state[1 + VAR_8->VAR_13 + VAR_9->VAR_13]) ? BLOCK_INTRA : 0; if(VAR_13){ pred_mv(VAR_0, &VAR_14, &VAR_15, 0, VAR_8, VAR_9, VAR_11); VAR_16 += get_symbol(&VAR_0->c, &VAR_0->block_state[32], 1); VAR_17+= get_symbol(&VAR_0->c, &VAR_0->block_state[64], 1); VAR_18+= get_symbol(&VAR_0->c, &VAR_0->block_state[96], 1); }else{ if(VAR_0->ref_frames > 1)
VAR_19= get_symbol(&VAR_0->c, &VAR_0->block_state[128 + 1024 + 32*VAR_20], 0); pred_mv(VAR_0, &VAR_14, &VAR_15, VAR_19, VAR_8, VAR_9, VAR_11); VAR_14+= get_symbol(&VAR_0->c, &VAR_0->block_state[128 + 32*(VAR_21 + 16*!!VAR_19)], 1); VAR_15+= get_symbol(&VAR_0->c, &VAR_0->block_state[128 + 32*(VAR_22 + 16*!!VAR_19)], 1); } set_blocks(VAR_0, VAR_1, VAR_2, VAR_3, VAR_16, VAR_17, VAR_18, VAR_14, VAR_15, VAR_19, VAR_13); }else{ FUNC_0(VAR_0, VAR_1+1, 2*VAR_2+0, 2*VAR_3+0); FUNC_0(VAR_0, VAR_1+1, 2*VAR_2+1, 2*VAR_3+0); FUNC_0(VAR_0, VAR_1+1, 2*VAR_2+0, 2*VAR_3+1); FUNC_0(VAR_0, VAR_1+1, 2*VAR_2+1, 2*VAR_3+1); } }