Revision 2bc70a76 tests/seek_test.c

View differences:

tests/seek_test.c
22 22
#include <stdint.h>
23 23
#include <stdlib.h>
24 24
#include <stdio.h>
25
#include <string.h>
25 26

  
26 27
#include "libavutil/common.h"
27 28
#include "libavformat/avformat.h"
......
45 46
    }
46 47
}
47 48

  
49
static void ts_str(char buffer[60], int64_t ts, AVRational base)
50
{
51
    double tsval;
52
    if (ts == AV_NOPTS_VALUE) {
53
        strcpy(buffer, " NOPTS   ");
54
        return;
55
    }
56
    tsval = ts * av_q2d(base);
57
    snprintf(buffer, 60, "%9f", tsval);
58
}
59

  
48 60
int main(int argc, char **argv)
49 61
{
50 62
    const char *filename;
......
89 101
    for(i=0; ; i++){
90 102
        AVPacket pkt;
91 103
        AVStream *av_uninit(st);
104
        char ts_buf[60];
92 105

  
93 106
        memset(&pkt, 0, sizeof(pkt));
94 107
        if(ret>=0){
95 108
            ret= av_read_frame(ic, &pkt);
96 109
            if(ret>=0){
110
                char dts_buf[60];
97 111
                st= ic->streams[pkt.stream_index];
98
                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);
112
                ts_str(dts_buf, pkt.dts, st->time_base);
113
                ts_str(ts_buf,  pkt.pts, st->time_base);
114
                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);
99 115
            } else
100 116
                printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace
101 117
            printf("\n");
......
112 128
        //FIXME fully test the new seek API
113 129
        if(i&1) ret = avformat_seek_file(ic, stream_id, INT64_MIN, timestamp, timestamp, 0);
114 130
        else    ret = avformat_seek_file(ic, stream_id, timestamp, timestamp, INT64_MAX, 0);
115
        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)));
131
        ts_str(ts_buf, timestamp, stream_id < 0 ? AV_TIME_BASE_Q : st->time_base);
132
        printf("ret:%-10s st:%2d flags:%d  ts:%s\n", ret_str(ret), stream_id, i&1, ts_buf);
116 133
    }
117 134

  
118 135
    return 0;

Also available in: Unified diff