?? coder_none.c
字號:
#include <stdlib.h>
#include <string.h>
#include <crblib/inc.h>
#include <crblib/arithc.h>
#include "coder.h"
void coderNone_encodeBand(coder *me,int *band,int w,int h,int fullw,int *parent);
void coderNone_decodeBand(coder *me,int *band,int w,int h,int fullw,int *parent);
void coderNone_init(coder *me) { }
void coderNone_free(coder *me) { }
#define RANGE 32
#define ESCAPE (RANGE-1)
coder coderNone = {
"none",
coderNone_init,
coderNone_free,
coderNone_encodeBand,
coderNone_decodeBand
};
void coderNone_encodeBand(coder *me,int *band,int width,int height,int fullw,int *parent)
{
int x,y,v,sign;
int *dp;
arithInfo *ari = me->arith;
dp = band;
for(y=0;y<height;y++) {
if ( coder_timetostop(me) ) { coder_didstop(me,y); return; }
for(x=width;x--;) {
v = *dp++;
if ( v == 0 ) {
arithEncode(ari,0,1,RANGE);
continue;
} else if ( isneg(v) ) { sign = 1; v = -v;
} else sign = 0;
while( v >= ESCAPE ) {
arithEncode(ari,ESCAPE,RANGE,RANGE);
v -= ESCAPE;
}
arithEncode(ari,v,v+1,RANGE);
arithBit(ari,sign);
}
dp += (fullw - width);
}
}
void coderNone_decodeBand(coder *me,int *band,int width,int height,int fullw,int *parent)
{
int x,y,v,got;
int *dp;
arithInfo *ari = me->arith;
dp = band;
for(y=0;y<height;y++) {
if ( coder_timetostopd(me,y) ) { dbf(); return; }
for(x=width;x--;) {
got = arithGet(ari,RANGE);
arithDecode(ari,got,got+1,RANGE);
if ( got == 0 ) {
*dp++ = 0;
continue;
}
v=0;
while ( got == ESCAPE ) {
v+=ESCAPE;
got = arithGet(ari,RANGE);
arithDecode(ari,got,got+1,RANGE);
}
v+=got;
if ( arithGetBit(ari) ) v = -v;
*dp++ = v;
}
dp += (fullw - width);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -