diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2005-04-05 17:59:05 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-04-05 17:59:05 +0000 |
commit | 538a38418c83a67de9d1bf9df085c61e7e7c3d81 (patch) | |
tree | 45dfef516d78a0dffb75e43c115ece16078d5a27 /libavcodec | |
parent | 3cff4572ce7a5f0953b13531776794a581131fc1 (diff) | |
download | ffmpeg-streaming-538a38418c83a67de9d1bf9df085c61e7e7c3d81.zip ffmpeg-streaming-538a38418c83a67de9d1bf9df085c61e7e7c3d81.tar.gz |
10% faster unpack_coeffs
Originally committed as revision 4108 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/snow.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 263918e..faed630 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -71,6 +71,24 @@ static const int8_t quant3b[256]={ -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 BlockNode{ typedef struct x_and_coeff{ int16_t x; - int16_t coeff; + uint16_t coeff; } x_and_coeff; typedef struct SubBand{ @@ -1702,9 +1720,11 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELE } 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 @@ static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, i } } 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 @@ static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, i } } 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 @@ static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, sli 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; } |