diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2005-04-15 13:24:30 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-04-15 13:24:30 +0000 |
commit | b44985ba12d927d643a7bc03b0db98b83bf4fc9e (patch) | |
tree | 44e1461b5c2e62ce81a5be6402cb92262a1ec4a6 | |
parent | 2cd340438abc02fc3c4214b2a22ebbdd0affa7cd (diff) | |
download | ffmpeg-b44985ba12d927d643a7bc03b0db98b83bf4fc9e.tar.gz |
store the number of runs to avoid storing the last run value
about 10% lower bitrate for -qscale 32 (forman & some music video)
worst case bitrate increase <0.1% (lossless or low qscale)
and now the bad news, even though this just adds a single subtraction and an if() into the medium sized unpack_coeffs() loop and the if() will only be false once per unpac_coeff() call, gcc produces 50% slower code, i didnt look at the generated asm yet, not sure if i want to ...
Originally committed as revision 4131 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/snow.c | 19 | ||||
-rw-r--r-- | tests/ffmpeg.regression.ref | 8 | ||||
-rw-r--r-- | tests/rotozoom.regression.ref | 8 |
3 files changed, 22 insertions, 13 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c index ffabafbc65..7020b39ba0 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -1657,6 +1657,7 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELE int run=0; int runs[w*h]; int run_index=0; + int max_index; for(y=0; y<h; y++){ for(x=0; x<w; x++){ @@ -1696,11 +1697,14 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELE } } } + max_index= run_index; runs[run_index++]= run; run_index=0; run= runs[run_index++]; - put_symbol2(&s->c, b->state[1], run, 3); + put_symbol2(&s->c, b->state[30], max_index, 0); + if(run_index <= max_index) + put_symbol2(&s->c, b->state[1], run, 3); for(y=0; y<h; y++){ if(s->c.bytestream_end - s->c.bytestream < w*40){ @@ -1742,7 +1746,8 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELE if(!run){ run= runs[run_index++]; - put_symbol2(&s->c, b->state[1], run, 3); + if(run_index <= max_index) + put_symbol2(&s->c, b->state[1], run, 3); assert(v); }else{ run--; @@ -1776,14 +1781,17 @@ static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, i int x,y; if(1){ - int run; + int run, runs; x_and_coeff *xc= b->x_coeff; x_and_coeff *prev_xc= NULL; x_and_coeff *prev2_xc= xc; x_and_coeff *parent_xc= parent ? parent->x_coeff : NULL; x_and_coeff *prev_parent_xc= parent_xc; - run= get_symbol2(&s->c, b->state[1], 3); + runs= get_symbol2(&s->c, b->state[30], 0); + if(runs-- > 0) run= get_symbol2(&s->c, b->state[1], 3); + else run= INT_MAX; + for(y=0; y<h; y++){ int v=0; int lt=0, t=0, rt=0; @@ -1826,7 +1834,8 @@ static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, i } }else{ if(!run){ - run= get_symbol2(&s->c, b->state[1], 3); + if(runs-- > 0) run= get_symbol2(&s->c, b->state[1], 3); + else run= INT_MAX; v= 2*(get_symbol2(&s->c, b->state[0 + 2], 0-4) + 1); v+=get_rac(&s->c, &b->state[0][16 + 1 + 3]); diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index 81e4745804..1f920a97e6 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -119,12 +119,12 @@ a7ef4746f27be309138c188e327d3ebe *./data/a-ffv1.avi 2653642 ./data/a-ffv1.avi 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -98f6913d98bccb4ba4829ccde7286e8f *./data/a-snow.avi -1266766 ./data/a-snow.avi +24c1fcbcdb08052359679700056ef4e5 *./data/a-snow.avi +1267526 ./data/a-snow.avi 575fdd879119902a8289c825c2389dca *./data/out.yuv stddev: 2.96 PSNR:38.67 bytes:7602176 -28b6a82fdd8058e2df35778c9a5edbbf *./data/a-snow53.avi -3537074 ./data/a-snow53.avi +0c570833b736a8d4c8c428bf6e82272f *./data/a-snow53.avi +3537490 ./data/a-snow53.avi 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 b5b6275f58f012de73644bbaa9080097 *./data/a-svq1.mov diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index 078df0a0d7..540f4176fc 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -119,12 +119,12 @@ d0831a8339491fd680b650f05262e5d9 *./data/a-ffv1.avi 3524768 ./data/a-ffv1.avi dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -d1546d2176c4cd3913ccb0920e5e556f *./data/a-snow.avi -326454 ./data/a-snow.avi +2d665a41c46d8e581cf5898e85a2b55f *./data/a-snow.avi +326532 ./data/a-snow.avi c0b1b63dc45141c76d538edfd618ac19 *./data/out.yuv stddev: 2.40 PSNR:40.51 bytes:7602176 -8b510a8e4a26d6d469bd80b46922d5e6 *./data/a-snow53.avi -2724602 ./data/a-snow53.avi +d0a8bdb25d7ed641eab0debcac396eb7 *./data/a-snow53.avi +2725842 ./data/a-snow53.avi dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 920c610ec324b772d882b0717e375943 *./data/a-svq1.mov |