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

📄 blit_arm_fix.c

📁 betaplayer的源码 tcpmp的老版本
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
 *
 * This program is free software ; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 * $Id: blit_arm_fix.c 155 2004-12-21 19:09:44Z picard $
 *
 * BetaPlayer Blit
 * Copyright (c) 2004 Gabor Kovacs
 *
 ****************************************************************************/

#include "../stdafx.h"
#include "../dyncode/dyncode.h"
#include "blit_soft.h"

#if defined( ARM ) 

typedef struct stack
{
	int EndOfLine;
	int EndOfRect;
	int DstPitch; 
	int DstNext;
	int SrcNext;
	int UVNext;

	int StackFrame[STACKFRAME];

	//void* this   R0
	//char* Dst    R1
	//char* Src    R2
	//int DstPitch R3 can be signed
	int SrcPitch; //can be signed
	int Width; 
	int Height;
	int Src2SrcLast;
} stack;

void Fix_RGB_UV_LoadUV(blit_soft* p)
{
	//set R4 =           RVMul*v + RAdd
	//set R5 = GUMul*u + GVMul*v + GAdd
	//set R6 = BUMul*u +           BAdd

	if (p->Dither)
	{
		//R0,R4,R8 for temporary
		//R5(DiffMask),R6(Src2SrcLast),R7(EndOfLine)

		if (p->OnlyDiff)
		{
			Half(); I3(LDR,R8,R12,R6);
			Half(); I2C(LDR_POST,R0,R12,2);
			Half(); I3(LDR,R4,R14,R6);
			//xscale stall
			I3(EOR,R8,R8,R0);
			Half(); I2C(LDR_POST,R0,R14,2);
			S(); I3(TST,NONE,R8,R5);
			C(EQ); Byte(); I3(LDR,R8,R10,R6);
			C(EQ); I3(EOR,R4,R4,R0);
			Byte(); I2C(LDR_POST,R0,R10,1); //u
			C(EQ); S(); I3(TST,NONE,R4,R5);
			C(EQ); Byte(); I3(LDR,R4,R11,R6);
			C(EQ); I3(EOR,R8,R8,R0);
			Byte(); I2C(LDR_POST,R0,R11,1); //v
			C(EQ); S(); I3(TST,NONE,R8,R5);
			//xscale stall

			C(EQ); I3(EOR,R4,R4,R0);
			C(EQ); S(); I3(TST,NONE,R4,R5);

			if (p->SwapXY)
			{
				MB(); I2C(LDR,R8,SP,OFS(stack,DstPitch));
				C(EQ); I3S(ADD,R9,R9,R8,LSL,1+p->DstDoubleY);
			}
			else
			{
				C(EQ); I2C(ADD,R9,R9,p->DstStepX);
			}
			I0P(B,EQ,p->Skip);

			// R0=v
			if (p->ColorLookup)
			{
				Byte(); I2C(LDR,R5,R10,-1);	  //u
				I1P(MOV,R8,p->LookUp,0);
			}
		}
		else
		{
			Byte(); I2C(LDR_POST,R0,R11,1); //v
			if (p->ColorLookup)
			{
				Byte(); I2C(LDR_POST,R5,R10,1); //u
			}
		}

		if (!p->ColorLookup)
		{
			I1P(LDR,R5,p->GAdd,0);
			I1P(LDR,R8,p->GVMul,0);
			I1P(LDR,R4,p->RAdd,0);
			I1P(LDR,R6,p->RVMul,0);
			I4(MLA,R5,R8,R0,R5);
			
			Byte(); 
			if (p->OnlyDiff) //already incremented
				I2C(LDR,R8,R10,-1);	  //u
			else
				I2C(LDR_POST,R8,R10,1); //u

			I4(MLA,R4,R6,R0,R4);
			I1P(LDR,R7,p->GUMul,0);
			I1P(LDR,R6,p->BAdd,0);
			I1P(LDR,R0,p->BUMul,0);
			I4(MLA,R5,R7,R8,R5);

			//R7 Y read will moveback here (this will prevent stall by R0)

			I4(MLA,R6,R0,R8,R6);
			I1P(LDR,R8,p->YMul,0); //restore R8
		}
		else
		{
			I2C(ADD,R0,R0,p->LookUp_V);
			I3S(LDR,R4,R8,R0,LSL,2);	// RVMul+RAdd | GVMul+GAdd
			I2C(ADD,R5,R5,p->LookUp_U);
			I3S(LDR,R6,R8,R5,LSL,2);	// BUMul | GUMul
			I3S(MOV,R5,NONE,R4,LSL,16); 
			I3S(ADD,R5,R5,R6,LSL,16);	// GUMul+GVMul+GAdd | 0000
		}
	}
	else
	{
		//R0,R1,R2,R3,R4 for temporary
		//R5(DiffMask),R6(Src2SrcLast),R7(EndOfLine)

		if (p->OnlyDiff)
		{
			Half(); I3(LDR,R0,R12,R6);
			Half(); I2C(LDR_POST,R1,R12,2);
			Half(); I3(LDR,R4,R14,R6);	
			Half(); I2C(LDR_POST,R2,R14,2);
			I3(EOR,R0,R0,R1);
			S(); I3(TST,NONE,R0,R5);
			I3(EOR,R4,R4,R2);
			C(EQ); S(); I3(TST,NONE,R4,R5);

			C(EQ); Byte(); I3(LDR,R0,R10,R6);
			Byte(); I2C(LDR_POST,R1,R10,1); //u
			C(EQ); Byte(); I3(LDR,R4,R11,R6);
			Byte(); I2C(LDR_POST,R2,R11,1); //v
			C(EQ); I3(EOR,R0,R0,R1);
			C(EQ); S(); I3(TST,NONE,R0,R5);
			C(EQ); I3(EOR,R4,R4,R2);
			C(EQ); S(); I3(TST,NONE,R4,R5);

			if (p->SwapXY)
			{
				MB(); I2C(LDR,R3,SP,OFS(stack,DstPitch));
				C(EQ); I3S(ADD,R9,R9,R3,LSL,1+p->DstDoubleY);
			}
			else
			{
				C(EQ); I2C(ADD,R9,R9,p->DstStepX);
			}
			I0P(B,EQ,p->Skip);
		}
		else
		{
			Byte(); I2C(LDR_POST,R1,R10,1); //u
			Byte(); I2C(LDR_POST,R2,R11,1); //v
		}

		if (!p->ColorLookup)
		{
			I1P(LDR,R5,p->GAdd,0);
			I1P(LDR,R0,p->GVMul,0);
			I1P(LDR,R4,p->RAdd,0);
			I1P(LDR,R7,p->RVMul,0);
			I1P(LDR,R6,p->BAdd,0);
			I4(MLA,R5,R0,R2,R5); 
			I1P(LDR,R0,p->BUMul,0);
			I1P(LDR,R3,p->GUMul,0);
			I4(MLA,R4,R7,R2,R4); 
			I4(MLA,R6,R0,R1,R6); 
			I4(MLA,R5,R3,R1,R5); 
		}
		else
		{
			I2C(ADD,R1,R1,p->LookUp_U);
			I2C(ADD,R2,R2,p->LookUp_V);
			I3S(LDR,R6,R8,R1,LSL,2);	// BUMul+BAdd | GUMul
			I3S(LDR,R4,R8,R2,LSL,2);	// RVMul+RAdd | GVMul+GAdd
			//double xscale stall
			I3S(MOV,R5,NONE,R6,LSL,16); 
			I3S(ADD,R5,R5,R4,LSL,16);	// GUMul+GVMul+GAdd | 0000
		}
	}
}

