1月9日,在线听RF检波器如何简化系统设计,与ADI工程师一起学习吧!→ 报名参会 ←
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 贴一段很简单的小程序,大家说说在arm926e上怎么优化?

共1条 1/1 1 跳转至

贴一段很简单的小程序,大家说说在arm926e上怎么优化?

菜鸟
2005-06-04 23:19:00    评分

2个函数,第一个是初始化标的函数,第二个是查表作计算的函数。第一个函数只跑一次,第二个函数是需要优化的。

void AllTablesInit(uint8 *pAllTables) { int16 * RGB_Y_tab = (int16*)pAllTables; int16 * B_U_tab = RGB_Y_tab + 256; int16 * G_U_tab = B_U_tab + 256; int16 * G_V_tab = G_U_tab + 256; int16 * R_V_tab = G_V_tab + 256; unsigned char * RGB_Clip = (unsigned char *)(R_V_tab + 256); int i; for (i = 0; i < 256; i++) { RGB_Y_tab = RGB_Y_OUT * (i - Y_ADD_OUT); B_U_tab = B_U_OUT * (i - U_ADD_OUT); G_U_tab = G_U_OUT * (i - U_ADD_OUT); G_V_tab = G_V_OUT * (i - V_ADD_OUT); R_V_tab = R_V_OUT * (i - V_ADD_OUT); }

for(i = -2048; i < 0; i++) RGB_Clip[i + 2048] = 0; for (i = 0; i <256 ; i++) { RGB_Clip[i + 2048] = i; } for (i = 256; i <2048 ; i++) { RGB_Clip[i + 2048] = 255; } }

/* yuv 4:2:0 planar -> rgb24 */ void YUV420RGB888(uint8 *pY, uint8 *pU, uint8 *pV, uint32 ImgWidth, uint32 ImgHeight, uint8 *pRGB, uint8 *pAllTables) { int16 * RGB_Y_tab = (int16*)pAllTables; int16 * B_U_tab = RGB_Y_tab + 256; int16 * G_U_tab = B_U_tab + 256; int16 * G_V_tab = G_U_tab + 256; int16 * R_V_tab = G_V_tab + 256; uint8 * RGB_Clip = (uint8 *)(R_V_tab + 256); const uint32 dst_dif = 3 * 3 * ImgWidth; int32 y_dif = 2 * ImgWidth - ImgWidth; uint8 *dst1 = pRGB + ImgWidth*3*(ImgHeight-1); uint8 *dst2 = dst1 - ImgWidth*3; uint8 *pY2 = pY + ImgWidth; uint32 x, y; uint32 ImgWidth2 = ImgWidth>>1; for (y = ImgHeight>>1; y; y--) { // process one 2x2 block per iteration for (x = 0; x < ImgWidth2; x++) { int32 u, v; int32 b_u, g_uv, r_v, rgb_y; int32 r, g, b; u = pU[x]; v = pV[x]; b_u = B_U_tab[u]; g_uv = G_U_tab[u] + G_V_tab[v]; r_v = R_V_tab[v]; rgb_y = RGB_Y_tab[*pY]; b = (rgb_y + b_u) >> SCALEBITS_OUT; g = (rgb_y - g_uv) >> SCALEBITS_OUT; r = (rgb_y + r_v) >> SCALEBITS_OUT; dst1[2] = RGB_Clip[(r)+2048]; dst1[1] = RGB_Clip[(g)+2048]; dst1[0] = RGB_Clip[(b)+2048]; pY++; rgb_y = RGB_Y_tab[*pY]; b = (rgb_y + b_u) >> SCALEBITS_OUT; g = (rgb_y - g_uv) >> SCALEBITS_OUT; r = (rgb_y + r_v) >> SCALEBITS_OUT; dst1[5] = RGB_Clip[(r)+2048]; dst1[4] = RGB_Clip[(g)+2048]; dst1[3] = RGB_Clip[(b)+2048]; pY++; rgb_y = RGB_Y_tab[*pY2]; b = (rgb_y + b_u) >> SCALEBITS_OUT; g = (rgb_y - g_uv) >> SCALEBITS_OUT; r = (rgb_y + r_v) >> SCALEBITS_OUT; dst2[2] = RGB_Clip[(r)+2048]; dst2[1] = RGB_Clip[(g)+2048]; dst2[0] = RGB_Clip[(b)+2048]; pY2++; rgb_y = RGB_Y_tab[*pY2]; b = (rgb_y + b_u) >> SCALEBITS_OUT; g = (rgb_y - g_uv) >> SCALEBITS_OUT; r = (rgb_y + r_v) >> SCALEBITS_OUT; dst2[5] = RGB_Clip[(r)+2048]; dst2[4] = RGB_Clip[(g)+2048]; dst2[3] = RGB_Clip[(b)+2048]; pY2++; dst1 += 6; dst2 += 6; } dst1 -= dst_dif; dst2 -= dst_dif; pY += y_dif; pY2 += y_dif; pU += ImgWidth2; pV += ImgWidth2; } }

怎么做?谢谢。




关键词: 一段     简单     程序     大家     说说     arm926e     怎么    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]