# HG changeset patch # User michael # Date 1099225320 0 # Node ID b7bb00973f997644fd34044565d37abf0a06be64 # Parent 37516ec97cd60921fcea7cecb10ed67e407b54df switch ffv1 to the put/get_symbol() from snow diff -r 37516ec97cd6 -r b7bb00973f99 ffv1.c --- a/ffv1.c Sun Oct 31 10:08:50 2004 +0000 +++ b/ffv1.c Sun Oct 31 12:22:00 2004 +0000 @@ -218,57 +218,52 @@ return f->quant_table[0][(L-LT) & 0xFF] + f->quant_table[1][(LT-T) & 0xFF] + f->quant_table[2][(T-RT) & 0xFF]; } -/** - * put - */ -static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed, int max_exp){ +static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){ int i; if(v){ const int a= ABS(v); const int e= av_log2(a); - put_rac(c, state+0, 0); + assert(e<=9); + for(i=0; i=0; i--){ + put_rac(c, state+22+i, (a>>i)&1); //22..31 } - if(e=0; i--){ - put_rac(c, state+16+e+i, (a>>i)&1); //17..29 - } - if(is_signed) - put_rac(c, state+9 + e, v < 0); //9..16 - } + if(is_signed) + put_rac(c, state+11 + e, v < 0); //11..21 }else{ put_rac(c, state+0, 1); } } -static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed, int max_exp){ +static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){ if(get_rac(c, state+0)) return 0; else{ - int i, e; - - for(e=0; e=0; i--){ - a += get_rac(c, state+16+e+i)<=0; i--){ + a += a + get_rac(c, state+22 + i); //22..31 + } - if(is_signed && get_rac(c, state+9 + e)) //9..16 - return -a; - else - return a; - } - } - return -(1<ac){ - put_symbol(c, p->state[context], diff, 1, bits-1); + put_symbol(c, p->state[context], diff, 1); }else{ if(context == 0) run_mode=1; @@ -492,11 +487,11 @@ for(i=1; i<128 ; i++){ if(quant_table[i] != quant_table[i-1]){ - put_symbol(c, state, i-last-1, 0, 7); + put_symbol(c, state, i-last-1, 0); last= i; } } - put_symbol(c, state, i-last-1, 0, 7); + put_symbol(c, state, i-last-1, 0); } static void write_header(FFV1Context *f){ @@ -506,12 +501,12 @@ memset(state, 128, sizeof(state)); - put_symbol(c, state, f->version, 0, 7); - put_symbol(c, state, f->avctx->coder_type, 0, 7); - put_symbol(c, state, f->colorspace, 0, 7); //YUV cs type + put_symbol(c, state, f->version, 0); + put_symbol(c, state, f->avctx->coder_type, 0); + put_symbol(c, state, f->colorspace, 0); //YUV cs type put_rac(c, state, 1); //chroma planes - put_symbol(c, state, f->chroma_h_shift, 0, 7); - put_symbol(c, state, f->chroma_v_shift, 0, 7); + put_symbol(c, state, f->chroma_h_shift, 0); + put_symbol(c, state, f->chroma_v_shift, 0); put_rac(c, state, 0); //no transparency plane for(i=0; i<5; i++) @@ -618,7 +613,6 @@ for(j=0; jcontext_count; j++){ if(f->ac){ memset(p->state[j], 128, sizeof(uint8_t)*CONTEXT_SIZE); - p->state[j][7] = 256-8; }else{ p->vlc_state[j].drift= 0; p->vlc_state[j].error_sum= 4; //FFMAX((RANGE + 32)/64, 2); @@ -723,9 +717,9 @@ sign=0; - if(s->ac) - diff= get_symbol(c, p->state[context], 1, bits-1); - else{ + if(s->ac){ + diff= get_symbol(c, p->state[context], 1); + }else{ if(context == 0 && run_mode==0) run_mode=1; if(run_mode){ @@ -838,7 +832,7 @@ memset(state, 128, sizeof(state)); for(v=0; i<128 ; v++){ - int len= get_symbol(c, state, 0, 7) + 1; + int len= get_symbol(c, state, 0) + 1; if(len + i > 128) return -1; @@ -865,12 +859,12 @@ memset(state, 128, sizeof(state)); - f->version= get_symbol(c, state, 0, 7); - f->ac= f->avctx->coder_type= get_symbol(c, state, 0, 7); - f->colorspace= get_symbol(c, state, 0, 7); //YUV cs type + f->version= get_symbol(c, state, 0); + f->ac= f->avctx->coder_type= get_symbol(c, state, 0); + f->colorspace= get_symbol(c, state, 0); //YUV cs type get_rac(c, state); //no chroma = false - f->chroma_h_shift= get_symbol(c, state, 0, 7); - f->chroma_v_shift= get_symbol(c, state, 0, 7); + f->chroma_h_shift= get_symbol(c, state, 0); + f->chroma_v_shift= get_symbol(c, state, 0); get_rac(c, state); //transparency plane f->plane_count= 2;