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

Side by Side Diff: media/bench/bench.cc

Issue 265050: Add -loop=N option to test ffmpeg ogv decoding on loop. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Standalone benchmarking application based on FFmpeg. This tool is used to 5 // Standalone benchmarking application based on FFmpeg. This tool is used to
6 // measure decoding performance between different FFmpeg compile and run-time 6 // measure decoding performance between different FFmpeg compile and run-time
7 // options. We also use this tool to measure performance regressions when 7 // options. We also use this tool to measure performance regressions when
8 // testing newer builds of FFmpeg from trunk. 8 // testing newer builds of FFmpeg from trunk.
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 24 matching lines...) Expand all
35 namespace switches { 35 namespace switches {
36 const wchar_t kStream[] = L"stream"; 36 const wchar_t kStream[] = L"stream";
37 const wchar_t kVideoThreads[] = L"video-threads"; 37 const wchar_t kVideoThreads[] = L"video-threads";
38 const wchar_t kVerbose[] = L"verbose"; 38 const wchar_t kVerbose[] = L"verbose";
39 const wchar_t kFast2[] = L"fast2"; 39 const wchar_t kFast2[] = L"fast2";
40 const wchar_t kSkip[] = L"skip"; 40 const wchar_t kSkip[] = L"skip";
41 const wchar_t kFlush[] = L"flush"; 41 const wchar_t kFlush[] = L"flush";
42 const wchar_t kDjb2[] = L"djb2"; 42 const wchar_t kDjb2[] = L"djb2";
43 const wchar_t kMd5[] = L"md5"; 43 const wchar_t kMd5[] = L"md5";
44 const wchar_t kFrames[] = L"frames"; 44 const wchar_t kFrames[] = L"frames";
45 const wchar_t kLoop[] = L"loop";
45 46
46 } // namespace switches 47 } // namespace switches
47 48
48 namespace { 49 namespace {
49 // DJB2 hash 50 // DJB2 hash
50 unsigned int DJB2Hash(const uint8* s, 51 unsigned int DJB2Hash(const uint8* s,
51 size_t len, unsigned int hash) { 52 size_t len, unsigned int hash) {
52 if (len > 0) { 53 if (len > 0) {
53 do { 54 do {
54 hash = hash * 33 + *s++; 55 hash = hash * 33 + *s++;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (filenames.empty()) { 98 if (filenames.empty()) {
98 std::cerr << "Usage: media_bench [OPTIONS] FILE [DUMPFILE]\n" 99 std::cerr << "Usage: media_bench [OPTIONS] FILE [DUMPFILE]\n"
99 << " --stream=[audio|video] " 100 << " --stream=[audio|video] "
100 << "Benchmark either the audio or video stream\n" 101 << "Benchmark either the audio or video stream\n"
101 << " --video-threads=N " 102 << " --video-threads=N "
102 << "Decode video using N threads\n" 103 << "Decode video using N threads\n"
103 << " --verbose=N " 104 << " --verbose=N "
104 << "Set FFmpeg log verbosity (-8 to 48)\n" 105 << "Set FFmpeg log verbosity (-8 to 48)\n"
105 << " --frames=N " 106 << " --frames=N "
106 << "Decode N frames\n" 107 << "Decode N frames\n"
108 << " --loop=N "
109 << "Loop N times\n"
107 << " --fast2 " 110 << " --fast2 "
108 << "Enable fast2 flag\n" 111 << "Enable fast2 flag\n"
109 << " --flush " 112 << " --flush "
110 << "Flush last frame\n" 113 << "Flush last frame\n"
111 << " --djb2 " 114 << " --djb2 "
112 << "Hash decoded buffers (DJB2)\n" 115 << "Hash decoded buffers (DJB2)\n"
113 << " --md5 " 116 << " --md5 "
114 << "Hash decoded buffers (MD5)\n" 117 << "Hash decoded buffers (MD5)\n"
115 << " --skip=[1|2|3] " 118 << " --skip=[1|2|3] "
116 << "1=loop nonref, 2=loop, 3= frame nonref\n" << std::endl; 119 << "1=loop nonref, 2=loop, 3= frame nonref\n" << std::endl;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 166 }
164 167
165 // Determine number of frames to decode (optional). 168 // Determine number of frames to decode (optional).
166 int max_frames = 0; 169 int max_frames = 0;
167 std::wstring frames_opt(cmd_line->GetSwitchValue(switches::kFrames)); 170 std::wstring frames_opt(cmd_line->GetSwitchValue(switches::kFrames));
168 if (!frames_opt.empty() && 171 if (!frames_opt.empty() &&
169 !StringToInt(WideToUTF16Hack(frames_opt), &max_frames)) { 172 !StringToInt(WideToUTF16Hack(frames_opt), &max_frames)) {
170 max_frames = 0; 173 max_frames = 0;
171 } 174 }
172 175
176 // Determine number of times to loop (optional).
177 int max_loops = 0;
178 std::wstring loop_opt(cmd_line->GetSwitchValue(switches::kLoop));
179 if (!loop_opt.empty() &&
180 !StringToInt(WideToUTF16Hack(loop_opt), &max_loops)) {
181 max_loops = 0;
182 }
183
173 bool fast2 = false; 184 bool fast2 = false;
174 if (cmd_line->HasSwitch(switches::kFast2)) { 185 if (cmd_line->HasSwitch(switches::kFast2)) {
175 fast2 = true; 186 fast2 = true;
176 } 187 }
177 188
178 bool flush = false; 189 bool flush = false;
179 if (cmd_line->HasSwitch(switches::kFlush)) { 190 if (cmd_line->HasSwitch(switches::kFlush)) {
180 flush = true; 191 flush = true;
181 } 192 }
182 193
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 std::vector<double> decode_times; 345 std::vector<double> decode_times;
335 decode_times.reserve(4096); 346 decode_times.reserve(4096);
336 // Parse through the entire stream until we hit EOF. 347 // Parse through the entire stream until we hit EOF.
337 base::TimeTicks start = base::TimeTicks::HighResNow(); 348 base::TimeTicks start = base::TimeTicks::HighResNow();
338 int frames = 0; 349 int frames = 0;
339 int read_result = 0; 350 int read_result = 0;
340 do { 351 do {
341 read_result = av_read_frame(format_context, &packet); 352 read_result = av_read_frame(format_context, &packet);
342 353
343 if (read_result < 0) { 354 if (read_result < 0) {
355 if (max_loops) {
356 --max_loops;
357 }
358 if (max_loops > 0) {
359 av_seek_frame(format_context, -1, 0, AVSEEK_FLAG_BACKWARD);
360 read_result = 0;
361 continue;
362 }
344 if (flush) { 363 if (flush) {
345 packet.stream_index = target_stream; 364 packet.stream_index = target_stream;
346 packet.size = 0; 365 packet.size = 0;
347 } else { 366 } else {
348 break; 367 break;
349 } 368 }
350 } 369 }
351 370
352 // Only decode packets from our target stream. 371 // Only decode packets from our target stream.
353 if (packet.stream_index == target_stream) { 372 if (packet.stream_index == target_stream) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 478 }
460 } 479 }
461 // Free our packet. 480 // Free our packet.
462 av_free_packet(&packet); 481 av_free_packet(&packet);
463 482
464 if (max_frames && (frames >= max_frames)) 483 if (max_frames && (frames >= max_frames))
465 break; 484 break;
466 } while (read_result >= 0); 485 } while (read_result >= 0);
467 base::TimeDelta total = base::TimeTicks::HighResNow() - start; 486 base::TimeDelta total = base::TimeTicks::HighResNow() - start;
468 LeaveTimingSection(); 487 LeaveTimingSection();
488
469 if (output) 489 if (output)
470 file_util::CloseFile(output); 490 file_util::CloseFile(output);
471 491
472 // Calculate the sum of times. Note that some of these may be zero. 492 // Calculate the sum of times. Note that some of these may be zero.
473 double sum = 0; 493 double sum = 0;
474 for (size_t i = 0; i < decode_times.size(); ++i) { 494 for (size_t i = 0; i < decode_times.size(); ++i) {
475 sum += decode_times[i]; 495 sum += decode_times[i];
476 } 496 }
477 497
478 // Print our results. 498 // Print our results.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 } 539 }
520 #if defined(OS_WIN) 540 #if defined(OS_WIN)
521 } __except(EXCEPTION_EXECUTE_HANDLER) { 541 } __except(EXCEPTION_EXECUTE_HANDLER) {
522 *log_out << " Exception:" << std::setw(11) << GetExceptionCode() 542 *log_out << " Exception:" << std::setw(11) << GetExceptionCode()
523 << " " << in_path << std::endl; 543 << " " << in_path << std::endl;
524 return 1; 544 return 1;
525 } 545 }
526 #endif 546 #endif
527 return 0; 547 return 0;
528 } 548 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698