www.pudn.com > xiaobo.zip.zip > subbands.h


#ifndef SUBBANDS_H 
#define SUBBANDS_H 
 
/**** 
* 
*	"subband" is either a "subband_leaf" or "subband_node" 
* 
*	 
	doStuff(subband *sb) { 
		if ( sb->leaf ) { 
			subband_leaf *sbl; 
			sbl = (subband_leaf *) sb; 
			// use sbl 
		} { 
			subband_node *sbn; 
			sbn = (subband_node *) sbn; 
			if ( sbn->LL ) doStuff(sbn->LL); 
			if ( sbn->LH ) doStuff(sbn->LH); 
			if ( sbn->HL ) doStuff(sbn->HL); 
			if ( sbn->HH ) doStuff(sbn->HH); 
		} 
	} 
* 
*****/ 
 
typedef struct _subband_leaf subband_leaf; 
typedef struct _subband subband_node; 
typedef struct _subband subband; 
 
struct _subband_leaf { 
	bool leaf;	// == true 
	subband *prev;	// the node that points to me 
	int width,height,rowpad,activity,max_value,type; 
		// activity must be trasmitted ; max_val is for *encoder* reference only, and decisions must be transmitted 
		//	max_val would help the BP coders 
 
	bool transposed; 
	int *band; 
		// points into an image 
	subband_leaf *parent; 
		// parent is gauranteed to be half the width & same type of band 
	subband_leaf *cntx1,*cntx2;	 
		// both are already sent, cntx1 is probably parent, cntx1 == cntx2 is possible 
	int cntx1shift,cntx2shift; 
		// the band[x,y] 's context is cntx1[(x)>>cntx1shift,(y)>>cntx1shift] 
		// in a normal EZ wavelet these are always 1 
}; 
 
struct _subband { 
	bool leaf;	// == false 
	subband_node *prev;	// the node that points to me 
	int width,height,rowpad,activity,max_value,type; 
 
	subband *LL,*HL,*LH,*HH; 
}; 
 
typedef struct _image image; 
typedef struct _coder coder; 
typedef struct _wavelet wavelet; 
 
extern void freeSubbands(subband *root); 
extern subband * imageToSubbands(image *im,int levels); 
	/** image can be empty or full, the subbands just point to 
	*	entry points in the image 
	***/ 
	// might return NULL as a valid return (when levels == 0 ) 
 
extern subband * makeSubbandQuad(int *band,int w,int h,int fullw,int levels,subband_node *prev); 
 
extern void encodeWaveletSubbands(wavelet *wavelet); 
extern void decodeWaveletSubbands(wavelet *wavelet); 
 
extern void activitySubbands(subband * sb); 
extern void transposeSubbandLHs(subband *sb); 
 
void findAllSubbandParents(subband *sb,int type); 
 
void printSubbandInfo(subband *sb,FILE *fp,int depth); 
 
#define leaf_op(sb,op) if ( ! (sb)->leaf ) ; else ((subband_leaf *)(sb))->op 
 
#define TYPE_LL	0 
#define TYPE_LH	1 
#define TYPE_HL	2 
#define TYPE_HH	3  
 
#endif //BANDLIST_H