summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 10:11:21 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 10:11:21 +0000
commit468c59edfa51ea485c46c3cfd944e8df8f8c2d83 (patch)
tree58ba0a3fc3ff8226f31d1c1136a5ae5a50023336 /media
parentf1e7aece82004ac5ce9f700216c246b3295057fa (diff)
downloadchromium_src-468c59edfa51ea485c46c3cfd944e8df8f8c2d83.zip
chromium_src-468c59edfa51ea485c46c3cfd944e8df8f8c2d83.tar.gz
chromium_src-468c59edfa51ea485c46c3cfd944e8df8f8c2d83.tar.bz2
Add VideoDecoder::NeedsBitStreamConversion().
In the future world where VideoDecoder doesn't talk to DemuxerStream directly (see issue 141788), the owner of the VideoDecoder (e.g. VideoFrameStream) needs to get the info about whether the decoder needs bitstream conversion so that it can call DemuxerStream::EnableBitstreamConverter() accordingly. BUG=141788,240342 TEST=Current media_unittests pass. Review URL: https://chromiumcodereview.appspot.com/15140002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/video_decoder.cc4
-rw-r--r--media/base/video_decoder.h3
-rw-r--r--media/filters/gpu_video_decoder.cc10
-rw-r--r--media/filters/gpu_video_decoder.h3
-rw-r--r--media/filters/video_frame_stream.cc5
5 files changed, 21 insertions, 4 deletions
diff --git a/media/base/video_decoder.cc b/media/base/video_decoder.cc
index dd1ab7c..ba47bae 100644
--- a/media/base/video_decoder.cc
+++ b/media/base/video_decoder.cc
@@ -14,6 +14,10 @@ bool VideoDecoder::HasAlpha() const {
return false;
}
+bool VideoDecoder::NeedsBitstreamConversion() const {
+ return false;
+}
+
bool VideoDecoder::HasOutputFrameAvailable() const {
return true;
}
diff --git a/media/base/video_decoder.h b/media/base/video_decoder.h
index 77e3ee8..6a4f66a 100644
--- a/media/base/video_decoder.h
+++ b/media/base/video_decoder.h
@@ -81,6 +81,9 @@ class MEDIA_EXPORT VideoDecoder {
// that return formats with an alpha channel.
virtual bool HasAlpha() const;
+ // Returns true if the decoder needs bitstream conversion before decoding.
+ virtual bool NeedsBitstreamConversion() const;
+
// Returns true if the decoder currently has the ability to decode and return
// a VideoFrame. Most implementations can allocate a new VideoFrame and hence
// this will always return true. Override and return false for decoders that
diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc
index 155f23c..3a5f018 100644
--- a/media/filters/gpu_video_decoder.cc
+++ b/media/filters/gpu_video_decoder.cc
@@ -161,6 +161,7 @@ GpuVideoDecoder::GpuVideoDecoder(
const scoped_refptr<base::MessageLoopProxy>& message_loop,
const scoped_refptr<Factories>& factories)
: demuxer_stream_(NULL),
+ needs_bitstream_conversion_(false),
gvd_loop_proxy_(message_loop),
weak_factory_(this),
vda_loop_proxy_(factories->GetMessageLoop()),
@@ -270,11 +271,9 @@ void GpuVideoDecoder::Initialize(DemuxerStream* stream,
return;
}
- if (config.codec() == kCodecH264)
- stream->EnableBitstreamConverter();
-
demuxer_stream_ = stream;
statistics_cb_ = statistics_cb;
+ needs_bitstream_conversion_ = (config.codec() == kCodecH264);
DVLOG(1) << "GpuVideoDecoder::Initialize() succeeded.";
PostTaskAndReplyWithResult(
@@ -477,6 +476,11 @@ bool GpuVideoDecoder::HasAlpha() const {
return true;
}
+bool GpuVideoDecoder::NeedsBitstreamConversion() const {
+ DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
+ return needs_bitstream_conversion_;
+}
+
bool GpuVideoDecoder::HasOutputFrameAvailable() const {
DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
return available_pictures_ > 0;
diff --git a/media/filters/gpu_video_decoder.h b/media/filters/gpu_video_decoder.h
index e9deefa..00a10be 100644
--- a/media/filters/gpu_video_decoder.h
+++ b/media/filters/gpu_video_decoder.h
@@ -85,6 +85,7 @@ class MEDIA_EXPORT GpuVideoDecoder
virtual void Reset(const base::Closure& closure) OVERRIDE;
virtual void Stop(const base::Closure& closure) OVERRIDE;
virtual bool HasAlpha() const OVERRIDE;
+ virtual bool NeedsBitstreamConversion() const OVERRIDE;
virtual bool HasOutputFrameAvailable() const OVERRIDE;
// VideoDecodeAccelerator::Client implementation.
@@ -168,6 +169,8 @@ class MEDIA_EXPORT GpuVideoDecoder
// Pointer to the demuxer stream that will feed us compressed buffers.
DemuxerStream* demuxer_stream_;
+ bool needs_bitstream_conversion_;
+
// Message loop on which to fire callbacks and trampoline calls to this class
// if they arrive on other loops.
scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_;
diff --git a/media/filters/video_frame_stream.cc b/media/filters/video_frame_stream.cc
index 13d8b38..e669ea3 100644
--- a/media/filters/video_frame_stream.cc
+++ b/media/filters/video_frame_stream.cc
@@ -147,7 +147,7 @@ DemuxerStream::Type VideoFrameStream::type() {
void VideoFrameStream::EnableBitstreamConverter() {
DCHECK(message_loop_->BelongsToCurrentThread());
- stream_->EnableBitstreamConverter();
+ NOTREACHED();
}
void VideoFrameStream::OnDecoderSelected(
@@ -164,6 +164,9 @@ void VideoFrameStream::OnDecoderSelected(
} else {
decoder_ = selected_decoder.Pass();
decrypting_demuxer_stream_ = decrypting_demuxer_stream.Pass();
+ if (decoder_->NeedsBitstreamConversion()) {
+ stream_->EnableBitstreamConverter();
+ }
state_ = NORMAL;
base::ResetAndReturn(&init_cb_).Run(true, decoder_->HasAlpha());
}