一: mipi raw10转 raw 10
//b1,b2,b3,b4,b5分别为连续读出的五个uint8类型的数据,p1,p2,p3,p4为四个像素点的像素值,那么
p1 = (b1 << 2) + ((b5 ) & 0x3); // & 0x3表示获取低两位
P2 = (b2 << 2) + ((b5 >> 2) & 0x3);
P3 = (b3 << 2) + ((b5 >> 4) & 0x3);
P4 = (b4 << 2) + ((b5 >> 6) & 0x3);
二: raw10 转raw 8
void MainWindow::Raw10toRaw8(BYTE *pIn, long number)
{
//raw10转Raw8
BYTE *pTemp = pIn;
BYTE *pOut = pIn;
for (long i = 0; i < number; i = i + 5)
{
*pOut++ = pTemp[i];
*pOut++ = pTemp[i + 1];
*pOut++ = pTemp[i + 2];
*pOut++ = pTemp[i + 3];
}
}
三: mipiRaw12 转raw 8
void MainWindow::MipiRaw12ToRaw8(BYTE *pIn,BYTE *pOut, USHORT DesW, USHORT DesH)
{
int index = 0;
USHORT iWidth=DesW*3/2;
for(USHORT j = 0 ; j < DesH; j++)
{
for(USHORT i = 0 ; i < iWidth ; i+=3)
{
pOut[index++] = pIn[j*iWidth+i];
pOut[index++] = pIn[j*iWidth+i+1];
}
}
}
四: mipiRaw10 转raw 8
void MainWindow::MipiRaw10ToP8(BYTE *pIn, BYTE *pOut, long number)
{
int index = 0;
//little endian
for (long i = 0; i < number *5/4; i = i + 5)
{
pOut[index++] = (pIn[i]);
pOut[index++] = (pIn[i+1] ) ;
pOut[index++] = (pIn[i+2] ) ;
pOut[index++] = (pIn[i+3] ) ;
}
}
五: mipiRaw 12转 raw12
void MainWindow::MipiRaw12ToP12(BYTE *pIn,BYTE *pOut, USHORT DesW, USHORT DesH)
{
int index = 0;
for(USHORT j = 0 ; j < DesH; j++)
{
for(USHORT i = 0 ; i < DesW*3/2; i+=3)
{
pOut[index++] = ((pIn[j*( DesW*3/2)+i] << 4) & 0xf0) + (pIn[j*( DesW*3/2)+i + 2] & 0xf);
pOut[index++] = (pIn[j*( DesW*3/2)+i] >> 4) & 0xf;
pIn[i+2] >>= 4;
pOut[index++] = ((pIn[j*( DesW*3/2)+i + 1] << 4) & 0xf0) + (pIn[j*( DesW*3/2)+i + 2] & 0xf);
pOut[index++] = (pIn[j*( DesW*3/2)+i + 1] >> 4) & 0xf;
}
}
}
六: MipiRaw10 转 raw10
void MainWindow::MipiRaw10ToP10(BYTE *pIn,BYTE *pOut, long number)
{
int index = 0;
//5个字节4个像素
//前面4个字节都是对应像素的高8位,最后一个字(第五个)每个像素的低2位
//BYTE0 :P1[9:2]
//BYTE1 :P2[9:2]
//BYTE2 :P3[9:2]
//BYTE3 :P4[9:2]
//BYTE4 :P5[1:0]P3[1:0]P2[1:0]P1[1:0]
//P10: Byte0: XXXXXX P1[9:8],byte1: P1[7:0],BYTE2: XXXXXX P2[9:8],,byte3: P2[7:0]
//little endian
for (long i = 0; i < number *5/4; i = i + 5)
{
pOut[index++] = ((pIn[i]<< 2) & 0xfc) | (pIn[i+4] & 0x03 );
pOut[index++] = ( pIn[i]>> 6) & 0x03;
//pIn[i+4] >>= 2;
pOut[index++] = ((pIn[i+1]<< 2) & 0xfc) | ((pIn[i+4]>>2) & 0x03);
pOut[index++] = ( pIn[i+1]>> 6) & 0x03;
//pIn[i+4] >>= 2;
pOut[index++] = ((pIn[i+2]<< 2) & 0xfc) | ((pIn[i+4]>>4) & 0x03);
pOut[index++] = ( pIn[i+2]>> 6) & 0x03;
//pIn[i+4] >>= 2;
pOut[index++] = ((pIn[i+3]<< 2) & 0xfc) | ((pIn[i+4]>>6) & 0x03);
pOut[index++] = ( pIn[i+3]>> 6) & 0x03;
}
}