# HG changeset patch # User michael # Date 1112723945 0 # Node ID 3e90a8cfddc6f56d2e8424f75a8b037e2ec283c1 # Parent 6b385f3e07a3cc64d8c99f4fbb094b5880e319eb 10% faster unpack_coeffs diff -r 6b385f3e07a3 -r 3e90a8cfddc6 snow.c --- a/snow.c Tue Apr 05 09:37:43 2005 +0000 +++ b/snow.c Tue Apr 05 17:59:05 2005 +0000 @@ -71,6 +71,24 @@ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, }; +static const int8_t quant3bA[256]={ + 0, 0, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, + 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, +}; static const int8_t quant5[256]={ 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -373,7 +391,7 @@ typedef struct x_and_coeff{ int16_t x; - int16_t coeff; + uint16_t coeff; } x_and_coeff; typedef struct SubBand{ @@ -1702,9 +1720,11 @@ } if(v){ int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); + int l2= 2*ABS(l) + (l<0); + int t2= 2*ABS(t) + (t<0); put_symbol2(&s->c, b->state[context + 2], ABS(v)-1, context-4); - put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]], v<0); + put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l2&0xFF] + 3*quant3bA[t2&0xFF]], v<0); } } } @@ -1763,7 +1783,7 @@ } } if(/*ll|*/l|lt|t|rt|p){ - int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); + int context= av_log2(/*ABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); v=get_rac(&s->c, &b->state[0][context]); }else{ @@ -1785,10 +1805,10 @@ } } if(v){ - int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); - v= get_symbol2(&s->c, b->state[context + 2], context-4) + 1; - if(get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]])) - v *= -1; + int context= av_log2(/*ABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); + v= 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1); + v+=get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l&0xFF] + 3*quant3bA[t&0xFF]]); + b->x_coeff[index].x=x; b->x_coeff[index++].coeff= v; } @@ -1842,10 +1862,10 @@ x = b->x_coeff[new_index++].x; while(x < w) { - if (v < 0) - line[x] = -(( -v*qmul + qadd)>>(QEXPSHIFT)); - else - line[x] = (( v*qmul + qadd)>>(QEXPSHIFT)); + register int t= ( (v>>1)*qmul + qadd)>>QEXPSHIFT; + register int u= -(v&1); + line[x] = (t^u) - u; + v = b->x_coeff[new_index].coeff; x = b->x_coeff[new_index++].x; }