?? coder.h
字號(hào):
#ifndef CODER_H
#define CODER_H
/***
***/
#include <crblib/arithc.h>
#define arithBit arithEncBitRaw
#define arithGetBit arithDecBitRaw
typedef struct _image image;
typedef struct _coder coder;
typedef struct _quantInfo quantInfo;
typedef struct _wavelet wavelet;
typedef struct _subband subband;
typedef struct _subband_leaf subband_leaf;
typedef void (*coder_init) (void *);
typedef void (*coder_free) (void *);
typedef void (*coder_encodeBand) (void *,int *,int,int,int,int *);
typedef void (*coder_decodeBand) (void *,int *,int,int,int,int *);
typedef void (*coder_flush) (void *);
typedef void (*coder_encodeBandBP) (void *,int *,int,int,int,int *,int);
typedef void (*coder_decodeBandBP) (void *,int *,int,int,int,int *,int);
typedef void (*coder_encodeBandZT) (void *,int *,int,int,int,int,int **);
typedef void (*coder_decodeBandZT) (void *,int *,int,int,int,int,int **);
typedef void (*coder_encodeSubbandBP) (void *,subband_leaf *,int);
typedef void (*coder_decodeSubbandBP) (void *,subband_leaf *,int);
struct _wavelet {
int complen,levels;
int width,height,planes;
int stoplen,stopline;
const coder * coder_template;
ubyte * comp;
image *im;
/* these are not necessarily set up if you did not use
* the wavelet to do the quantizing and transforming
**/
quantInfo *qi;
int transform;
subband *subband_root;
};
typedef struct _coder {
const char * name;
coder_init init;
coder_free free;
/** one family of pairs must be provided : **/
coder_encodeBand encodeBand;
coder_decodeBand decodeBand;
coder_encodeBandBP encodeBandBP;
coder_decodeBandBP decodeBandBP;
coder_encodeBandZT encodeBandZT;
coder_decodeBandZT decodeBandZT;
coder_encodeSubbandBP encodeSubbandBP;
coder_decodeSubbandBP decodeSubbandBP;
coder_flush flush; /** optional ; set to null if you need no flushing **/
void * data; /** setup by init, killed by free **/
arithInfo * arith; /** controlled by the global coder routines **/
wavelet *w;
} coder;
extern wavelet * newWavelet(const image *template,int levels);
extern void freeWavelet(wavelet *w);
extern void waveletRealloc(wavelet *w); // call after complen is set correctly
extern coder * coder_create_write(const coder *template,wavelet *w,int stoplen);
extern coder * coder_create_read( wavelet *w);
extern void coder_flush_write(coder *);
extern void coder_flush_read(coder *);
extern void coder_destroy(coder *);
#define coder_getpos(c) arithTellEncPos(c->arith)
#define coder_getposd(c) arithTellDecPos(c->arith)
#define coder_timetostop(c) ( coder_getpos(c) >= (c)->w->stoplen )
#define coder_timetostopd(c,y) ( coder_getposd(c) >= (c)->w->stoplen )
//#define coder_timetostopd(c,y) ( ( coder_getposd(c) >= (c)->w->stoplen && ((y) == (c)->w->stopline) ) || ( (coder_getposd(c)) >= (c)->w->stoplen && (y) == 0 ) )
#define coder_didstop(c,y) do { if ( (c)->w->stopline < 0 ) (c)->w->stopline = y; } while(0);
/** getposd makes sure we're in the same band, but isn't reliable for picking the
** right line because of the hidden 4 bytes in the arithcoder state variables
** we need the 'or' in later bands (if we stop before the last)
***/
extern void coder_encodeDPCM(coder *c,int *plane,int width,int height,int rowpad);
extern void coder_decodeDPCM(coder *c,int *plane,int width,int height,int rowpad);
// some order -1 routines for your convenience:
extern void encode_m1(arithInfo * ari,int sym);
extern int decode_m1(arithInfo *ari);
/**** zero tree flags : *****/
#define BASE_SHIFT 29
#define FLAG_ISOLATED_ZERO (1<<(BASE_SHIFT))
#define FLAG_CHILD_ZERO (1<<(BASE_SHIFT-1))
#define FLAG_ALREADY_DECODED FLAG_CHILD_ZERO
#define CODE_MAX_BPN (BASE_SHIFT-2)
#define CODE_MAX_VAL (1<<CODE_MAX_BPN)
// a common coding question:
#define signbit(x) (isneg(x)?1:0)
/**** the mother-list of all coders : ***/
extern const num_coders;
extern const coder * coder_list[];
/*** tune me ! **/
extern int tune_param;
#endif //CODER_H
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -