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

📄 yuvrgb16.c

📁 超级解霸源代码。纯c语言写的。适合有一定编程基础的开发人员用来学习提高
💻 C
📖 第 1 页 / 共 5 页
字号:
////////////////////////////////////////////////////////
//		  YUV to RGB Decoder.
//	Display on different mode use different ways.
//		    Southern.Liang
//		       1996.5.25
////////////////////////////////////////////////////////
//#pragma	option	-zC_TEXT	//This Must in _TEXT segment because the library & Enter point in _TEXT
#include <windows.h>
#include "DOS.H"
#include "DCI.H"
#include "VCDAPI.H"

extern	WORD	Linear;
extern	HGLOBAL	OffScrSel;
extern	int	DisplayVideo;
extern	long	VCDHigh;
extern	int	DeleteLine;
int	Line;
int	Pixels;
int	Counter;
int	TimesColor=0;
DWORD	LinearOffSurface;
DWORD	LinearSelSurface;
extern	LPDCIOFFSCREEN	DCISurfaceScreenPtr;
extern	DCIOFFSCREEN	DCISurfaceScreen;	//Offscreen or primary
RECT	VideoRc={0,0,640,240};
#pragma	warn	-par
///////////////// Draw YUV to RGB supported VGA ///////////////
extern	DWORD	DCIYUVFormat;
extern	int	DisplayPreView;
extern	int	CapturePictureFlags;
static	void	Align00(void){}
void	PASCAL _huge DrawYUVDCI(LPDCISURFACEINFO lpSurface)
{	//Only for DCI Supported YUV to RGB
	//BeginAccess
	if(!DisplayVideo)
		{
		if(DisplayPreView)	PreViewPicture();//Draw preview
		if(CapturePictureFlags)	DecodeCapturePicture();//Capture
		_AX=0;
		return;
		}
	if(DCISurfaceScreen.dciInfo.BeginAccess!=NULL)
		(*DCISurfaceScreen.dciInfo.BeginAccess)(DCISurfaceScreenPtr,&VideoRc);
	// Move Data to Offscreen with its format.
	_ES=LinearSelSurface;
	_EDX=VCDHigh;
	_EDI=LinearOffSurface;		//ES:EDI->Offscreen
	if(DCIYUVFormat==0x32595559) DrawYUY2();	//'YUY2'
	if(DCIYUVFormat==0x55595659) DrawYVYU();	//'YVYU'
	if(DCIYUVFormat==0x59565955) DrawUYVY();	//'UYVY'
	if(DCIYUVFormat==0x39304649) DrawYVU9();//DrawIF09();	//'IF09'
	if(DCIYUVFormat==0x39555659) DrawYVU9();	//'YVU9'
	if(DCIYUVFormat==0x32315659) DrawYVU12();	//'YV12'
	//Draw YUV data with standard format.
	(*DCISurfaceScreen.Draw)((LPDCISURFACEINFO)DCISurfaceScreenPtr);
	//EndAccess
	if(DCISurfaceScreen.dciInfo.EndAccess!=NULL)
		(*DCISurfaceScreen.dciInfo.EndAccess)(DCISurfaceScreenPtr);
	_AX=0;
}
#pragma	warn	.par
void	FastYUV2RGB16Bits(void);
void	FastYUV2RGB16BitsDeletePixel(void);
void	FastYUV2RGB16Bits1Line(void);
void	FastYUV2RGB16Bits1LineDeletePixel(void);//Delete one pixel
static	void	Align36(void)
{
	asm	nop
}
void	PASCAL near DrawYVU16Color(void)
{	//Only for 320x200 64K Color

	asm	mov	es,OffScrSel;
	asm	xor	di,di
	Counter=0;
	if(DeleteLine==5)
		{
		/////////////352x240/////////////
		_DX=Linear;
		__emit__(0x26,0x66,0x8B,0x75,0x04);//asm mov esi,es:[di+4]
		__emit__(0x26,0x66,0x8B,0x6D,0x08);//asm mov ebp,es:[di+8]
		__emit__(0x26,0x8E,0x6D,0x10);//asm	mov	gs,es:[di+0x10]	//GS-> Video data
		asm	mov	es,dx
		_EDI=0;
		Line=120;
		MoveVideoData240:
		asm	inc	Counter
		asm	cmp	Counter,3
		asm	je	DeleteLine240
		////// 352 bytes 32 times.
		Pixels=8;
		LoopLine240:
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		asm	dec	Pixels		//asm	loop	LoopLine240
		asm	jnz	LoopLine240
		_EBP+=976;
		_ESI+=(800+0x480);	//2 line had draw
		_EDI+=640;
		asm	dec	Line
		asm	jnz	near ptr MoveVideoData240
		goto	RETURN;
		DeleteLine240:
		asm	mov	Counter,0
		Pixels=8;
		LoopLine240Delete:
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1LineDeletePixel();//Delete one pixel
		asm	dec	Pixels		//asm	loop	LoopLine240
		asm	jnz	LoopLine240Delete
		_EBP+=976;
		_ESI+=(800+0x480);//2 line had draw only one
		asm	dec	Line
		asm	jz	NextRet240
		asm	jmp	MoveVideoData240
		NextRet240:
		}
	else	{// 288 - > 200 36/25 delete 11 lines.
		TimesColor=0;
		/////////////352x288/////////
		_DX=Linear;
		__emit__(0x26,0x66,0x8B,0x75,0x04);//asm mov esi,es:[di+4]
		__emit__(0x26,0x66,0x8B,0x6D,0x08);//asm mov ebp,es:[di+8]
		__emit__(0x26,0x8E,0x6D,0x10);//asm	mov	gs,es:[di+0x10]	//GS-> Video data
		asm	mov	es,dx
		_EDI=0;
		Line=144;//=288/2
		MoveVideoData288:
		asm	inc	TimesColor
		if(TimesColor>18) TimesColor=1;
		asm	inc	Counter
		asm	cmp	Counter,1
		asm	je	NoDeleteLine288
		////// 352 bytes 32 times.
		if(TimesColor>12 || Counter>=3) Counter=0;
		Pixels=8;	//Draw 1 lines
		LoopLine288Delete:
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits1Line();
		FastYUV2RGB16Bits1LineDeletePixel();//Delete one pixel
		asm	dec	Pixels
		asm	jnz	LoopLine288Delete
		_EBP+=976;
		_ESI+=(800+0x480);	//2 line had draw only one
		asm	dec	Line
		asm	jnz	near ptr MoveVideoData288
		goto	RETURN;
		NoDeleteLine288://Draw 2 lines
		Pixels=8;
		LoopLine288:
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		asm	dec	Pixels
		asm	jnz	LoopLine288
		_EBP+=976;
		_ESI+=(800+0x480);	//2 line had draw
		_EDI+=640;	//2 line had draw
		asm	dec	Line
		asm	jz	RETURN
		asm	jmp	MoveVideoData288
		}
	RETURN:
	_AX=0;	//return 0;
}
/////////////////////// RGB 15 ///////////////////
static	void	Align1(void)
{
	asm	nop
}
void	FastYUV2RGB15Bits(void);
void	FastYUV2RGB15BitsDeletePixel(void);
void	FastYUV2RGB15Bits1Line(void);
void	FastYUV2RGB15Bits1LineDeletePixel(void);//Delete one pixel
void	PASCAL near DrawYVU15Color(void)
{	//Only for 320x200 32K Color

	asm	mov	es,OffScrSel;
	asm	xor	di,di
	Counter=0;
	if(DeleteLine==5)
		{
		/////////////352x240/////////////
		_DX=Linear;
		__emit__(0x26,0x66,0x8B,0x75,0x04);//asm mov esi,es:[di+4]
		__emit__(0x26,0x66,0x8B,0x6D,0x08);//asm mov ebp,es:[di+8]
		__emit__(0x26,0x8E,0x6D,0x10);//asm	mov	gs,es:[di+0x10]	//GS-> Video data
		asm	mov	es,dx
		_EDI=0;
		Line=120;
		MoveVideoData240:
		asm	inc	Counter
		asm	cmp	Counter,3
		asm	je	DeleteLine240
		////// 352 bytes 32 times.
		Pixels=8;
		LoopLine240:
		FastYUV2RGB15Bits();
		FastYUV2RGB15Bits();
		FastYUV2RGB15BitsDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits();
		FastYUV2RGB15Bits();
		FastYUV2RGB15BitsDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits();
		FastYUV2RGB15Bits();
		FastYUV2RGB15BitsDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits();
		FastYUV2RGB15BitsDeletePixel();//Delete one pixel
		asm	dec	Pixels		//asm	loop	LoopLine240
		asm	jnz	LoopLine240
		_EBP+=976;
		_ESI+=(800+0x480);	//2 line had draw
		_EDI+=640;
		asm	dec	Line
		asm	jnz	near ptr MoveVideoData240
		goto	RETURN;
		DeleteLine240:
		asm	mov	Counter,0
		Pixels=8;
		LoopLine240Delete:
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1LineDeletePixel();//Delete one pixel
		asm	dec	Pixels		//asm	loop	LoopLine240
		asm	jnz	LoopLine240Delete
		_EBP+=976;
		_ESI+=(800+0x480);	//2 line had draw only one
		asm	dec	Line
		asm	jz	NextRet240
		asm	jmp	MoveVideoData240
		NextRet240:
		}
	else	{// 288 - > 200 36/25 delete 11 lines.
		TimesColor=0;
		/////////////352x288/////////
		_DX=Linear;
		__emit__(0x26,0x66,0x8B,0x75,0x04);//asm mov esi,es:[di+4]
		__emit__(0x26,0x66,0x8B,0x6D,0x08);//asm mov ebp,es:[di+8]
		__emit__(0x26,0x8E,0x6D,0x10);//asm	mov	gs,es:[di+0x10]	//GS-> Video data
		asm	mov	es,dx
		_EDI=0;
		Line=144;//=288/2
		MoveVideoData288:
		asm	inc	TimesColor
		if(TimesColor>18) TimesColor=1;
		asm	inc	Counter
		asm	cmp	Counter,1
		asm	je	NoDeleteLine288
		////// 352 bytes 32 times.
		if(TimesColor>12 || Counter>=3) Counter=0;
		Pixels=8;	//Draw 1 lines
		LoopLine288Delete:
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1LineDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits1Line();
		FastYUV2RGB15Bits1LineDeletePixel();//Delete one pixel
		asm	dec	Pixels
		asm	jnz	LoopLine288Delete
		_EBP+=976;
		_ESI+=(800+0x480);	//2 line had draw only one
		asm	dec	Line
		asm	jnz	near ptr MoveVideoData288
		goto	RETURN;
		NoDeleteLine288://Draw 2 lines
		Pixels=8;
		LoopLine288:
		FastYUV2RGB15Bits();
		FastYUV2RGB15Bits();
		FastYUV2RGB15BitsDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits();
		FastYUV2RGB15Bits();
		FastYUV2RGB15BitsDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits();
		FastYUV2RGB15Bits();
		FastYUV2RGB15BitsDeletePixel();//Delete one pixel
		FastYUV2RGB15Bits();
		FastYUV2RGB15BitsDeletePixel();//Delete one pixel
		asm	dec	Pixels
		asm	jnz	LoopLine288
		_EBP+=976;
		_ESI+=(800+0x480);	//2 line had draw
		_EDI+=640;	//2 line had draw
		asm	dec	Line
		asm	jz	RETURN
		asm	jmp	MoveVideoData288
		}
	RETURN:
	_AX=0;	//return 0;
}
////////////////// Draw Memory Buffer of Video ////////////////
int	DCIType=0;//If now be 640x480 and had DCI Primary 64K/32K set 1
		// If be offscreen YUV->RGB set 2;
