Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * time.c -- time functions  | 
3  |  |  *  | 
4  |  |  * Copyright (C) 2004, 2005, 2006, 2007 Svend Sorensen  | 
5  |  |  * For license terms, see the file COPYING in this distribution.  | 
6  |  |  */  | 
7  |  |  | 
8  |  | #include "time.h"  | 
9  |  | #include <stdio.h>  | 
10  |  | #include <stdlib.h>  | 
11  |  |  | 
12  |  | long time_msf_to_frame(int m, int s, int f)  | 
13  | 4.36k  | { | 
14  | 4.36k  |   if (m < 0 || m > 99 || s < 0 || s >= 60 || f < 0 || f >= 75) { | 
15  | 3.42k  |     return -1;  | 
16  | 3.42k  |   }  | 
17  | 941  |   return (m * 60 + s) * 75 + f;  | 
18  | 4.36k  | }  | 
19  |  |  | 
20  |  | void time_frame_to_msf(long frame, int *m, int *s, int *f)  | 
21  | 0  | { | 
22  | 0  |   *f = frame % 75;           /* 0 <= frames <= 74 */  | 
23  | 0  |   frame /= 75;  | 
24  | 0  |   *s = frame % 60;          /* 0 <= seconds <= 59 */  | 
25  | 0  |   frame /= 60;  | 
26  | 0  |   *m = frame;               /* 0 <= minutes */  | 
27  | 0  | }  | 
28  |  |  | 
29  |  | /* print frame in mm:ss:ff format */  | 
30  |  | char *time_frame_to_mmssff(long f)  | 
31  | 0  | { | 
32  | 0  |   static char msf[9];  | 
33  | 0  |   int minutes, seconds, frames;  | 
34  |  | 
  | 
35  | 0  |   time_frame_to_msf(f, &minutes, &seconds, &frames);  | 
36  | 0  |   sprintf(msf, "%02d:%02d:%02d", minutes, seconds, frames);  | 
37  |  | 
  | 
38  | 0  |   return msf;  | 
39  | 0  | }  |