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

📄 common.c

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 C
📖 第 1 页 / 共 3 页
字号:
								(psf)->header [(psf)->headindex++] = (x) ;	}#elif (CPU_IS_LITTLE_ENDIAN == 1)#define	PUT_MARKER(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 4)	\							{	(psf)->header [(psf)->headindex++] = (x) ;				\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 16) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 24) ;	}#else#	error "Cannot determine endian-ness of processor."#endif#define	PUT_BE_SHORT(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 2)	\							{	(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = (x) ; 		}#define	PUT_LE_SHORT(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 2)	\							{	(psf)->header [(psf)->headindex++] = (x) ;				\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;	}#define	PUT_BE_3BYTE(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 3)	\							{	(psf)->header [(psf)->headindex++] = ((x) >> 16) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = (x) ;		}#define	PUT_LE_3BYTE(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 3)	\							{	(psf)->header [(psf)->headindex++] = (x) ;				\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 16) ;	}#define	PUT_BE_INT(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 4)	\							{	(psf)->header [(psf)->headindex++] = ((x) >> 24) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 16) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = (x) ;		}#define	PUT_LE_INT(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 4)	\							{	(psf)->header [(psf)->headindex++] = (x) ;				\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 16) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 24) ;	}#if (SIZEOF_SF_COUNT_T == 4)#define	PUT_BE_8BYTE(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 8)	\							{	(psf)->header [(psf)->headindex++] = 0 ;				\								(psf)->header [(psf)->headindex++] = 0 ;				\								(psf)->header [(psf)->headindex++] = 0 ;				\								(psf)->header [(psf)->headindex++] = 0 ;				\								(psf)->header [(psf)->headindex++] = ((x) >> 24) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 16) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = (x) ;		}#define	PUT_LE_8BYTE(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 8)	\							{	(psf)->header [(psf)->headindex++] = (x) ;				\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 16) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 24) ;		\								(psf)->header [(psf)->headindex++] = 0 ;				\								(psf)->header [(psf)->headindex++] = 0 ;				\								(psf)->header [(psf)->headindex++] = 0 ;				\								(psf)->header [(psf)->headindex++] = 0 ;	}#elif (SIZEOF_SF_COUNT_T == 8)#define	PUT_BE_8BYTE(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 8)	\							{	(psf)->header [(psf)->headindex++] = ((x) >> 56) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 48) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 40) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 32) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 24) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 16) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = (x) ;		}#define	PUT_LE_8BYTE(psf,x)	if ((psf)->headindex < SIGNED_SIZEOF ((psf)->header) - 8)	\							{	(psf)->header [(psf)->headindex++] = (x) ;				\								(psf)->header [(psf)->headindex++] = ((x) >> 8) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 16) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 24) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 32) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 40) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 48) ;		\								(psf)->header [(psf)->headindex++] = ((x) >> 56) ;	}#else#error "SIZEOF_SF_COUNT_T is not defined."#endifintpsf_binheader_writef (SF_PRIVATE *psf, const char *format, ...){	va_list	argptr ;	sf_count_t 		countdata ;	unsigned long 	longdata ;	unsigned int 	data ;	float			floatdata ;	double			doubledata ;	void			*bindata ;	size_t			size ;	char			c, *strptr ;	int				count = 0, trunc_8to4 ;	trunc_8to4 = SF_FALSE ;	va_start (argptr, format) ;	while ((c = *format++))	{	switch (c)		{	case 'e' : /* All conversions are now from LE to host. */					psf->rwf_endian = SF_ENDIAN_LITTLE ;					break ;			case 'E' : /* All conversions are now from BE to host. */					psf->rwf_endian = SF_ENDIAN_BIG ;					break ;			case 't' : /* All 8 byte values now get written as 4 bytes. */					trunc_8to4 = SF_TRUE ;					break ;			case 'T' : /* All 8 byte values now get written as 8 bytes. */					trunc_8to4 = SF_FALSE ;					break ;			case 'm' :					data = va_arg (argptr, unsigned int) ;					PUT_MARKER (psf, data) ;					count += 4 ;					break ;			case '1' :					data = va_arg (argptr, unsigned int) ;					PUT_BYTE (psf, data) ;					count += 1 ;					break ;			case '2' :					data = va_arg (argptr, unsigned int) ;					if (psf->rwf_endian == SF_ENDIAN_BIG)					{	PUT_BE_SHORT (psf, data) ;						}					else					{	PUT_LE_SHORT (psf, data) ;						} ;					count += 2 ;					break ;			case '3' : /* tribyte */					data = va_arg (argptr, unsigned int) ;					if (psf->rwf_endian == SF_ENDIAN_BIG)					{	PUT_BE_3BYTE (psf, data) ;						}					else					{	PUT_LE_3BYTE (psf, data) ;						} ;					count += 3 ;					break ;			case '4' :					data = va_arg (argptr, unsigned int) ;					if (psf->rwf_endian == SF_ENDIAN_BIG)					{	PUT_BE_INT (psf, data) ;						}					else					{	PUT_LE_INT (psf, data) ;						} ;					count += 4 ;					break ;			case '8' :					countdata = va_arg (argptr, sf_count_t) ;					if (psf->rwf_endian == SF_ENDIAN_BIG && trunc_8to4 == SF_FALSE)					{	PUT_BE_8BYTE (psf, countdata) ;						count += 8 ;						}					else if (psf->rwf_endian == SF_ENDIAN_LITTLE && trunc_8to4 == SF_FALSE)					{	PUT_LE_8BYTE (psf, countdata) ;						count += 8 ;						}					else if (psf->rwf_endian == SF_ENDIAN_BIG && trunc_8to4 == SF_TRUE)					{	longdata = countdata & 0xFFFFFFFF ;						PUT_BE_INT (psf, longdata) ;						count += 4 ;						}					else if (psf->rwf_endian == SF_ENDIAN_LITTLE && trunc_8to4 == SF_TRUE)					{	longdata = countdata & 0xFFFFFFFF ;						PUT_LE_INT (psf, longdata) ;						count += 4 ;						}					break ;			case 'f' :					/* Floats are passed as doubles. Is this always true? */					floatdata = (float) va_arg (argptr, double) ;					if (psf->rwf_endian == SF_ENDIAN_BIG)						float32_be_write (floatdata, psf->header + psf->headindex) ;					else						float32_le_write (floatdata, psf->header + psf->headindex) ;					psf->headindex += 4 ;					count += 4 ;					break ;			case 'd' :					doubledata = va_arg (argptr, double) ;					if (psf->rwf_endian == SF_ENDIAN_BIG)						double64_be_write (doubledata, psf->header + psf->headindex) ;					else						double64_le_write (doubledata, psf->header + psf->headindex) ;					psf->headindex += 8 ;					count += 8 ;					break ;			case 's' :					strptr = va_arg (argptr, char *) ;					size = strlen (strptr) + 1 ;					size += (size & 1) ;					if (psf->rwf_endian == SF_ENDIAN_BIG)					{	PUT_BE_INT (psf, size) ;						}					else					{	PUT_LE_INT (psf, size) ;						} ;					memcpy (&(psf->header [psf->headindex]), strptr, size) ;					psf->headindex += size ;					psf->header [psf->headindex - 1] = 0 ;					count += 4 + size ;					break ;			case 'S' :					strptr	= va_arg (argptr, char *) ;					size	= strlen (strptr) + 1 ;					memcpy (&(psf->header [psf->headindex]), strptr, size) ;					psf->headindex += size ;					count += size ;					break ;			case 'b' :					bindata	= va_arg (argptr, void *) ;					size	= va_arg (argptr, size_t) ;					memcpy (&(psf->header [psf->headindex]), bindata, size) ;					psf->headindex += size ;					count += size ;					break ;			case 'z' :					size = va_arg (argptr, size_t) ;					count += size ;					while (size)					{	psf->header [psf->headindex] = 0 ;						psf->headindex ++ ;						size -- ;						} ;					break ;			case 'h' :					bindata = va_arg (argptr, void *) ;					memcpy (&(psf->header [psf->headindex]), bindata, 16) ;					psf->headindex += 16 ;					count += 16 ;					break ;			case 'j' :					size = va_arg (argptr, int) ;					psf->headindex += size ;					count = size ;					break ;			default :				psf_log_printf (psf, "*** Invalid format specifier `%c'\n", c) ;				psf->error = SFE_INTERNAL ;				break ;			} ;		} ;	va_end (argptr) ;	return count ;} /* psf_binheader_writef *//*-----------------------------------------------------------------------------------------------**  Binary header reading functions. Returns number of bytes read.****	Format specifiers are the same as for header write function above with the following**	additions:****		p   - jump a given number of position from start of file.****	If format is NULL, psf_binheader_readf returns the current offset.*/#if (CPU_IS_BIG_ENDIAN == 1)#define	GET_MARKER(ptr)	(	((ptr) [0] << 24)	| ((ptr) [1] << 16) |	\							((ptr) [2] << 8)	| ((ptr) [3]) )#elif (CPU_IS_LITTLE_ENDIAN == 1)#define	GET_MARKER(ptr)	(	((ptr) [0])			| ((ptr) [1] << 8) |	\							((ptr) [2] << 16)	| ((ptr) [3] << 24) )#else#	error "Cannot determine endian-ness of processor."#endif#define	GET_LE_SHORT(ptr)	( ((ptr) [1] << 8) | ((ptr) [0]) )#define	GET_BE_SHORT(ptr)	( ((ptr) [0] << 8) | ((ptr) [1]) )#define	GET_LE_3BYTE(ptr)	( 	((ptr) [2] << 16) | ((ptr) [1] << 8) | ((ptr) [0]) )#define	GET_BE_3BYTE(ptr)	( 	((ptr) [0] << 16) | ((ptr) [1] << 8) | ((ptr) [2]) )#define	GET_LE_INT(ptr)		( 	((ptr) [3] << 24)	| ((ptr) [2] << 16) |	\								((ptr) [1] << 8)	| ((ptr) [0]) )#define	GET_BE_INT(ptr)		( 	((ptr) [0] << 24)	| ((ptr) [1] << 16) |	\							 	((ptr) [2] << 8)	| ((ptr) [3]) )#if (SIZEOF_LONG == 4)#define	GET_LE_8BYTE(ptr)	( 	((ptr) [3] << 24)	| ((ptr) [2] << 16) |	\							 	((ptr) [1] << 8)	| ((ptr) [0]) )#define	GET_BE_8BYTE(ptr)	( 	((ptr) [4] << 24)	| ((ptr) [5] << 16) |	\								((ptr) [6] << 8)	| ((ptr) [7]) )#else#define	GET_LE_8BYTE(ptr)	( 	(((ptr) [7] * 1L) << 56) | (((ptr) [6] * 1L) << 48) |	\							 	(((ptr) [5] * 1L) << 40) | (((ptr) [4] * 1L) << 32) |	\							 	(((ptr) [3] * 1L) << 24) | (((ptr) [2] * 1L) << 16) |	\							 	(((ptr) [1] * 1L) << 8 ) | ((ptr) [0]))#define	GET_BE_8BYTE(ptr)	( 	(((ptr) [0] * 1L) << 56) | (((ptr) [1] * 1L) << 48) |	\							 	(((ptr) [2] * 1L) << 40) | (((ptr) [3] * 1L) << 32) |	\							 	(((ptr) [4] * 1L) << 24) | (((ptr) [5] * 1L) << 16) |	\							 	(((ptr) [6] * 1L) << 8 ) | ((ptr) [7]))#endifstatic intheader_read (SF_PRIVATE *psf, void *ptr, int bytes){	int count = 0 ;	if (psf->headindex + bytes > SIGNED_SIZEOF (psf->header))	{	if (psf->headend < SIGNED_SIZEOF (psf->header))			psf_log_printf (psf, "Warning : Further header read would overflow buffer.\n") ;		psf->headend = SIGNED_SIZEOF (psf->header) ;		/* This is the best that we can do. */		return psf_fread (ptr, 1, bytes, psf) ;		} ;	if (psf->headindex + bytes > psf->headend)	{	count = psf_fread (psf->header + psf->headend, 1, bytes - (psf->headend - psf->headindex), psf) ;		if (count != bytes - (int) (psf->headend - psf->headindex))		{	psf_log_printf (psf, "Error : psf_fread returned short count.\n") ;			return 0 ;			} ;		psf->headend += count ;		} ;	memcpy (ptr, psf->header + psf->headindex, bytes) ;	psf->headindex += bytes ;	return bytes ;} /* header_read */static voidheader_seek (SF_PRIVATE *psf, sf_count_t position, int whence){	switch (whence)	{	case SEEK_SET :			if (position > SIGNED_SIZEOF (psf->header))			{	/* Too much header to cache so just seek instead. */				psf_fseek (psf, position, whence) ;				return ;				} ;			if (position > psf->headend)				psf->headend += psf_fread (psf->header + psf->headend, 1, position - psf->headend, psf) ;			psf->headindex = position ;			break ;		case SEEK_CUR :			if (psf->headindex + position < 0)				break ;			if (psf->headindex >= SIGNED_SIZEOF (psf->header))			{	psf_fseek (psf, position, whence) ;				return ;				} ;			if (psf->headindex + position <= psf->headend)			{	psf->headindex += position ;				break ;				} ;			if (psf->headindex + position > SIGNED_SIZEOF (psf->header))			{	/* Need to jump this without caching it. */				psf->headindex = psf->headend ;				psf_fseek (psf, position, SEEK_CUR) ;				break ;				} ;

⌨️ 快捷键说明

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