# HG changeset patch # User michael # Date 1113571470 0 # Node ID 0f74a379a8904d0db000a07bb1ab6f150082e38e # Parent 4fb7fa34050bb674c191f7242aca0efaca588b7e 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 ... diff -r 4fb7fa34050b -r 0f74a379a890 snow.c --- a/snow.c Fri Apr 15 05:54:47 2005 +0000 +++ b/snow.c Fri Apr 15 13:24:30 2005 +0000 @@ -1657,6 +1657,7 @@ int run=0; int runs[w*h]; int run_index=0; + int max_index; for(y=0; yc, 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; yc.bytestream_end - s->c.bytestream < w*40){ @@ -1742,7 +1746,8 @@ 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 @@ 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; yc, 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]);