Commit 2bc70a76 authored by Reimar Döffinger's avatar Reimar Döffinger

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
parent 711e69a7
This diff is collapsed.
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "libavutil/common.h" #include "libavutil/common.h"
#include "libavformat/avformat.h" #include "libavformat/avformat.h"
...@@ -45,6 +46,17 @@ static const char *ret_str(int v) ...@@ -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) int main(int argc, char **argv)
{ {
const char *filename; const char *filename;
...@@ -89,13 +101,17 @@ int main(int argc, char **argv) ...@@ -89,13 +101,17 @@ int main(int argc, char **argv)
for(i=0; ; i++){ for(i=0; ; i++){
AVPacket pkt; AVPacket pkt;
AVStream *av_uninit(st); AVStream *av_uninit(st);
char ts_buf[60];
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
if(ret>=0){ if(ret>=0){
ret= av_read_frame(ic, &pkt); ret= av_read_frame(ic, &pkt);
if(ret>=0){ if(ret>=0){
char dts_buf[60];
st= ic->streams[pkt.stream_index]; 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 } else
printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace
printf("\n"); printf("\n");
...@@ -112,7 +128,8 @@ int main(int argc, char **argv) ...@@ -112,7 +128,8 @@ int main(int argc, char **argv)
//FIXME fully test the new seek API //FIXME fully test the new seek API
if(i&1) ret = avformat_seek_file(ic, stream_id, INT64_MIN, timestamp, timestamp, 0); 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); 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; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment