summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-05 00:43:14 +0000
committerfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-05 00:43:14 +0000
commit3f9a579bfea1c987e9685a9ee59abf03660223af (patch)
treea4e21248dff3fc7fbc85574b06ca8bc537a7caf6 /media
parentbd4c26fff5a9ab6682081a56d9074922921a0284 (diff)
downloadchromium_src-3f9a579bfea1c987e9685a9ee59abf03660223af.zip
chromium_src-3f9a579bfea1c987e9685a9ee59abf03660223af.tar.gz
chromium_src-3f9a579bfea1c987e9685a9ee59abf03660223af.tar.bz2
Media bench add -hash, 64 bit IO, and some cleanup of dump
BUG=21126 TEST=use media_bench -hash and it compare txt files instead of raw dump output. Should be substantially faster. Review URL: http://codereview.chromium.org/195012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/bench/bench.cc54
-rw-r--r--media/bench/file_protocol.cc5
2 files changed, 47 insertions, 12 deletions
diff --git a/media/bench/bench.cc b/media/bench/bench.cc
index 05f8da3..717af42 100644
--- a/media/bench/bench.cc
+++ b/media/bench/bench.cc
@@ -32,8 +32,19 @@ const wchar_t kVideoThreads[] = L"video-threads";
const wchar_t kFast2[] = L"fast2";
const wchar_t kSkip[] = L"skip";
const wchar_t kFlush[] = L"flush";
+const wchar_t kHash[] = L"hash";
} // namespace switches
+namespace {
+// DJB2 hash
+unsigned int hash_djb2(const uint8* s,
+ size_t len, unsigned int hash) {
+ while (len--)
+ hash = hash * 33 + *s++;
+ return hash;
+}
+}
+
int main(int argc, const char** argv) {
base::AtExitManager exit_manager;
@@ -51,6 +62,8 @@ int main(int argc, const char** argv) {
<< "Enable fast2 flag\n"
<< " --flush "
<< "Flush last frame\n"
+ << " --hash "
+ << "Hash decoded buffers\n"
<< " --skip=[1|2|3] "
<< "1=loop nonref, 2=loop, 3= frame nonref\n" << std::endl;
return 1;
@@ -103,6 +116,12 @@ int main(int argc, const char** argv) {
flush = true;
}
+ unsigned int hash_value = 5381u; // Seed for DJB2.
+ bool hash = false;
+ if (cmd_line->HasSwitch(switches::kHash)) {
+ hash = true;
+ }
+
int skip = 0;
if (cmd_line->HasSwitch(switches::kSkip)) {
std::wstring skip_opt(cmd_line->GetSwitchValue(switches::kSkip));
@@ -246,6 +265,10 @@ int main(int argc, const char** argv) {
return 1;
}
}
+ if (hash) {
+ hash_value = hash_djb2(reinterpret_cast<const uint8*>(samples),
+ size_out, hash_value);
+ }
}
} else if (target_codec == CODEC_TYPE_VIDEO) {
int got_picture = 0;
@@ -255,8 +278,7 @@ int main(int argc, const char** argv) {
++frames;
read_result = 0; // Force continuation.
- // TODO(fbarchard): support formats other than YV12.
- if (output) {
+ if (output || hash) {
for (int plane = 0; plane < 3; ++plane) {
const uint8* source = frame->data[plane];
const size_t source_stride = frame->linesize[plane];
@@ -272,11 +294,9 @@ int main(int argc, const char** argv) {
case PIX_FMT_YUV422P:
case PIX_FMT_YUVJ422P:
bytes_per_line /= 2;
- copy_lines = copy_lines;
break;
case PIX_FMT_YUV444P:
case PIX_FMT_YUVJ444P:
- copy_lines = copy_lines;
break;
default:
std::cerr << "unknown video format: "
@@ -284,14 +304,22 @@ int main(int argc, const char** argv) {
return 1;
}
}
- for (size_t i = 0; i < copy_lines; ++i) {
- if (fwrite(source, 1, bytes_per_line, output) !=
- bytes_per_line) {
- std::cerr << "could not write data after "
- << bytes_per_line;
- return 1;
+ if (output) {
+ for (size_t i = 0; i < copy_lines; ++i) {
+ if (fwrite(source, 1, bytes_per_line, output) !=
+ bytes_per_line) {
+ std::cerr << "could not write data after "
+ << bytes_per_line;
+ return 1;
+ }
+ source += source_stride;
+ }
+ }
+ if (hash) {
+ for (size_t i = 0; i < copy_lines; ++i) {
+ hash_value = hash_djb2(source, bytes_per_line, hash_value);
+ source += source_stride;
}
- source += source_stride;
}
}
}
@@ -333,6 +361,10 @@ int main(int argc, const char** argv) {
<< " ms" << std::endl;
std::cout << " Summation:" << std::setw(10) << sum
<< " ms" << std::endl;
+ if (hash) {
+ std::cout << " Hash:" << std::setw(10) << hash_value
+ << std::endl;
+ }
if (frames > 0u) {
// Calculate the average time per frame.
diff --git a/media/bench/file_protocol.cc b/media/bench/file_protocol.cc
index fc1be89..517d101 100644
--- a/media/bench/file_protocol.cc
+++ b/media/bench/file_protocol.cc
@@ -4,6 +4,7 @@
#include "media/bench/file_protocol.h"
+#include <stdio.h>
#include "base/file_util.h"
#include "base/logging.h"
#include "media/filters/ffmpeg_common.h"
@@ -37,7 +38,9 @@ int WriteContext(URLContext* h, unsigned char* buf, int size) {
offset_t SeekContext(URLContext* h, offset_t offset, int whence) {
#if defined(OS_WIN)
- return _fseeki64(ToFile(h->priv_data), offset, whence);
+ return static_cast<offset_t> (_fseeki64(ToFile(h->priv_data),
+ static_cast<int64>(offset),
+ whence));
#else
return fseek(ToFile(h->priv_data), offset, whence);
#endif