FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavutil/tests/timestamp.c
Date: 2026-09-05 04:28:30
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 1 1 100.0%
Branches: 4 4 100.0%

Line Branch Exec Source
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <inttypes.h>
20 #include <stdio.h>
21
22 #include "libavutil/avutil.h"
23 #include "libavutil/macros.h"
24 #include "libavutil/rational.h"
25 #include "libavutil/timestamp.h"
26
27 1 int main(void)
28 {
29 char buf[AV_TS_MAX_STRING_SIZE];
30 static const struct { const char *label; int64_t ts; } ts_vals[] = {
31 { "NOPTS", AV_NOPTS_VALUE },
32 { "0", 0 },
33 { "90000", 90000 },
34 { "-1", -1 },
35 { "INT64_MAX", INT64_MAX },
36 { "INT64_MIN+1", INT64_MIN + 1 },
37 };
38 static const struct { const char *label; int64_t ts; AVRational tb; } time_vals[] = {
39 { "NOPTS", AV_NOPTS_VALUE, {1, 90000} },
40 { "90000 at 1/90000", 90000, {1, 90000} },
41 { "0 at 1/1000", 0, {1, 1000} },
42 { "48000 at 1/48000", 48000, {1, 48000} },
43 { "44100 at 1/44100", 44100, {1, 44100} },
44 { "-90000 at 1/90000", -90000, {1, 90000} },
45 };
46
47 /* av_ts_make_string */
48 1 printf("Testing av_ts_make_string()\n");
49
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 for (int i = 0; i < FF_ARRAY_ELEMS(ts_vals); i++)
50 6 printf("%s: %s\n", ts_vals[i].label,
51 6 av_ts_make_string(buf, ts_vals[i].ts));
52
53 /* av_ts2str macro */
54 1 printf("\nTesting av_ts2str()\n");
55 1 printf("NOPTS: %s\n", av_ts2str(AV_NOPTS_VALUE));
56 1 printf("48000: %s\n", av_ts2str(48000));
57
58 /* av_ts_make_time_string2 */
59 1 printf("\nTesting av_ts_make_time_string2()\n");
60
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 for (int i = 0; i < FF_ARRAY_ELEMS(time_vals); i++)
61 6 printf("%s: %s\n", time_vals[i].label,
62 6 av_ts_make_time_string2(buf, time_vals[i].ts, time_vals[i].tb));
63
64 /* av_ts_make_time_string (AVRational pointer version) */
65 1 printf("\nTesting av_ts_make_time_string()\n");
66 {
67 1 AVRational tb = {1, 1000};
68 1 printf("5000 at 1/1000: %s\n",
69 av_ts_make_time_string(buf, 5000, &tb));
70 1 printf("NOPTS: %s\n",
71 av_ts_make_time_string(buf, AV_NOPTS_VALUE, &tb));
72 }
73
74 1 return 0;
75 }
76