summaryrefslogtreecommitdiffstats
path: root/media/tools
diff options
context:
space:
mode:
authordalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-02 21:23:08 +0000
committerdalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-02 21:23:08 +0000
commit7ec682d8c28dd5276d0374546498124613ed70d9 (patch)
treee958b90bc079ccf7ac5d9f13fba3feb1373afa36 /media/tools
parent8eba8aba49eb852396f902f523918d656e250bbe (diff)
downloadchromium_src-7ec682d8c28dd5276d0374546498124613ed70d9.zip
chromium_src-7ec682d8c28dd5276d0374546498124613ed70d9.tar.gz
chromium_src-7ec682d8c28dd5276d0374546498124613ed70d9.tar.bz2
Roll ffmpeg DEPS for fixes, patch removal, and better GOMA detection.
Also fixes various media tools which were using the old av_register_protocol2() path instead of the new FFmpegGlue hotness. Includes: 3d123ab Zero initialize ff_lockmgr_cb. b694550 Remove custom av_register_protocol2() patch. c317c1c Use build.ninja to see the user uses GOMA or not. BUG=146529,118986,159139 TEST=builds. Review URL: https://codereview.chromium.org/11365050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/tools')
-rw-r--r--media/tools/media_bench/media_bench.cc77
1 files changed, 25 insertions, 52 deletions
diff --git a/media/tools/media_bench/media_bench.cc b/media/tools/media_bench/media_bench.cc
index abba5f0..844372f 100644
--- a/media/tools/media_bench/media_bench.cc
+++ b/media/tools/media_bench/media_bench.cc
@@ -7,14 +7,6 @@
// options. We also use this tool to measure performance regressions when
// testing newer builds of FFmpeg from trunk.
-#include "build/build_config.h"
-
-// For pipe _setmode to binary
-#if defined(OS_WIN)
-#include <fcntl.h>
-#include <io.h>
-#endif
-
#include <iomanip>
#include <iostream>
#include <string>
@@ -24,21 +16,30 @@
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/logging.h"
#include "base/md5.h"
+#include "base/path_service.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
+#include "build/build_config.h"
#include "media/base/djb2.h"
#include "media/base/media.h"
#include "media/ffmpeg/ffmpeg_common.h"
-#include "media/ffmpeg/file_protocol.h"
+#include "media/filters/ffmpeg_glue.h"
#include "media/filters/ffmpeg_video_decoder.h"
+#include "media/filters/in_memory_url_protocol.h"
+
+// For pipe _setmode to binary
+#if defined(OS_WIN)
+#include <fcntl.h>
+#include <io.h>
+#endif
namespace switches {
const char kStream[] = "stream";
const char kVideoThreads[] = "video-threads";
-const char kVerbose[] = "verbose";
const char kFast2[] = "fast2";
const char kErrorCorrection[] = "error-correction";
const char kSkip[] = "skip";
@@ -105,8 +106,6 @@ int main(int argc, const char** argv) {
<< "Benchmark either the audio or video stream\n"
<< " --video-threads=N "
<< "Decode video using N threads\n"
- << " --verbose=N "
- << "Set FFmpeg log verbosity (-8 to 48)\n"
<< " --frames=N "
<< "Decode N frames\n"
<< " --loop=N "
@@ -127,9 +126,9 @@ int main(int argc, const char** argv) {
}
// Initialize our media library (try loading DLLs, etc.) before continuing.
- // We use an empty file path as the parameter to force searching of the
- // default locations for necessary DLLs and DSOs.
- if (!media::InitializeMediaLibrary(FilePath())) {
+ FilePath media_path;
+ PathService::Get(base::DIR_MODULE, &media_path);
+ if (!media::InitializeMediaLibrary(media_path)) {
std::cerr << "Unable to initialize the media library." << std::endl;
return 1;
}
@@ -162,14 +161,6 @@ int main(int argc, const char** argv) {
video_threads = 0;
}
- // FFmpeg verbosity. See libavutil/log.h for values: -8 quiet..48 verbose.
- int verbose_level = AV_LOG_FATAL;
- std::string verbose(cmd_line->GetSwitchValueASCII(switches::kVerbose));
- if (!verbose.empty() &&
- !base::StringToInt(verbose, &verbose_level)) {
- verbose_level = AV_LOG_FATAL;
- }
-
// Determine number of frames to decode (optional).
int max_frames = 0;
std::string frames_opt(cmd_line->GetSwitchValueASCII(switches::kFrames));
@@ -227,35 +218,21 @@ int main(int argc, const char** argv) {
__try {
#endif
+ file_util::MemoryMappedFile file_data;
+ file_data.Initialize(in_path);
+ media::InMemoryUrlProtocol protocol(
+ file_data.data(), file_data.length(), false);
+
// Register FFmpeg and attempt to open file.
- av_log_set_level(verbose_level);
- av_register_all();
- av_register_protocol2(&kFFmpegFileProtocol, sizeof(kFFmpegFileProtocol));
- AVFormatContext* format_context = NULL;
- // avformat_open_input() wants a char*, which can't work with wide paths.
- // So we assume ASCII on Windows. On other platforms we can pass the
- // path bytes through verbatim.
-#if defined(OS_WIN)
- std::string string_path = WideToASCII(in_path.value());
-#else
- const std::string& string_path = in_path.value();
-#endif
- int result = avformat_open_input(&format_context, string_path.c_str(),
- NULL, NULL);
- if (result < 0) {
- switch (result) {
- case AVERROR(EINVAL):
- std::cerr << "Error: File format not supported "
- << in_path.value() << std::endl;
- break;
- default:
- std::cerr << "Error: Could not open input for "
- << in_path.value() << std::endl;
- break;
- }
+ media::FFmpegGlue glue(&protocol);
+ if (!glue.OpenContext()) {
+ std::cerr << "Error: Could not open input for "
+ << in_path.value() << std::endl;
return 1;
}
+ AVFormatContext* format_context = glue.format_context();
+
// Open output file.
FILE *output = NULL;
if (!out_path.empty()) {
@@ -545,10 +522,6 @@ int main(int argc, const char** argv) {
// Clean up.
if (output)
file_util::CloseFile(output);
- if (codec_context)
- avcodec_close(codec_context);
- if (format_context)
- avformat_close_input(&format_context);
// Calculate the sum of times. Note that some of these may be zero.
double sum = 0;