summaryrefslogtreecommitdiff
path: root/tests/seek_test.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-10-20 15:37:50 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-10-20 15:37:50 +0000
commit2bc70a76811e7fae3e0ae2528b4abc9dfb4104a0 (patch)
tree7b2fb8f3865e97955d2a5f382f37d0b41cac384c /tests/seek_test.c
parent711e69a730904a341652d4999a1d1402bcbb7b6e (diff)
Print "NOPTS" when AV_NOPTS_VALUE is encountered during seek regression tests.
This makes the output nicely aligned even in for those cases, and might also avoid some issues with printf implementations that can not handle well very large float values (e.g. msvcrt without MinGW wrapper IIRC). Originally committed as revision 20334 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'tests/seek_test.c')
-rw-r--r--tests/seek_test.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/seek_test.c b/tests/seek_test.c
index 40a8f2c4f2..315fcfc790 100644
--- a/tests/seek_test.c
+++ b/tests/seek_test.c
@@ -22,6 +22,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include "libavutil/common.h"
#include "libavformat/avformat.h"
@@ -45,6 +46,17 @@ static const char *ret_str(int v)
}
}
+static void ts_str(char buffer[60], int64_t ts, AVRational base)
+{
+ double tsval;
+ if (ts == AV_NOPTS_VALUE) {
+ strcpy(buffer, " NOPTS ");
+ return;
+ }
+ tsval = ts * av_q2d(base);
+ snprintf(buffer, 60, "%9f", tsval);
+}
+
int main(int argc, char **argv)
{
const char *filename;
@@ -89,13 +101,17 @@ int main(int argc, char **argv)
for(i=0; ; i++){
AVPacket pkt;
AVStream *av_uninit(st);
+ char ts_buf[60];
memset(&pkt, 0, sizeof(pkt));
if(ret>=0){
ret= av_read_frame(ic, &pkt);
if(ret>=0){
+ char dts_buf[60];
st= ic->streams[pkt.stream_index];
- printf("ret:%-10s st:%2d flags:%d dts:%9f pts:%9f pos:%7" PRId64 " size:%6d", ret_str(ret), pkt.stream_index, pkt.flags, pkt.dts*av_q2d(st->time_base), pkt.pts*av_q2d(st->time_base), pkt.pos, pkt.size);
+ ts_str(dts_buf, pkt.dts, st->time_base);
+ ts_str(ts_buf, pkt.pts, st->time_base);
+ printf("ret:%-10s st:%2d flags:%d dts:%s pts:%s pos:%7" PRId64 " size:%6d", ret_str(ret), pkt.stream_index, pkt.flags, dts_buf, ts_buf, pkt.pos, pkt.size);
} else
printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace
printf("\n");
@@ -112,7 +128,8 @@ int main(int argc, char **argv)
//FIXME fully test the new seek API
if(i&1) ret = avformat_seek_file(ic, stream_id, INT64_MIN, timestamp, timestamp, 0);
else ret = avformat_seek_file(ic, stream_id, timestamp, timestamp, INT64_MAX, 0);
- printf("ret:%-10s st:%2d flags:%d ts:%9f\n", ret_str(ret), stream_id, i&1, timestamp*(stream_id<0 ? 1.0/AV_TIME_BASE : av_q2d(st->time_base)));
+ ts_str(ts_buf, timestamp, stream_id < 0 ? AV_TIME_BASE_Q : st->time_base);
+ printf("ret:%-10s st:%2d flags:%d ts:%s\n", ret_str(ret), stream_id, i&1, ts_buf);
}
return 0;