Logo Search packages:      
Sourcecode: blender version File versions

static void put_cabac_ueg ( CABACContext *  c,
uint8_t *  state,
int  v,
int  max,
int  is_signed,
int  k,
int  max_index 
) [inline, static]

put unary exp golomb k-th order binarization.

Definition at line 214 of file cabac.h.

References put_cabac_bypass().

                                                                                                                       {
    int i;

    if(v==0)
        put_cabac(c, state, 0);
    else{
        const int sign= v < 0;

        if(is_signed) v= ABS(v);

        if(v<max){
            for(i=0; i<v; i++){
                put_cabac(c, state, 1);
                if(i < max_index) state++;
            }

            put_cabac(c, state, 0);
        }else{
            int m= 1<<k;

            for(i=0; i<max; i++){
                put_cabac(c, state, 1);
                if(i < max_index) state++;
            }

            v -= max;
            while(v >= m){ //FIXME optimize
                put_cabac_bypass(c, 1);
                v-= m;
                m+= m;
            }
            put_cabac_bypass(c, 0);
            while(m>>=1){
                put_cabac_bypass(c, v&m);
            }
        }

        if(is_signed)
            put_cabac_bypass(c, sign);
    }
}


Generated by  Doxygen 1.6.0   Back to index