📄 blit_arm_yuv.c
字号:
I3S(ADD,R6,R6,R6,LSL,1);
I3S(ADD,R4,R6,R4,LSL,3);
I3S(ADD,R4,R4,R5,LSL,4);
I3S(MOV,R4,NONE,R4,ASR,5);
S(); I2C(ADD,Val,R4,16+p->FX.Brightness);
if (p->FX.Brightness+16<0)
{
C(MI);I2C(MOV,Val,NONE,0x00);
}
if (p->FX.Brightness+16+215>=255)
{
I2C(CMP,NONE,Val,0xFF);
C(GT);I2C(MOV,Val,NONE,0xFF);
}
break;
case 1:
// U = (-5*R - 9*G + 14*B)/32 + 128;
I3S(RSB,R6,R6,R6,LSL,3);
I3(ADD,R6,R6,R6);
I3S(ADD,R4,R4,R4,LSL,2);
I3S(ADD,R5,R5,R5,LSL,3);
I3(SUB,R4,R6,R4);
I3(SUB,R4,R4,R5);
I3S(MOV,R4,NONE,R4,ASR,5);
I2C(ADD,Val,R4,128);
break;
case 2:
// V = (14*R - 12*G - 2*B)/32 + 128;
I3(ADD,R6,R6,R6);
I3S(RSB,R4,R4,R4,LSL,3);
I3S(ADD,R5,R5,R5,LSL,1);
I3S(RSB,R4,R6,R4,LSL,1);
I3S(SUB,R4,R4,R5,LSL,2);
I3S(MOV,R4,NONE,R4,ASR,5);
I2C(ADD,Val,R4,128);
break;
}
if (x>0)
I3S(ORR,Out,Out,Val,LSL,x*8);
}
I3S(ADD,R7,R7,R14,ASR,SrcUVPitch-HalfY);
}
I3S(SUB,R7,R7,R14,ASR,SrcUVPitch-2-HalfY);
}
else
{
int mode = HalfX + 2*HalfY;
int x = 2;
if (!p->SrcYUV && mode==0)
{
//possible alignment problems...
mode = 1;
x = 1;
}
switch (mode)
{
case 0:
I3S(LDR_POST,R0,R7,R14,ASR,SrcUVPitch-1);
I3S(LDR_POST,R2,R7,R14,ASR,SrcUVPitch);
I3S(LDR_POSTSUB,R3,R7,R14,ASR,SrcUVPitch-1);
I3S(LDR_POSTSUB,R1,R7,R14,ASR,SrcUVPitch);
break;
case 1: // halfx (not average...)
Byte(); I2C(LDR,R0,R7,3*x);
Byte(); I2C(LDR,R4,R7,2*x);
Byte(); I2C(LDR,R5,R7,1*x);
Byte(); I3S(LDR_POST,R6,R7,R14,ASR,SrcUVPitch-1);
I3S(ORR,R0,R4,R0,LSL,8);
I3S(ORR,R0,R5,R0,LSL,8);
I3S(ORR,R0,R6,R0,LSL,8);
Byte(); I2C(LDR,R2,R7,3*x);
Byte(); I2C(LDR,R4,R7,2*x);
Byte(); I2C(LDR,R5,R7,1*x);
Byte(); I3S(LDR_POST,R6,R7,R14,ASR,SrcUVPitch);
I3S(ORR,R2,R4,R2,LSL,8);
I3S(ORR,R2,R5,R2,LSL,8);
I3S(ORR,R2,R6,R2,LSL,8);
Byte(); I2C(LDR,R3,R7,3*x);
Byte(); I2C(LDR,R4,R7,2*x);
Byte(); I2C(LDR,R5,R7,1*x);
Byte(); I3S(LDR_POSTSUB,R6,R7,R14,ASR,SrcUVPitch-1);
I3S(ORR,R3,R4,R3,LSL,8);
I3S(ORR,R3,R5,R3,LSL,8);
I3S(ORR,R3,R6,R3,LSL,8);
Byte(); I2C(LDR,R1,R7,3*x);
Byte(); I2C(LDR,R4,R7,2*x);
Byte(); I2C(LDR,R5,R7,1*x);
Byte(); I3S(LDR_POSTSUB,R6,R7,R14,ASR,SrcUVPitch);
I3S(ORR,R1,R4,R1,LSL,8);
I3S(ORR,R1,R5,R1,LSL,8);
I3S(ORR,R1,R6,R1,LSL,8);
break;
case 2: // halfy
I3S(LDR,R4,R7,R14,ASR,SrcUVPitch);
I3S(LDR_POST,R0,R7,R14,ASR,SrcUVPitch-1-1);
I3S(LDR,R6,R7,R14,ASR,SrcUVPitch);
I3S(LDR_POST,R2,R7,R14,ASR,SrcUVPitch-1);
I3S(AND,R4,R5,R4,LSR,1);
I3S(AND,R0,R5,R0,LSR,1);
I3(ADD,R0,R0,R4);
I3S(AND,R6,R5,R6,LSR,1);
I3S(AND,R2,R5,R2,LSR,1);
I3(ADD,R2,R2,R6);
I3S(LDR,R4,R7,R14,ASR,SrcUVPitch);
I3S(LDR_POSTSUB,R3,R7,R14,ASR,SrcUVPitch-1-1);
I3S(LDR,R6,R7,R14,ASR,SrcUVPitch);
I3S(LDR_POSTSUB,R1,R7,R14,ASR,SrcUVPitch-1);
I3S(AND,R4,R5,R4,LSR,1);
I3S(AND,R3,R5,R3,LSR,1);
I3(ADD,R3,R3,R4);
I3S(AND,R6,R5,R6,LSR,1);
I3S(AND,R1,R5,R1,LSR,1);
I3(ADD,R1,R1,R4);
break;
case 3: // halfx + halfy (no average..., used by palette mode as well)
Byte(); I2C(LDR,R0,R7,6);
Byte(); I2C(LDR,R4,R7,4);
Byte(); I2C(LDR,R5,R7,2);
Byte(); I3S(LDR_POST,R6,R7,R14,ASR,SrcUVPitch-1-1);
I3S(ORR,R0,R4,R0,LSL,8);
I3S(ORR,R0,R5,R0,LSL,8);
I3S(ORR,R0,R6,R0,LSL,8);
Byte(); I2C(LDR,R2,R7,6);
Byte(); I2C(LDR,R4,R7,4);
Byte(); I2C(LDR,R5,R7,2);
Byte(); I3S(LDR_POST,R6,R7,R14,ASR,SrcUVPitch-1);
I3S(ORR,R2,R4,R2,LSL,8);
I3S(ORR,R2,R5,R2,LSL,8);
I3S(ORR,R2,R6,R2,LSL,8);
Byte(); I2C(LDR,R3,R7,6);
Byte(); I2C(LDR,R4,R7,4);
Byte(); I2C(LDR,R5,R7,2);
Byte(); I3S(LDR_POSTSUB,R6,R7,R14,ASR,SrcUVPitch-1-1);
I3S(ORR,R3,R4,R3,LSL,8);
I3S(ORR,R3,R5,R3,LSL,8);
I3S(ORR,R3,R6,R3,LSL,8);
Byte(); I2C(LDR,R1,R7,6);
Byte(); I2C(LDR,R4,R7,4);
Byte(); I2C(LDR,R5,R7,2);
Byte(); I3S(LDR_POSTSUB,R6,R7,R14,ASR,SrcUVPitch-1);
I3S(ORR,R1,R4,R1,LSL,8);
I3S(ORR,R1,R5,R1,LSL,8);
I3S(ORR,R1,R6,R1,LSL,8);
break;
}
}
if (p->SwapXY && (HalfX || HalfY || !p->SrcYUV))
I2C(STR,R0,SP,OFS(stack,SaveR0));
RA = (reg)YUV_4(p,R0,0,Plane);
I3S(STR_POST,RA,R11,R12,ASR,DstUVPitch-1);
RA = (reg)YUV_4(p,R2,16,Plane);
I3S(STR_POST,RA,R11,R12,ASR,DstUVPitch);
RA = (reg)YUV_4(p,R3,24,Plane);
I3S(STR_POSTSUB,RA,R11,R12,ASR,DstUVPitch-1);
RA = (reg)YUV_4(p,R1,8,Plane);
I3S(STR_POSTSUB,RA,R11,R12,ASR,DstUVPitch);
if (p->LookUp && p->LookUpOfs)
{
I2C(SUB,R8,R8,p->LookUpOfs);
p->LookUpOfs = 0;
}
if (p->RealOnlyDiff)
InstPost(p->Skip);
I2C(ADD,R7,R7,(4 << HalfX)*(p->SrcBPP/8));
if (p->SwapXY)
I3S(ADD,R11,R11,R12,ASR,DstUVPitch-2);
else
I2C(ADD,R11,R11,4*p->DirX);
I3(CMP,NONE,R7,R10);
I0P(B,NE,LoopX);
I2C(LDR,R0,SP,OFS(stack,SrcNext[UV]));
I2C(LDR,R1,SP,OFS(stack,DstNext[UV]));
I3(ADD,R7,R7,R0);
I3(ADD,R11,R11,R1);
}
I2C(STR,R7,SP,OFS(stack,Src[Plane]));
I2C(STR,R11,SP,OFS(stack,Dst[Plane]));
}
void Fix_Any_YUV(blit_soft* p)
{
dyninst* Add32 = NULL;
dyninst* MaskCarry = NULL;
dyninst* LoopY;
reg RSrcWidth;
p->SrcAlignPos = p->DstAlignPos = p->DstAlignSize = 8;
CodeBegin();
I2C(SUB,SP,SP,OFS(stack,StackFrame));
p->DiffMask = NULL;
I2C(LDR,R6,R1,0);//Dst[0] U
I2C(LDR,R7,R1,4);//Dst[1] V
I2C(LDR,R8,R1,8);//Dst[2] Y
I2C(LDR,R10,R2,0); //Src[0] U
if (!p->SrcYUV)
{
I3(MOV,R11,NONE,R10);
I3(MOV,R12,NONE,R10);
p->SrcUVX2 = 0;
p->SrcUVY2 = 0;
p->SrcUVPitch2 = 0;
p->Caps = VC_BRIGHTNESS;
}
else
{
I2C(LDR,R11,R2,4); //Src[1] V
I2C(LDR,R12,R2,8); //Src[2] Y
}
if (p->DirX<0)
{
//adjust reversed destination for block size
I2C(SUB,R6,R6,3);
I2C(SUB,R7,R7,3);
I2C(SUB,R8,R8,3);
}
I2C(STR,R6,SP,OFS(stack,Dst[0]));
I2C(STR,R7,SP,OFS(stack,Dst[1]));
I2C(STR,R8,SP,OFS(stack,Dst[2]));
I2C(STR,R10,SP,OFS(stack,Src[0]));
I2C(STR,R11,SP,OFS(stack,Src[1]));
I2C(STR,R12,SP,OFS(stack,Src[2]));
I3(MOV,R12,NONE,R3); //DstPitch
I2C(LDR,R14,SP,OFS(stack,SrcPitch));
I2C(LDR,R2,SP,OFS(stack,Height));
I2C(LDR,R1,SP,OFS(stack,Width));
p->RealOnlyDiff = p->OnlyDiff;
p->HalfX = (boolmem_t)(p->SrcUVX2+1 == p->DstUVX2);
p->HalfY = (boolmem_t)(p->SrcUVY2+1 == p->DstUVY2);
if (p->HalfX || p->HalfY)
p->RealOnlyDiff = 0;
if (p->RealOnlyDiff)
{
int Mask = 0x03030303;
p->DiffMask = InstCreate32(Mask,NONE,NONE,NONE,0,0);
I1P(LDR,R5,p->DiffMask,0);
I2C(LDR,R6,SP,OFS(stack,Src2SrcLast));
}
else
if ((p->HalfX + 2*p->HalfY)==2)
{
int Mask = 0x7F7F7F7F;
p->DiffMask = InstCreate32(Mask,NONE,NONE,NONE,0,0);
I1P(LDR,R5,p->DiffMask,0);
}
p->LookUp = NULL;
if (p->SrcYUV)
CalcYUVLookUp(p);
else if (p->Src.Palette)
CalcPalYUVLookUp(p);
if (p->LookUp_Data)
{
p->LookUp = InstCreate(p->LookUp_Data,p->LookUp_Size,NONE,NONE,NONE,0,0);
free(p->LookUp_Data);
p->LookUp_Data = NULL;
I1P(MOV,R8,p->LookUp,0);
p->LookUpOfs = 0;
}
else
if (p->FX.Brightness)
{
int i = p->FX.Brightness;
if (i<0) i=-i;
if (i>127) i=127;
MaskCarry = InstCreate32(0x80808080U,NONE,NONE,NONE,0,0);
Add32 = InstCreate32(0x01010101U * (uint8_t)i,NONE,NONE,NONE,0,0);
I1P(LDR,R8,MaskCarry,0);
I1P(LDR,R9,Add32,0);
}
//EndOfRect
//DstNext[2]
//SrcNext[2]
RSrcWidth = R1;
if (p->SrcBPP2>0)
{
IMul(R3,R1,p->SrcBPP/8);
RSrcWidth = R3;
}
//SrcYNext = 4*Src->Pitch - Width
I3S(RSB,R0,RSrcWidth,R14,LSL,2);
I2C(STR,R0,SP,OFS(stack,SrcNext[0]));
//SrcUVNext = (4 << HalfY)*(Src->Pitch >> SrcUVPitch2) - (Width >> SrcUVX)
I3S(MOV,R0,NONE,R14,LSL,2+p->HalfY-p->SrcUVPitch2);
I3S(SUB,R0,R0,RSrcWidth,LSR,p->SrcUVX2);
I2C(STR,R0,SP,OFS(stack,SrcNext[1]));
//EndOfRect = Src + Src->Pitch * Height
I3(MUL,R0,R14,R2);
I3(ADD,R0,R0,R10);
I2C(STR,R0,SP,OFS(stack,EndOfRect));
if (p->SwapXY)
{
//DstYNext = 4*DirX - Width*Dst->Pitch
I3(MUL,R3,R1,R12);
I2C(MOV,R0,NONE,4*p->DirX);
I3(SUB,R0,R0,R3);
I2C(STR,R0,SP,OFS(stack,DstNext[0]));
//DstUVNext = 4*DirX - (Width >> DstUVY2)*(Dst->Pitch >> DstUVPitch2)
if (p->DstUVY2+p->DstUVPitch2) I3S(MOV,R3,NONE,R3,ASR,p->DstUVY2+p->DstUVPitch2);
I2C(MOV,R0,NONE,4*p->DirX);
I3(SUB,R0,R0,R3);
I2C(STR,R0,SP,OFS(stack,DstNext[1]));
}
else
{
//DstYNext = 4*Dst->Pitch - DirX * Width
I3S(p->DirX<0?ADD:RSB,R0,R1,R12,LSL,2);
I2C(STR,R0,SP,OFS(stack,DstNext[0]));
//DstUVNext = 4*Dst->Pitch >> DstUVPitch2 - DirX * (Width >> DstUVX2)
I3S(MOV,R0,NONE,R12,LSL,2-p->DstUVPitch2);
I3S(p->DirX<0?ADD:SUB,R0,R0,R1,LSR,p->DstUVX2);
I2C(STR,R0,SP,OFS(stack,DstNext[1]));
}
LoopY = Label(0);
I0P(B,AL,LoopY);
if (p->DiffMask) InstPost(p->DiffMask);
if (Add32) InstPost(Add32);
if (MaskCarry) InstPost(MaskCarry);
if (p->LookUp)
{
Align(16);
InstPost(p->LookUp);
}
InstPost(LoopY);
{
if (p->LookUp)
I2C(ADD,R8,R8,256+4);
YUV_4X4(p,1);
if (p->LookUp)
I2C(ADD,R8,R8,256);
YUV_4X4(p,2);
if (p->LookUp)
I2C(SUB,R8,R8,256+256+4);
YUV_4X4(p,0);
MB(); I2C(LDR,R2,SP,OFS(stack,EndOfRect));
I3(CMP,NONE,R2,R7);
I0P(B,NE,LoopY);
}
I2C(ADD,SP,SP,OFS(stack,StackFrame));
CodeEnd();
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -