1 |
+ |
#define _FILE_OFFSET_BITS 64 |
2 |
+ |
|
3 |
|
#include <stdlib.h> |
4 |
|
#include <stdio.h> |
5 |
+ |
#include <string.h> |
6 |
|
|
7 |
|
#include "frameCount.h" |
8 |
|
|
9 |
|
|
10 |
< |
int frameCount( char* in_name ){ |
10 |
> |
int frameCount( char* in_name, int outTime ){ |
11 |
|
|
12 |
|
FILE *in_file; |
13 |
|
int nFrames = 0; |
14 |
+ |
double time; |
15 |
|
int i, j, k; |
16 |
|
int lineNum = 0; |
17 |
|
char readBuffer[2000]; |
18 |
+ |
char* foo; |
19 |
|
|
20 |
+ |
|
21 |
|
in_file = fopen( in_name, "r" ); |
22 |
|
if( in_file == NULL ){ |
23 |
|
printf( "Error opening \"%s\"\n", in_name ); |
31 |
|
exit(8); |
32 |
|
} |
33 |
|
|
34 |
+ |
if(outTime) printf("# frame Num\tTime\n" ); |
35 |
+ |
|
36 |
|
while( !feof( in_file ) ){ |
37 |
|
|
38 |
|
i = atoi(readBuffer); |
45 |
|
exit(8); |
46 |
|
} |
47 |
|
|
48 |
+ |
if(outTime){ |
49 |
+ |
foo = strtok( readBuffer, " ,;\t" ); |
50 |
+ |
time = atof( foo ); |
51 |
+ |
} |
52 |
|
|
53 |
|
for(j=0; j<i; j++){ |
54 |
|
|
63 |
|
} |
64 |
|
|
65 |
|
nFrames++; |
66 |
+ |
if( outTime ){ |
67 |
+ |
printf("%d\t%f\n", nFrames, time ); |
68 |
+ |
} |
69 |
|
|
70 |
|
fgets( readBuffer, sizeof( readBuffer ), in_file ); |
71 |
|
lineNum++; |