www.pudn.com > xiaobo.zip.zip > coder_sm_o0.c
/***** SigMap : send "significance map" then residual values order zero version -------- slightly better than plain order 0 ******/ #include#include #include #include #include #include extern int tune_param; /*** some convenient debug routines: ** #define SEND_TAG() if(0); else { arithEncode(ari,43,44,77); } ** #define GET_TAG() if(0); else { int got; got = arithGet(ari,77); arithDecode(ari,43,44,77); if ( got != 43 ) errexit("tag failure"); } ********/ #define SMo0_ALPHABET 5 /** 0,1,-1,pos,neg **/ #define SMo0_TOTMAX 5000 #define SMo0_INC 30 #define ORDER0_TOTMAX 500 #define ORDER0_ALPHABET 25 #define ORDER0_ESCAPE (ORDER0_ALPHABET-1) #include "coder.h" void coderSMo0_encodeBand(coder *me,int *band,int w,int h,int fullw,int *parent); void coderSMo0_decodeBand(coder *me,int *band,int w,int h,int fullw,int *parent); typedef struct { ozero * o0; scontext * o1; } myInfo; void coderSMo0_init(coder *c) { myInfo *d; //int i; if ( (d = new(myInfo)) == NULL ) errexit("ozero init failed"); c->data = d; if ( (d->o0 = ozeroCreateMax(c->arith,ORDER0_ALPHABET,ORDER0_TOTMAX)) == NULL ) errexit("ozero init failed"); if ( (d->o1 = scontextCreate(c->arith,SMo0_ALPHABET,0, SMo0_TOTMAX,SMo0_INC,true)) == NULL ) errexit("context creation failed!"); } void coderSMo0_free(coder *c) { if ( c->data ) { myInfo *d; d = c->data; if ( d->o0 ) ozeroFree(d->o0); if ( d->o1 ) scontextFree(d->o1); free(d); c->data = NULL; } } coder coderSMo0 = { "SigMap o0", coderSMo0_init, coderSMo0_free, coderSMo0_encodeBand, coderSMo0_decodeBand }; void coderSMo0_encodeBand(coder *me,int *band,int width,int height,int fullw,int *parent) { int x,y,val; int *dp; ozero *o0 = ((myInfo *)me->data)->o0; scontext *o1 = ((myInfo *)me->data)->o1; arithInfo *ari = me->arith; dp = band; for(y=0;y data)->o0; scontext *o1 = ((myInfo *)me->data)->o1; arithInfo *ari = me->arith; dp = band; for(y=0;y