void Fix_RGB_UV_Pixel(blit_soft* p, int Col, int Row )
{
	int SatBitR = p->QAdd ? 32 : 24;
	int SatBitG = SatBitR;
	int SatBitB = SatBitR;
	int RPos = p->RPos;
	int GPos = p->GPos;
	int BPos = p->BPos;

	p->Upper = (p->DirX<0) ^ (Col>0);

	if (p->Upper && p->DstBPP==8 && p->DstDoubleX)
	{
		RPos += 16;
		GPos += 16;
		BPos += 16;
	}
	else
	if (p->Upper && p->DstBPP<=16)
	{
		RPos += p->DstBPP;
		GPos += p->DstBPP;
		BPos += p->DstBPP;
	}

	//load Y
	MB();
	Byte(); 

	if (p->OnlyDiff) //is R12,R14 already incremented?
	{
		if (p->SwapXY)
			I2C(LDR,R7,(reg)(Col==0?R12:R14),-2+Row);
		else
			I2C(LDR,R7,(reg)(Row==0?R14:R12),-2+Col);
	}
	else
		if (p->SwapXY)
			I2C(LDR_POST,R7,(reg)(Col==0?R12:R14),1);
		else
			I2C(LDR_POST,R7,(reg)(Row==0?R14:R12),1);

	if (p->Dither)
	{
		if (!p->ColorLookup)
		{
			I3S(ADD,R1,R4,R1,LSR,32-SatBitR+p->RSize);
			I3S(ADD,R2,R5,R2,LSR,32-SatBitG+p->GSize);
			I3S(ADD,R3,R6,R3,LSR,32-SatBitB+p->BSize);
			I4(MLA,R1,R8,R7,R1);
			I4(MLA,R2,R8,R7,R2);
			I4(MLA,R3,R8,R7,R3);
		}
		else
		{
			I3S(ADD,R1,R4,R1,LSL,16+LOOKUP_FIX-p->RSize);
			I3S(LDR,R7,R8,R7,LSL,2); // YMul * y
			I3S(ADD,R2,R5,R2,LSL,16+LOOKUP_FIX-p->GSize);
			I3S(ADD,R3,R6,R3,LSL,16+LOOKUP_FIX-p->BSize);
			I3(ADD,R1,R7,R1);
			I3(ADD,R2,R7,R2);
			I3(ADD,R3,R7,R3);
			Byte(); I3S(LDR,R1,R8,R1,LSR,16+LOOKUP_FIX); //sat and 8bit ror (8-RSize)
			Byte(); I3S(LDR,R2,R8,R2,LSR,16+LOOKUP_FIX); //sat and 8bit ror (8-GSize)
			Byte(); I3S(LDR,R3,R8,R3,LSR,16+LOOKUP_FIX); //sat and 8bit ror (8-BSize)

			// R1 = Dither[8-RSize] | Value[RSize]
			// R2 = Dither[8-GSize] | Value[GSize]
			// R3 = Dither[8-BSize] | Value[BSize]

			RPos += p->RSize; // LSB part -> MSB part
			GPos += p->GSize; // LSB part -> MSB part
			BPos += p->BSize; // LSB part -> MSB part

			SatBitR = 2*p->RSize - 32;
			SatBitG = 2*p->GSize - 32;
			SatBitB = 2*p->BSize - 32;
		}
	}
	else
	{
		if (!p->ColorLookup)
		{
			I4(MLA,R1,R8,R7,R4);
			I4(MLA,R2,R8,R7,R5);
			I4(MLA,R3,R8,R7,R6);
		}
		else
		{
			I3S(LDR,R7,R8,R7,LSL,2); // YMul * y
			I3(ADD,R1,R7,R4);
			I3(ADD,R2,R7,R5);
			I3(ADD,R3,R7,R6);
			Byte(); I3S(LDR,R1,R8,R1,LSR,16+LOOKUP_FIX); // sat to 8bit
			Byte(); I3S(LDR,R2,R8,R2,LSR,16+LOOKUP_FIX); // sat to 8bit
			Byte(); I3S(LDR,R3,R8,R3,LSR,16+LOOKUP_FIX); // sat to 8bit
			SatBitR = SatBitB = SatBitG = 8;
		}
	}

	if (!p->ColorLookup)
	{
		if (p->QAdd)
		{
			I3(QDADD,R1,R1,R1);
			I3(QDADD,R2,R2,R2);
			I3(QDADD,R3,R3,R3);
		}
		else
		{
			I2C(TST,NONE,R1,0xFF000000);
			C(NE);I2C(MVN,R1,NONE,0xFF000000);
			C(MI);I2C(MOV,R1,NONE,0x00000000);
			I2C(TST,NONE,R2,0xFF000000);
			C(NE);I2C(MVN,R2,NONE,0xFF000000);
			C(MI);I2C(MOV,R2,NONE,0x00000000);
			I2C(TST,NONE,R3,0xFF000000);
			C(NE);I2C(MVN,R3,NONE,0xFF000000);
			C(MI);I2C(MOV,R3,NONE,0x00000000);
		}
	}

	if (p->InvertMask && p->Pos<0)
	{

⌨️ 快捷键说明

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