annotate lib/libavutil/timestamp.h @ 2221:c69013c186c7

for video
author Ritor1
date Tue, 18 Feb 2014 16:18:20 +0600
parents 992d2e6f907d
children
rev   line source
2134
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
1 /*
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
2 * This file is part of FFmpeg.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
3 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
4 * FFmpeg is free software; you can redistribute it and/or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
5 * modify it under the terms of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
7 * version 2.1 of the License, or (at your option) any later version.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
8 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
9 * FFmpeg is distributed in the hope that it will be useful,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
12 * Lesser General Public License for more details.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
13 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
14 * You should have received a copy of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
15 * License along with FFmpeg; if not, write to the Free Software
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
17 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
18
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
19 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
20 * @file
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
21 * timestamp utils, mostly useful for debugging/logging purposes
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
22 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
23
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
24 #ifndef AVUTIL_TIMESTAMP_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
25 #define AVUTIL_TIMESTAMP_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
26
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
27 #include "common.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
28
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
29 #define AV_TS_MAX_STRING_SIZE 32
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
30
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
31 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
32 * Fill the provided buffer with a string containing a timestamp
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
33 * representation.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
34 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
35 * @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
36 * @param ts the timestamp to represent
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
37 * @return the buffer in input
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
38 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
39 static inline char *av_ts_make_string(char *buf, int64_t ts)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
40 {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
41 if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
42 else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%"PRId64"", ts);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
43 return buf;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
44 }
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
45
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
46 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
47 * Convenience macro, the return value should be used only directly in
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
48 * function arguments but never stand-alone.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
49 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
50 #define av_ts2str(ts) av_ts_make_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
51
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
52 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
53 * Fill the provided buffer with a string containing a timestamp time
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
54 * representation.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
55 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
56 * @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
57 * @param ts the timestamp to represent
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
58 * @param tb the timebase of the timestamp
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
59 * @return the buffer in input
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
60 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
61 static inline char *av_ts_make_time_string(char *buf, int64_t ts, AVRational *tb)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
62 {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
63 if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
64 else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.6g", av_q2d(*tb) * ts);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
65 return buf;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
66 }
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
67
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
68 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
69 * Convenience macro, the return value should be used only directly in
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
70 * function arguments but never stand-alone.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
71 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
72 #define av_ts2timestr(ts, tb) av_ts_make_time_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts, tb)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
73
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
74 #endif /* AVUTIL_TIMESTAMP_H */