阅读:1411回复:0
请教高手关于内核态指针存取数据慢的问题
我是采集视频数据,然后进行显示,下述代码为线程中运行的代码,但图像进行显示时,一秒钟只能显示十帧,经过测试,发现
在此循环语句中*buffer_rgb++= rgb_data语句占用时间特别多,在此处运行时,不仅是这种指向内存的指针很费时间,还有数组的存取也很费时间,请高手赐教这是什么原因,可以采取什么样的办法来解决 #if (DOTNET_DRIVER) SetKMode(TRUE); #endif buffer_rgb =(unsigned int *)(0xAc100000); buffer_y1 = (unsigned char *)y_address; buffer_cb1 = (unsigned char *)cb_address; buffer_cr1= (unsigned char *)cr_address; s2440IOP->rGPADAT |=(1<<12) ; for (y=234;y>0;y--) // YCbCr 4:2:2 format { for (x=480;x>0;x--) { R =YCbCrtoR(*buffer_y1, *buffer_cb1, *buffer_cr1); G =YCbCrtoG(*buffer_y1, *buffer_cb1, *buffer_cr1); B =YCbCrtoB(*buffer_y1, *buffer_cb1, *buffer_cr1); if (R>255 ) R = 255; if (G>255 ) G = 255; if (B>255 ) B = 255; if (R<0 ) R = 0; if (G<0 ) G = 0; if (B<0 ) B = 0; rgb_data= 0; rgb_data |=(R&0xff)<<16; // R 8bits rgb_data |=(G&0xff)<<8; // G 8bits rgb_data |=(B&0xff); // B 8bits *buffer_rgb++= rgb_data; // data[x]= rgb_data; buffer_y1++; if((x%2)) { buffer_cb1++; buffer_cr1++; } } } s2440IOP->rGPADAT &=~(1<<12) ; //memcpy((void *)buffer_rgb,(void *)y_address,480*4*234); #if (DOTNET_DRIVER) SetKMode(FALSE); #endif |
|