comparison arib25/src/td.c @ 123:ec7c87854f2f b25

updated to arib25 0.2.5
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Wed, 15 Feb 2012 11:09:02 +0900
parents 080414aa8f21
children
comparison
equal deleted inserted replaced
73:c44e16dbb0e2 123:ec7c87854f2f
12 #include <crtdbg.h> 12 #include <crtdbg.h>
13 #else 13 #else
14 #define __STDC_FORMAT_MACROS 14 #define __STDC_FORMAT_MACROS
15 #include <inttypes.h> 15 #include <inttypes.h>
16 #include <unistd.h> 16 #include <unistd.h>
17 #include <sys/time.h>
17 #endif 18 #endif
18 19
19 #include "arib_std_b25.h" 20 #include "arib_std_b25.h"
20 #include "b_cas_card.h" 21 #include "b_cas_card.h"
21 22
34 35
35 int main(int argc, char **argv) 36 int main(int argc, char **argv)
36 { 37 {
37 int n; 38 int n;
38 OPTION opt; 39 OPTION opt;
39 40
40 #if defined(WIN32) 41 #if defined(WIN32)
41 _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); 42 _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
42 _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); 43 _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
43 _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); 44 _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
44 _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); 45 _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
51 if(n+2 > argc){ 52 if(n+2 > argc){
52 show_usage(); 53 show_usage();
53 exit(EXIT_FAILURE); 54 exit(EXIT_FAILURE);
54 } 55 }
55 56
56 test_arib_std_b25(argv[n+0], argv[n+1], &opt); 57 for(;n<=(argc-2);n+=2){
58 test_arib_std_b25(argv[n+0], argv[n+1], &opt);
59 }
57 60
58 #if defined(WIN32) 61 #if defined(WIN32)
59 _CrtDumpMemoryLeaks(); 62 _CrtDumpMemoryLeaks();
60 #endif 63 #endif
61 64
62 return EXIT_SUCCESS; 65 return EXIT_SUCCESS;
63 } 66 }
64 67
65 static void show_usage() 68 static void show_usage()
66 { 69 {
67 fprintf(stderr, "b25 - ARIB STD-B25 test program ver. 0.2.4 (2009, 4/18)\n"); 70 fprintf(stderr, "b25 - ARIB STD-B25 test program ver. 0.2.5 (2012, 2/13)\n");
68 fprintf(stderr, "usage: b25 [options] src.m2t dst.m2t\n"); 71 fprintf(stderr, "usage: b25 [options] src.m2t dst.m2t [more pair ..]\n");
69 fprintf(stderr, "options:\n"); 72 fprintf(stderr, "options:\n");
70 fprintf(stderr, " -r round (integer, default=4)\n"); 73 fprintf(stderr, " -r round (integer, default=4)\n");
71 fprintf(stderr, " -s strip\n"); 74 fprintf(stderr, " -s strip\n");
72 fprintf(stderr, " 0: keep null(padding) stream (default)\n"); 75 fprintf(stderr, " 0: keep null(padding) stream (default)\n");
73 fprintf(stderr, " 1: strip null stream\n"); 76 fprintf(stderr, " 1: strip null stream\n");
152 int code,i,n,m; 155 int code,i,n,m;
153 int sfd,dfd; 156 int sfd,dfd;
154 157
155 int64_t total; 158 int64_t total;
156 int64_t offset; 159 int64_t offset;
160 #if defined(WIN32)
161 unsigned long tick,tock;
162 #else
163 struct timeval tick,tock;
164 double millisec;
165 #endif
166 double mbps;
157 167
158 ARIB_STD_B25 *b25; 168 ARIB_STD_B25 *b25;
159 B_CAS_CARD *bcas; 169 B_CAS_CARD *bcas;
160 170
161 ARIB_STD_B25_PROGRAM_INFO pgrm; 171 ARIB_STD_B25_PROGRAM_INFO pgrm;
162 172
163 uint8_t data[8*1024]; 173 uint8_t data[64*1024];
164 174
165 ARIB_STD_B25_BUFFER sbuf; 175 ARIB_STD_B25_BUFFER sbuf;
166 ARIB_STD_B25_BUFFER dbuf; 176 ARIB_STD_B25_BUFFER dbuf;
167 177
168 sfd = -1; 178 sfd = -1;
173 sfd = _open(src, _O_BINARY|_O_RDONLY|_O_SEQUENTIAL); 183 sfd = _open(src, _O_BINARY|_O_RDONLY|_O_SEQUENTIAL);
174 if(sfd < 0){ 184 if(sfd < 0){
175 fprintf(stderr, "error - failed on _open(%s) [src]\n", src); 185 fprintf(stderr, "error - failed on _open(%s) [src]\n", src);
176 goto LAST; 186 goto LAST;
177 } 187 }
178 188
179 _lseeki64(sfd, 0, SEEK_END); 189 _lseeki64(sfd, 0, SEEK_END);
180 total = _telli64(sfd); 190 total = _telli64(sfd);
181 _lseeki64(sfd, 0, SEEK_SET); 191 _lseeki64(sfd, 0, SEEK_SET);
182 192
183 b25 = create_arib_std_b25(); 193 b25 = create_arib_std_b25();
227 fprintf(stderr, "error - failed on _open(%s) [dst]\n", dst); 237 fprintf(stderr, "error - failed on _open(%s) [dst]\n", dst);
228 goto LAST; 238 goto LAST;
229 } 239 }
230 240
231 offset = 0; 241 offset = 0;
242 #if defined(WIN32)
243 tock = GetTickCount();
244 #else
245 gettimeofday(&tock, NULL);
246 #endif
232 while( (n = _read(sfd, data, sizeof(data))) > 0 ){ 247 while( (n = _read(sfd, data, sizeof(data))) > 0 ){
233 sbuf.data = data; 248 sbuf.data = data;
234 sbuf.size = n; 249 sbuf.size = n;
235 250
236 code = b25->put(b25, &sbuf); 251 code = b25->put(b25, &sbuf);
250 if(n != dbuf.size){ 265 if(n != dbuf.size){
251 fprintf(stderr, "error failed on _write(%d)\n", dbuf.size); 266 fprintf(stderr, "error failed on _write(%d)\n", dbuf.size);
252 goto LAST; 267 goto LAST;
253 } 268 }
254 } 269 }
255 270
256 offset += sbuf.size; 271 offset += sbuf.size;
257 if(opt->verbose != 0){ 272 if(opt->verbose != 0){
258 m = (int)(10000*offset/total); 273 m = (int)(10000*offset/total);
259 fprintf(stderr, "\rprocessing: %2d.%02d%% ", m/100, m%100); 274 mbps = 0.0;
275 #if defined(WIN32)
276 tick = GetTickCount();
277 if (tick-tock > 100) {
278 mbps = offset;
279 mbps /= 1024;
280 mbps /= (tick-tock);
281 }
282 #else
283 gettimeofday(&tick, NULL);
284 millisec = (tick.tv_sec - tock.tv_sec) * 1000;
285 millisec += (tick.tv_usec - tock.tv_usec) / 1000;
286 if(millisec > 100.0) {
287 mbps = offset;
288 mbps /= 1024;
289 mbps /= millisec;
290 }
291 #endif
292 fprintf(stderr, "\rprocessing: %2d.%02d%% [%6.2f MB/sec]", m/100, m%100, mbps);
260 } 293 }
261 } 294 }
262 295
263 code = b25->flush(b25); 296 code = b25->flush(b25);
264 if(code < 0){ 297 if(code < 0){
265 fprintf(stderr, "error - failed on ARIB_STD_B25::flush() : code=%d\n", code); 298 fprintf(stderr, "error - failed on ARIB_STD_B25::flush() : code=%d\n", code);
266 goto LAST; 299 goto LAST;
267 } 300 }
268 301
269 code = b25->get(b25, &dbuf); 302 code = b25->get(b25, &dbuf);
270 if(code < 0){ 303 if(code < 0){
271 fprintf(stderr, "error - failed on ARIB_STD_B25::get() : code=%d\n", code); 304 fprintf(stderr, "error - failed on ARIB_STD_B25::get() : code=%d\n", code);
272 goto LAST; 305 goto LAST;
273 } 306 }
279 goto LAST; 312 goto LAST;
280 } 313 }
281 } 314 }
282 315
283 if(opt->verbose != 0){ 316 if(opt->verbose != 0){
284 fprintf(stderr, "\rprocessing: finish \n"); 317 mbps = 0.0;
318 #if defined(WIN32)
319 tick = GetTickCount();
320 if (tick-tock > 100) {
321 mbps = offset;
322 mbps /= 1024;
323 mbps /= (tick-tock);
324 }
325 #else
326 gettimeofday(&tick, NULL);
327 millisec = (tick.tv_sec - tock.tv_sec) * 1000;
328 millisec += (tick.tv_usec - tock.tv_usec) / 1000;
329 if(millisec > 100.0) {
330 mbps = offset;
331 mbps /= 1024;
332 mbps /= millisec;
333 }
334 #endif
335 fprintf(stderr, "\rprocessing: finish [%6.2f MB/sec]\n", mbps);
285 fflush(stderr); 336 fflush(stderr);
286 fflush(stdout); 337 fflush(stdout);
287 } 338 }
288 339
289 n = b25->get_program_count(b25); 340 n = b25->get_program_count(b25);