Home > other >  O master reference C process written in SSE inline assembly function, separate the asm file
O master reference C process written in SSE inline assembly function, separate the asm file

Time:11-28

A RGB turn an HSL in computing, and then an HSL transfer RGB code, how to write in sse assembly
If (hue_!=0 | | saturation_!
=1){
For (int I=0; I & lt; 16. I++)
{
TB=m_b. M128i_u8 [I];
Tg=m_g. M128i_u8 [I];
Tr=m_r. M128i_u8 [I];

//RGB an HSL
Min=tr;
If (tg & lt; Min)
{
Min=tg;
}

If (TB & lt; Min)
{
Min=TB;
}

Max=tr;
F2=tg - TB;
If (tg & gt; Max)
{
Max=tg;
F1=120.0 f;
F2=TB - tr.
}
If (TB & gt; Max)
{
Max=TB;
F1=240.0 f;
F2=tr - tg;
}
Dif=(Max - min);
Sum=(Max + min);
L=0.5 f * (float) sum;
If (dif==0)
{//the maximum and minimum values are the same, is expressed as the gray, the definition of 0 s and h undefined is usually written as 0
H=0.0 f;
S=0.0 f;
}
Else if (l & lt; 127.5 f)
{//l calculation according to the luminosity saturation
S=255.0 f * (float) dif/(float) sum;
}
The else
{
S=255.0 f * (float) dif/(510.0 f - (float), sum);
}
If (dif!=0)
{
H=+ 60.0 f * (f1 f2/(float) dif);//calculate tonal h
}

If (h & lt; 0.0 f)
{
H +=360.0 f;
}
If (h & gt; 360.0 f)
{
H - f=360.0;
}

//adjust the chromaticity
H=h + hue_;
If (h & gt;=360.0 f)
{
H=h - 360.0 f;
}

//saturation adjustment
S=s * saturation_;
If (s & lt; 0.0 f) {
S=0.0 f;
}
If (s & gt; 255.0 f) {
S=255.0 f;
}

//an HSL convert RGB
If (s==0.0 f)
{//said gray, R, G, B is defined as 0
Tr=(int) l;
Tg=(int) l;
TB=(int) l;
}
The else
{
If (l & lt; 127.5 f)
{
V2=c1o255_ * l * (255.0 f + s);
}
The else
{
V2=l + s - c1o255_ * s * l;
}
V1=2 * l - v2;
V3=v2 - v1;
H1=h + 120.0 f;
If (h1 & gt;=360.0 f)
H1 - f=360.0;
//calculate the tr
If (h1 & lt; 60.0 f)
{
Tr=(int) (v1 + v3 * * c1o60_ h1);
}
Else if (h1 & lt; 180.0 f)
{
Tr=(int) v2;
}
Else if (h1 & lt; 240.0 f)
{
Tr=(int) (v1 + v3 * (4.0 f - h1 * c1o60_));
}
The else
{
Tr=(int) v1;
}
/tg/computing
H1=h;
If (h1 & lt; 60.0 f)
{
Tg=(int) (v1 + v3 * * c1o60_ h1);
}
Else if (h1 & lt; 180.0 f)
{
Tg=(int) v2;
}
Else if (h1 & lt; 240.0 f)
{
Tg=(int) (v1 + v3 * (4.0 f - h1 * c1o60_));
}
The else
{
Tg=(int) v1;
}
//calculate TB
H1=h - 120.0 f;
If (h1 & lt; 0.0 f)
{
H1 +=360.0 f;
}
If (h1 & lt; 60.0 f)
{
TB=(int) (v1 + v3 * * c1o60_ h1);
}
Else if (h1 & lt; 180.0 f)
{
TB=(int) v2;
}
Else if (h1 & lt; 240.0 f)
{
TB=(int) (v1 + v3 * (4.0 f - h1 * c1o60_));
}
The else
{
TB=(int) v1;
}
}

If (TB & gt; 255)
{
TB=255;
}
Else if (TB & lt; 0)
{
TB=0;
}

If (tg & gt; 255)
{
Tg=255;
}
Else if (tg & lt; 0)
{
Tg=0;
}

If (tr & gt; 255)
{
Tr=255;
}
Else if (tr & lt; 0)
{
Tr=0;
}

M_b. M128i_u8 [I]=TB;
M_g. M128i_u8 [I]=tg;
M_r. M128i_u8 [I]=tr;
}

}

CodePudding user response:

If (l & lt; 127.5 f)
{
Calculate according to the brightness l//saturation
S=255.0 f * (float) dif/(float) sum;
}
The else
{
S=255.0 f * (float) dif/(510.0 f - (float), sum);
}
Problem in this piece, I wanted to do
Movups xmm1, l//xmm1 is l, l, l, l
Movups xmm2, f/127.5/xmm2 is 127.5 f, f 127.5, 127.5 f, 127.5 f
CMPPS xmm1 xmm2, 1//if the value is 0, 0, get xmm1 - nan, - nan
The following the if, else how to determine, from xmm1 to retrieve one judgment is 0 or - nan, or in other ways in judge xmm1 4 logo, for the ifelse operation
  • Related