[libav-devel] [PATCH 10/10] snow: move away the remaining shared inline functions

Luca Barbato lu_zero at gentoo.org
Wed Nov 16 16:26:09 CET 2011


---
 libavcodec/snow.h     |  234 ++++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/snowdata.h |   19 ++++
 libavcodec/snowdec.c  |  248 -------------------------------------------------
 libavcodec/snowenc.c  |  248 -------------------------------------------------
 4 files changed, 253 insertions(+), 496 deletions(-)

diff --git a/libavcodec/snow.h b/libavcodec/snow.h
index 971fce3..7a806c6 100644
--- a/libavcodec/snow.h
+++ b/libavcodec/snow.h
@@ -455,4 +455,238 @@ static av_always_inline void predict_plane(SnowContext *s, IDWTELEM *buf, int pl
         predict_slice(s, buf, plane_index, add, mb_y);
 }
 
+static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, int cb, int cr, int mx, int my, int ref, int type){
+    const int w= s->b_width << s->block_max_depth;
+    const int rem_depth= s->block_max_depth - level;
+    const int index= (x + y*w) << rem_depth;
+    const int block_w= 1<<rem_depth;
+    BlockNode block;
+    int i,j;
+
+    block.color[0]= l;
+    block.color[1]= cb;
+    block.color[2]= cr;
+    block.mx= mx;
+    block.my= my;
+    block.ref= ref;
+    block.type= type;
+    block.level= level;
+
+    for(j=0; j<block_w; j++){
+        for(i=0; i<block_w; i++){
+            s->block[index + i + j*w]= block;
+        }
+    }
+}
+
+static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
+    const int offset[3]= {
+          y*c->  stride + x,
+        ((y*c->uvstride + x)>>1),
+        ((y*c->uvstride + x)>>1),
+    };
+    int i;
+    for(i=0; i<3; i++){
+        c->src[0][i]= src [i];
+        c->ref[0][i]= ref [i] + offset[i];
+    }
+    assert(!ref_index);
+}
+
+
+/* bitstream functions */
+
+extern const int8_t quant3bA[256];
+
+#define QEXPSHIFT (7-FRAC_BITS+8) //FIXME try to change this to 0
+
+static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){
+    int i;
+
+    if(v){
+        const int a= FFABS(v);
+        const int e= av_log2(a);
+        const int el= FFMIN(e, 10);
+        put_rac(c, state+0, 0);
+
+        for(i=0; i<el; i++){
+            put_rac(c, state+1+i, 1);  //1..10
+        }
+        for(; i<e; i++){
+            put_rac(c, state+1+9, 1);  //1..10
+        }
+        put_rac(c, state+1+FFMIN(i,9), 0);
+
+        for(i=e-1; i>=el; i--){
+            put_rac(c, state+22+9, (a>>i)&1); //22..31
+        }
+        for(; i>=0; i--){
+            put_rac(c, state+22+i, (a>>i)&1); //22..31
+        }
+
+        if(is_signed)
+            put_rac(c, state+11 + el, v < 0); //11..21
+    }else{
+        put_rac(c, state+0, 1);
+    }
+}
+
+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, a;
+        e= 0;
+        while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
+            e++;
+        }
+
+        a= 1;
+        for(i=e-1; i>=0; i--){
+            a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31
+        }
+
+        e= -(is_signed && get_rac(c, state+11 + FFMIN(e,10))); //11..21
+        return (a^e)-e;
+    }
+}
+
+static inline void put_symbol2(RangeCoder *c, uint8_t *state, int v, int log2){
+    int i;
+    int r= log2>=0 ? 1<<log2 : 1;
+
+    assert(v>=0);
+    assert(log2>=-4);
+
+    while(v >= r){
+        put_rac(c, state+4+log2, 1);
+        v -= r;
+        log2++;
+        if(log2>0) r+=r;
+    }
+    put_rac(c, state+4+log2, 0);
+
+    for(i=log2-1; i>=0; i--){
+        put_rac(c, state+31-i, (v>>i)&1);
+    }
+}
+
+static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2){
+    int i;
+    int r= log2>=0 ? 1<<log2 : 1;
+    int v=0;
+
+    assert(log2>=-4);
+
+    while(get_rac(c, state+4+log2)){
+        v+= r;
+        log2++;
+        if(log2>0) r+=r;
+    }
+
+    for(i=log2-1; i>=0; i--){
+        v+= get_rac(c, state+31-i)<<i;
+    }
+
+    return v;
+}
+
+static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, int orientation){
+    const int w= b->width;
+    const int h= b->height;
+    int x,y;
+
+    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;
+
+    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;
+
+        if(y && prev_xc->x == 0){
+            rt= prev_xc->coeff;
+        }
+        for(x=0; x<w; x++){
+            int p=0;
+            const int l= v;
+
+            lt= t; t= rt;
+
+            if(y){
+                if(prev_xc->x <= x)
+                    prev_xc++;
+                if(prev_xc->x == x + 1)
+                    rt= prev_xc->coeff;
+                else
+                    rt=0;
+            }
+            if(parent_xc){
+                if(x>>1 > parent_xc->x){
+                    parent_xc++;
+                }
+                if(x>>1 == parent_xc->x){
+                    p= parent_xc->coeff;
+                }
+            }
+            if(/*ll|*/l|lt|t|rt|p){
+                int context= av_log2(/*FFABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1));
+
+                v=get_rac(&s->c, &b->state[0][context]);
+                if(v){
+                    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]]);
+
+                    xc->x=x;
+                    (xc++)->coeff= v;
+                }
+            }else{
+                if(!run){
+                    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]);
+
+                    xc->x=x;
+                    (xc++)->coeff= v;
+                }else{
+                    int max_run;
+                    run--;
+                    v=0;
+
+                    if(y) max_run= FFMIN(run, prev_xc->x - x - 2);
+                    else  max_run= FFMIN(run, w-x-1);
+                    if(parent_xc)
+                        max_run= FFMIN(max_run, 2*parent_xc->x - x - 1);
+                    x+= max_run;
+                    run-= max_run;
+                }
+            }
+        }
+        (xc++)->x= w+1; //end marker
+        prev_xc= prev2_xc;
+        prev2_xc= xc;
+
+        if(parent_xc){
+            if(y&1){
+                while(parent_xc->x != parent->width+1)
+                    parent_xc++;
+                parent_xc++;
+                prev_parent_xc= parent_xc;
+            }else{
+                parent_xc= prev_parent_xc;
+            }
+        }
+    }
+
+    (xc++)->x= w+1; //end marker
+}
+
 #endif /* AVCODEC_SNOW_H */
diff --git a/libavcodec/snowdata.h b/libavcodec/snowdata.h
index f1e8218..ca2468c 100644
--- a/libavcodec/snowdata.h
+++ b/libavcodec/snowdata.h
@@ -101,6 +101,25 @@ static const uint8_t obmc4[16]={
 //error:0.000000
 };
 
+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,
+};
+
 const uint8_t * const obmc_tab[4]= {
     obmc32, obmc16, obmc8, obmc4
 };
diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index f2cc7db..3f7629b 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -35,254 +35,6 @@
 #undef NDEBUG
 #include <assert.h>
 
-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,
-};
-
-#define QEXPSHIFT (7-FRAC_BITS+8) //FIXME try to change this to 0
-
-static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){
-    int i;
-
-    if(v){
-        const int a= FFABS(v);
-        const int e= av_log2(a);
-        const int el= FFMIN(e, 10);
-        put_rac(c, state+0, 0);
-
-        for(i=0; i<el; i++){
-            put_rac(c, state+1+i, 1);  //1..10
-        }
-        for(; i<e; i++){
-            put_rac(c, state+1+9, 1);  //1..10
-        }
-        put_rac(c, state+1+FFMIN(i,9), 0);
-
-        for(i=e-1; i>=el; i--){
-            put_rac(c, state+22+9, (a>>i)&1); //22..31
-        }
-        for(; i>=0; i--){
-            put_rac(c, state+22+i, (a>>i)&1); //22..31
-        }
-
-        if(is_signed)
-            put_rac(c, state+11 + el, v < 0); //11..21
-    }else{
-        put_rac(c, state+0, 1);
-    }
-}
-
-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, a;
-        e= 0;
-        while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
-            e++;
-        }
-
-        a= 1;
-        for(i=e-1; i>=0; i--){
-            a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31
-        }
-
-        e= -(is_signed && get_rac(c, state+11 + FFMIN(e,10))); //11..21
-        return (a^e)-e;
-    }
-}
-
-static inline void put_symbol2(RangeCoder *c, uint8_t *state, int v, int log2){
-    int i;
-    int r= log2>=0 ? 1<<log2 : 1;
-
-    assert(v>=0);
-    assert(log2>=-4);
-
-    while(v >= r){
-        put_rac(c, state+4+log2, 1);
-        v -= r;
-        log2++;
-        if(log2>0) r+=r;
-    }
-    put_rac(c, state+4+log2, 0);
-
-    for(i=log2-1; i>=0; i--){
-        put_rac(c, state+31-i, (v>>i)&1);
-    }
-}
-
-static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2){
-    int i;
-    int r= log2>=0 ? 1<<log2 : 1;
-    int v=0;
-
-    assert(log2>=-4);
-
-    while(get_rac(c, state+4+log2)){
-        v+= r;
-        log2++;
-        if(log2>0) r+=r;
-    }
-
-    for(i=log2-1; i>=0; i--){
-        v+= get_rac(c, state+31-i)<<i;
-    }
-
-    return v;
-}
-
-static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, int orientation){
-    const int w= b->width;
-    const int h= b->height;
-    int x,y;
-
-    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;
-
-    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;
-
-        if(y && prev_xc->x == 0){
-            rt= prev_xc->coeff;
-        }
-        for(x=0; x<w; x++){
-            int p=0;
-            const int l= v;
-
-            lt= t; t= rt;
-
-            if(y){
-                if(prev_xc->x <= x)
-                    prev_xc++;
-                if(prev_xc->x == x + 1)
-                    rt= prev_xc->coeff;
-                else
-                    rt=0;
-            }
-            if(parent_xc){
-                if(x>>1 > parent_xc->x){
-                    parent_xc++;
-                }
-                if(x>>1 == parent_xc->x){
-                    p= parent_xc->coeff;
-                }
-            }
-            if(/*ll|*/l|lt|t|rt|p){
-                int context= av_log2(/*FFABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1));
-
-                v=get_rac(&s->c, &b->state[0][context]);
-                if(v){
-                    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]]);
-
-                    xc->x=x;
-                    (xc++)->coeff= v;
-                }
-            }else{
-                if(!run){
-                    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]);
-
-                    xc->x=x;
-                    (xc++)->coeff= v;
-                }else{
-                    int max_run;
-                    run--;
-                    v=0;
-
-                    if(y) max_run= FFMIN(run, prev_xc->x - x - 2);
-                    else  max_run= FFMIN(run, w-x-1);
-                    if(parent_xc)
-                        max_run= FFMIN(max_run, 2*parent_xc->x - x - 1);
-                    x+= max_run;
-                    run-= max_run;
-                }
-            }
-        }
-        (xc++)->x= w+1; //end marker
-        prev_xc= prev2_xc;
-        prev2_xc= xc;
-
-        if(parent_xc){
-            if(y&1){
-                while(parent_xc->x != parent->width+1)
-                    parent_xc++;
-                parent_xc++;
-                prev_parent_xc= parent_xc;
-            }else{
-                parent_xc= prev_parent_xc;
-            }
-        }
-    }
-
-    (xc++)->x= w+1; //end marker
-}
-
-static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, int cb, int cr, int mx, int my, int ref, int type){
-    const int w= s->b_width << s->block_max_depth;
-    const int rem_depth= s->block_max_depth - level;
-    const int index= (x + y*w) << rem_depth;
-    const int block_w= 1<<rem_depth;
-    BlockNode block;
-    int i,j;
-
-    block.color[0]= l;
-    block.color[1]= cb;
-    block.color[2]= cr;
-    block.mx= mx;
-    block.my= my;
-    block.ref= ref;
-    block.type= type;
-    block.level= level;
-
-    for(j=0; j<block_w; j++){
-        for(i=0; i<block_w; i++){
-            s->block[index + i + j*w]= block;
-        }
-    }
-}
-
-static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
-    const int offset[3]= {
-          y*c->  stride + x,
-        ((y*c->uvstride + x)>>1),
-        ((y*c->uvstride + x)>>1),
-    };
-    int i;
-    for(i=0; i<3; i++){
-        c->src[0][i]= src [i];
-        c->ref[0][i]= ref [i] + offset[i];
-    }
-    assert(!ref_index);
-}
-
 static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, IDWTELEM * old_buffer, int plane_index, int add, int mb_y){
     Plane *p= &s->plane[plane_index];
     const int mb_w= s->b_width  << s->block_max_depth;
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 61830b0..334c460 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -35,254 +35,6 @@
 #undef NDEBUG
 #include <assert.h>
 
-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,
-};
-
-#define QEXPSHIFT (7-FRAC_BITS+8) //FIXME try to change this to 0
-
-static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){
-    int i;
-
-    if(v){
-        const int a= FFABS(v);
-        const int e= av_log2(a);
-        const int el= FFMIN(e, 10);
-        put_rac(c, state+0, 0);
-
-        for(i=0; i<el; i++){
-            put_rac(c, state+1+i, 1);  //1..10
-        }
-        for(; i<e; i++){
-            put_rac(c, state+1+9, 1);  //1..10
-        }
-        put_rac(c, state+1+FFMIN(i,9), 0);
-
-        for(i=e-1; i>=el; i--){
-            put_rac(c, state+22+9, (a>>i)&1); //22..31
-        }
-        for(; i>=0; i--){
-            put_rac(c, state+22+i, (a>>i)&1); //22..31
-        }
-
-        if(is_signed)
-            put_rac(c, state+11 + el, v < 0); //11..21
-    }else{
-        put_rac(c, state+0, 1);
-    }
-}
-
-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, a;
-        e= 0;
-        while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
-            e++;
-        }
-
-        a= 1;
-        for(i=e-1; i>=0; i--){
-            a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31
-        }
-
-        e= -(is_signed && get_rac(c, state+11 + FFMIN(e,10))); //11..21
-        return (a^e)-e;
-    }
-}
-
-static inline void put_symbol2(RangeCoder *c, uint8_t *state, int v, int log2){
-    int i;
-    int r= log2>=0 ? 1<<log2 : 1;
-
-    assert(v>=0);
-    assert(log2>=-4);
-
-    while(v >= r){
-        put_rac(c, state+4+log2, 1);
-        v -= r;
-        log2++;
-        if(log2>0) r+=r;
-    }
-    put_rac(c, state+4+log2, 0);
-
-    for(i=log2-1; i>=0; i--){
-        put_rac(c, state+31-i, (v>>i)&1);
-    }
-}
-
-static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2){
-    int i;
-    int r= log2>=0 ? 1<<log2 : 1;
-    int v=0;
-
-    assert(log2>=-4);
-
-    while(get_rac(c, state+4+log2)){
-        v+= r;
-        log2++;
-        if(log2>0) r+=r;
-    }
-
-    for(i=log2-1; i>=0; i--){
-        v+= get_rac(c, state+31-i)<<i;
-    }
-
-    return v;
-}
-
-static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, int orientation){
-    const int w= b->width;
-    const int h= b->height;
-    int x,y;
-
-    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;
-
-    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;
-
-        if(y && prev_xc->x == 0){
-            rt= prev_xc->coeff;
-        }
-        for(x=0; x<w; x++){
-            int p=0;
-            const int l= v;
-
-            lt= t; t= rt;
-
-            if(y){
-                if(prev_xc->x <= x)
-                    prev_xc++;
-                if(prev_xc->x == x + 1)
-                    rt= prev_xc->coeff;
-                else
-                    rt=0;
-            }
-            if(parent_xc){
-                if(x>>1 > parent_xc->x){
-                    parent_xc++;
-                }
-                if(x>>1 == parent_xc->x){
-                    p= parent_xc->coeff;
-                }
-            }
-            if(/*ll|*/l|lt|t|rt|p){
-                int context= av_log2(/*FFABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1));
-
-                v=get_rac(&s->c, &b->state[0][context]);
-                if(v){
-                    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]]);
-
-                    xc->x=x;
-                    (xc++)->coeff= v;
-                }
-            }else{
-                if(!run){
-                    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]);
-
-                    xc->x=x;
-                    (xc++)->coeff= v;
-                }else{
-                    int max_run;
-                    run--;
-                    v=0;
-
-                    if(y) max_run= FFMIN(run, prev_xc->x - x - 2);
-                    else  max_run= FFMIN(run, w-x-1);
-                    if(parent_xc)
-                        max_run= FFMIN(max_run, 2*parent_xc->x - x - 1);
-                    x+= max_run;
-                    run-= max_run;
-                }
-            }
-        }
-        (xc++)->x= w+1; //end marker
-        prev_xc= prev2_xc;
-        prev2_xc= xc;
-
-        if(parent_xc){
-            if(y&1){
-                while(parent_xc->x != parent->width+1)
-                    parent_xc++;
-                parent_xc++;
-                prev_parent_xc= parent_xc;
-            }else{
-                parent_xc= prev_parent_xc;
-            }
-        }
-    }
-
-    (xc++)->x= w+1; //end marker
-}
-
-static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, int cb, int cr, int mx, int my, int ref, int type){
-    const int w= s->b_width << s->block_max_depth;
-    const int rem_depth= s->block_max_depth - level;
-    const int index= (x + y*w) << rem_depth;
-    const int block_w= 1<<rem_depth;
-    BlockNode block;
-    int i,j;
-
-    block.color[0]= l;
-    block.color[1]= cb;
-    block.color[2]= cr;
-    block.mx= mx;
-    block.my= my;
-    block.ref= ref;
-    block.type= type;
-    block.level= level;
-
-    for(j=0; j<block_w; j++){
-        for(i=0; i<block_w; i++){
-            s->block[index + i + j*w]= block;
-        }
-    }
-}
-
-static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
-    const int offset[3]= {
-          y*c->  stride + x,
-        ((y*c->uvstride + x)>>1),
-        ((y*c->uvstride + x)>>1),
-    };
-    int i;
-    for(i=0; i<3; i++){
-        c->src[0][i]= src [i];
-        c->ref[0][i]= ref [i] + offset[i];
-    }
-    assert(!ref_index);
-}
-
 #define QUANTIZE2 0
 
 #if QUANTIZE2==1
-- 
1.7.7



More information about the libav-devel mailing list