const int h= s->b_height<< s->block_max_depth;
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 h= s->b_height<< s->block_max_depth;    const int rem_depth= s->block_max_depth - level;    const int index= (x + y*w) << rem_depth;    static BlockNode null_block= { //FIXME add border maybe        .color= {128,128,128},        .mx= 0,        .my= 0,        .type= 0,        .level= 0,    };    int trx= (x+1)<<rem_depth;    int try= (y+1)<<rem_depth;    BlockNode *left  = x ? &s->block[index-1] : &null_block;    BlockNode *top   = y ? &s->block[index-w] : &null_block;    BlockNode *tl    = y && x ? &s->block[index-w-1] : left;    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, BLOCK_INTRA);        return;    }    if(level==s->block_max_depth || get_cabac(&s->c, &s->block_state[4 + s_context])){        int type;        int l = left->color[0];        int cb= left->color[1];        int cr= left->color[2];        int mx= mid_pred(left->mx, top->mx, tr->mx);        int my= mid_pred(left->my, top->my, tr->my);        int mx_context= av_log2(2*ABS(left->mx - top->mx)) + 0*av_log2(2*ABS(tr->mx - top->mx));        int my_context= av_log2(2*ABS(left->my - top->my)) + 0*av_log2(2*ABS(tr->my - top->my));                type= get_cabac(&s->c, &s->block_state[1 + left->type + top->type]) ? BLOCK_INTRA : 0;        if(type){            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{            mx+= get_symbol(&s->c, &s->block_state[128 + 32*mx_context], 1);            my+= get_symbol(&s->c, &s->block_state[128 + 32*my_context], 1);        }        set_blocks(s, level, x, y, l, cb, cr, mx, my, 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);    }}