由于png没有硬件解码,特别是大尺寸的png图片的解码时间比较长,使用浮点优化以后,速度有明显改善。
方法是在libpng和zlib的makefile中的CFLAG 加上-DPNG_FLOATING_POINT_SUPPORTED -mfpu=vfpv3-d16 -mfloat-abi=softfp -O3 -funroll-loops -fomit-frame-pointer -ffast-math
另外再修改directfb的idirectfbp_w_picpathprovider_png.c的IDirectFBImageProvider_PNG_RenderTo()函数中添加时间打印
struct timeval tv;
float render_start, render_end, decoder_end, decoder_time, render_time;
float render_start, render_end, decoder_end, decoder_time, render_time;
gettimeofday(&tv, NULL);
render_start = (float) (tv.tv_sec) + (float) (tv.tv_usec) / 1000000;
render_start = (float) (tv.tv_sec) + (float) (tv.tv_usec) / 1000000;
......
gettimeofday(&tv, NULL);
decoder_end = (float) (tv.tv_sec) + (float) (tv.tv_usec) / 1000000;
/* actual rendering */
decoder_end = (float) (tv.tv_sec) + (float) (tv.tv_usec) / 1000000;
/* actual rendering */
......
gettimeofday(&tv, NULL);
render_end = (float) (tv.tv_sec) + (float) (tv.tv_usec) / 1000000;
decoder_time = decoder_end - render_start;
render_time = render_end - decoder_end;
printf("\n Time Taken in Png Decoding: %f seconds\n",decoder_time);
printf("\n Time Taken in Png Render: %f seconds\n",render_time);
结果如下:
render_end = (float) (tv.tv_sec) + (float) (tv.tv_usec) / 1000000;
decoder_time = decoder_end - render_start;
render_time = render_end - decoder_end;
printf("\n Time Taken in Png Decoding: %f seconds\n",decoder_time);
printf("\n Time Taken in Png Render: %f seconds\n",render_time);
结果如下:
1.未优化前,运行dfb_neo
Time Taken in Jpeg Decoding: 0.054200 seconds
(*) Direct/Interface: Using 'PNG' implementation of 'IDirectFBImageProvider'.
(*) Direct/Interface: Using 'PNG' implementation of 'IDirectFBImageProvider'.
Time Taken in Png Decoding: 0.004192 seconds
Time Taken in Png Render: 0.000473 seconds
Time Taken in Png Decoding: 0.003410 seconds
Time Taken in Png Render: 0.000420 seconds
Time Taken in Png Decoding: 0.003462 seconds
Time Taken in Png Render: 0.000420 seconds
Time Taken in Png Decoding: 0.003510 seconds
Time Taken in Png Render: 0.000423 seconds
Time Taken in Png Decoding: 0.003885 seconds
Time Taken in Png Render: 0.000431 seconds
Time Taken in Png Decoding: 0.003639 seconds
Time Taken in Png Render: 0.000422 seconds
Time Taken in Png Decoding: 0.004333 seconds
Time Taken in Png Render: 0.000418 seconds
Time Taken in Png Decoding: 0.003736 seconds
Time Taken in Png Render: 0.000427 seconds
2.libpng优化以后:
Time Taken in Jpeg Decoding: 0.055157 seconds
(*) Direct/Interface: Using 'PNG' implementation of 'IDirectFBImageProvider'.
(*) Direct/Interface: Using 'PNG' implementation of 'IDirectFBImageProvider'.
Time Taken in Png Decoding: 0.003592 seconds
Time Taken in Png Render: 0.000477 seconds
Time Taken in Png Decoding: 0.002720 seconds
Time Taken in Png Render: 0.000420 seconds
Time Taken in Png Decoding: 0.002691 seconds
Time Taken in Png Render: 0.000441 seconds
Time Taken in Png Decoding: 0.002802 seconds
Time Taken in Png Render: 0.000456 seconds
Time Taken in Png Decoding: 0.003124 seconds
Time Taken in Png Render: 0.000422 seconds
Time Taken in Png Decoding: 0.002975 seconds
Time Taken in Png Render: 0.000422 seconds
Time Taken in Png Decoding: 0.003540 seconds
Time Taken in Png Render: 0.000422 seconds
Time Taken in Png Decoding: 0.003166 seconds
Time Taken in Png Render: 0.000423 seconds
3.libpng和zlib都优化以后:
Time Taken in Jpeg Decoding: 0.054309 seconds
(*) Direct/Interface: Using 'PNG' implementation of 'IDirectFBImageProvider'.
(*) Direct/Interface: Using 'PNG' implementation of 'IDirectFBImageProvider'.
Time Taken in Png Decoding: 0.001759 seconds
Time Taken in Png Render: 0.000479 seconds
Time Taken in Png Decoding: 0.001179 seconds
Time Taken in Png Render: 0.000418 seconds
Time Taken in Png Decoding: 0.001266 seconds
Time Taken in Png Render: 0.000412 seconds
Time Taken in Png Decoding: 0.001179 seconds
Time Taken in Png Render: 0.000420 seconds
Time Taken in Png Decoding: 0.001324 seconds
Time Taken in Png Render: 0.000420 seconds
Time Taken in Png Decoding: 0.001316 seconds
Time Taken in Png Render: 0.000422 seconds
Time Taken in Png Decoding: 0.001591 seconds
Time Taken in Png Render: 0.000420 seconds
Time Taken in Png Decoding: 0.001381 seconds
Time Taken in Png Render: 0.000431 seconds