Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: patched-ffmpeg-mt/tests/seek_test.c

Issue 789004: ffmpeg roll of source to mar 9 version... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2003 Fabrice Bellard 2 * Copyright (c) 2003 Fabrice Bellard
3 * Copyright (c) 2007 Michael Niedermayer 3 * Copyright (c) 2007 Michael Niedermayer
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 strcpy(buffer, " NOPTS "); 53 strcpy(buffer, " NOPTS ");
54 return; 54 return;
55 } 55 }
56 tsval = ts * av_q2d(base); 56 tsval = ts * av_q2d(base);
57 snprintf(buffer, 60, "%9f", tsval); 57 snprintf(buffer, 60, "%9f", tsval);
58 } 58 }
59 59
60 int main(int argc, char **argv) 60 int main(int argc, char **argv)
61 { 61 {
62 const char *filename; 62 const char *filename;
63 AVFormatContext *ic; 63 AVFormatContext *ic = NULL;
64 int i, ret, stream_id; 64 int i, ret, stream_id;
65 int64_t timestamp; 65 int64_t timestamp;
66 AVFormatParameters params, *ap= &params; 66 AVFormatParameters params, *ap= &params;
67 memset(ap, 0, sizeof(params)); 67 memset(ap, 0, sizeof(params));
68 ap->channels=1; 68 ap->channels=1;
69 ap->sample_rate= 22050; 69 ap->sample_rate= 22050;
70 70
71 /* initialize libavcodec, and register all codecs and formats */ 71 /* initialize libavcodec, and register all codecs and formats */
72 av_register_all(); 72 av_register_all();
73 73
74 if (argc != 2) { 74 if (argc != 2) {
75 printf("usage: %s input_file\n" 75 printf("usage: %s input_file\n"
76 "\n", argv[0]); 76 "\n", argv[0]);
77 exit(1); 77 exit(1);
78 } 78 }
79 79
80 filename = argv[1]; 80 filename = argv[1];
81 81
82 /* allocate the media context */
83 ic = avformat_alloc_context();
84 if (!ic) {
85 fprintf(stderr, "Memory error\n");
86 exit(1);
87 }
88
89 ret = av_open_input_file(&ic, filename, NULL, 0, ap); 82 ret = av_open_input_file(&ic, filename, NULL, 0, ap);
90 if (ret < 0) { 83 if (ret < 0) {
91 fprintf(stderr, "cannot open %s\n", filename); 84 fprintf(stderr, "cannot open %s\n", filename);
92 exit(1); 85 exit(1);
93 } 86 }
94 87
95 ret = av_find_stream_info(ic); 88 ret = av_find_stream_info(ic);
96 if (ret < 0) { 89 if (ret < 0) {
97 fprintf(stderr, "%s: could not find codec parameters\n", filename); 90 fprintf(stderr, "%s: could not find codec parameters\n", filename);
98 exit(1); 91 exit(1);
99 } 92 }
100 93
101 for(i=0; ; i++){ 94 for(i=0; ; i++){
102 AVPacket pkt; 95 AVPacket pkt;
103 AVStream *av_uninit(st); 96 AVStream *av_uninit(st);
104 char ts_buf[60]; 97 char ts_buf[60];
105 98
106 memset(&pkt, 0, sizeof(pkt)); 99 memset(&pkt, 0, sizeof(pkt));
107 if(ret>=0){ 100 if(ret>=0){
108 ret= av_read_frame(ic, &pkt); 101 ret= av_read_frame(ic, &pkt);
109 if(ret>=0){ 102 if(ret>=0){
110 char dts_buf[60]; 103 char dts_buf[60];
111 st= ic->streams[pkt.stream_index]; 104 st= ic->streams[pkt.stream_index];
112 ts_str(dts_buf, pkt.dts, st->time_base); 105 ts_str(dts_buf, pkt.dts, st->time_base);
113 ts_str(ts_buf, pkt.pts, st->time_base); 106 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); 107 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);
108 av_free_packet(&pkt);
115 } else 109 } else
116 printf("ret:%s", ret_str(ret)); // necessary to avoid trailing w hitespace 110 printf("ret:%s", ret_str(ret)); // necessary to avoid trailing w hitespace
117 printf("\n"); 111 printf("\n");
118 } 112 }
119 113
120 if(i>25) break; 114 if(i>25) break;
121 115
122 stream_id= (i>>1)%(ic->nb_streams+1) - 1; 116 stream_id= (i>>1)%(ic->nb_streams+1) - 1;
123 timestamp= (i*19362894167LL) % (4*AV_TIME_BASE) - AV_TIME_BASE; 117 timestamp= (i*19362894167LL) % (4*AV_TIME_BASE) - AV_TIME_BASE;
124 if(stream_id>=0){ 118 if(stream_id>=0){
125 st= ic->streams[stream_id]; 119 st= ic->streams[stream_id];
126 timestamp= av_rescale_q(timestamp, AV_TIME_BASE_Q, st->time_base); 120 timestamp= av_rescale_q(timestamp, AV_TIME_BASE_Q, st->time_base);
127 } 121 }
128 //FIXME fully test the new seek API 122 //FIXME fully test the new seek API
129 if(i&1) ret = avformat_seek_file(ic, stream_id, INT64_MIN, timestamp, ti mestamp, 0); 123 if(i&1) ret = avformat_seek_file(ic, stream_id, INT64_MIN, timestamp, ti mestamp, 0);
130 else ret = avformat_seek_file(ic, stream_id, timestamp, timestamp, IN T64_MAX, 0); 124 else ret = avformat_seek_file(ic, stream_id, timestamp, timestamp, IN T64_MAX, 0);
131 ts_str(ts_buf, timestamp, stream_id < 0 ? AV_TIME_BASE_Q : st->time_base ); 125 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); 126 printf("ret:%-10s st:%2d flags:%d ts:%s\n", ret_str(ret), stream_id, i& 1, ts_buf);
133 } 127 }
134 128
129 av_close_input_file(ic);
130
135 return 0; 131 return 0;
136 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698