extern	int	BankSize;	//K
extern	WORD	A000Buffer;//A0000 Base address selector
/*********************************************\
/////////////// 640x480 64K///////////////////
void	PASCAL near BuildYVURGB16Color(void)
{	//for 320x240 64K Color in memory
	asm	mov	es,OffScrSel;
	asm	xor	di,di
	Counter=0;
	if(DeleteLine==5)
		{
		/////////////352x240/////////////
		_DX=Linear;
		__emit__(0x26,0x66,0x8B,0x75,0x04);//asm mov esi,es:[di+4]
		__emit__(0x26,0x66,0x8B,0x6D,0x08);//asm mov ebp,es:[di+8]
		__emit__(0x26,0x8E,0x6D,0x10);//asm	mov	gs,es:[di+0x10]	//GS-> Video data
		asm	mov	es,dx
		_EDI=0;
		Line=120;
		MoveVideoData240:
		////// 352 bytes 32 times.
		Pixels=8;
		LoopLine240:
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		asm	dec	Pixels		//asm	loop	LoopLine240
		asm	jnz	LoopLine240
		_EBP+=976;
		_ESI+=(800+0x480);	//2 line had draw
		_EDI+=640;
		asm	dec	Line
		asm	jnz	near ptr MoveVideoData240
		}
	else	{// 288 - > 240 6/5 delete 1 lines.
		/////////////352x288/////////
		_DX=Linear;
		__emit__(0x26,0x66,0x8B,0x75,0x04);//asm mov esi,es:[di+4]
		__emit__(0x26,0x66,0x8B,0x6D,0x08);//asm mov ebp,es:[di+8]
		__emit__(0x26,0x8E,0x6D,0x10);//asm	mov	gs,es:[di+0x10]	//GS-> Video data
		asm	mov	es,dx
		_EDI=0;
		Line=144;//=288/2
		MoveVideoData288:
		asm	inc	Counter
		asm	cmp	Counter,3
		asm	je	DeleteLine288
		////// 352 bytes 32 times.
		Pixels=8;	//Draw 2 lines
		LoopLine288Delete:
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		FastYUV2RGB16Bits();
		FastYUV2RGB16BitsDeletePixel();//Delete one pixel
		asm	dec	Pixels
		asm	jnz	LoopLine288Delete
		_EBP+=976;
		_ESI+=(800+0x480);	//2 line had draw
		_EDI+=640;	//2 line had draw
		asm	dec	Line
		asm	jnz	near ptr MoveVideoData288
		goto	RETURN;
		DeleteLine288://Draw 1 lines
		Counter=0;
		Pixels=8;
		LoopLine288:

⌨️ 快捷键说明

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