FFmpeg
Loading...
Searching...
No Matches
timestamp.c
Go to the documentation of this file.
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
27int 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 printf("Testing av_ts_make_string()\n");
49 for (int i = 0; i < FF_ARRAY_ELEMS(ts_vals); i++)
50 printf("%s: %s\n", ts_vals[i].label,
51 av_ts_make_string(buf, ts_vals[i].ts));
52
53 /* av_ts2str macro */
54 printf("\nTesting av_ts2str()\n");
55 printf("NOPTS: %s\n", av_ts2str(AV_NOPTS_VALUE));
56 printf("48000: %s\n", av_ts2str(48000));
57
58 /* av_ts_make_time_string2 */
59 printf("\nTesting av_ts_make_time_string2()\n");
60 for (int i = 0; i < FF_ARRAY_ELEMS(time_vals); i++)
61 printf("%s: %s\n", time_vals[i].label,
62 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 printf("\nTesting av_ts_make_time_string()\n");
66 {
67 AVRational tb = {1, 1000};
68 printf("5000 at 1/1000: %s\n",
69 av_ts_make_time_string(buf, 5000, &tb));
70 printf("NOPTS: %s\n",
72 }
73
74 return 0;
75}
Convenience header that includes libavutil's core.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
long long int64_t
Definition coverity.c:34
__device__ int printf(const char *,...)
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
Utility Preprocessor macros.
Utilities for rational number calculation.
#define FF_ARRAY_ELEMS(a)
Rational number (pair of numerator and denominator).
Definition rational.h:58
int main(void)
Definition timestamp.c:27
char * av_ts_make_time_string2(char *buf, int64_t ts, AVRational tb)
Fill the provided buffer with a string containing a timestamp time representation.
Definition timestamp.c:21
timestamp utils, mostly useful for debugging/logging purposes
static char * av_ts_make_time_string(char *buf, int64_t ts, const AVRational *tb)
Fill the provided buffer with a string containing a timestamp representation.
Definition timestamp.h:73
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition timestamp.h:54
static char * av_ts_make_string(char *buf, int64_t ts)
Fill the provided buffer with a string containing a timestamp representation.
Definition timestamp.h:43
#define AV_TS_MAX_STRING_SIZE
Definition timestamp.h:33