summaryrefslogtreecommitdiffstats
path: root/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'media/video')
-rw-r--r--media/video/ffmpeg_video_decode_engine.cc61
-rw-r--r--media/video/ffmpeg_video_decode_engine.h13
-rw-r--r--media/video/ffmpeg_video_decode_engine_unittest.cc82
-rw-r--r--media/video/mft_h264_decode_engine.cc8
-rw-r--r--media/video/mft_h264_decode_engine.h6
-rw-r--r--media/video/omx_video_decode_engine.cc10
-rw-r--r--media/video/omx_video_decode_engine.h6
-rw-r--r--media/video/video_decode_engine.cc59
-rw-r--r--media/video/video_decode_engine.h48
9 files changed, 108 insertions, 185 deletions
diff --git a/media/video/ffmpeg_video_decode_engine.cc b/media/video/ffmpeg_video_decode_engine.cc
index ce6b8f5..786be41 100644
--- a/media/video/ffmpeg_video_decode_engine.cc
+++ b/media/video/ffmpeg_video_decode_engine.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -21,9 +21,8 @@ namespace media {
FFmpegVideoDecodeEngine::FFmpegVideoDecodeEngine()
: codec_context_(NULL),
+ av_stream_(NULL),
event_handler_(NULL),
- frame_rate_numerator_(0),
- frame_rate_denominator_(0),
direct_rendering_(false),
pending_input_buffers_(0),
pending_output_buffers_(0),
@@ -32,10 +31,6 @@ FFmpegVideoDecodeEngine::FFmpegVideoDecodeEngine()
}
FFmpegVideoDecodeEngine::~FFmpegVideoDecodeEngine() {
- if (codec_context_) {
- av_free(codec_context_->extradata);
- av_free(codec_context_);
- }
}
void FFmpegVideoDecodeEngine::Initialize(
@@ -57,27 +52,8 @@ void FFmpegVideoDecodeEngine::Initialize(
static const int kDecodeThreads = 2;
static const int kMaxDecodeThreads = 16;
- // Initialize AVCodecContext structure.
- codec_context_ = avcodec_alloc_context();
-
- // TODO(scherkus): should video format get passed in via VideoCodecConfig?
- codec_context_->pix_fmt = PIX_FMT_YUV420P;
- codec_context_->codec_type = AVMEDIA_TYPE_VIDEO;
- codec_context_->codec_id = VideoCodecToCodecID(config.codec());
- codec_context_->coded_width = config.width();
- codec_context_->coded_height = config.height();
-
- frame_rate_numerator_ = config.frame_rate_numerator();
- frame_rate_denominator_ = config.frame_rate_denominator();
-
- if (config.extra_data() != NULL) {
- codec_context_->extradata_size = config.extra_data_size();
- codec_context_->extradata =
- reinterpret_cast<uint8_t*>(av_malloc(config.extra_data_size()));
- memcpy(codec_context_->extradata, config.extra_data(),
- config.extra_data_size());
- }
-
+ av_stream_ = static_cast<AVStream*>(config.opaque_context);
+ codec_context_ = av_stream_->codec;
// Enable motion vector search (potentially slow), strong deblocking filter
// for damaged macroblocks, and set our error detection sensitivity.
codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
@@ -117,8 +93,8 @@ void FFmpegVideoDecodeEngine::Initialize(
info.provides_buffers = true;
info.stream_info.surface_type = VideoFrame::TYPE_SYSTEM_MEMORY;
info.stream_info.surface_format = GetSurfaceFormat();
- info.stream_info.surface_width = config.width();
- info.stream_info.surface_height = config.height();
+ info.stream_info.surface_width = config.width;
+ info.stream_info.surface_height = config.height;
// If we do not have enough buffers, we will report error too.
bool buffer_allocated = true;
@@ -128,8 +104,8 @@ void FFmpegVideoDecodeEngine::Initialize(
for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) {
scoped_refptr<VideoFrame> video_frame;
VideoFrame::CreateFrame(VideoFrame::YV12,
- config.width(),
- config.height(),
+ config.width,
+ config.height,
kNoTimestamp,
kNoTimestamp,
&video_frame);
@@ -282,15 +258,18 @@ void FFmpegVideoDecodeEngine::DecodeFrame(scoped_refptr<Buffer> buffer) {
// Determine timestamp and calculate the duration based on the repeat picture
// count. According to FFmpeg docs, the total duration can be calculated as
// follows:
- // fps = 1 / time_base
- //
// duration = (1 / fps) + (repeat_pict) / (2 * fps)
// = (2 + repeat_pict) / (2 * fps)
- // = (2 + repeat_pict) / (2 * (1 / time_base))
DCHECK_LE(av_frame_->repeat_pict, 2); // Sanity check.
+ // Even frame rate is fixed, for some streams and codecs, the value of
+ // |codec_context_->time_base| and |av_stream_->time_base| are not the
+ // inverse of the |av_stream_->r_frame_rate|. They use 1 milli-second as
+ // time-base units and use increment of av_packet->pts which is not one.
+ // Use the inverse of |av_stream_->r_frame_rate| instead of time_base.
AVRational doubled_time_base;
- doubled_time_base.num = frame_rate_denominator_;
- doubled_time_base.den = frame_rate_numerator_ * 2;
+ doubled_time_base.den = av_stream_->r_frame_rate.num;
+ doubled_time_base.num = av_stream_->r_frame_rate.den;
+ doubled_time_base.den *= 2;
base::TimeDelta timestamp =
base::TimeDelta::FromMicroseconds(av_frame_->reordered_opaque);
@@ -362,6 +341,14 @@ void FFmpegVideoDecodeEngine::Seek() {
event_handler_->OnSeekComplete();
}
+AVCodecContext* FFmpegVideoDecodeEngine::codec_context() const {
+ return codec_context_;
+}
+
+void FFmpegVideoDecodeEngine::SetCodecContextForTest(AVCodecContext* context) {
+ codec_context_ = context;
+}
+
void FFmpegVideoDecodeEngine::ReadInput() {
DCHECK_EQ(output_eos_reached_, false);
pending_input_buffers_++;
diff --git a/media/video/ffmpeg_video_decode_engine.h b/media/video/ffmpeg_video_decode_engine.h
index b9e76b7..53baa54 100644
--- a/media/video/ffmpeg_video_decode_engine.h
+++ b/media/video/ffmpeg_video_decode_engine.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -14,6 +14,7 @@
// FFmpeg types.
struct AVCodecContext;
struct AVFrame;
+struct AVStream;
namespace media {
@@ -35,21 +36,21 @@ class FFmpegVideoDecodeEngine : public VideoDecodeEngine {
virtual void Flush();
virtual void Seek();
- VideoFrame::Format GetSurfaceFormat() const;
+ virtual AVCodecContext* codec_context() const;
+
+ virtual void SetCodecContextForTest(AVCodecContext* context);
+ VideoFrame::Format GetSurfaceFormat() const;
private:
void DecodeFrame(scoped_refptr<Buffer> buffer);
void ReadInput();
void TryToFinishPendingFlush();
AVCodecContext* codec_context_;
+ AVStream* av_stream_;
scoped_ptr_malloc<AVFrame, ScopedPtrAVFree> av_frame_;
VideoDecodeEngine::EventHandler* event_handler_;
- // Frame rate of the video.
- int frame_rate_numerator_;
- int frame_rate_denominator_;
-
// Whether direct rendering is used.
bool direct_rendering_;
diff --git a/media/video/ffmpeg_video_decode_engine_unittest.cc b/media/video/ffmpeg_video_decode_engine_unittest.cc
index a4e3123..e3bea41 100644
--- a/media/video/ffmpeg_video_decode_engine_unittest.cc
+++ b/media/video/ffmpeg_video_decode_engine_unittest.cc
@@ -23,7 +23,7 @@ namespace media {
static const int kWidth = 320;
static const int kHeight = 240;
-static const AVRational kFrameRate = { 100, 1 };
+static const AVRational kTimeBase = { 1, 100 };
static void InitializeFrame(uint8_t* data, int width, AVFrame* frame) {
frame->data[0] = data;
@@ -35,7 +35,7 @@ static void InitializeFrame(uint8_t* data, int width, AVFrame* frame) {
}
ACTION_P(DecodeComplete, decoder) {
- decoder->set_video_frame(arg0);
+ decoder->video_frame_ = arg0;
}
ACTION_P2(DemuxComplete, engine, buffer) {
@@ -43,27 +43,33 @@ ACTION_P2(DemuxComplete, engine, buffer) {
}
ACTION_P(SaveInitializeResult, engine) {
- engine->set_video_codec_info(arg0);
+ engine->info_ = arg0;
}
class FFmpegVideoDecodeEngineTest : public testing::Test,
public VideoDecodeEngine::EventHandler {
- public:
- FFmpegVideoDecodeEngineTest()
- : config_(kCodecH264, kWidth, kHeight,
- kFrameRate.num, kFrameRate.den, NULL, 0) {
-
+ protected:
+ FFmpegVideoDecodeEngineTest() {
// Setup FFmpeg structures.
frame_buffer_.reset(new uint8[kWidth * kHeight]);
memset(&yuv_frame_, 0, sizeof(yuv_frame_));
InitializeFrame(frame_buffer_.get(), kWidth, &yuv_frame_);
memset(&codec_context_, 0, sizeof(codec_context_));
+ codec_context_.width = kWidth;
+ codec_context_.height = kHeight;
+ codec_context_.time_base = kTimeBase;
+
memset(&codec_, 0, sizeof(codec_));
+ memset(&stream_, 0, sizeof(stream_));
+ stream_.codec = &codec_context_;
+ stream_.r_frame_rate.num = kTimeBase.den;
+ stream_.r_frame_rate.den = kTimeBase.num;
buffer_ = new DataBuffer(1);
test_engine_.reset(new FFmpegVideoDecodeEngine());
+ test_engine_->SetCodecContextForTest(&codec_context_);
VideoFrame::CreateFrame(VideoFrame::YV12,
kWidth,
@@ -78,9 +84,7 @@ class FFmpegVideoDecodeEngineTest : public testing::Test,
}
void Initialize() {
- EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext())
- .WillOnce(Return(&codec_context_));
- EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264))
+ EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_NONE))
.WillOnce(Return(&codec_));
EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
@@ -90,9 +94,11 @@ class FFmpegVideoDecodeEngineTest : public testing::Test,
.WillOnce(Return(0));
EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
.Times(1);
- EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_))
- .Times(1);
+ config_.codec = kCodecH264;
+ config_.opaque_context = &stream_;
+ config_.width = kWidth;
+ config_.height = kHeight;
EXPECT_CALL(*this, OnInitializeComplete(_))
.WillOnce(SaveInitializeResult(this));
test_engine_->Initialize(MessageLoop::current(), this, NULL, config_);
@@ -120,7 +126,7 @@ class FFmpegVideoDecodeEngineTest : public testing::Test,
codec_context_.height = height;
}
- // VideoDecodeEngine::EventHandler implementation.
+ public:
MOCK_METHOD2(ConsumeVideoFrame,
void(scoped_refptr<VideoFrame> video_frame,
const PipelineStatistics& statistics));
@@ -134,30 +140,20 @@ class FFmpegVideoDecodeEngineTest : public testing::Test,
MOCK_METHOD0(OnError, void());
MOCK_METHOD1(OnFormatChange, void(VideoStreamInfo stream_info));
- // Used by gmock actions.
- void set_video_frame(scoped_refptr<VideoFrame> video_frame) {
- video_frame_ = video_frame;
- }
-
- void set_video_codec_info(const VideoCodecInfo& info) {
- info_ = info;
- }
-
- protected:
+ scoped_refptr<VideoFrame> video_frame_;
VideoCodecConfig config_;
VideoCodecInfo info_;
- scoped_refptr<VideoFrame> video_frame_;
+ protected:
scoped_ptr<FFmpegVideoDecodeEngine> test_engine_;
scoped_array<uint8_t> frame_buffer_;
StrictMock<MockFFmpeg> mock_ffmpeg_;
AVFrame yuv_frame_;
AVCodecContext codec_context_;
+ AVStream stream_;
AVCodec codec_;
scoped_refptr<DataBuffer> buffer_;
- private:
- DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecodeEngineTest);
};
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) {
@@ -166,17 +162,17 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) {
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
// Test avcodec_find_decoder() returning NULL.
- EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext())
- .WillOnce(Return(&codec_context_));
- EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264))
+ EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_NONE))
.WillOnce(ReturnNull());
EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
.Times(1);
- EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_))
- .Times(1);
+ config_.codec = kCodecH264;
+ config_.opaque_context = &stream_;
+ config_.width = kWidth;
+ config_.height = kHeight;
EXPECT_CALL(*this, OnInitializeComplete(_))
.WillOnce(SaveInitializeResult(this));
test_engine_->Initialize(MessageLoop::current(), this, NULL, config_);
@@ -186,9 +182,7 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
// 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))
+ EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_NONE))
.WillOnce(Return(&codec_));
EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
@@ -196,9 +190,11 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_InitThreadFails) {
.WillOnce(Return(-1));
EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
.Times(1);
- EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_))
- .Times(1);
+ config_.codec = kCodecH264;
+ config_.opaque_context = &stream_;
+ config_.width = kWidth;
+ config_.height = kHeight;
EXPECT_CALL(*this, OnInitializeComplete(_))
.WillOnce(SaveInitializeResult(this));
test_engine_->Initialize(MessageLoop::current(), this, NULL, config_);
@@ -207,9 +203,7 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_InitThreadFails) {
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
// Test avcodec_open() failing.
- EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext())
- .WillOnce(Return(&codec_context_));
- EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264))
+ EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_NONE))
.WillOnce(Return(&codec_));
EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
@@ -219,9 +213,11 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
.WillOnce(Return(-1));
EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
.Times(1);
- EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_))
- .Times(1);
+ config_.codec = kCodecH264;
+ config_.opaque_context = &stream_;
+ config_.width = kWidth;
+ config_.height = kHeight;
EXPECT_CALL(*this, OnInitializeComplete(_))
.WillOnce(SaveInitializeResult(this));
test_engine_->Initialize(MessageLoop::current(), this, NULL, config_);
@@ -314,8 +310,6 @@ TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) {
}
TEST_F(FFmpegVideoDecodeEngineTest, GetSurfaceFormat) {
- Initialize();
-
// YV12 formats.
codec_context_.pix_fmt = PIX_FMT_YUV420P;
EXPECT_EQ(VideoFrame::YV12, test_engine_->GetSurfaceFormat());
diff --git a/media/video/mft_h264_decode_engine.cc b/media/video/mft_h264_decode_engine.cc
index 4acfc7f..bb3143c 100644
--- a/media/video/mft_h264_decode_engine.cc
+++ b/media/video/mft_h264_decode_engine.cc
@@ -151,12 +151,11 @@ const GUID ConvertVideoFrameFormatToGuid(VideoFrame::Format format) {
MftH264DecodeEngine::MftH264DecodeEngine(bool use_dxva)
: use_dxva_(use_dxva),
state_(kUninitialized),
- width_(0),
- height_(0),
event_handler_(NULL),
context_(NULL) {
memset(&input_stream_info_, 0, sizeof(input_stream_info_));
memset(&output_stream_info_, 0, sizeof(output_stream_info_));
+ memset(&config_, 0, sizeof(config_));
memset(&info_, 0, sizeof(info_));
}
@@ -178,6 +177,7 @@ void MftH264DecodeEngine::Initialize(
return;
}
context_ = context;
+ config_ = config;
event_handler_ = event_handler;
info_.provides_buffers = true;
@@ -473,8 +473,8 @@ bool MftH264DecodeEngine::SetDecodeEngineOutputMediaType(const GUID subtype) {
hr = MFGetAttributeSize(out_media_type, MF_MT_FRAME_SIZE,
reinterpret_cast<UINT32*>(&info_.stream_info.surface_width),
reinterpret_cast<UINT32*>(&info_.stream_info.surface_height));
- width_ = info_.stream_info.surface_width;
- height_ = info_.stream_info.surface_height;
+ config_.width = info_.stream_info.surface_width;
+ config_.height = info_.stream_info.surface_height;
if (FAILED(hr)) {
LOG(ERROR) << "Failed to SetOutputType to |subtype| or obtain "
<< "width/height " << std::hex << hr;
diff --git a/media/video/mft_h264_decode_engine.h b/media/video/mft_h264_decode_engine.h
index 9ce7935..d543631 100644
--- a/media/video/mft_h264_decode_engine.h
+++ b/media/video/mft_h264_decode_engine.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
//
@@ -88,10 +88,8 @@ class MftH264DecodeEngine : public media::VideoDecodeEngine {
State state_;
- int width_;
- int height_;
-
VideoDecodeEngine::EventHandler* event_handler_;
+ VideoCodecConfig config_;
VideoCodecInfo info_;
VideoDecodeContext* context_;
diff --git a/media/video/omx_video_decode_engine.cc b/media/video/omx_video_decode_engine.cc
index a6996d3..df3f9cf 100644
--- a/media/video/omx_video_decode_engine.cc
+++ b/media/video/omx_video_decode_engine.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -90,8 +90,8 @@ void OmxVideoDecodeEngine::Initialize(
message_loop_ = message_loop;
event_handler_ = event_handler;
- width_ = config.width();
- height_ = config.height();
+ width_ = config.width;
+ height_ = config.height;
// TODO(wjia): Find the right way to determine the codec type.
OmxConfigurator::MediaFormat input_format, output_format;
@@ -115,8 +115,8 @@ void OmxVideoDecodeEngine::Initialize(
uses_egl_image_ ? VideoFrame::TYPE_GL_TEXTURE
: VideoFrame::TYPE_SYSTEM_MEMORY;
info.stream_info.surface_format = GetSurfaceFormat();
- info.stream_info.surface_width = config.width();
- info.stream_info.surface_height = config.height();
+ info.stream_info.surface_width = config.width;
+ info.stream_info.surface_height = config.height;
event_handler_->OnInitializeComplete(info);
}
diff --git a/media/video/omx_video_decode_engine.h b/media/video/omx_video_decode_engine.h
index 1609548..9a6c0a7 100644
--- a/media/video/omx_video_decode_engine.h
+++ b/media/video/omx_video_decode_engine.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -175,8 +175,8 @@ class OmxVideoDecodeEngine : public VideoDecodeEngine {
scoped_refptr<VideoFrame> CreateOmxBufferVideoFrame(
OMX_BUFFERHEADERTYPE* omx_buffer);
- int width_;
- int height_;
+ size_t width_;
+ size_t height_;
MessageLoop* message_loop_;
diff --git a/media/video/video_decode_engine.cc b/media/video/video_decode_engine.cc
index ca0093f..04f3bea 100644
--- a/media/video/video_decode_engine.cc
+++ b/media/video/video_decode_engine.cc
@@ -1,61 +1,18 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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/video/video_decode_engine.h"
-#include "base/logging.h"
-
namespace media {
-VideoCodecConfig::VideoCodecConfig(VideoCodec codec,
- int width,
- int height,
- int frame_rate_numerator,
- int frame_rate_denominator,
- uint8* extra_data,
- size_t extra_data_size)
- : codec_(codec),
- width_(width),
- height_(height),
- frame_rate_numerator_(frame_rate_numerator),
- frame_rate_denominator_(frame_rate_denominator),
- extra_data_size_(extra_data_size) {
- CHECK(extra_data_size_ == 0 || extra_data);
- if (extra_data_size_ > 0) {
- extra_data_.reset(new uint8[extra_data_size_]);
- memcpy(extra_data_.get(), extra_data, extra_data_size_);
- }
-}
-
-VideoCodecConfig::~VideoCodecConfig() {}
-
-VideoCodec VideoCodecConfig::codec() const {
- return codec_;
-}
-
-int VideoCodecConfig::width() const {
- return width_;
-}
-
-int VideoCodecConfig::height() const {
- return height_;
-}
-
-int VideoCodecConfig::frame_rate_numerator() const {
- return frame_rate_numerator_;
-}
-
-int VideoCodecConfig::frame_rate_denominator() const {
- return frame_rate_denominator_;
-}
-
-uint8* VideoCodecConfig::extra_data() const {
- return extra_data_.get();
-}
-
-size_t VideoCodecConfig::extra_data_size() const {
- return extra_data_size_;
+VideoCodecConfig::VideoCodecConfig()
+ : codec(kCodecH264),
+ profile(kProfileDoNotCare),
+ level(kLevelDoNotCare),
+ width(0),
+ height(0),
+ opaque_context(NULL) {
}
} // namespace media
diff --git a/media/video/video_decode_engine.h b/media/video/video_decode_engine.h
index 5893b3a..57b76a2 100644
--- a/media/video/video_decode_engine.h
+++ b/media/video/video_decode_engine.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -6,7 +6,6 @@
#define MEDIA_VIDEO_VIDEO_DECODE_ENGINE_H_
#include "base/callback.h"
-#include "base/scoped_ptr.h"
#include "media/base/video_frame.h"
class MessageLoop;
@@ -19,7 +18,6 @@ class VideoDecodeContext;
struct PipelineStatistics;
enum VideoCodec {
- kUnknown,
kCodecH264,
kCodecVC1,
kCodecMPEG2,
@@ -28,38 +26,26 @@ enum VideoCodec {
kCodecVP8,
};
-class VideoCodecConfig {
- public:
- VideoCodecConfig(VideoCodec codec, int width, int height,
- int frame_rate_numerator, int frame_rate_denominator,
- uint8* extra_data, size_t extra_data_size);
- ~VideoCodecConfig();
-
- VideoCodec codec() const;
- int width() const;
- int height() const;
- int frame_rate_numerator() const;
- int frame_rate_denominator() const;
- uint8* extra_data() const;
- size_t extra_data_size() const;
-
- private:
- VideoCodec codec_;
+static const uint32 kProfileDoNotCare = static_cast<uint32>(-1);
+static const uint32 kLevelDoNotCare = static_cast<uint32>(-1);
- // Container's concept of width and height of this video.
- int width_;
- int height_;
+struct VideoCodecConfig {
+ VideoCodecConfig();
- // Frame rate in seconds expressed as a fraction.
- // TODO(scherkus): fairly certain decoders don't require frame rates.
- int frame_rate_numerator_;
- int frame_rate_denominator_;
+ VideoCodec codec;
- // Optional byte data requied to initialize video decoders.
- scoped_array<uint8> extra_data_;
- size_t extra_data_size_;
+ // TODO(jiesun): video profile and level are specific to individual codec.
+ // Define enum to.
+ uint32 profile;
+ uint32 level;
+
+ // Container's concept of width and height of this video.
+ int32 width;
+ int32 height; // TODO(jiesun): Do we allow height to be negative to
+ // indicate output is upside-down?
- DISALLOW_COPY_AND_ASSIGN(VideoCodecConfig);
+ // FFMPEG's will use this to pass AVStream. Otherwise, we should remove this.
+ void* opaque_context;
};
struct VideoStreamInfo {