diff options
author | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-13 21:30:33 +0000 |
---|---|---|
committer | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-13 21:30:33 +0000 |
commit | 17d4f3df2f94a479c9486a86737bcff756008781 (patch) | |
tree | aece0bc00b0ded1aa0d8754575a2daf6d6313fd6 /media | |
parent | 24fe6f1e5832c4351cc973a6ef887d635517d7a1 (diff) | |
download | chromium_src-17d4f3df2f94a479c9486a86737bcff756008781.zip chromium_src-17d4f3df2f94a479c9486a86737bcff756008781.tar.gz chromium_src-17d4f3df2f94a479c9486a86737bcff756008781.tar.bz2 |
media: bit stream converter
we need enable bitstream converter by which decoder is actually in pipeline.
instead of use command line.
Review URL: http://codereview.chromium.org/3159014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56095 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/filters.h | 2 | ||||
-rw-r--r-- | media/base/mock_filters.h | 1 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer.cc | 51 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer.h | 5 | ||||
-rw-r--r-- | media/filters/omx_video_decoder.cc | 3 |
5 files changed, 32 insertions, 30 deletions
diff --git a/media/base/filters.h b/media/base/filters.h index e9d2c27..62fab2d 100644 --- a/media/base/filters.h +++ b/media/base/filters.h @@ -256,6 +256,8 @@ class DemuxerStream : public base::RefCountedThreadSafe<DemuxerStream> { return (NULL != i); }; + virtual void EnableBitstreamConverter() = 0; + protected: // Optional method that is implemented by filters that support extended // interfaces. The filter should return a pointer to the interface diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index 7f1bdaf..6438916 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -147,6 +147,7 @@ class MockDemuxerStream : public DemuxerStream { MOCK_METHOD0(media_format, const MediaFormat&()); MOCK_METHOD1(Read, void(Callback1<Buffer*>::Type* read_callback)); MOCK_METHOD1(QueryInterface, void*(const char* interface_id)); + MOCK_METHOD0(EnableBitstreamConverter, void()); protected: virtual ~MockDemuxerStream() {} diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc index 7a74d13..c871343 100644 --- a/media/filters/ffmpeg_demuxer.cc +++ b/media/filters/ffmpeg_demuxer.cc @@ -205,9 +205,29 @@ void FFmpegDemuxerStream::FulfillPendingRead() { read_callback->Run(buffer); } -void FFmpegDemuxerStream::SetBitstreamConverter( - BitstreamConverter* converter) { - bitstream_converter_.reset(converter); +void FFmpegDemuxerStream::EnableBitstreamConverter() { + // Called by hardware decoder to require different bitstream converter. + // Currently we assume that converter is determined by codec_id; + DCHECK(stream_); + + const char* filter_name = NULL; + if (stream_->codec->codec_id == CODEC_ID_H264) { + filter_name = "h264_mp4toannexb"; + } else if (stream_->codec->codec_id == CODEC_ID_MPEG4) { + filter_name = "mpeg4video_es"; + } else if (stream_->codec->codec_id == CODEC_ID_WMV3) { + filter_name = "vc1_asftorcv"; + } else if (stream_->codec->codec_id == CODEC_ID_VC1) { + filter_name = "vc1_asftoannexg"; + } else { + NOTREACHED(); + } + + if (filter_name) { + bitstream_converter_.reset( + new FFmpegBitstreamConverter(filter_name, stream_->codec)); + CHECK(bitstream_converter_->Initialize()); + } } // static @@ -424,31 +444,6 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source, FFmpegDemuxerStream* demuxer_stream = new FFmpegDemuxerStream(this, stream); - // Initialize the bitstream if OpenMAX is enabled. - // TODO(hclam): Should be enabled by the decoder. - CommandLine* cmd = CommandLine::ForCurrentProcess(); - if (cmd->HasSwitch(switches::kEnableAcceleratedDecoding)) { - // TODO(ajwong): Unittest this branch of the if statement. - // TODO(hclam): In addition to codec we should also check the container. - const char* filter_name = NULL; - if (stream->codec->codec_id == CODEC_ID_H264) { - filter_name = "h264_mp4toannexb"; - } else if (stream->codec->codec_id == CODEC_ID_MPEG4) { - filter_name = "mpeg4video_es"; - } else if (stream->codec->codec_id == CODEC_ID_WMV3) { - filter_name = "vc1_asftorcv"; - } else if (stream->codec->codec_id == CODEC_ID_VC1) { - filter_name = "vc1_asftoannexg"; - } - - if (filter_name) { - BitstreamConverter* bitstream_converter = - new FFmpegBitstreamConverter(filter_name, codec_context); - CHECK(bitstream_converter->Initialize()); - demuxer_stream->SetBitstreamConverter(bitstream_converter); - } - } - DCHECK(demuxer_stream); streams_.push_back(demuxer_stream); packet_streams_.push_back(demuxer_stream); diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h index bb52ce4..ef74abe 100644 --- a/media/filters/ffmpeg_demuxer.h +++ b/media/filters/ffmpeg_demuxer.h @@ -75,12 +75,13 @@ class FFmpegDemuxerStream : public DemuxerStream, public AVStreamProvider { // DemuxerStream implementation. virtual const MediaFormat& media_format(); virtual void Read(Callback1<Buffer*>::Type* read_callback); + // Bitstream converter to convert input packet. + void EnableBitstreamConverter(); // AVStreamProvider implementation. virtual AVStream* GetAVStream() { return stream_; } - // Bitstream converter to convert input packet. - void SetBitstreamConverter(BitstreamConverter* converter); + protected: virtual void* QueryInterface(const char* interface_id); diff --git a/media/filters/omx_video_decoder.cc b/media/filters/omx_video_decoder.cc index 663e489..2c96117 100644 --- a/media/filters/omx_video_decoder.cc +++ b/media/filters/omx_video_decoder.cc @@ -69,6 +69,9 @@ void OmxVideoDecoder::Initialize(DemuxerStream* demuxer_stream, initialize_callback_.reset(callback); demuxer_stream_ = demuxer_stream; + // We require bit stream converter for openmax hardware decoder. + demuxer_stream->EnableBitstreamConverter(); + // Get the AVStream by querying for the provider interface. AVStreamProvider* av_stream_provider; if (!demuxer_stream->QueryInterface(&av_stream_provider)) { |