把它加到程序中就可以计算每秒帧率。
void fps_count(void){
static struct timeval tBegin = {0},tEnd = {0};
static int init = 0, count = 0,fps = 0;
if(!init){ //init
init = 1;
printf("fps count init \n");
gettimeofday(&tBegin, NULL);
gettimeofday(&tEnd, NULL);
}else{ //count
gettimeofday(&tEnd, NULL);
printf("[%ld.%ld]", tEnd.tv_sec,tEnd.tv_usec);
printf("Succeed to decode 1 frame!--->fps : %d\n",fps);
if(tBegin.tv_sec != tEnd.tv_sec){
gettimeofday(&tBegin, NULL);
fps = count;
count = 0;
}
count++;
}
}