static void encode_header(SnowContext *s){

    int plane_index, level, orientation;



    put_cabac(&s->c, s->header_state, s->keyframe); // state clearing stuff?

    if(s->keyframe){

        put_symbol(&s->c, s->header_state, s->version, 0);

        put_symbol(&s->c, s->header_state, s->temporal_decomposition_type, 0);

        put_symbol(&s->c, s->header_state, s->temporal_decomposition_count, 0);

        put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0);

        put_symbol(&s->c, s->header_state, s->colorspace_type, 0);

        put_symbol(&s->c, s->header_state, s->b_width, 0);

        put_symbol(&s->c, s->header_state, s->b_height, 0);

        put_symbol(&s->c, s->header_state, s->chroma_h_shift, 0);

        put_symbol(&s->c, s->header_state, s->chroma_v_shift, 0);

        put_cabac(&s->c, s->header_state, s->spatial_scalability);

//        put_cabac(&s->c, s->header_state, s->rate_scalability);



        for(plane_index=0; plane_index<2; plane_index++){

            for(level=0; level<s->spatial_decomposition_count; level++){

                for(orientation=level ? 1:0; orientation<4; orientation++){

                    if(orientation==2) continue;

                    put_symbol(&s->c, s->header_state, s->plane[plane_index].band[level][orientation].qlog, 1);

                }

            }

        }

    }

    put_symbol(&s->c, s->header_state, s->spatial_decomposition_type, 0);

    put_symbol(&s->c, s->header_state, s->qlog, 1); 

    put_symbol(&s->c, s->header_state, s->mv_scale, 0); 

    put_symbol(&s->c, s->header_state, s->qbias, 1);

}

static void encode_header(SnowContext *s){

    int plane_index, level, orientation;



    put_cabac(&s->c, s->header_state, s->keyframe); 

    if(s->keyframe){

        put_symbol(&s->c, s->header_state, s->version, 0);

        put_symbol(&s->c, s->header_state, s->temporal_decomposition_type, 0);

        put_symbol(&s->c, s->header_state, s->temporal_decomposition_count, 0);

        put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0);

        put_symbol(&s->c, s->header_state, s->colorspace_type, 0);

        put_symbol(&s->c, s->header_state, s->b_width, 0);

        put_symbol(&s->c, s->header_state, s->b_height, 0);

        put_symbol(&s->c, s->header_state, s->chroma_h_shift, 0);

        put_symbol(&s->c, s->header_state, s->chroma_v_shift, 0);

        put_cabac(&s->c, s->header_state, s->spatial_scalability);





        for(plane_index=0; plane_index<2; plane_index++){

            for(level=0; level<s->spatial_decomposition_count; level++){

                for(orientation=level ? 1:0; orientation<4; orientation++){

                    if(orientation==2) continue;

                    put_symbol(&s->c, s->header_state, s->plane[plane_index].band[level][orientation].qlog, 1);

                }

            }

        }

    }

    put_symbol(&s->c, s->header_state, s->spatial_decomposition_type, 0);

    put_symbol(&s->c, s->header_state, s->qlog, 1); 

    put_symbol(&s->c, s->header_state, s->mv_scale, 0); 

    put_symbol(&s->c, s->header_state, s->qbias, 1);

}

static void FUNC_0(SnowContext *VAR_0){

    int VAR_1, VAR_2, VAR_3;



    put_cabac(&VAR_0->c, VAR_0->header_state, VAR_0->keyframe); 

    if(VAR_0->keyframe){

        put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->version, 0);

        put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->temporal_decomposition_type, 0);

        put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->temporal_decomposition_count, 0);

        put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->spatial_decomposition_count, 0);

        put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->colorspace_type, 0);

        put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->b_width, 0);

        put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->b_height, 0);

        put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->chroma_h_shift, 0);

        put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->chroma_v_shift, 0);

        put_cabac(&VAR_0->c, VAR_0->header_state, VAR_0->spatial_scalability);





        for(VAR_1=0; VAR_1<2; VAR_1++){

            for(VAR_2=0; VAR_2<VAR_0->spatial_decomposition_count; VAR_2++){

                for(VAR_3=VAR_2 ? 1:0; VAR_3<4; VAR_3++){

                    if(VAR_3==2) continue;

                    put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->plane[VAR_1].band[VAR_2][VAR_3].qlog, 1);

                }

            }

        }

    }

    put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->spatial_decomposition_type, 0);

    put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->qlog, 1); 

    put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->mv_scale, 0); 

    put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->qbias, 1);

}

static void FUNC_0(SnowContext *VAR_0){ int VAR_1, VAR_2, VAR_3; put_cabac(&VAR_0->c, VAR_0->header_state, VAR_0->keyframe); if(VAR_0->keyframe){ put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->version, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->temporal_decomposition_type, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->temporal_decomposition_count, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->spatial_decomposition_count, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->colorspace_type, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->b_width, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->b_height, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->chroma_h_shift, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->chroma_v_shift, 0); put_cabac(&VAR_0->c, VAR_0->header_state, VAR_0->spatial_scalability); for(VAR_1=0; VAR_1<2; VAR_1++){ for(VAR_2=0; VAR_2<VAR_0->spatial_decomposition_count; VAR_2++){ for(VAR_3=VAR_2 ? 1:0; VAR_3<4; VAR_3++){ if(VAR_3==2) continue; put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->plane[VAR_1].band[VAR_2][VAR_3].qlog, 1); } } } } put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->spatial_decomposition_type, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->qlog, 1); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->mv_scale, 0); put_symbol(&VAR_0->c, VAR_0->header_state, VAR_0->qbias, 1); }