p_get_frame_total函数指针 原型:int(*P_get_frame_total ) (hnd_t handle)
所指函数包括: get_frame_total_yuv get_frame_total_avis get_frame_total_v4m get_frame_total_thread
以get_frame_total_yuv为例: int get_frame_total_yuv( hnd_t handle ) { yuv_input_t *h = handle; inti_frame_total = 0;
if(!fseek( h->fh, 0, SEEK_END ) ) { uint64_t i_size = ftell(h->fh ); fseek( h->fh, 0, SEEK_SET); i_frame_total = (int)(i_size / ( h->width * h->height * 3 / 2)); }
returni_frame_total; }
顾名思义,此函数yuv_input-t图像帧总数,此处介绍fseek与ftell函数
ftell()函数 原型: longftell(FILE *fp) 功能:得到流式文件的当前读写位置,其返回值是当前读写位置偏离文件头部的字节数。如:ban=ftell(fp); 是获取fp指定的文件的当前读写位置,并将其值传给变量ban。
Fseek()函数 原型: intfseek(FILE *fp,long offset,int origin); 功能:把fp的文件读写位置指针移到指定的位置。如:fseek(fp,20,SEEK_SET);意思是把fp文件读写位置指针从文件开始后移20个字节。
fseek函数与ftell函数结合使用:可以用fseek函数把位置指针移到文件尾,再用ftell函数获得这时位置指针距文件头的字节数,这个字节数就是文件的长度。 |
|