00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00024 #ifndef AVUTIL_TIMESTAMP_H
00025 #define AVUTIL_TIMESTAMP_H
00026 
00027 #include "common.h"
00028 
00029 #define AV_TS_MAX_STRING_SIZE 32
00030 
00039 static inline char *av_ts_make_string(char *buf, int64_t ts)
00040 {
00041     if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
00042     else                      snprintf(buf, AV_TS_MAX_STRING_SIZE, "%"PRId64"", ts);
00043     return buf;
00044 }
00045 
00050 #define av_ts2str(ts) av_ts_make_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts)
00051 
00061 static inline char *av_ts_make_time_string(char *buf, int64_t ts, AVRational *tb)
00062 {
00063     if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
00064     else                      snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.6g", av_q2d(*tb) * ts);
00065     return buf;
00066 }
00067 
00072 #define av_ts2timestr(ts, tb) av_ts_make_time_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts, tb)
00073 
00074 #endif