Coverage Report

Created: 2026-06-30 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libcue/time.c
Line
Count
Source
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 <stdio.h>
9
#include <stdlib.h>
10
#include <string.h>
11
12
#include "cue_time.h"
13
#include "libcue.h"
14
15
long time_msf_to_frame(int m, int s, int f)
16
3.73k
{
17
3.73k
  if (m < 0 || m > 99 || s < 0 || s >= 60 || f < 0 || f >= CUE_FPS) {
18
3.29k
    return -1;
19
3.29k
  }
20
436
  return (m * 60 + s) * CUE_FPS + f;
21
3.73k
}
22
23
void time_frame_to_msf(long frame, int *m, int *s, int *f)
24
0
{
25
0
  *f = frame % CUE_FPS;           /* 0 <= frames <= 74 */
26
0
  frame /= CUE_FPS;
27
0
  *s = frame % 60;          /* 0 <= seconds <= 59 */
28
0
  frame /= 60;
29
0
  *m = frame;               /* 0 <= minutes */
30
0
}
31
32
/* print frame in mm:ss:ff format */
33
char *time_frame_to_mmssff(long f)
34
0
{
35
0
  static char msf[9];
36
0
  int minutes, seconds, frames;
37
38
0
  if (f < 0 || f >= CUE_FPS * 60 * 100) {
39
0
    strcpy(msf, "00:00:00");
40
0
    return msf;
41
0
  }
42
43
0
  time_frame_to_msf(f, &minutes, &seconds, &frames);
44
0
  snprintf(msf, sizeof(msf), "%02d:%02d:%02d", minutes, seconds, frames);
45
46
0
  return msf;
47
0
}