ringbuf.h

来自「代码有点长,需细心阅读,仅供影音视听类产品的开发人员参考」· C头文件 代码 · 共 76 行

H
76
字号
#ifndef	__RINGBUF_H
#define	__RINGBUF_H

#include "config.h"

/*
** ring buffer control
**
**	..uuudddddd...
**	  B  R    W
**
*/
#if 0
//static inline int  WRAPl(int r, int s) {return (r<0) ? (r+s) : r;}
//static inline int  WRAPr(int r, int s) {return (r>=s) ? (r-s) : r;}
#endif

#ifdef ENABLE_INLINE
static inline int WRAPl(int r, int s)
{
	return (r < 0) ? (r + s) : r;
}
static inline int WRAPr(int r, int s)
{
	return (r >= s) ? (r - s) : r;
}
#else
#define WRAPl(r,s) (((r)<0) ? ((r)+(s)) : (r))
#define WRAPr(r,s) (((r)>=(s)) ? ((r)-(s)) : (r))
#endif

//#define WRAPl(r,s) (((r)<0) ? ((r)+(s)) : (r))
//#define WRAPr(r,s) (((r)>=(s)) ? ((r)-(s)) : (r))
//#ifdef SUPPORT_CD_MOVE
static inline int RingBufferSize_CD(int Wp, int Rp, int L)
{
	int     S = Wp - Rp;

	if(S < 0)
		S += L;
	S = (S * 288) / 1024;					// because CD_MOVE width is 288 and original is 1024
	return S;
}

static inline int RingBufferFree_CD(int Wp, int Bp, int L)
{
	int     F = Bp - Wp;

	if(F <= 0)
		F += L;
	F = (F * 288) / 1024;					// because CD_MOVE width is 288 and original is 1024
	return F;
}

//#endif

static inline int RingBufferSize(int Wp, int Rp, int L)
{
	int     S = Wp - Rp;

	if(S < 0)
		S += L;
	return S;
}

static inline int RingBufferFree(int Wp, int Bp, int L)
{
	int     F = Bp - Wp;

	if(F <= 0)
		F += L;
	return F;
}

#endif/*__RINGBUF_H*/

⌨️ 快捷键说明

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