summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-11 22:31:24 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-11 22:31:24 +0000
commit0b5f7e52bab18455a11ea763ae424f30755dc20f (patch)
treeddcfd55906e694285269a2bf683175d2320cab95 /chrome
parent33cdc9b854044864f7494c23a21f78733a961236 (diff)
downloadchromium_src-0b5f7e52bab18455a11ea763ae424f30755dc20f.zip
chromium_src-0b5f7e52bab18455a11ea763ae424f30755dc20f.tar.gz
chromium_src-0b5f7e52bab18455a11ea763ae424f30755dc20f.tar.bz2
Remove FFmpegVideoDecodeEngine's dependency on AVStream (again).
First step of many towards removing DemuxerStream::QueryInterface, AVStreamProvider, and MediaFormat. This time without memory leaks! BUG=28206 TEST=media_unittests git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77875 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/gpu/gpu_video_decoder.cc19
-rw-r--r--chrome/gpu/gpu_video_decoder.h3
-rw-r--r--chrome/gpu/media/fake_gl_video_decode_engine.cc6
-rw-r--r--chrome/renderer/gpu_video_decoder_host.cc54
-rw-r--r--chrome/renderer/gpu_video_decoder_host.h10
-rw-r--r--chrome/renderer/gpu_video_decoder_host_unittest.cc16
-rw-r--r--chrome/renderer/media/ipc_video_decoder.cc18
7 files changed, 72 insertions, 54 deletions
diff --git a/chrome/gpu/gpu_video_decoder.cc b/chrome/gpu/gpu_video_decoder.cc
index ca72c40..96be0c3 100644
--- a/chrome/gpu/gpu_video_decoder.cc
+++ b/chrome/gpu/gpu_video_decoder.cc
@@ -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.
@@ -86,7 +86,8 @@ void GpuVideoDecoder::OnInitializeComplete(const VideoCodecInfo& info) {
}
// TODO(jiesun): Check the assumption of input size < original size.
- param.input_buffer_size = config_.width * config_.height * 3 / 2;
+ param.input_buffer_size =
+ info.stream_info.surface_width * info.stream_info.surface_height * 3 / 2;
if (!CreateInputTransferBuffer(param.input_buffer_size,
&param.input_buffer_handle)) {
SendInitializeDone(param);
@@ -249,7 +250,6 @@ GpuVideoDecoder::GpuVideoDecoder(
sender_(sender),
renderer_handle_(handle),
gles2_decoder_(decoder) {
- memset(&config_, 0, sizeof(config_));
memset(&info_, 0, sizeof(info_));
// TODO(jiesun): find a better way to determine which VideoDecodeEngine
@@ -272,11 +272,14 @@ GpuVideoDecoder::~GpuVideoDecoder() {}
void GpuVideoDecoder::OnInitialize(const GpuVideoDecoderInitParam& param) {
// TODO(jiesun): codec id should come from |param|.
- config_.codec = media::kCodecH264;
- config_.width = param.width;
- config_.height = param.height;
- config_.opaque_context = NULL;
- decode_engine_->Initialize(message_loop_, this, this, config_);
+ media::VideoCodecConfig config(media::kCodecH264,
+ param.width,
+ param.height,
+ param.frame_rate_num,
+ param.frame_rate_den,
+ NULL,
+ 0);
+ decode_engine_->Initialize(message_loop_, this, this, config);
}
void GpuVideoDecoder::OnUninitialize() {
diff --git a/chrome/gpu/gpu_video_decoder.h b/chrome/gpu/gpu_video_decoder.h
index bda31c7..92bbb70 100644
--- a/chrome/gpu/gpu_video_decoder.h
+++ b/chrome/gpu/gpu_video_decoder.h
@@ -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.
@@ -201,7 +201,6 @@ class GpuVideoDecoder
typedef std::map<int32, scoped_refptr<media::VideoFrame> > VideoFrameMap;
VideoFrameMap video_frame_map_;
- media::VideoCodecConfig config_;
media::VideoCodecInfo info_;
DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder);
diff --git a/chrome/gpu/media/fake_gl_video_decode_engine.cc b/chrome/gpu/media/fake_gl_video_decode_engine.cc
index 0e6a696..2c68f11 100644
--- a/chrome/gpu/media/fake_gl_video_decode_engine.cc
+++ b/chrome/gpu/media/fake_gl_video_decode_engine.cc
@@ -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.
@@ -25,8 +25,8 @@ void FakeGlVideoDecodeEngine::Initialize(
const media::VideoCodecConfig& config) {
handler_ = event_handler;
context_ = context;
- width_ = config.width;
- height_ = config.height;
+ width_ = config.width();
+ height_ = config.height();
// Create an internal VideoFrame that we can write to. This is going to be
// uploaded through VideoDecodeContext.
diff --git a/chrome/renderer/gpu_video_decoder_host.cc b/chrome/renderer/gpu_video_decoder_host.cc
index f031ab7..5afa69c 100644
--- a/chrome/renderer/gpu_video_decoder_host.cc
+++ b/chrome/renderer/gpu_video_decoder_host.cc
@@ -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.
@@ -19,12 +19,13 @@ GpuVideoDecoderHost::GpuVideoDecoderHost(MessageRouter* router,
message_loop_(NULL),
event_handler_(NULL),
context_(NULL),
+ width_(0),
+ height_(0),
state_(kStateUninitialized),
decoder_host_id_(decoder_host_id),
decoder_id_(0),
input_buffer_busy_(false),
current_frame_id_(0) {
- memset(&config_, 0, sizeof(config_));
}
GpuVideoDecoderHost::~GpuVideoDecoderHost() {}
@@ -65,33 +66,21 @@ bool GpuVideoDecoderHost::OnMessageReceived(const IPC::Message& msg) {
void GpuVideoDecoderHost::Initialize(
MessageLoop* message_loop, VideoDecodeEngine::EventHandler* event_handler,
media::VideoDecodeContext* context, const media::VideoCodecConfig& config) {
- if (MessageLoop::current() != message_loop) {
- message_loop->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &GpuVideoDecoderHost::Initialize, message_loop,
- event_handler, context, config));
- return;
- }
-
- // Initialization operations should be performed on the message loop assigned.
- // Save the parameters and post a task to complete initialization.
DCHECK_EQ(kStateUninitialized, state_);
DCHECK(!message_loop_);
message_loop_ = message_loop;
event_handler_ = event_handler;
context_ = context;
- config_ = config;
-
- // Add the route so we'll receive messages.
- router_->AddRoute(decoder_host_id_, this);
+ width_ = config.width();
+ height_ = config.height();
- if (!ipc_sender_->Send(
- new GpuChannelMsg_CreateVideoDecoder(context_route_id_,
- decoder_host_id_))) {
- LOG(ERROR) << "GpuChannelMsg_CreateVideoDecoder failed";
- event_handler_->OnError();
+ if (MessageLoop::current() != message_loop) {
+ message_loop->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &GpuVideoDecoderHost::CreateVideoDecoder));
return;
}
+ CreateVideoDecoder();
}
void GpuVideoDecoderHost::ConsumeVideoSample(scoped_refptr<Buffer> buffer) {
@@ -190,14 +179,29 @@ void GpuVideoDecoderHost::Seek() {
}
}
+void GpuVideoDecoderHost::CreateVideoDecoder() {
+ DCHECK_EQ(message_loop_, MessageLoop::current());
+
+ // Add the route so we'll receive messages.
+ router_->AddRoute(decoder_host_id_, this);
+
+ if (!ipc_sender_->Send(
+ new GpuChannelMsg_CreateVideoDecoder(context_route_id_,
+ decoder_host_id_))) {
+ LOG(ERROR) << "GpuChannelMsg_CreateVideoDecoder failed";
+ event_handler_->OnError();
+ return;
+ }
+}
+
void GpuVideoDecoderHost::OnCreateVideoDecoderDone(int32 decoder_id) {
DCHECK_EQ(message_loop_, MessageLoop::current());
decoder_id_ = decoder_id;
// TODO(hclam): Initialize |param| with the right values.
GpuVideoDecoderInitParam param;
- param.width = config_.width;
- param.height = config_.height;
+ param.width = width_;
+ param.height = height_;
if (!ipc_sender_->Send(
new GpuVideoDecoderMsg_Initialize(decoder_id, param))) {
@@ -225,8 +229,8 @@ void GpuVideoDecoderHost::OnInitializeDone(
// TODO(hclam): Need to fill in more information.
media::VideoCodecInfo info;
info.success = success;
- info.stream_info.surface_width = config_.width;
- info.stream_info.surface_height = config_.height;
+ info.stream_info.surface_width = width_;
+ info.stream_info.surface_height = height_;
event_handler_->OnInitializeComplete(info);
}
diff --git a/chrome/renderer/gpu_video_decoder_host.h b/chrome/renderer/gpu_video_decoder_host.h
index b5c7178..34b5903 100644
--- a/chrome/renderer/gpu_video_decoder_host.h
+++ b/chrome/renderer/gpu_video_decoder_host.h
@@ -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.
@@ -75,6 +75,9 @@ class GpuVideoDecoderHost : public media::VideoDecodeEngine,
kStateFlushing,
};
+ // Takes care of sending IPC message to create a video decoder.
+ void CreateVideoDecoder();
+
// Handlers for messages received from the GPU process.
void OnCreateVideoDecoderDone(int32 decoder_id);
void OnInitializeDone(const GpuVideoDecoderInitDoneParam& param);
@@ -124,8 +127,9 @@ class GpuVideoDecoderHost : public media::VideoDecodeEngine,
// A Context for allocating video frame textures.
media::VideoDecodeContext* context_;
- // Hold information about GpuVideoDecoder configuration.
- media::VideoCodecConfig config_;
+ // Dimensions of the video.
+ int width_;
+ int height_;
// Current state of video decoder.
GpuVideoDecoderHostState state_;
diff --git a/chrome/renderer/gpu_video_decoder_host_unittest.cc b/chrome/renderer/gpu_video_decoder_host_unittest.cc
index 7d23f1d..6186e48 100644
--- a/chrome/renderer/gpu_video_decoder_host_unittest.cc
+++ b/chrome/renderer/gpu_video_decoder_host_unittest.cc
@@ -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.
@@ -23,6 +23,8 @@ static const int kDecoderId = 51;
static const int kVideoFrames = 3;
static const int kWidth = 320;
static const int kHeight = 240;
+static const int kFrameRateNumerator = 25;
+static const int kFrameRateDenominator = 1;
static const int kTransportBufferSize = 1024;
ACTION_P(SimulateAllocateVideoFrames, frames) {
@@ -128,10 +130,14 @@ class GpuVideoDecoderHostTest : public testing::Test,
.WillOnce(SendMessage(decoder_host_.get(), msg2));
EXPECT_CALL(*this, OnInitializeComplete(_));
- media::VideoCodecConfig config;
- config.codec = media::kCodecH264;
- config.width = kWidth;
- config.height = kHeight;
+ media::VideoCodecConfig config(
+ media::kCodecH264,
+ kWidth,
+ kHeight,
+ kFrameRateNumerator,
+ kFrameRateDenominator,
+ NULL,
+ 0);
decoder_host_->Initialize(&message_loop_, this, &context_, config);
message_loop_.RunAllPending();
}
diff --git a/chrome/renderer/media/ipc_video_decoder.cc b/chrome/renderer/media/ipc_video_decoder.cc
index eeaebf3..9593cfb 100644
--- a/chrome/renderer/media/ipc_video_decoder.cc
+++ b/chrome/renderer/media/ipc_video_decoder.cc
@@ -52,8 +52,8 @@ void IpcVideoDecoder::Initialize(media::DemuxerStream* demuxer_stream,
AVStream* av_stream = av_stream_provider->GetAVStream();
- int width = av_stream->codec->width;
- int height = av_stream->codec->height;
+ int width = av_stream->codec->coded_width;
+ int height = av_stream->codec->coded_height;
if (width > media::Limits::kMaxDimension ||
height > media::Limits::kMaxDimension ||
(width * height) > media::Limits::kMaxCanvas) {
@@ -71,16 +71,18 @@ void IpcVideoDecoder::Initialize(media::DemuxerStream* demuxer_stream,
// Create a hardware video decoder handle.
decode_engine_.reset(ggl::CreateVideoDecodeEngine(ggl_context_));
- // Initialize hardware decoder.
- media::VideoCodecConfig param;
- memset(&param, 0, sizeof(param));
- param.width = width;
- param.height = height;
+ media::VideoCodecConfig config(
+ media::CodecIDToVideoCodec(av_stream->codec->codec_id),
+ width, height,
+ av_stream->r_frame_rate.num,
+ av_stream->r_frame_rate.den,
+ av_stream->codec->extradata,
+ av_stream->codec->extradata_size);
// VideoDecodeEngine will perform initialization on the message loop
// given to it so it doesn't matter on which thread we are calling this.
decode_engine_->Initialize(ChildProcess::current()->io_message_loop(), this,
- decode_context_.get(), param);
+ decode_context_.get(), config);
}
const media::MediaFormat& IpcVideoDecoder::media_format() {