History

lavu: add timestamp.h header with convenience timestamp utilities

Stefano Sabatini committed 14 years ago

Commit c28e7af1 parent 71d6b464 files · +82 −2Browse files

Unified · Split

4 files
  1. doc/APIchanges +4 −0
  2. libavutil/Makefile +1 −0
  3. libavutil/avutil.h +2 −2
  4. libavutil/timestamp.h +75 −0
doc/APIchanges+4−0
@@ -13,6 +13,10 @@ libavutil: 2011-04-18 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162012-02-09 - xxxxxxx - lavu 51.39.100
17 Add a new installed header libavutil/timestamp.h with timestamp
18 utilities.
19
162012-02-06 - xxxxxxx - lavu 51.38.100202012-02-06 - xxxxxxx - lavu 51.38.100
17 Add av_parse_ratio() function to parseutils.h.21 Add av_parse_ratio() function to parseutils.h.
18 22
libavutil/Makefile+1−0
@@ -38,6 +38,7 @@ HEADERS = adler32.h \ · 37 unmodified lines
38 samplefmt.h \38 samplefmt.h \
39 sha.h \39 sha.h \
40 timecode.h \40 timecode.h \
41 timestamp.h \
41 42
42BUILT_HEADERS = avconfig.h43BUILT_HEADERS = avconfig.h
43 44
libavutil/avutil.h+2−2
@@ -154,8 +154,8 @@ · 153 unmodified lines
154 */154 */
155 155
156#define LIBAVUTIL_VERSION_MAJOR 51156#define LIBAVUTIL_VERSION_MAJOR 51
157#define LIBAVUTIL_VERSION_MINOR 38157#define LIBAVUTIL_VERSION_MINOR 39
158#define LIBAVUTIL_VERSION_MICRO 101158#define LIBAVUTIL_VERSION_MICRO 100
159 159
160#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \160#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
161 LIBAVUTIL_VERSION_MINOR, \161 LIBAVUTIL_VERSION_MINOR, \
libavutil/timestamp.h+75−0
@@ -0,0 +1,75 @@
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/**
20 * @file
21 * timestamp utils, mostly useful for debugging/logging purposes
22 */
23
24#ifndef AVUTIL_TIMESTAMP_H
25#define AVUTIL_TIMESTAMP_H
26
27#include "common.h"
28
29#define AV_TS_MAX_STRING_SIZE 32
30#define AV_TS_MAX_STRING_SIZE 32
31
32/**
33 * Fill the provided buffer with a string containing a timestamp
34 * representation.
35 *
36 * @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
37 * @param ts the timestamp to represent
38 * @return the buffer in input
39 */
40static inline char *av_ts_make_string(char *buf, int64_t ts)
41{
42 if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
43 else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%"PRId64"", ts);
44 return buf;
45}
46
47/**
48 * Convenience macro, the return value should be used only directly in
49 * function arguments but never stand-alone.
50 */
51#define av_ts2str(ts) av_ts_make_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts)
52
53/**
54 * Fill the provided buffer with a string containing a timestamp time
55 * representation.
56 *
57 * @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
58 * @param ts the timestamp to represent
59 * @param tb the timebase of the timestamp
60 * @return the buffer in input
61 */
62static inline char *av_ts_make_time_string(char *buf, int64_t ts, AVRational *tb)
63{
64 if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
65 else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.6g", av_q2d(*tb) * ts);
66 return buf;
67}
68
69/**
70 * Convenience macro, the return value should be used only directly in
71 * function arguments but never stand-alone.
72 */
73#define av_ts2timestr(ts, tb) av_ts_make_time_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts, tb)
74
75#endif /* AVUTIL_TIMESTAMP_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t