diff options
author | dalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 21:23:08 +0000 |
---|---|---|
committer | dalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 21:23:08 +0000 |
commit | 7ec682d8c28dd5276d0374546498124613ed70d9 (patch) | |
tree | e958b90bc079ccf7ac5d9f13fba3feb1373afa36 | |
parent | 8eba8aba49eb852396f902f523918d656e250bbe (diff) | |
download | chromium_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
-rw-r--r-- | DEPS | 4 | ||||
-rw-r--r-- | media/ffmpeg/ffmpeg_unittest.cc | 75 | ||||
-rw-r--r-- | media/ffmpeg/file_protocol.cc | 90 | ||||
-rw-r--r-- | media/ffmpeg/file_protocol.h | 16 | ||||
-rw-r--r-- | media/filters/ffmpeg_glue.cc | 2 | ||||
-rw-r--r-- | media/media.gyp | 4 | ||||
-rw-r--r-- | media/test/ffmpeg_tests/ffmpeg_tests.cc | 52 | ||||
-rw-r--r-- | media/tools/media_bench/media_bench.cc | 77 |
8 files changed, 60 insertions, 260 deletions
@@ -25,8 +25,8 @@ vars = { # These two FFmpeg variables must be updated together. One is used for SVN # checkouts and the other for Git checkouts. - "ffmpeg_revision": "164413", - "ffmpeg_hash": "f1b9c50b8b14c6a5299c022a3a677a5c9941427a", + "ffmpeg_revision": "165704", + "ffmpeg_hash": "3d123ab057180446e18cc746721e924ace3fc072", "sfntly_revision": "134", "skia_revision": "6257", diff --git a/media/ffmpeg/ffmpeg_unittest.cc b/media/ffmpeg/ffmpeg_unittest.cc index edfb95a..c0a64d1 100644 --- a/media/ffmpeg/ffmpeg_unittest.cc +++ b/media/ffmpeg/ffmpeg_unittest.cc @@ -14,13 +14,15 @@ #include "base/base_paths.h" #include "base/file_path.h" #include "base/file_util.h" +#include "base/memory/scoped_ptr.h" #include "base/path_service.h" #include "base/perftimer.h" #include "base/string_util.h" #include "base/test/perf_test_suite.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/in_memory_url_protocol.h" #include "testing/gtest/include/gtest/gtest.h" int main(int argc, char** argv) { @@ -111,20 +113,16 @@ class FFmpegTest : public testing::TestWithParam<const char*> { .AppendASCII("data") .AppendASCII("content") .AppendASCII(name.c_str()); - FilePath::StringType raw_path = path.value(); EXPECT_TRUE(file_util::PathExists(path)); -#if defined(OS_WIN) - std::string ascii_path = WideToASCII(path.value()); -#else - std::string ascii_path = path.value(); -#endif - - EXPECT_EQ(0, avformat_open_input(&av_format_context_, - ascii_path.c_str(), - NULL, NULL)) - << "Could not open " << path.value(); - EXPECT_LE(0, avformat_find_stream_info(av_format_context_, NULL)) + CHECK(file_data_.Initialize(path)); + protocol_.reset(new InMemoryUrlProtocol( + file_data_.data(), file_data_.length(), false)); + glue_.reset(new FFmpegGlue(protocol_.get())); + + ASSERT_TRUE(glue_->OpenContext()) << "Could not open " << path.value(); + av_format_context_ = glue_->format_context(); + ASSERT_LE(0, avformat_find_stream_info(av_format_context_, NULL)) << "Could not find stream information for " << path.value(); // Determine duration by picking max stream duration. @@ -143,10 +141,6 @@ class FFmpegTest : public testing::TestWithParam<const char*> { duration_ = std::max(duration_, duration); } - void CloseFile() { - avformat_close_input(&av_format_context_); - } - void OpenCodecs() { for (unsigned int i = 0; i < av_format_context_->nb_streams; ++i) { AVStream* av_stream = av_format_context_->streams[i]; @@ -177,14 +171,6 @@ class FFmpegTest : public testing::TestWithParam<const char*> { } } - void CloseCodecs() { - for (unsigned int i = 0; i < av_format_context_->nb_streams; ++i) { - AVStream* av_stream = av_format_context_->streams[i]; - av_stream->discard = AVDISCARD_ALL; - avcodec_close(av_stream->codec); - } - } - void Flush() { if (has_audio()) { audio_packets_.flush(); @@ -389,9 +375,6 @@ class FFmpegTest : public testing::TestWithParam<const char*> { EXPECT_TRUE(InitializeMediaLibrary(path)) << "Could not initialize media library."; - av_log_set_level(AV_LOG_FATAL); - av_register_all(); - av_register_protocol2(&kFFmpegFileProtocol, sizeof(kFFmpegFileProtocol)); initialized = true; } @@ -410,6 +393,10 @@ class FFmpegTest : public testing::TestWithParam<const char*> { int64 decoded_video_duration_; int64 duration_; + file_util::MemoryMappedFile file_data_; + scoped_ptr<InMemoryUrlProtocol> protocol_; + scoped_ptr<FFmpegGlue> glue_; + DISALLOW_COPY_AND_ASSIGN(FFmpegTest); }; @@ -462,14 +449,6 @@ TEST_P(FFmpegTest, Perf) { PerfTimeLogger timer("Seeking to zero"); SeekTo(0); } - { - PerfTimeLogger timer("Closing codecs"); - CloseCodecs(); - } - { - PerfTimeLogger timer("Closing file"); - CloseFile(); - } } TEST_P(FFmpegTest, Loop_Audio) { @@ -493,9 +472,6 @@ TEST_P(FFmpegTest, Loop_Audio) { EXPECT_EQ(expected_timestamps_[i], decoded_audio_time()) << "Frame " << i << " had a mismatched timestamp."; } - - CloseCodecs(); - CloseFile(); } TEST_P(FFmpegTest, Loop_Video) { @@ -519,9 +495,6 @@ TEST_P(FFmpegTest, Loop_Video) { EXPECT_EQ(expected_timestamps_[i], decoded_video_time()) << "Frame " << i << " had a mismatched timestamp."; } - - CloseCodecs(); - CloseFile(); } TEST_P(FFmpegTest, Seek_Audio) { @@ -535,9 +508,6 @@ TEST_P(FFmpegTest, Seek_Audio) { EXPECT_TRUE(StepDecodeAudio()); EXPECT_NE(static_cast<int64>(AV_NOPTS_VALUE), decoded_audio_time()); - - CloseCodecs(); - CloseFile(); } TEST_P(FFmpegTest, Seek_Video) { @@ -551,9 +521,6 @@ TEST_P(FFmpegTest, Seek_Video) { EXPECT_TRUE(StepDecodeVideo()); EXPECT_NE(static_cast<int64>(AV_NOPTS_VALUE), decoded_video_time()); - - CloseCodecs(); - CloseFile(); } TEST_P(FFmpegTest, Decode_Audio) { @@ -567,9 +534,6 @@ TEST_P(FFmpegTest, Decode_Audio) { ASSERT_GT(decoded_audio_time(), last_audio_time); last_audio_time = decoded_audio_time(); } - - CloseCodecs(); - CloseFile(); } TEST_P(FFmpegTest, Decode_Video) { @@ -583,9 +547,6 @@ TEST_P(FFmpegTest, Decode_Video) { ASSERT_GT(decoded_video_time(), last_video_time); last_video_time = decoded_video_time(); } - - CloseCodecs(); - CloseFile(); } TEST_P(FFmpegTest, Duration) { @@ -605,9 +566,6 @@ TEST_P(FFmpegTest, Duration) { decoded_video_time() + decoded_video_duration())); EXPECT_NEAR(expected, actual, 500000) << "Duration is off by more than 0.5 seconds."; - - CloseCodecs(); - CloseFile(); } TEST_F(FFmpegTest, VideoPlayedCollapse) { @@ -628,9 +586,6 @@ TEST_F(FFmpegTest, VideoPlayedCollapse) { ReadRemainingFile(); EXPECT_TRUE(StepDecodeVideo()); VLOG(1) << decoded_video_time(); - - CloseCodecs(); - CloseFile(); } } // namespace media diff --git a/media/ffmpeg/file_protocol.cc b/media/ffmpeg/file_protocol.cc deleted file mode 100644 index 49b9f1c..0000000 --- a/media/ffmpeg/file_protocol.cc +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/ffmpeg/file_protocol.h" - -#include "build/build_config.h" - -#if defined(OS_WIN) -#include <io.h> -#else -#include <unistd.h> -#endif -#include <fcntl.h> - -#include "base/compiler_specific.h" -#include "base/eintr_wrapper.h" -#include "base/file_util.h" -#include "media/ffmpeg/ffmpeg_common.h" - -// warning C4996: 'open': The POSIX name for this item is deprecated. -MSVC_PUSH_DISABLE_WARNING(4996) - -static int GetHandle(URLContext *h) { - return static_cast<int>(reinterpret_cast<intptr_t>(h->priv_data)); -} - -// FFmpeg protocol interface. -static int OpenContext(URLContext* h, const char* filename, int flags) { - int access = O_RDONLY; - - if ((flags & AVIO_FLAG_WRITE) && (flags & AVIO_FLAG_READ)) { - access = O_CREAT | O_TRUNC | O_RDWR; - } else if (flags & AVIO_FLAG_WRITE) { - access = O_CREAT | O_TRUNC | O_WRONLY; - } - -#ifdef O_BINARY - access |= O_BINARY; -#endif - - int f = open(filename, access, 0666); - if (f == -1) - return AVERROR(ENOENT); - - h->priv_data = reinterpret_cast<void*>(static_cast<intptr_t>(f)); - h->is_streamed = false; - return 0; -} - -static int ReadContext(URLContext* h, unsigned char* buf, int size) { - return HANDLE_EINTR(read(GetHandle(h), buf, size)); -} - -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 68, 0) -static int WriteContext(URLContext* h, const unsigned char* buf, int size) { -#else -static int WriteContext(URLContext* h, unsigned char* buf, int size) { -#endif - return HANDLE_EINTR(write(GetHandle(h), buf, size)); -} - -static int64 SeekContext(URLContext* h, int64 offset, int whence) { -#if defined(OS_WIN) - return _lseeki64(GetHandle(h), static_cast<__int64>(offset), whence); -#else - COMPILE_ASSERT(sizeof(off_t) == 8, off_t_not_64_bit); - return lseek(GetHandle(h), static_cast<off_t>(offset), whence); -#endif -} - -static int CloseContext(URLContext* h) { - return HANDLE_EINTR(close(GetHandle(h))); -} - -MSVC_POP_WARNING() - -URLProtocol kFFmpegFileProtocol = { - "file", - &OpenContext, - NULL, // url_open2 - &ReadContext, - &WriteContext, - &SeekContext, - &CloseContext, - NULL, // *next - NULL, // url_read_pause - NULL, // url_read_seek - &GetHandle -}; diff --git a/media/ffmpeg/file_protocol.h b/media/ffmpeg/file_protocol.h deleted file mode 100644 index 7c16c4b..0000000 --- a/media/ffmpeg/file_protocol.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// Implements a basic file I/O URLProtocol for FFmpeg. Since we don't build -// FFmpeg binaries with protocols, we have to write our own. - -#ifndef MEDIA_FFMPEG_FILE_PROTOCOL_H_ -#define MEDIA_FFMPEG_FILE_PROTOCOL_H_ - -#include "media/base/media_export.h" - -struct URLProtocol; -MEDIA_EXPORT extern URLProtocol kFFmpegFileProtocol; - -#endif // MEDIA_FFMPEG_FILE_PROTOCOL_H_ diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc index d5921c1..71e92b4 100644 --- a/media/filters/ffmpeg_glue.cc +++ b/media/filters/ffmpeg_glue.cc @@ -65,8 +65,6 @@ static int LockManagerOperation(void** lock, enum AVLockOp op) { switch (op) { case AV_LOCK_CREATE: *lock = new base::Lock(); - if (!*lock) - return 1; return 0; case AV_LOCK_OBTAIN: diff --git a/media/media.gyp b/media/media.gyp index 339dbb1..afd48be 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -249,8 +249,6 @@ 'crypto/aes_decryptor.h', 'ffmpeg/ffmpeg_common.cc', 'ffmpeg/ffmpeg_common.h', - 'ffmpeg/file_protocol.cc', - 'ffmpeg/file_protocol.h', 'filters/audio_file_reader.cc', 'filters/audio_file_reader.h', 'filters/audio_renderer_algorithm.cc', @@ -365,8 +363,6 @@ 'base/media_posix.cc', 'ffmpeg/ffmpeg_common.cc', 'ffmpeg/ffmpeg_common.h', - 'ffmpeg/file_protocol.cc', - 'ffmpeg/file_protocol.h', 'filters/audio_file_reader.cc', 'filters/audio_file_reader.h', 'filters/chunk_demuxer.cc', diff --git a/media/test/ffmpeg_tests/ffmpeg_tests.cc b/media/test/ffmpeg_tests/ffmpeg_tests.cc index fb62b64..b1b96e5 100644 --- a/media/test/ffmpeg_tests/ffmpeg_tests.cc +++ b/media/test/ffmpeg_tests/ffmpeg_tests.cc @@ -15,15 +15,18 @@ #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_util.h" #include "base/time.h" #include "base/utf_string_conversions.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" #ifdef DEBUG #define SHOW_VERBOSE 1 @@ -80,9 +83,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()) == false) { + FilePath media_path; + PathService::Get(base::DIR_MODULE, &media_path); + if (!media::InitializeMediaLibrary(media_path)) { std::cerr << "Unable to initialize the media library."; return 1; } @@ -95,7 +98,6 @@ int main(int argc, const char** argv) { // Default flags that match Chrome defaults. int video_threads = 2; - int verbose_level = AV_LOG_FATAL; int max_frames = 0; int max_loops = 0; bool flush = false; @@ -113,35 +115,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()) { @@ -426,10 +414,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; 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; |