快速YUV422转RGB,有做过的么?

2019-07-20 16:04发布

最近研究STM32F7的硬件JPEG解码,需要用到YUV转RGB.测试发现解码耗时最严重的就是YUV到RGB的转换。
STM32F7的硬件JPEG解码一张800*480的图片,只需要27ms,而转换出来的YUV数据转RGB的时间却高达70多ms,完全耗在了数据转换上面。
所以想提高一下这个时间,这样可以做一个800*480的视频播放器,爽歪歪....

ST官方的转换函数:
[mw_shl_code=c,true]
//范围限定宏定义
#define CLAMP(value) CLAMP_LUT[(value)+0X100]
JPEG_MCU_RGB_ConvertorTypeDef JPEG_ConvertorParams;

//将YCbCr 4:2:2 Blocks转换到RGB像素
//pInBuffer:指向输入的 YCbCr blocks缓冲区
//pOutBuffer:指向输出的 RGB888/ARGB8888帧缓冲区
//BlockIndex:输入buf里面的第一个MCU块编号
//DataCount:输入缓冲区的大小
u32 JPEG_MCU_YCbCr422_ARGB_ConvertBlocks(u8 *pInBuffer,u8 *pOutBuffer,u32 BlockIndex,u32 DataCount)
{  
        static vu16 tempadd=0;
        u32 numberMCU;
        u32 i,j,k,currentMCU,xRef,yRef;
        u32 refline;
        int ycomp,crcomp,cbcomp;
        int c_red,c_blue,c_green;
        u8 *pOutAddr;
        u8 *pChrom,*pLum;
        numberMCU=DataCount/YCBCR_422_BLOCK_SIZE;
        currentMCU=BlockIndex;
        while(currentMCU<(numberMCU+BlockIndex))
        {
                xRef=((currentMCU*16)/JPEG_ConvertorParams.WidthExtend)*8;
                yRef=((currentMCU*16)%JPEG_ConvertorParams.WidthExtend);
                refline=JPEG_ConvertorParams.ScaledWidth*xRef+(JPEG_BYTES_PER_PIXEL*yRef);
                currentMCU++;
                pChrom=pInBuffer+128;        //pChroma=pInBuffer+2*64
                pLum=pInBuffer;
                for(i=0;i<8;i++)
                {
                        if(refline<JPEG_ConvertorParams.ImageSize_Bytes)
                        {
                                pOutAddr=pOutBuffer+refline;
                                for(k=0;k<2;k++)
                                {
                                        for(j=0;j<8;j+=2)
                                        {
                                                cbcomp=(int)(*(pChrom));
                                                c_blue=(int)(*(CB_BLUE_LUT+cbcomp));
                                                crcomp=(int)(*(pChrom+64));
                                                c_red=(int)(*(CR_RED_LUT+crcomp));
                                                c_green=((int)(*(CR_GREEN_LUT+crcomp))+(int)(*(CB_GREEN_LUT+cbcomp)))>>16;
#if JPEG_BYTES_PER_PIXEL==4                //ARGB_8888颜 {MOD}格式   
                                                ycomp=(int)(*(pLum+j));
                                                *(vu32*)pOutAddr=
                                                (CLAMP(ycomp+c_red)<<JPEG_RED_OFFSET)|
                                                (CLAMP(ycomp+c_green)<<JPEG_GREEN_OFFSET)|
                                                (CLAMP(ycomp+c_blue)<<JPEG_BLUE_OFFSET);
                                                ycomp=(int)(*(pLum+j+1));
                                                *((vu32*)(pOutAddr+4))=
                                                (CLAMP(ycomp+c_red)<<JPEG_RED_OFFSET)|
                                                (CLAMP(ycomp+c_green)<<JPEG_GREEN_OFFSET)|
                                                (CLAMP(ycomp+c_blue)<<JPEG_BLUE_OFFSET);   
#elif JPEG_BYTES_PER_PIXEL==3        //RGB_888颜 {MOD}格式
                                                ycomp=(int)(*(pLum+j));
                                                pOutAddr[JPEG_RED_OFFSET/8]=CLAMP(ycomp+c_red);
                                                pOutAddr[JPEG_GREEN_OFFSET/8]=CLAMP(ycomp+c_green);
                                                pOutAddr[JPEG_BLUE_OFFSET/8]=CLAMP(ycomp+c_blue);
                                                ycomp=(int)(*(pLum+j+1));
                                                pOutAddr[3+JPEG_RED_OFFSET/8]=CLAMP(ycomp+c_red);
                                                pOutAddr[3+JPEG_GREEN_OFFSET/8]=CLAMP(ycomp+c_green);
                                                pOutAddr[3+JPEG_BLUE_OFFSET/8]=CLAMP(ycomp+c_blue);
#elif JPEG_BYTES_PER_PIXEL==2        //RGB_565颜 {MOD}格式
                                                ycomp=(int)(*(pLum+j));
                                                *(vu16*)pOutAddr=(CLAMP(ycomp+c_red)&0XF8)<<8|(CLAMP(ycomp+c_green)&0XFC)<<3|CLAMP(ycomp+c_blue)>>3;
                                                ycomp=(int)(*(pLum+j+1));
                                                *((vu16*)pOutAddr+1)=(CLAMP(ycomp+c_red)&0XF8)<<8|(CLAMP(ycomp+c_green)&0XFC)<<3|CLAMP(ycomp+c_blue)>>3;
#endif
                                                pOutAddr+=JPEG_BYTES_PER_PIXEL*2;
                                                pChrom++;
                                        }
                                        pLum+=64;                  
                                }
                                pLum=pLum-128+8;
                                refline+=JPEG_ConvertorParams.ScaledWidth;        
                        }
                }   
                pInBuffer+=YCBCR_422_BLOCK_SIZE;
        }
        return numberMCU;
}
[mw_shl_code=c,true]
使用到的数组:
[mw_shl_code=applescript,true]
//Cr to Red color conversion Look Up Table
const u32 CR_RED_LUT[256]=
{
        0XFFFFFF4D,0XFFFFFF4E,0XFFFFFF4F,0XFFFFFF51,0XFFFFFF52,0XFFFFFF54,0XFFFFFF55,0XFFFFFF56,
        0XFFFFFF58,0XFFFFFF59,0XFFFFFF5B,0XFFFFFF5C,0XFFFFFF5D,0XFFFFFF5F,0XFFFFFF60,0XFFFFFF62,
        0XFFFFFF63,0XFFFFFF64,0XFFFFFF66,0XFFFFFF67,0XFFFFFF69,0XFFFFFF6A,0XFFFFFF6B,0XFFFFFF6D,
        0XFFFFFF6E,0XFFFFFF70,0XFFFFFF71,0XFFFFFF72,0XFFFFFF74,0XFFFFFF75,0XFFFFFF77,0XFFFFFF78,
        0XFFFFFF79,0XFFFFFF7B,0XFFFFFF7C,0XFFFFFF7E,0XFFFFFF7F,0XFFFFFF80,0XFFFFFF82,0XFFFFFF83,
        0XFFFFFF85,0XFFFFFF86,0XFFFFFF87,0XFFFFFF89,0XFFFFFF8A,0XFFFFFF8C,0XFFFFFF8D,0XFFFFFF8E,
        0XFFFFFF90,0XFFFFFF91,0XFFFFFF93,0XFFFFFF94,0XFFFFFF95,0XFFFFFF97,0XFFFFFF98,0XFFFFFF9A,
        0XFFFFFF9B,0XFFFFFF9C,0XFFFFFF9E,0XFFFFFF9F,0XFFFFFFA1,0XFFFFFFA2,0XFFFFFFA3,0XFFFFFFA5,
        0XFFFFFFA6,0XFFFFFFA8,0XFFFFFFA9,0XFFFFFFAA,0XFFFFFFAC,0XFFFFFFAD,0XFFFFFFAF,0XFFFFFFB0,
        0XFFFFFFB1,0XFFFFFFB3,0XFFFFFFB4,0XFFFFFFB6,0XFFFFFFB7,0XFFFFFFB8,0XFFFFFFBA,0XFFFFFFBB,
        0XFFFFFFBD,0XFFFFFFBE,0XFFFFFFC0,0XFFFFFFC1,0XFFFFFFC2,0XFFFFFFC4,0XFFFFFFC5,0XFFFFFFC7,
        0XFFFFFFC8,0XFFFFFFC9,0XFFFFFFCB,0XFFFFFFCC,0XFFFFFFCE,0XFFFFFFCF,0XFFFFFFD0,0XFFFFFFD2,
        0XFFFFFFD3,0XFFFFFFD5,0XFFFFFFD6,0XFFFFFFD7,0XFFFFFFD9,0XFFFFFFDA,0XFFFFFFDC,0XFFFFFFDD,
        0XFFFFFFDE,0XFFFFFFE0,0XFFFFFFE1,0XFFFFFFE3,0XFFFFFFE4,0XFFFFFFE5,0XFFFFFFE7,0XFFFFFFE8,
        0XFFFFFFEA,0XFFFFFFEB,0XFFFFFFEC,0XFFFFFFEE,0XFFFFFFEF,0XFFFFFFF1,0XFFFFFFF2,0XFFFFFFF3,
        0XFFFFFFF5,0XFFFFFFF6,0XFFFFFFF8,0XFFFFFFF9,0XFFFFFFFA,0XFFFFFFFC,0XFFFFFFFD,0XFFFFFFFF,
        0X00000000,0X00000001,0X00000003,0X00000004,0X00000006,0X00000007,0X00000008,0X0000000A,
        0X0000000B,0X0000000D,0X0000000E,0X0000000F,0X00000011,0X00000012,0X00000014,0X00000015,
        0X00000016,0X00000018,0X00000019,0X0000001B,0X0000001C,0X0000001D,0X0000001F,0X00000020,
        0X00000022,0X00000023,0X00000024,0X00000026,0X00000027,0X00000029,0X0000002A,0X0000002B,
        0X0000002D,0X0000002E,0X00000030,0X00000031,0X00000032,0X00000034,0X00000035,0X00000037,
        0X00000038,0X00000039,0X0000003B,0X0000003C,0X0000003E,0X0000003F,0X00000040,0X00000042,
        0X00000043,0X00000045,0X00000046,0X00000048,0X00000049,0X0000004A,0X0000004C,0X0000004D,
        0X0000004F,0X00000050,0X00000051,0X00000053,0X00000054,0X00000056,0X00000057,0X00000058,
        0X0000005A,0X0000005B,0X0000005D,0X0000005E,0X0000005F,0X00000061,0X00000062,0X00000064,
        0X00000065,0X00000066,0X00000068,0X00000069,0X0000006B,0X0000006C,0X0000006D,0X0000006F,
        0X00000070,0X00000072,0X00000073,0X00000074,0X00000076,0X00000077,0X00000079,0X0000007A,
        0X0000007B,0X0000007D,0X0000007E,0X00000080,0X00000081,0X00000082,0X00000084,0X00000085,
        0X00000087,0X00000088,0X00000089,0X0000008B,0X0000008C,0X0000008E,0X0000008F,0X00000090,
        0X00000092,0X00000093,0X00000095,0X00000096,0X00000097,0X00000099,0X0000009A,0X0000009C,
        0X0000009D,0X0000009E,0X000000A0,0X000000A1,0X000000A3,0X000000A4,0X000000A5,0X000000A7,
        0X000000A8,0X000000AA,0X000000AB,0X000000AC,0X000000AE,0X000000AF,0X000000B1,0X000000B2,
};
//Cb to Blue color conversion Look Up Table
const u32 CB_BLUE_LUT[256]=
{
        0XFFFFFF1D,0XFFFFFF1F,0XFFFFFF21,0XFFFFFF23,0XFFFFFF24,0XFFFFFF26,0XFFFFFF28,0XFFFFFF2A,
        0XFFFFFF2B,0XFFFFFF2D,0XFFFFFF2F,0XFFFFFF31,0XFFFFFF32,0XFFFFFF34,0XFFFFFF36,0XFFFFFF38,
        0XFFFFFF3A,0XFFFFFF3B,0XFFFFFF3D,0XFFFFFF3F,0XFFFFFF41,0XFFFFFF42,0XFFFFFF44,0XFFFFFF46,
        0XFFFFFF48,0XFFFFFF49,0XFFFFFF4B,0XFFFFFF4D,0XFFFFFF4F,0XFFFFFF51,0XFFFFFF52,0XFFFFFF54,
        0XFFFFFF56,0XFFFFFF58,0XFFFFFF59,0XFFFFFF5B,0XFFFFFF5D,0XFFFFFF5F,0XFFFFFF61,0XFFFFFF62,
        0XFFFFFF64,0XFFFFFF66,0XFFFFFF68,0XFFFFFF69,0XFFFFFF6B,0XFFFFFF6D,0XFFFFFF6F,0XFFFFFF70,
        0XFFFFFF72,0XFFFFFF74,0XFFFFFF76,0XFFFFFF78,0XFFFFFF79,0XFFFFFF7B,0XFFFFFF7D,0XFFFFFF7F,
        0XFFFFFF80,0XFFFFFF82,0XFFFFFF84,0XFFFFFF86,0XFFFFFF88,0XFFFFFF89,0XFFFFFF8B,0XFFFFFF8D,
        0XFFFFFF8F,0XFFFFFF90,0XFFFFFF92,0XFFFFFF94,0XFFFFFF96,0XFFFFFF97,0XFFFFFF99,0XFFFFFF9B,
        0XFFFFFF9D,0XFFFFFF9F,0XFFFFFFA0,0XFFFFFFA2,0XFFFFFFA4,0XFFFFFFA6,0XFFFFFFA7,0XFFFFFFA9,
        0XFFFFFFAB,0XFFFFFFAD,0XFFFFFFAE,0XFFFFFFB0,0XFFFFFFB2,0XFFFFFFB4,0XFFFFFFB6,0XFFFFFFB7,
        0XFFFFFFB9,0XFFFFFFBB,0XFFFFFFBD,0XFFFFFFBE,0XFFFFFFC0,0XFFFFFFC2,0XFFFFFFC4,0XFFFFFFC6,
        0XFFFFFFC7,0XFFFFFFC9,0XFFFFFFCB,0XFFFFFFCD,0XFFFFFFCE,0XFFFFFFD0,0XFFFFFFD2,0XFFFFFFD4,
        0XFFFFFFD5,0XFFFFFFD7,0XFFFFFFD9,0XFFFFFFDB,0XFFFFFFDD,0XFFFFFFDE,0XFFFFFFE0,0XFFFFFFE2,
        0XFFFFFFE4,0XFFFFFFE5,0XFFFFFFE7,0XFFFFFFE9,0XFFFFFFEB,0XFFFFFFED,0XFFFFFFEE,0XFFFFFFF0,
        0XFFFFFFF2,0XFFFFFFF4,0XFFFFFFF5,0XFFFFFFF7,0XFFFFFFF9,0XFFFFFFFB,0XFFFFFFFC,0XFFFFFFFE,
        0X00000000,0X00000002,0X00000004,0X00000005,0X00000007,0X00000009,0X0000000B,0X0000000C,
        0X0000000E,0X00000010,0X00000012,0X00000013,0X00000015,0X00000017,0X00000019,0X0000001B,
        0X0000001C,0X0000001E,0X00000020,0X00000022,0X00000023,0X00000025,0X00000027,0X00000029,
        0X0000002B,0X0000002C,0X0000002E,0X00000030,0X00000032,0X00000033,0X00000035,0X00000037,
        0X00000039,0X0000003A,0X0000003C,0X0000003E,0X00000040,0X00000042,0X00000043,0X00000045,
        0X00000047,0X00000049,0X0000004A,0X0000004C,0X0000004E,0X00000050,0X00000052,0X00000053,
        0X00000055,0X00000057,0X00000059,0X0000005A,0X0000005C,0X0000005E,0X00000060,0X00000061,
        0X00000063,0X00000065,0X00000067,0X00000069,0X0000006A,0X0000006C,0X0000006E,0X00000070,
        0X00000071,0X00000073,0X00000075,0X00000077,0X00000078,0X0000007A,0X0000007C,0X0000007E,
        0X00000080,0X00000081,0X00000083,0X00000085,0X00000087,0X00000088,0X0000008A,0X0000008C,
        0X0000008E,0X00000090,0X00000091,0X00000093,0X00000095,0X00000097,0X00000098,0X0000009A,
        0X0000009C,0X0000009E,0X0000009F,0X000000A1,0X000000A3,0X000000A5,0X000000A7,0X000000A8,
        0X000000AA,0X000000AC,0X000000AE,0X000000AF,0X000000B1,0X000000B3,0X000000B5,0X000000B7,
        0X000000B8,0X000000BA,0X000000BC,0X000000BE,0X000000BF,0X000000C1,0X000000C3,0X000000C5,
        0X000000C6,0X000000C8,0X000000CA,0X000000CC,0X000000CE,0X000000CF,0X000000D1,0X000000D3,
        0X000000D5,0X000000D6,0X000000D8,0X000000DA,0X000000DC,0X000000DD,0X000000DF,0X000000E1,
};
//Cr to Green color conversion Look Up Table
const u32 CR_GREEN_LUT[256]=
{
        0X005B6800,0X005AB130,0X0059FA60,0X00594390,0X00588CC0,0X0057D5F0,0X00571F20,0X00566850,
        0X0055B180,0X0054FAB0,0X005443E0,0X00538D10,0X0052D640,0X00521F70,0X005168A0,0X0050B1D0,
        0X004FFB00,0X004F4430,0X004E8D60,0X004DD690,0X004D1FC0,0X004C68F0,0X004BB220,0X004AFB50,
        0X004A4480,0X00498DB0,0X0048D6E0,0X00482010,0X00476940,0X0046B270,0X0045FBA0,0X004544D0,
        0X00448E00,0X0043D730,0X00432060,0X00426990,0X0041B2C0,0X0040FBF0,0X00404520,0X003F8E50,
        0X003ED780,0X003E20B0,0X003D69E0,0X003CB310,0X003BFC40,0X003B4570,0X003A8EA0,0X0039D7D0,
        0X00392100,0X00386A30,0X0037B360,0X0036FC90,0X003645C0,0X00358EF0,0X0034D820,0X00342150,
        0X00336A80,0X0032B3B0,0X0031FCE0,0X00314610,0X00308F40,0X002FD870,0X002F21A0,0X002E6AD0,
        0X002DB400,0X002CFD30,0X002C4660,0X002B8F90,0X002AD8C0,0X002A21F0,0X00296B20,0X0028B450,
        0X0027FD80,0X002746B0,0X00268FE0,0X0025D910,0X00252240,0X00246B70,0X0023B4A0,0X0022FDD0,
        0X00224700,0X00219030,0X0020D960,0X00202290,0X001F6BC0,0X001EB4F0,0X001DFE20,0X001D4750,
        0X001C9080,0X001BD9B0,0X001B22E0,0X001A6C10,0X0019B540,0X0018FE70,0X001847A0,0X001790D0,
        0X0016DA00,0X00162330,0X00156C60,0X0014B590,0X0013FEC0,0X001347F0,0X00129120,0X0011DA50,
        0X00112380,0X00106CB0,0X000FB5E0,0X000EFF10,0X000E4840,0X000D9170,0X000CDAA0,0X000C23D0,
        0X000B6D00,0X000AB630,0X0009FF60,0X00094890,0X000891C0,0X0007DAF0,0X00072420,0X00066D50,
        0X0005B680,0X0004FFB0,0X000448E0,0X00039210,0X0002DB40,0X00022470,0X00016DA0,0X0000B6D0,
        0X00000000,0XFFFF4930,0XFFFE9260,0XFFFDDB90,0XFFFD24C0,0XFFFC6DF0,0XFFFBB720,0XFFFB0050,
        0XFFFA4980,0XFFF992B0,0XFFF8DBE0,0XFFF82510,0XFFF76E40,0XFFF6B770,0XFFF600A0,0XFFF549D0,
        0XFFF49300,0XFFF3DC30,0XFFF32560,0XFFF26E90,0XFFF1B7C0,0XFFF100F0,0XFFF04A20,0XFFEF9350,
        0XFFEEDC80,0XFFEE25B0,0XFFED6EE0,0XFFECB810,0XFFEC0140,0XFFEB4A70,0XFFEA93A0,0XFFE9DCD0,
        0XFFE92600,0XFFE86F30,0XFFE7B860,0XFFE70190,0XFFE64AC0,0XFFE593F0,0XFFE4DD20,0XFFE42650,
        0XFFE36F80,0XFFE2B8B0,0XFFE201E0,0XFFE14B10,0XFFE09440,0XFFDFDD70,0XFFDF26A0,0XFFDE6FD0,
        0XFFDDB900,0XFFDD0230,0XFFDC4B60,0XFFDB9490,0XFFDADDC0,0XFFDA26F0,0XFFD97020,0XFFD8B950,
        0XFFD80280,0XFFD74BB0,0XFFD694E0,0XFFD5DE10,0XFFD52740,0XFFD47070,0XFFD3B9A0,0XFFD302D0,
        0XFFD24C00,0XFFD19530,0XFFD0DE60,0XFFD02790,0XFFCF70C0,0XFFCEB9F0,0XFFCE0320,0XFFCD4C50,
        0XFFCC9580,0XFFCBDEB0,0XFFCB27E0,0XFFCA7110,0XFFC9BA40,0XFFC90370,0XFFC84CA0,0XFFC795D0,
        0XFFC6DF00,0XFFC62830,0XFFC57160,0XFFC4BA90,0XFFC403C0,0XFFC34CF0,0XFFC29620,0XFFC1DF50,
        0XFFC12880,0XFFC071B0,0XFFBFBAE0,0XFFBF0410,0XFFBE4D40,0XFFBD9670,0XFFBCDFA0,0XFFBC28D0,
        0XFFBB7200,0XFFBABB30,0XFFBA0460,0XFFB94D90,0XFFB896C0,0XFFB7DFF0,0XFFB72920,0XFFB67250,
        0XFFB5BB80,0XFFB504B0,0XFFB44DE0,0XFFB39710,0XFFB2E040,0XFFB22970,0XFFB172A0,0XFFB0BBD0,
        0XFFB00500,0XFFAF4E30,0XFFAE9760,0XFFADE090,0XFFAD29C0,0XFFAC72F0,0XFFABBC20,0XFFAB0550,
        0XFFAA4E80,0XFFA997B0,0XFFA8E0E0,0XFFA82A10,0XFFA77340,0XFFA6BC70,0XFFA605A0,0XFFA54ED0,
};
//Cb to Green color conversion Look Up Table
const u32 CB_GREEN_LUT[256]=
{
        0X002C0C00,0X002BB3E8,0X002B5BD0,0X002B03B8,0X002AABA0,0X002A5388,0X0029FB70,0X0029A358,
        0X00294B40,0X0028F328,0X00289B10,0X002842F8,0X0027EAE0,0X002792C8,0X00273AB0,0X0026E298,
        0X00268A80,0X00263268,0X0025DA50,0X00258238,0X00252A20,0X0024D208,0X002479F0,0X002421D8,
        0X0023C9C0,0X002371A8,0X00231990,0X0022C178,0X00226960,0X00221148,0X0021B930,0X00216118,
        0X00210900,0X0020B0E8,0X002058D0,0X002000B8,0X001FA8A0,0X001F5088,0X001EF870,0X001EA058,
        0X001E4840,0X001DF028,0X001D9810,0X001D3FF8,0X001CE7E0,0X001C8FC8,0X001C37B0,0X001BDF98,
        0X001B8780,0X001B2F68,0X001AD750,0X001A7F38,0X001A2720,0X0019CF08,0X001976F0,0X00191ED8,
        0X0018C6C0,0X00186EA8,0X00181690,0X0017BE78,0X00176660,0X00170E48,0X0016B630,0X00165E18,
        0X00160600,0X0015ADE8,0X001555D0,0X0014FDB8,0X0014A5A0,0X00144D88,0X0013F570,0X00139D58,
        0X00134540,0X0012ED28,0X00129510,0X00123CF8,0X0011E4E0,0X00118CC8,0X001134B0,0X0010DC98,
        0X00108480,0X00102C68,0X000FD450,0X000F7C38,0X000F2420,0X000ECC08,0X000E73F0,0X000E1BD8,
        0X000DC3C0,0X000D6BA8,0X000D1390,0X000CBB78,0X000C6360,0X000C0B48,0X000BB330,0X000B5B18,
        0X000B0300,0X000AAAE8,0X000A52D0,0X0009FAB8,0X0009A2A0,0X00094A88,0X0008F270,0X00089A58,
        0X00084240,0X0007EA28,0X00079210,0X000739F8,0X0006E1E0,0X000689C8,0X000631B0,0X0005D998,
        0X00058180,0X00052968,0X0004D150,0X00047938,0X00042120,0X0003C908,0X000370F0,0X000318D8,
        0X0002C0C0,0X000268A8,0X00021090,0X0001B878,0X00016060,0X00010848,0X0000B030,0X00005818,
        0X00000000,0XFFFFA7E8,0XFFFF4FD0,0XFFFEF7B8,0XFFFE9FA0,0XFFFE4788,0XFFFDEF70,0XFFFD9758,
        0XFFFD3F40,0XFFFCE728,0XFFFC8F10,0XFFFC36F8,0XFFFBDEE0,0XFFFB86C8,0XFFFB2EB0,0XFFFAD698,
        0XFFFA7E80,0XFFFA2668,0XFFF9CE50,0XFFF97638,0XFFF91E20,0XFFF8C608,0XFFF86DF0,0XFFF815D8,
        0XFFF7BDC0,0XFFF765A8,0XFFF70D90,0XFFF6B578,0XFFF65D60,0XFFF60548,0XFFF5AD30,0XFFF55518,
        0XFFF4FD00,0XFFF4A4E8,0XFFF44CD0,0XFFF3F4B8,0XFFF39CA0,0XFFF34488,0XFFF2EC70,0XFFF29458,
        0XFFF23C40,0XFFF1E428,0XFFF18C10,0XFFF133F8,0XFFF0DBE0,0XFFF083C8,0XFFF02BB0,0XFFEFD398,
        0XFFEF7B80,0XFFEF2368,0XFFEECB50,0XFFEE7338,0XFFEE1B20,0XFFEDC308,0XFFED6AF0,0XFFED12D8,
        0XFFECBAC0,0XFFEC62A8,0XFFEC0A90,0XFFEBB278,0XFFEB5A60,0XFFEB0248,0XFFEAAA30,0XFFEA5218,
        0XFFE9FA00,0XFFE9A1E8,0XFFE949D0,0XFFE8F1B8,0XFFE899A0,0XFFE84188,0XFFE7E970,0XFFE79158,
        0XFFE73940,0XFFE6E128,0XFFE68910,0XFFE630F8,0XFFE5D8E0,0XFFE580C8,0XFFE528B0,0XFFE4D098,
        0XFFE47880,0XFFE42068,0XFFE3C850,0XFFE37038,0XFFE31820,0XFFE2C008,0XFFE267F0,0XFFE20FD8,
        0XFFE1B7C0,0XFFE15FA8,0XFFE10790,0XFFE0AF78,0XFFE05760,0XFFDFFF48,0XFFDFA730,0XFFDF4F18,
        0XFFDEF700,0XFFDE9EE8,0XFFDE46D0,0XFFDDEEB8,0XFFDD96A0,0XFFDD3E88,0XFFDCE670,0XFFDC8E58,
        0XFFDC3640,0XFFDBDE28,0XFFDB8610,0XFFDB2DF8,0XFFDAD5E0,0XFFDA7DC8,0XFFDA25B0,0XFFD9CD98,
        0XFFD97580,0XFFD91D68,0XFFD8C550,0XFFD86D38,0XFFD81520,0XFFD7BD08,0XFFD764F0,0XFFD70CD8,
        0XFFD6B4C0,0XFFD65CA8,0XFFD60490,0XFFD5AC78,0XFFD55460,0XFFD4FC48,0XFFD4A430,0XFFD44C18,
};
// {MOD}彩转换颜 {MOD}范围限制表
const u8 CLAMP_LUT[]=
{
        //限制范围:0xffffffff to 0xffffff00
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        //限制范围:0x00 to 0xff  
        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
        0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
        0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
        0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
        0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
        0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
        0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
        0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
        0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
        0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
        //限制范围:0x100 to 0x1ff
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};[/mw_shl_code]

CR_RED_LUT,CB_BLUE_LUT,CR_GREEN_LUT等数组,官方是用算法生成的,我直接搞成const数据存放在flash,发现对速度几乎没有提升。

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
5条回答
正点原子
1楼-- · 2019-07-20 21:34
 精彩回答 2  元偷偷看……
正点原子
2楼-- · 2019-07-21 01:40
今天研究了一天,解码出来一帧图片(读取文件+硬解JPEG+YUV转RGB),可以控制在50ms左右(个别可以在40ms),基本满足要求了,算了不优化了。
xkwy
3楼-- · 2019-07-21 02:15
可能是Flash速度太慢了吧
正点原子
4楼-- · 2019-07-21 02:45
xkwy 发表于 2016-7-30 03:30
可能是Flash速度太慢了吧

应该不是。
我把数组放sram/tcm,都比FLASH慢。数组放flash最快。
另外,还发现一个小技巧。
读取3个不同地址的数组,速度比读取同一个数组不同位置来的慢。
所以大家要提高速度,可以把数据尽量放一个数组,然后偏移去取值,比放不同数组要快!!
lbyjy
5楼-- · 2019-07-21 06:39
 精彩回答 2  元偷偷看……

一周热门 更多>