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

📄 util.h

📁 代码有点长,需细心阅读,仅供影音视听类产品的开发人员参考
💻 H
字号:
#ifndef __UTIL_H
#define __UTIL_H

#include "types.h"
#include "regmap.h"

#ifndef	__GNUC__
#define	__attribute__(x) /**/
#endif
/*
** BCD processing
*/
int     bin2bcd(BYTE x) __attribute__ ((const));
int     bcd2bin(BYTE x) __attribute__ ((const));

#define	MSF(mm,ss,ff)	(((UINT32)(mm)<<16) | ((UINT32)(ss)<<8) | (BYTE)(ff))
#define	MSF2l(mm,ss,ff)	(((mm)*60+(ss))*75+(ff)-150)	//(((mm)*60+(ss))*60+(ff)+150)

#define	MSFC(cna,mm,ss,ff)	( ((UINT32)(cna)<<24) \
				| ((UINT32)(mm) <<16) \
				| ((UINT32)(ss)<<8) \
				| (BYTE)(ff))


UINT32  l2msf(UINT32);
UINT32  msf2l(UINT32);

UINT32  addmsf(UINT32, int) __attribute__ ((const));
UINT32  addmsf_ss(UINT32, int) __attribute__ ((const));

#define	msf_mm(msf)	(((msf)>>16) & 0xff)
#define	msf_ss(msf)	(((msf)>>8) & 0xff)
#define	msf_ff(msf)	(((msf)>>0) & 0xff)
#define M2I(msf)	(msf_mm(msf)*60+msf_ss(msf))

#ifdef gcc
static inline int min(int x, int y)
{
	return (x) > (y) ? (y) : (x);
}
static inline int max(int x, int y)
{
	return (x) > (y) ? (x) : (y);
}
#else
#define	min(x,y) ((x)>(y) ? (y) : (x))
#define	max(x,y) ((x)>(y) ? (x) : (y))
#endif

UINT32  endian_swap_32(UINT32);
UINT16  endian_swap_16(UINT16);

/*
 * Multiplication
 * 1.15*1.15 => 2.30
 */
static __inline int mul16(int x, int y)
{
	int     product;

asm("mult %0, %1, %2": "=r"(product):"r"(x), "r"(y));
	return product;
}
static __inline unsigned int mul_u16(unsigned int x, unsigned int y)
{
	unsigned int product;

asm("multu %0, %1, %2": "=r"(product):"r"(x), "r"(y));
	return product;
}
UINT32 Msf2lba(BYTE min, BYTE sec, BYTE frame);
#endif/*__UTIL_H*/

⌨️ 快捷键说明

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