diff options
author | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 19:21:28 +0000 |
---|---|---|
committer | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 19:21:28 +0000 |
commit | 434eba616e4b61c9a2b6547e20ec0fa4d7b8d635 (patch) | |
tree | 088706b6dbe6998de0b6953de99fb69262ed64a3 /media/test | |
parent | a2255c26c667e445fc99e7f910c67862a6c13b3b (diff) | |
download | chromium_src-434eba616e4b61c9a2b6547e20ec0fa4d7b8d635.zip chromium_src-434eba616e4b61c9a2b6547e20ec0fa4d7b8d635.tar.gz chromium_src-434eba616e4b61c9a2b6547e20ec0fa4d7b8d635.tar.bz2 |
ffmpeg_tests do audio for audio formats (ie wma)
BUG=http://code.google.com/p/chromium-os/issues/detail?id=2156
TEST=run ffmpeg_tests on an audio file and it should report success and performance
Review URL: http://codereview.chromium.org/1544002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/test')
-rw-r--r-- | media/test/ffmpeg_tests/ffmpeg_tests.cc | 87 |
1 files changed, 47 insertions, 40 deletions
diff --git a/media/test/ffmpeg_tests/ffmpeg_tests.cc b/media/test/ffmpeg_tests/ffmpeg_tests.cc index 72f85ab..9dd7277 100644 --- a/media/test/ffmpeg_tests/ffmpeg_tests.cc +++ b/media/test/ffmpeg_tests/ffmpeg_tests.cc @@ -6,25 +6,10 @@ // software decoding quality and performance of FFmpeg meets a mimimum // standard. -#include "build/build_config.h" - -// For pipe _setmode to binary -#if defined(OS_WIN) -#include <fcntl.h> -#include <io.h> -#endif - -#ifdef DEBUG -#define SHOW_VERBOSE 1 -#else -#define SHOW_VERBOSE 0 -#endif - #include <iomanip> #include <iostream> #include <string> -#include "base/at_exit.h" #include "base/basictypes.h" #include "base/command_line.h" #include "base/file_path.h" @@ -38,6 +23,12 @@ #include "media/ffmpeg/file_protocol.h" #include "media/filters/ffmpeg_video_decoder.h" +#ifdef DEBUG +#define SHOW_VERBOSE 1 +#else +#define SHOW_VERBOSE 0 +#endif + #if defined(OS_WIN) // warning: disable warning about exception handler. #pragma warning(disable:4509) @@ -94,7 +85,6 @@ int main(int argc, const char** argv) { if (filenames.size() > 1) { out_path = WideToUTF8(filenames[1]); } - CodecType target_codec = CODEC_TYPE_VIDEO; // Default flags that match Chrome defaults. int video_threads = 2; @@ -141,17 +131,7 @@ int main(int argc, const char** argv) { // Open output file. FILE *output = NULL; if (!out_path.empty()) { - // TODO(fbarchard): Add pipe:1 for piping to stderr. - if (!strncmp(out_path.c_str(), "pipe:", 5) || - !strcmp(out_path.c_str(), "-")) { - output = stdout; - log_out = &std::cerr; -#if defined(OS_WIN) - _setmode(_fileno(stdout), _O_BINARY); -#endif - } else { - output = file_util::OpenFile(out_path.c_str(), "wb"); - } + output = file_util::OpenFile(out_path.c_str(), "wb"); if (!output) { std::cerr << "Error: Could not open output " << out_path << std::endl; @@ -166,21 +146,28 @@ int main(int argc, const char** argv) { return 1; } - // Find our target stream. - int target_stream = -1; + // Find our target stream(s) + int video_stream = -1; + int audio_stream = -1; for (size_t i = 0; i < format_context->nb_streams; ++i) { AVCodecContext* codec_context = format_context->streams[i]->codec; - // See if we found our target codec. - if (codec_context->codec_type == target_codec && target_stream < 0) { + if (codec_context->codec_type == CODEC_TYPE_VIDEO && video_stream < 0) { #if SHOW_VERBOSE - *log_out << "* "; + *log_out << "V "; #endif - target_stream = i; + video_stream = i; } else { + if (codec_context->codec_type == CODEC_TYPE_AUDIO && audio_stream < 0) { +#if SHOW_VERBOSE + *log_out << "A "; +#endif + audio_stream = i; + } else { #if SHOW_VERBOSE *log_out << " "; #endif + } } #if SHOW_VERBOSE @@ -194,6 +181,12 @@ int main(int argc, const char** argv) { } #endif } + int target_stream = video_stream; + CodecType target_codec = CODEC_TYPE_VIDEO; + if (target_stream < 0) { + target_stream = audio_stream; + target_codec = CODEC_TYPE_AUDIO; + } // Only continue if we found our target stream. if (target_stream < 0) { @@ -407,12 +400,26 @@ int main(int argc, const char** argv) { } if (sum > 0) { - // Calculate the average frames per second. - double fps = frames * 1000.0 / sum; - // Print our results. - log_out->setf(std::ios::fixed); - log_out->precision(2); - *log_out << "FPS:" << std::setw(11) << fps << std::endl; + if (target_codec == CODEC_TYPE_AUDIO) { + // Calculate the average milliseconds per frame. + // Audio decoding is usually in the millisecond or range, and + // best expressed in time (ms) rather than FPS, which can approach + // infinity. + double ms = sum / frames; + // Print our results. + log_out->setf(std::ios::fixed); + log_out->precision(2); + *log_out << "TIME PER FRAME (MS):" << std::setw(11) << ms << std::endl; + } else if (target_codec == CODEC_TYPE_VIDEO) { + // Calculate the average frames per second. + // Video decoding is expressed in Frames Per Second - a term easily + // understood and should exceed a typical target of 30 fps. + double fps = frames * 1000.0 / sum; + // Print our results. + log_out->setf(std::ios::fixed); + log_out->precision(2); + *log_out << "FPS:" << std::setw(11) << fps << std::endl; + } } #if SHOW_VERBOSE @@ -458,7 +465,7 @@ int main(int argc, const char** argv) { *log_out << " MD5 Hash: " << MD5DigestToBase16(digest) << " " << in_path << std::endl; } -#endif // SHOW_VERBOSE +#endif // SHOW_VERBOSE #if defined(OS_WIN) } __except(EXCEPTION_EXECUTE_HANDLER) { *log_out << " Exception:" << std::setw(11) << GetExceptionCode() |