⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basetype.h

📁 傅立叶变换和小波变换是图像压缩的重要工具。该代大戏是利用小波变换进行图像压缩。
💻 H
字号:
#ifndef GE_BASETYPE_H
#define GE_BASETYPE_H
 
/*
	Some basic types defined with clear names for
	more specific data definitions
*/

#include <crblib/inc.h>
 
#ifdef __cplusplus
extern "C" {
#endif

//------------------------------

typedef float geFloat;

typedef signed short    int16;
typedef signed char     int8 ;
typedef unsigned short	uint16;

//------------------------------

#ifndef NULL
#define NULL													((void *)0)
#endif

#define	GE_PI													((geFloat)3.14159265358979323846)
#define	GE_TWOPI											((geFloat)6.28318530717958647692)
#define	GE_HALFPI											((geFloat)1.57079632679489661923)

#define GE_DEGS_PER_RAD								((geFloat)0.01745329251994329576)
#define GE_RADS_PER_DEG								((geFloat)57.2957795130823208767)

// should probably be moved to trig module
__inline geFloat geFloat_DegToRad(geFloat d)
{
	return d * GE_DEGS_PER_RAD;
}

__inline geFloat geFloat_RadToDeg(geFloat r)
{
	return r * GE_RADS_PER_DEG;
}


//------------------------------
// macros on basic genesis types

#define GE_ABS(x)										( (x) < 0 ? (-(x)) : (x) )
#define GE_CLAMP(x,lo,hi)								( (x) < (lo) ? (lo) : ( (x) > (hi) ? (hi) : (x) ) )
#define GE_CLAMP8(x)									GE_CLAMP(x,0,255)
#define GE_CLAMP16(x)									GE_CLAMP(x,0,65536)
#define GE_BOOLSAME(x,y)								( ( (x) && (y) ) || ( !(x) && !(y) ) )

#define GE_EPSILON										((geFloat)0.000797f)
#define GE_FLOATS_EQUAL(x,y)							( GE_ABS((x) - (y)) < GE_EPSILON )
#define GE_FLOAT_ISZERO(x)								GE_FLOATS_EQUAL(x,0.0f)

// you're right... inline funcs are more useful :^)
static __inline geFloat geFloat_Sqr(geFloat a)
{
	return a * a;
}

static __inline geFloat geFloat_Cube(geFloat a)
{
	return a * a * a;
}

//------------------------------

// CB : what does the optimizer do with inline assembly in inline functions ?
//		will it turn off all optimizations?

static geFloat __inline geFloat_RoundToInt(geFloat val) // rounds depending on how you set geCPU_FloatControl
{
	__asm
	{
		FLD  val
		FRNDINT
		FSTP val
	}
return val;
}

static geFloat __inline geFloat_Sqrt(geFloat val)
{
	__asm 
	{
		FLD  val		// 1 clock
		FSQRT			// 30-70 clocks
		FSTP val		// 2 clocks
	}
return val;
}

static geFloat __inline geFloat_Sin(geFloat val)
{
	__asm 
	{
		FLD  val		// 1 clock
		FSIN			// ~ 200 clocks
		FSTP val		// 2 clocks
	}
return val;
}

static geFloat __inline geFloat_Cos(geFloat val)
{
	__asm 
	{
		FLD  val		// 1 clock
		FCOS			// ~ 200 clocks
		FSTP val		// 2 clocks
	}
return val;
}

static int __inline geFloat_ToInt(geFloat f)
{
int i;
	__asm
	{
		FLD   f
		FISTP i
	}
return i;
}

#pragma warning (disable:4514)	// unreferenced inline function

//------------------------------

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -