0

Glue ffmpeg to Chrome

1) works for Linux, OSX, Windows
2) mostly renaming #defines
3) avcodec_thread_init is deprecated and has been removed, see
   http://ffmpeg.org/pipermail/ffmpeg-cvslog/2011-February/034326.html
4) will require a rebaseline of 
   platform/chromium-mac/media/video-currentTime-set-expected.txt
   platform/chromium-win/media/video-currentTime-set-expected.txt
   with a change of
   -video.currentTime.toFixed(2) == '5.82'
   +video.currentTime.toFixed(2) == '5.81'


BUG=87831
TESTS=ran Theora Testsuite, media tests, WebKit media tests
Review URL: http://codereview.chromium.org/6993042

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91259 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
ihf@chromium.org
2011-07-01 02:25:17 +00:00
parent a78313b476
commit 2decb263ae
27 changed files with 122 additions and 143 deletions

2
DEPS

@ -15,7 +15,7 @@ vars = {
"nacl_tools_revision": "5360",
"libjingle_revision": "66",
"libvpx_revision": "90416",
"ffmpeg_revision": "88382",
"ffmpeg_revision": "90064",
"skia_revision": "1763",
"v8_revision": "8431",
"webrtc_revision": "90",

@ -31,9 +31,9 @@ delay_loaded = [
'dbghelp.dll',
'COMDLG32.dll',
'urlmon.dll',
'avcodec-52.dll',
'avformat-52.dll',
'avutil-50.dll',
'avcodec-53.dll',
'avformat-53.dll',
'avutil-51.dll',
'pthreads.dll',
'IPHLPAPI.dll',
]

@ -38,7 +38,7 @@ const char* kBrowserSupportedExtensions[] = {
};
// List of file extension that can be handled with the media player.
const char* kAVExtensions[] = {
".webm", ".mp4", ".m4v", ".mov", ".ogm", ".ogv", ".ogx",
".avi", ".webm", ".mp4", ".m4v", ".mov", ".ogm", ".ogv", ".ogx",
".mp3", ".m4a", ".ogg", ".oga", ".wav",
/* TODO(zelidrag): Add unsupported ones as we enable them:
".3gp", ".mkv", ".avi", ".divx", ".xvid", ".wmv", ".asf", ".mpeg", ".mpg",

@ -153,7 +153,7 @@ FileManager.prototype = {
'image': /\.(bmp|gif|jpe?g|ico|png|webp)$/i,
'pdf' : /\.(pdf)$/i,
'text': /\.(pod|rst|txt|log)$/i,
'video': /\.(mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i
'video': /\.(avi|mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i
};
const previewArt = {

@ -133,6 +133,7 @@ const ExtensionIconSizeMap::value_type kExtensionIdrBySizeData[] = {
std::make_pair(".pod", kTextIdrs),
std::make_pair(".rst", kTextIdrs),
std::make_pair(".txt", kTextIdrs),
std::make_pair(".avi", kVideoIdrs),
std::make_pair(".m4v", kVideoIdrs),
std::make_pair(".mov", kVideoIdrs),
std::make_pair(".mp4", kVideoIdrs),

@ -1,6 +1,6 @@
avcodec-52.dll
avformat-52.dll
avutil-50.dll
avcodec-53.dll
avformat-53.dll
avutil-51.dll
chrome.exe
nacl64.exe
chrome.dll

@ -1,7 +1,7 @@
# -*- python -*-
# ex: set syntax=python:
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# 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.
@ -16,17 +16,17 @@
FILES = [
{
'filename': 'avcodec-52.dll',
'filename': 'avcodec-53.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'avformat-52.dll',
'filename': 'avformat-53.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
'filename': 'avutil-50.dll',
'filename': 'avutil-51.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},

@ -295,9 +295,9 @@ class ChromeFrameStartupTest : public ChromeFramePerfTestBase {
chrome_frame_dll_ = dir_app_.Append(L"servers");
chrome_frame_dll_ = chrome_frame_dll_.Append(kChromeFrameDllName);
icu_dll_ = dir_app_.Append(L"icudt.dll");
avcodec52_dll_ = dir_app_.Append(L"avcodec-52.dll");
avformat52_dll_ = dir_app_.Append(L"avformat-52.dll");
avutil50_dll_ = dir_app_.Append(L"avutil-50.dll");
avcodec_dll_ = dir_app_.Append(L"avcodec-53.dll");
avformat_dll_ = dir_app_.Append(L"avformat-53.dll");
avutil_dll_ = dir_app_.Append(L"avutil-51.dll");
}
// TODO(iyengar)
@ -355,9 +355,9 @@ class ChromeFrameStartupTest : public ChromeFramePerfTestBase {
FilePath chrome_exe_;
FilePath chrome_frame_dll_;
FilePath icu_dll_;
FilePath avcodec52_dll_;
FilePath avformat52_dll_;
FilePath avutil50_dll_;
FilePath avcodec_dll_;
FilePath avformat_dll_;
FilePath avutil_dll_;
protected:
// Individual startup tests should implement this function.
@ -964,7 +964,7 @@ TEST_F(ChromeFrameBinariesLoadTest, PerfWarm) {
TEST_F(ChromeFrameStartupTestActiveX, PerfCold) {
SetConfigInt(L"PreRead", 0);
FilePath binaries_to_evict[] = {
avcodec52_dll_, avformat52_dll_, avutil50_dll_, chrome_exe_, chrome_dll_,
avcodec_dll_, avformat_dll_, avutil_dll_, chrome_exe_, chrome_dll_,
chrome_frame_dll_
};
RunStartupTest("cold", "t", "about:blank", true /* cold */,
@ -976,7 +976,7 @@ TEST_F(ChromeFrameStartupTestActiveX, PerfCold) {
TEST_F(ChromeFrameStartupTestActiveX, PerfColdPreRead) {
SetConfigInt(L"PreRead", 1);
FilePath binaries_to_evict[] = {
avcodec52_dll_, avformat52_dll_, avutil50_dll_, chrome_exe_, chrome_dll_,
avcodec_dll_, avformat_dll_, avutil_dll_, chrome_exe_, chrome_dll_,
chrome_frame_dll_
};
RunStartupTest("cold_preread", "t", "about:blank", true /* cold */,

@ -54,11 +54,11 @@ static std::string GetDSOName(tp_ffmpeg::StubModules stub_key) {
// TODO(ajwong): Remove this once mac is migrated. Either that, or have GYP
// set a constant that we can switch implementations based off of.
switch (stub_key) {
case tp_ffmpeg::kModuleAvcodec52:
case tp_ffmpeg::kModuleAvcodec53:
return FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION));
case tp_ffmpeg::kModuleAvformat52:
case tp_ffmpeg::kModuleAvformat53:
return FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION));
case tp_ffmpeg::kModuleAvutil50:
case tp_ffmpeg::kModuleAvutil51:
return FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION));
default:
LOG(DFATAL) << "Invalid stub module requested: " << stub_key;

@ -25,11 +25,11 @@ static FilePath::CharType* GetDLLName(FFmpegDLLKeys dll_key) {
// TODO(ajwong): Do we want to lock to a specific ffmpeg version?
switch (dll_key) {
case FILE_LIBAVCODEC:
return FILE_PATH_LITERAL("avcodec-52.dll");
return FILE_PATH_LITERAL("avcodec-53.dll");
case FILE_LIBAVFORMAT:
return FILE_PATH_LITERAL("avformat-52.dll");
return FILE_PATH_LITERAL("avformat-53.dll");
case FILE_LIBAVUTIL:
return FILE_PATH_LITERAL("avutil-50.dll");
return FILE_PATH_LITERAL("avutil-51.dll");
default:
LOG(DFATAL) << "Invalid DLL key requested: " << dll_key;
return FILE_PATH_LITERAL("");

@ -112,10 +112,6 @@ int avcodec_close(AVCodecContext* avctx) {
return MockFFmpeg::get()->AVCodecClose(avctx);
}
int avcodec_thread_init(AVCodecContext* avctx, int threads) {
return MockFFmpeg::get()->AVCodecThreadInit(avctx, threads);
}
void avcodec_flush_buffers(AVCodecContext* avctx) {
return MockFFmpeg::get()->AVCodecFlushBuffers(avctx);
}

@ -210,19 +210,21 @@ void DestroyAVFormatContext(AVFormatContext* format_context) {
DCHECK(format_context);
// Iterate each stream and destroy each one of them.
int streams = format_context->nb_streams;
for (int i = 0; i < streams; ++i) {
AVStream* stream = format_context->streams[i];
if (format_context->streams) {
int streams = format_context->nb_streams;
for (int i = 0; i < streams; ++i) {
AVStream* stream = format_context->streams[i];
// The conditions for calling avcodec_close():
// 1. AVStream is alive.
// 2. AVCodecContext in AVStream is alive.
// 3. AVCodec in AVCodecContext is alive.
// Notice that closing a codec context without prior avcodec_open() will
// result in a crash in FFmpeg.
if (stream && stream->codec && stream->codec->codec) {
stream->discard = AVDISCARD_ALL;
avcodec_close(stream->codec);
// The conditions for calling avcodec_close():
// 1. AVStream is alive.
// 2. AVCodecContext in AVStream is alive.
// 3. AVCodec in AVCodecContext is alive.
// Notice that closing a codec context without prior avcodec_open() will
// result in a crash in FFmpeg.
if (stream && stream->codec && stream->codec->codec) {
stream->discard = AVDISCARD_ALL;
avcodec_close(stream->codec);
}
}
}

@ -173,10 +173,10 @@ class FFmpegTest : public testing::TestWithParam<const char*> {
<< "Could not open AVCodecContext with CodecID "
<< av_codec_context->codec_id;
if (av_codec->type == CODEC_TYPE_AUDIO) {
if (av_codec->type == AVMEDIA_TYPE_AUDIO) {
EXPECT_EQ(-1, audio_stream_index_) << "Found multiple audio streams.";
audio_stream_index_ = static_cast<int>(i);
} else if (av_codec->type == CODEC_TYPE_VIDEO) {
} else if (av_codec->type == AVMEDIA_TYPE_VIDEO) {
EXPECT_EQ(-1, video_stream_index_) << "Found multiple video streams.";
video_stream_index_ = static_cast<int>(i);
} else {

@ -71,7 +71,7 @@ bool AudioFileReader::Open() {
codec_context_ = NULL;
for (size_t i = 0; i < format_context_->nb_streams; ++i) {
AVCodecContext* c = format_context_->streams[i]->codec;
if (c->codec_type == CODEC_TYPE_AUDIO) {
if (c->codec_type == AVMEDIA_TYPE_AUDIO) {
codec_context_ = c;
break;
}

@ -1,4 +1,4 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// 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.
@ -52,7 +52,7 @@ bool FFmpegBitstreamConverter::ConvertPacket(AVPacket* packet) {
if (av_bitstream_filter_filter(stream_filter_, stream_context_, NULL,
&converted_data, &converted_size,
packet->data, packet->size,
packet->flags & PKT_FLAG_KEY) < 0) {
packet->flags & AV_PKT_FLAG_KEY) < 0) {
return false;
}

@ -91,7 +91,7 @@ TEST_F(BitstreamConverterTest, ConvertPacket_FailedFilter) {
AVBitstreamFilterFilter(&test_filter_, &test_stream_context_,
NULL, _, _,
test_packet_.data, test_packet_.size, _))
.WillOnce(Return(AVERROR_UNKNOWN));
.WillOnce(Return(AVERROR(EINVAL)));
EXPECT_FALSE(converter.ConvertPacket(&test_packet_));

@ -534,9 +534,9 @@ bool ChunkDemuxer::SetupStreams() {
for (size_t i = 0; i < format_context_->nb_streams; ++i) {
AVStream* stream = format_context_->streams[i];
AVCodecContext* codec_context = stream->codec;
CodecType codec_type = codec_context->codec_type;
AVMediaType codec_type = codec_context->codec_type;
if (codec_type == CODEC_TYPE_AUDIO &&
if (codec_type == AVMEDIA_TYPE_AUDIO &&
stream->codec->codec_id == CODEC_ID_VORBIS &&
!audio_.get()) {
audio_ = new ChunkDemuxerStream(DemuxerStream::AUDIO, stream);
@ -544,7 +544,7 @@ bool ChunkDemuxer::SetupStreams() {
continue;
}
if (codec_type == CODEC_TYPE_VIDEO &&
if (codec_type == AVMEDIA_TYPE_VIDEO &&
stream->codec->codec_id == CODEC_ID_VP8 &&
!video_.get()) {
video_ = new ChunkDemuxerStream(DemuxerStream::VIDEO, stream);

@ -45,12 +45,12 @@ class ChunkDemuxerTest : public testing::Test{
memset(&streams_, 0, sizeof(streams_));
memset(&codecs_, 0, sizeof(codecs_));
codecs_[VIDEO].codec_type = CODEC_TYPE_VIDEO;
codecs_[VIDEO].codec_type = AVMEDIA_TYPE_VIDEO;
codecs_[VIDEO].codec_id = CODEC_ID_VP8;
codecs_[VIDEO].width = 320;
codecs_[VIDEO].height = 240;
codecs_[AUDIO].codec_type = CODEC_TYPE_AUDIO;
codecs_[AUDIO].codec_type = AVMEDIA_TYPE_AUDIO;
codecs_[AUDIO].codec_id = CODEC_ID_VORBIS;
codecs_[AUDIO].channels = 2;
codecs_[AUDIO].sample_rate = 44100;
@ -59,6 +59,11 @@ class ChunkDemuxerTest : public testing::Test{
virtual ~ChunkDemuxerTest() {
if (demuxer_.get())
demuxer_->Shutdown();
if (format_context_.streams) {
delete[] format_context_.streams;
format_context_.streams = NULL;
format_context_.nb_streams = 0;
}
}
void ReadFile(const std::string& name, scoped_array<uint8>* buffer,
@ -137,6 +142,7 @@ class ChunkDemuxerTest : public testing::Test{
void SetupAVFormatContext(bool has_audio, bool has_video) {
int i = 0;
format_context_.streams = new AVStream *[MAX_CODECS_INDEX];
if (has_audio) {
format_context_.streams[i] = &streams_[i];
streams_[i].codec = &codecs_[AUDIO];

@ -65,10 +65,10 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(FFmpegDemuxer* demuxer,
// Determine our media format.
switch (stream->codec->codec_type) {
case CODEC_TYPE_AUDIO:
case AVMEDIA_TYPE_AUDIO:
type_ = AUDIO;
break;
case CODEC_TYPE_VIDEO:
case AVMEDIA_TYPE_VIDEO:
type_ = VIDEO;
break;
default:
@ -361,7 +361,7 @@ int FFmpegDemuxer::Read(int size, uint8* data) {
// If read has ever failed, return with an error.
// TODO(hclam): use a more meaningful constant as error.
if (read_has_failed_)
return AVERROR_IO;
return AVERROR(EIO);
// Even though FFmpeg defines AVERROR_EOF, it's not to be used with I/O
// routines. Instead return 0 for any read at or past EOF.
@ -385,7 +385,7 @@ int FFmpegDemuxer::Read(int size, uint8* data) {
// Returns with a negative number to signal an error to FFmpeg.
read_has_failed_ = true;
return AVERROR_IO;
return AVERROR(EIO);
}
read_position_ += last_read_bytes;
@ -471,8 +471,8 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source,
bool no_supported_streams = true;
for (size_t i = 0; i < format_context_->nb_streams; ++i) {
AVCodecContext* codec_context = format_context_->streams[i]->codec;
CodecType codec_type = codec_context->codec_type;
if (codec_type == CODEC_TYPE_AUDIO || codec_type == CODEC_TYPE_VIDEO) {
AVMediaType codec_type = codec_context->codec_type;
if (codec_type == AVMEDIA_TYPE_AUDIO || codec_type == AVMEDIA_TYPE_VIDEO) {
AVStream* stream = format_context_->streams[i];
// WebM is currently strictly VP8 and Vorbis.
if (kDemuxerIsWebm && (stream->codec->codec_id != CODEC_ID_VP8 &&
@ -647,7 +647,7 @@ void FFmpegDemuxer::DisableAudioStreamTask() {
// look for such reference, and this will result in deleting the
// audio packets after they are demuxed.
if (packet_streams_[i]->GetAVStream()->codec->codec_type ==
CODEC_TYPE_AUDIO) {
AVMEDIA_TYPE_AUDIO) {
packet_streams_[i] = NULL;
}
}

@ -82,15 +82,15 @@ class FFmpegDemuxerTest : public testing::Test {
memset(&codecs_, 0, sizeof(codecs_));
// Initialize AVCodecContext structures.
codecs_[AV_STREAM_DATA].codec_type = CODEC_TYPE_DATA;
codecs_[AV_STREAM_DATA].codec_type = AVMEDIA_TYPE_DATA;
codecs_[AV_STREAM_DATA].codec_id = CODEC_ID_NONE;
codecs_[AV_STREAM_VIDEO].codec_type = CODEC_TYPE_VIDEO;
codecs_[AV_STREAM_VIDEO].codec_type = AVMEDIA_TYPE_VIDEO;
codecs_[AV_STREAM_VIDEO].codec_id = CODEC_ID_THEORA;
codecs_[AV_STREAM_VIDEO].width = kWidth;
codecs_[AV_STREAM_VIDEO].height = kHeight;
codecs_[AV_STREAM_AUDIO].codec_type = CODEC_TYPE_AUDIO;
codecs_[AV_STREAM_AUDIO].codec_type = AVMEDIA_TYPE_AUDIO;
codecs_[AV_STREAM_AUDIO].codec_id = CODEC_ID_VORBIS;
codecs_[AV_STREAM_AUDIO].channels = kChannels;
codecs_[AV_STREAM_AUDIO].sample_rate = kSampleRate;
@ -101,6 +101,7 @@ class FFmpegDemuxerTest : public testing::Test {
// Initialize AVStream and AVFormatContext structures. We set the time base
// of the streams such that duration is reported in microseconds.
format_context_.nb_streams = AV_STREAM_MAX;
format_context_.streams = new AVStream*[AV_STREAM_MAX];
for (size_t i = 0; i < AV_STREAM_MAX; ++i) {
format_context_.streams[i] = &streams_[i];
streams_[i].codec = &codecs_[i];
@ -116,9 +117,14 @@ class FFmpegDemuxerTest : public testing::Test {
// Finish up any remaining tasks.
message_loop_.RunAllPending();
// Release the reference to the demuxer.
demuxer_ = NULL;
if (format_context_.streams) {
delete[] format_context_.streams;
format_context_.streams = NULL;
format_context_.nb_streams = 0;
}
}
// Sets up MockFFmpeg to allow FFmpegDemuxer to successfully initialize.
@ -190,7 +196,7 @@ TEST_F(FFmpegDemuxerTest, Initialize_ParseFails) {
EXPECT_CALL(mock_ffmpeg_, AVOpenInputFile(_, _, NULL, 0, NULL))
.WillOnce(DoAll(SetArgumentPointee<0>(&format_context_), Return(0)));
EXPECT_CALL(mock_ffmpeg_, AVFindStreamInfo(&format_context_))
.WillOnce(Return(AVERROR_IO));
.WillOnce(Return(AVERROR(EIO)));
EXPECT_CALL(mock_ffmpeg_, AVCloseInputFile(&format_context_));
demuxer_->Initialize(
@ -266,7 +272,7 @@ TEST_F(FFmpegDemuxerTest, Read_DiscardUninteresting) {
EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_DATA, kNullData, 0));
EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
.WillOnce(Return(AVERROR_IO));
.WillOnce(Return(AVERROR(EIO)));
// Attempt a read from the audio stream and run the message loop until done.
scoped_refptr<DemuxerStream> audio =
@ -474,7 +480,7 @@ TEST_F(FFmpegDemuxerTest, Read_EndOfStream) {
EXPECT_CALL(mock_ffmpeg_, AVFreePacket(_)).Times(AnyNumber());
EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
.WillOnce(Return(AVERROR_IO));
.WillOnce(Return(AVERROR(EIO)));
// We should now expect an end of stream buffer.
scoped_refptr<DemuxerStream> audio =
@ -717,7 +723,7 @@ TEST_F(FFmpegDemuxerTest, DisableAudioStream) {
// Then an end-of-stream packet is read.
EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
.WillOnce(Return(AVERROR_IO));
.WillOnce(Return(AVERROR(EIO)));
// Get our streams.
scoped_refptr<DemuxerStream> video =

@ -20,7 +20,7 @@ static int OpenContext(URLContext* h, const char* filename, int flags) {
FFmpegURLProtocol* protocol;
FFmpegGlue::GetInstance()->GetProtocol(filename, &protocol);
if (!protocol)
return AVERROR_IO;
return AVERROR(EIO);
h->priv_data = protocol;
h->flags = URL_RDONLY;
@ -32,7 +32,7 @@ static int ReadContext(URLContext* h, unsigned char* buf, int size) {
FFmpegURLProtocol* protocol = ToProtocol(h->priv_data);
int result = protocol->Read(size, buf);
if (result < 0)
result = AVERROR_IO;
result = AVERROR(EIO);
return result;
}
@ -42,12 +42,12 @@ static int WriteContext(URLContext* h, const unsigned char* buf, int size) {
static int WriteContext(URLContext* h, unsigned char* buf, int size) {
#endif
// We don't support writing.
return AVERROR_IO;
return AVERROR(EIO);
}
static int64 SeekContext(URLContext* h, int64 offset, int whence) {
FFmpegURLProtocol* protocol = ToProtocol(h->priv_data);
int64 new_offset = AVERROR_IO;
int64 new_offset = AVERROR(EIO);
switch (whence) {
case SEEK_SET:
if (protocol->SetPosition(offset))
@ -78,7 +78,7 @@ static int64 SeekContext(URLContext* h, int64 offset, int whence) {
NOTREACHED();
}
if (new_offset < 0)
new_offset = AVERROR_IO;
new_offset = AVERROR(EIO);
return new_offset;
}

@ -150,7 +150,7 @@ TEST_F(FFmpegGlueTest, OpenClose) {
memset(&context, 0, sizeof(context));
// Test opening a URLContext with a protocol that doesn't exist.
EXPECT_EQ(AVERROR_IO, protocol_->url_open(&context, "foobar", 0));
EXPECT_EQ(AVERROR(EIO), protocol_->url_open(&context, "foobar", 0));
// Test opening a URLContext with our protocol.
EXPECT_EQ(0, protocol_->url_open(&context, key.c_str(), 0));
@ -190,9 +190,9 @@ TEST_F(FFmpegGlueTest, Write) {
uint8 buffer[kBufferSize];
// Writing should always fail and never call the protocol.
EXPECT_EQ(AVERROR_IO, protocol_->url_write(&context, NULL, 0));
EXPECT_EQ(AVERROR_IO, protocol_->url_write(&context, buffer, 0));
EXPECT_EQ(AVERROR_IO, protocol_->url_write(&context, buffer, kBufferSize));
EXPECT_EQ(AVERROR(EIO), protocol_->url_write(&context, NULL, 0));
EXPECT_EQ(AVERROR(EIO), protocol_->url_write(&context, buffer, 0));
EXPECT_EQ(AVERROR(EIO), protocol_->url_write(&context, buffer, kBufferSize));
// Destroy the protocol.
protocol_->url_close(&context);
@ -218,7 +218,7 @@ TEST_F(FFmpegGlueTest, Read) {
EXPECT_EQ(0, protocol_->url_read(&context, buffer, 0));
EXPECT_EQ(kBufferSize, protocol_->url_read(&context, buffer, kBufferSize));
EXPECT_EQ(AVERROR_IO, protocol_->url_read(&context, buffer, kBufferSize));
EXPECT_EQ(AVERROR(EIO), protocol_->url_read(&context, buffer, kBufferSize));
// Destroy the protocol.
protocol_->url_close(&context);
@ -241,7 +241,7 @@ TEST_F(FFmpegGlueTest, Seek) {
EXPECT_CALL(*protocol, GetPosition(_))
.WillOnce(DoAll(SetArgumentPointee<0>(8), Return(true)));
EXPECT_EQ(AVERROR_IO, protocol_->url_seek(&context, -16, SEEK_SET));
EXPECT_EQ(AVERROR(EIO), protocol_->url_seek(&context, -16, SEEK_SET));
EXPECT_EQ(8, protocol_->url_seek(&context, 16, SEEK_SET));
// SEEK_CUR should call GetPosition() first, and if it succeeds add the offset
@ -261,8 +261,8 @@ TEST_F(FFmpegGlueTest, Seek) {
EXPECT_CALL(*protocol, GetPosition(_))
.WillOnce(DoAll(SetArgumentPointee<0>(16), Return(true)));
EXPECT_EQ(AVERROR_IO, protocol_->url_seek(&context, 8, SEEK_CUR));
EXPECT_EQ(AVERROR_IO, protocol_->url_seek(&context, 8, SEEK_CUR));
EXPECT_EQ(AVERROR(EIO), protocol_->url_seek(&context, 8, SEEK_CUR));
EXPECT_EQ(AVERROR(EIO), protocol_->url_seek(&context, 8, SEEK_CUR));
EXPECT_EQ(16, protocol_->url_seek(&context, 8, SEEK_CUR));
// SEEK_END should call GetSize() first, and if it succeeds add the offset
@ -282,8 +282,8 @@ TEST_F(FFmpegGlueTest, Seek) {
EXPECT_CALL(*protocol, GetPosition(_))
.WillOnce(DoAll(SetArgumentPointee<0>(8), Return(true)));
EXPECT_EQ(AVERROR_IO, protocol_->url_seek(&context, -8, SEEK_END));
EXPECT_EQ(AVERROR_IO, protocol_->url_seek(&context, -8, SEEK_END));
EXPECT_EQ(AVERROR(EIO), protocol_->url_seek(&context, -8, SEEK_END));
EXPECT_EQ(AVERROR(EIO), protocol_->url_seek(&context, -8, SEEK_END));
EXPECT_EQ(8, protocol_->url_seek(&context, -8, SEEK_END));
// AVSEEK_SIZE should be a straight-through call to GetSize().
@ -293,7 +293,7 @@ TEST_F(FFmpegGlueTest, Seek) {
EXPECT_CALL(*protocol, GetSize(_))
.WillOnce(DoAll(SetArgumentPointee<0>(16), Return(true)));
EXPECT_EQ(AVERROR_IO, protocol_->url_seek(&context, 0, AVSEEK_SIZE));
EXPECT_EQ(AVERROR(EIO), protocol_->url_seek(&context, 0, AVSEEK_SIZE));
EXPECT_EQ(16, protocol_->url_seek(&context, 0, AVSEEK_SIZE));
// Destroy the protocol.

@ -130,7 +130,7 @@ int main(int argc, const char** argv) {
NULL, 0, NULL);
if (result < 0) {
switch (result) {
case AVERROR_NOFMT:
case AVERROR(EINVAL):
std::cerr << "Error: File format not supported "
<< in_path.value() << std::endl;
break;
@ -166,13 +166,13 @@ int main(int argc, const char** argv) {
for (size_t i = 0; i < format_context->nb_streams; ++i) {
AVCodecContext* codec_context = format_context->streams[i]->codec;
if (codec_context->codec_type == CODEC_TYPE_VIDEO && video_stream < 0) {
if (codec_context->codec_type == AVMEDIA_TYPE_VIDEO && video_stream < 0) {
#if SHOW_VERBOSE
*log_out << "V ";
#endif
video_stream = i;
} else {
if (codec_context->codec_type == CODEC_TYPE_AUDIO && audio_stream < 0) {
if (codec_context->codec_type == AVMEDIA_TYPE_AUDIO && audio_stream < 0) {
#if SHOW_VERBOSE
*log_out << "A ";
#endif
@ -186,7 +186,7 @@ int main(int argc, const char** argv) {
#if SHOW_VERBOSE
AVCodec* codec = avcodec_find_decoder(codec_context->codec_id);
if (!codec || (codec_context->codec_type == CODEC_TYPE_UNKNOWN)) {
if (!codec || (codec_context->codec_type == AVMEDIA_TYPE_UNKNOWN)) {
*log_out << "Stream #" << i << ": Unknown" << std::endl;
} else {
// Print out stream information
@ -196,10 +196,10 @@ int main(int argc, const char** argv) {
#endif
}
int target_stream = video_stream;
CodecType target_codec = CODEC_TYPE_VIDEO;
AVMediaType target_codec = AVMEDIA_TYPE_VIDEO;
if (target_stream < 0) {
target_stream = audio_stream;
target_codec = CODEC_TYPE_AUDIO;
target_codec = AVMEDIA_TYPE_AUDIO;
}
// Only continue if we found our target stream.
@ -232,11 +232,8 @@ int main(int argc, const char** argv) {
codec_context->error_recognition = FF_ER_CAREFUL;
// Initialize threaded decode.
if (target_codec == CODEC_TYPE_VIDEO && video_threads > 0) {
if (avcodec_thread_init(codec_context, video_threads) < 0) {
std::cerr << "Warning: Could not initialize threading!\n"
<< "Did you build with pthread/w32thread support?" << std::endl;
}
if (target_codec == AVMEDIA_TYPE_VIDEO && video_threads > 0) {
codec_context->thread_count = video_threads;
}
// Initialize our codec.
@ -291,7 +288,7 @@ int main(int argc, const char** argv) {
// Only decode packets from our target stream.
if (packet.stream_index == target_stream) {
int result = -1;
if (target_codec == CODEC_TYPE_AUDIO) {
if (target_codec == AVMEDIA_TYPE_AUDIO) {
int size_out = AVCODEC_MAX_AUDIO_FRAME_SIZE;
base::TimeTicks decode_start = base::TimeTicks::HighResNow();
@ -323,7 +320,7 @@ int main(int argc, const char** argv) {
MD5Update(&ctx, u8_samples, size_out);
}
}
} else if (target_codec == CODEC_TYPE_VIDEO) {
} else if (target_codec == AVMEDIA_TYPE_VIDEO) {
int got_picture = 0;
base::TimeTicks decode_start = base::TimeTicks::HighResNow();
@ -425,7 +422,7 @@ int main(int argc, const char** argv) {
}
if (sum > 0) {
if (target_codec == CODEC_TYPE_AUDIO) {
if (target_codec == AVMEDIA_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
@ -435,7 +432,7 @@ int main(int argc, const char** argv) {
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) {
} else if (target_codec == AVMEDIA_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.

@ -1,4 +1,4 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// 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.
@ -132,15 +132,15 @@ int main(int argc, const char** argv) {
FilePath out_path;
if (filenames.size() > 1)
out_path = FilePath(filenames[1]);
CodecType target_codec = CODEC_TYPE_UNKNOWN;
AVMediaType target_codec = AVMEDIA_TYPE_UNKNOWN;
// Determine whether to benchmark audio or video decoding.
std::string stream(cmd_line->GetSwitchValueASCII(switches::kStream));
if (!stream.empty()) {
if (stream.compare("audio") == 0) {
target_codec = CODEC_TYPE_AUDIO;
target_codec = AVMEDIA_TYPE_AUDIO;
} else if (stream.compare("video") == 0) {
target_codec = CODEC_TYPE_VIDEO;
target_codec = AVMEDIA_TYPE_VIDEO;
} else {
std::cerr << "Unknown --stream option " << stream << std::endl;
return 1;
@ -239,7 +239,7 @@ int main(int argc, const char** argv) {
NULL, 0, NULL);
if (result < 0) {
switch (result) {
case AVERROR_NOFMT:
case AVERROR(EINVAL):
std::cerr << "Error: File format not supported "
<< in_path.value() << std::endl;
break;
@ -293,7 +293,7 @@ int main(int argc, const char** argv) {
*log_out << " ";
}
if (!codec || (codec_context->codec_type == CODEC_TYPE_UNKNOWN)) {
if (!codec || (codec_context->codec_type == AVMEDIA_TYPE_UNKNOWN)) {
*log_out << "Stream #" << i << ": Unknown" << std::endl;
} else {
// Print out stream information
@ -339,11 +339,8 @@ int main(int argc, const char** argv) {
}
// Initialize threaded decode.
if (target_codec == CODEC_TYPE_VIDEO && video_threads > 0) {
if (avcodec_thread_init(codec_context, video_threads) < 0) {
std::cerr << "Warning: Could not initialize threading!\n"
<< "Did you build with pthread/w32thread support?" << std::endl;
}
if (target_codec == AVMEDIA_TYPE_VIDEO && video_threads > 0) {
codec_context->thread_count = video_threads;
}
// Initialize our codec.
@ -402,7 +399,7 @@ int main(int argc, const char** argv) {
// Only decode packets from our target stream.
if (packet.stream_index == target_stream) {
int result = -1;
if (target_codec == CODEC_TYPE_AUDIO) {
if (target_codec == AVMEDIA_TYPE_AUDIO) {
int size_out = AVCODEC_MAX_AUDIO_FRAME_SIZE;
base::TimeTicks decode_start = base::TimeTicks::HighResNow();
@ -434,7 +431,7 @@ int main(int argc, const char** argv) {
MD5Update(&ctx, u8_samples, size_out);
}
}
} else if (target_codec == CODEC_TYPE_VIDEO) {
} else if (target_codec == AVMEDIA_TYPE_VIDEO) {
int got_picture = 0;
base::TimeTicks decode_start = base::TimeTicks::HighResNow();

@ -127,9 +127,8 @@ void FFmpegVideoDecodeEngine::Initialize(
}
frame_queue_available_.push_back(video_frame);
}
codec_context_->thread_count = decode_threads;
if (codec &&
avcodec_thread_init(codec_context_, decode_threads) >= 0 &&
avcodec_open(codec_context_, codec) >= 0 &&
av_frame_.get() &&
buffer_allocated) {

@ -86,8 +86,6 @@ class FFmpegVideoDecodeEngineTest : public testing::Test,
.WillOnce(Return(&codec_));
EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2))
.WillOnce(Return(0));
EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_))
.WillOnce(Return(0));
EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_))
@ -189,30 +187,6 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
EXPECT_FALSE(info_.success);
}
// Note There are 2 threads for FFmpeg-mt.
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_InitThreadFails) {
// Test avcodec_thread_init() failing.
EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext())
.WillOnce(Return(&codec_context_));
EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264))
.WillOnce(Return(&codec_));
EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2))
.WillOnce(Return(-1));
EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_))
.WillOnce(Return(0));
EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
.Times(1);
EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_))
.Times(1);
EXPECT_CALL(*this, OnInitializeComplete(_))
.WillOnce(SaveInitializeResult(this));
test_engine_->Initialize(MessageLoop::current(), this, NULL, config_);
EXPECT_FALSE(info_.success);
}
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
// Test avcodec_open() failing.
EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext())
@ -221,8 +195,6 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
.WillOnce(Return(&codec_));
EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2))
.WillOnce(Return(0));
EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_))
.WillOnce(Return(-1));
EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_))

@ -15,3 +15,6 @@ BUGCR86570 MAC : platform/gtk/fonts/custom-font-missing-glyphs.html = IMAGE+TEXT
BUGCR86570 MAC : platform/gtk/fonts/font-face-with-complex-text.html = IMAGE+TEXT CRASH
BUGCR86570 MAC : platform/mac/fast/text/myanmar-shaping.html = CRASH
BUGCR86570 MAC : platform/mac/fast/text/thai-combining-mark-positioning.html = CRASH
// needs to be disabled until http://codereview.chromium.org/6993042/ is landed and WebKit is rebased
BUGCR87831 GPU : media/video-currentTime-set.html = TEXT FAIL