diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-10 01:03:23 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-10 01:03:23 +0000 |
commit | 907bc6fb0e9db6b31eef1d3403b116e43ea7bec9 (patch) | |
tree | eb41d143dab8fca0cb5c55296125160462617833 /media/base | |
parent | bb12d853e4af985379bd56ba3025ec0d2b087148 (diff) | |
download | chromium_src-907bc6fb0e9db6b31eef1d3403b116e43ea7bec9.zip chromium_src-907bc6fb0e9db6b31eef1d3403b116e43ea7bec9.tar.gz chromium_src-907bc6fb0e9db6b31eef1d3403b116e43ea7bec9.tar.bz2 |
Revert 113895 - <video> decode in hardware!
This uses the GpuVideoDecodeAccelerator machinery (already written to enable
ppapi to take advantage of OpenMAX HW where available) to decode <video> data.
This increases idle CPU from 20% to 45% on one particularly large (internal)
test video (red0.mp4), on an ARM crosbook.
HW decode is done on a best-effort basis; if the GPU code doesn't know how to
deal with a codec/profile we still fall back to ffmpeg for decode. Because the
vast majority of chrome installs will be on HW with no video decode support
(yet) we only attempt HW video decode on platforms we know have a shot at it.
BUG=104579
TEST=manual testing w/ video test matrix, trybots.
Review URL: http://codereview.chromium.org/8686010
TBR=fischman@chromium.org
Review URL: http://codereview.chromium.org/8897022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/composite_filter.cc | 21 | ||||
-rw-r--r-- | media/base/composite_filter.h | 3 | ||||
-rw-r--r-- | media/base/composite_filter_unittest.cc | 18 | ||||
-rw-r--r-- | media/base/filter_collection.h | 1 | ||||
-rw-r--r-- | media/base/filters.cc | 5 | ||||
-rw-r--r-- | media/base/filters.h | 13 | ||||
-rw-r--r-- | media/base/mock_filters.cc | 4 | ||||
-rw-r--r-- | media/base/mock_filters.h | 3 | ||||
-rw-r--r-- | media/base/pipeline_impl.cc | 32 | ||||
-rw-r--r-- | media/base/pipeline_impl.h | 9 | ||||
-rw-r--r-- | media/base/pipeline_impl_unittest.cc | 4 | ||||
-rw-r--r-- | media/base/video_decoder_config.cc | 34 | ||||
-rw-r--r-- | media/base/video_decoder_config.h | 32 | ||||
-rw-r--r-- | media/base/video_frame.cc | 48 | ||||
-rw-r--r-- | media/base/video_frame.h | 33 |
15 files changed, 41 insertions, 219 deletions
diff --git a/media/base/composite_filter.cc b/media/base/composite_filter.cc index d6e45df..5c4b1c5 100644 --- a/media/base/composite_filter.cc +++ b/media/base/composite_filter.cc @@ -57,8 +57,6 @@ CompositeFilter::~CompositeFilter() { } bool CompositeFilter::AddFilter(scoped_refptr<Filter> filter) { - // TODO(fischman,scherkus): s/bool/void/ the return type and CHECK on failure - // of the sanity-checks that return false today. DCHECK_EQ(message_loop_, MessageLoop::current()); if (!filter.get() || state_ != kCreated || !host()) return false; @@ -69,23 +67,6 @@ bool CompositeFilter::AddFilter(scoped_refptr<Filter> filter) { return true; } -void CompositeFilter::RemoveFilter(scoped_refptr<Filter> filter) { - DCHECK_EQ(message_loop_, MessageLoop::current()); - if (!filter.get() || state_ != kCreated || !host()) - LOG(FATAL) << "Unknown filter, or in unexpected state."; - - bool found = false; - for (FilterVector::iterator it = filters_.begin(); - it != filters_.end() && !found; ++it) { - if (it->get() == filter.get()) { - filters_.erase(it); - found = true; - } - } - filter->clear_host(); - CHECK(found); -} - void CompositeFilter::set_host(FilterHost* host) { DCHECK_EQ(message_loop_, MessageLoop::current()); DCHECK(host); @@ -356,6 +337,7 @@ void CompositeFilter::SerialCallback() { DispatchPendingCallback(status_); return; } + if (!filters_.empty()) sequence_index_++; @@ -393,6 +375,7 @@ void CompositeFilter::ParallelCallback() { void CompositeFilter::OnCallSequenceDone() { State next_state = GetNextState(state_); + if (next_state == kInvalid) { // We somehow got into an unexpected state. ChangeState(kError); diff --git a/media/base/composite_filter.h b/media/base/composite_filter.h index 9821d03f..4b35be3 100644 --- a/media/base/composite_filter.h +++ b/media/base/composite_filter.h @@ -27,9 +27,6 @@ class MEDIA_EXPORT CompositeFilter : public Filter { // because the composite is in the wrong state. bool AddFilter(scoped_refptr<Filter> filter); - // Undoes AddFilter's actions. CHECK-fails if |filter| is unknown. - void RemoveFilter(scoped_refptr<Filter> filter); - // media::Filter methods. virtual void set_host(FilterHost* host) OVERRIDE; virtual FilterHost* host() OVERRIDE; diff --git a/media/base/composite_filter_unittest.cc b/media/base/composite_filter_unittest.cc index 36ea0b8..23b7f56 100644 --- a/media/base/composite_filter_unittest.cc +++ b/media/base/composite_filter_unittest.cc @@ -379,8 +379,8 @@ TEST_F(CompositeFilterTest, TestAddFilterFailCases) { EXPECT_FALSE(composite_->AddFilter(filter)); } -// Test successful {Add,Remove}Filter() cases. -TEST_F(CompositeFilterTest, TestAddRemoveFilter) { +// Test successful AddFilter() cases. +TEST_F(CompositeFilterTest, TestAddFilter) { composite_->set_host(mock_filter_host_.get()); // Add a filter. @@ -388,20 +388,8 @@ TEST_F(CompositeFilterTest, TestAddRemoveFilter) { EXPECT_EQ(NULL, filter->host()); EXPECT_TRUE(composite_->AddFilter(filter)); - EXPECT_TRUE(filter->host() != NULL); - - composite_->RemoveFilter(filter); - EXPECT_TRUE(filter->host() == NULL); -} - -class CompositeFilterDeathTest : public CompositeFilterTest {}; -// Test failure of RemoveFilter() on an unknown filter. -TEST_F(CompositeFilterDeathTest, TestRemoveUnknownFilter) { - composite_->set_host(mock_filter_host_.get()); - // Remove unknown filter. - scoped_refptr<StrictMock<MockFilter> > filter = new StrictMock<MockFilter>(); - EXPECT_DEATH(composite_->RemoveFilter(filter), ""); + EXPECT_TRUE(filter->host() != NULL); } TEST_F(CompositeFilterTest, TestPlay) { diff --git a/media/base/filter_collection.h b/media/base/filter_collection.h index edf6b29..97e7232 100644 --- a/media/base/filter_collection.h +++ b/media/base/filter_collection.h @@ -40,7 +40,6 @@ class MEDIA_EXPORT FilterCollection { // Selects a filter of the specified type from the collection. // If the required filter cannot be found, NULL is returned. // If a filter is returned it is removed from the collection. - // Filters are selected in FIFO order. void SelectVideoDecoder(scoped_refptr<VideoDecoder>* filter_out); void SelectAudioDecoder(scoped_refptr<AudioDecoder>* filter_out); void SelectVideoRenderer(scoped_refptr<VideoRenderer>* filter_out); diff --git a/media/base/filters.cc b/media/base/filters.cc index ace7d4e..877f391 100644 --- a/media/base/filters.cc +++ b/media/base/filters.cc @@ -29,11 +29,6 @@ Filter::Filter() : host_(NULL) {} Filter::~Filter() {} -void Filter::clear_host() { - DCHECK(host_); - host_ = NULL; -} - void Filter::set_host(FilterHost* host) { DCHECK(host); DCHECK(!host_); diff --git a/media/base/filters.h b/media/base/filters.h index 5cd4cf8..e464202 100644 --- a/media/base/filters.h +++ b/media/base/filters.h @@ -62,8 +62,8 @@ enum Preload { // Used for completing asynchronous methods. typedef base::Callback<void(PipelineStatus)> FilterStatusCB; -// These functions copy |*cb|, call Reset() on |*cb|, and then call Run() -// on the copy. This is used in the common case where you need to clear +// This function copies |*cb|, calls Reset() on |*cb|, and then calls Run() +// on the copy. This is used in the common case where you need to clear // a callback member variable before running the callback. MEDIA_EXPORT void ResetAndRunCB(FilterStatusCB* cb, PipelineStatus status); MEDIA_EXPORT void ResetAndRunCB(base::Closure* cb); @@ -81,10 +81,6 @@ class MEDIA_EXPORT Filter : public base::RefCountedThreadSafe<Filter> { // to be released before the host object is destroyed by the pipeline. virtual void set_host(FilterHost* host); - // Clear |host_| to signal abandonment. Must be called after set_host() and - // before any state-changing method below. - virtual void clear_host(); - virtual FilterHost* host(); // The pipeline has resumed playback. Filters can continue requesting reads. @@ -168,8 +164,9 @@ class MEDIA_EXPORT VideoDecoder : public Filter { // Initialize a VideoDecoder with the given DemuxerStream, executing the // callback upon completion. // stats_callback is used to update global pipeline statistics. - virtual void Initialize(DemuxerStream* stream, - const PipelineStatusCB& callback, + // + // TODO(scherkus): switch to PipelineStatus callback. + virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, const StatisticsCallback& stats_callback) = 0; // Request a frame to be decoded and returned via the provided callback. diff --git a/media/base/mock_filters.cc b/media/base/mock_filters.cc index c8f71e8..d398448 100644 --- a/media/base/mock_filters.cc +++ b/media/base/mock_filters.cc @@ -166,10 +166,6 @@ void RunPipelineStatusCB(PipelineStatus status, const PipelineStatusCB& cb) { cb.Run(status); } -void RunPipelineStatusOKCB(const PipelineStatusCB& cb) { - cb.Run(PIPELINE_OK); -} - void RunFilterCallback3(::testing::Unused, const base::Closure& callback, ::testing::Unused) { callback.Run(); diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index 5c36b10..13a8d2c 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -188,7 +188,7 @@ class MockVideoDecoder : public VideoDecoder { // VideoDecoder implementation. MOCK_METHOD3(Initialize, void(DemuxerStream* stream, - const PipelineStatusCB& callback, + const base::Closure& callback, const StatisticsCallback& stats_callback)); MOCK_METHOD1(Read, void(const ReadCB& callback)); MOCK_METHOD0(natural_size, const gfx::Size&()); @@ -322,7 +322,6 @@ class MockFilterCollection { void RunFilterCallback(::testing::Unused, const base::Closure& callback); void RunFilterStatusCB(::testing::Unused, const FilterStatusCB& cb); void RunPipelineStatusCB(PipelineStatus status, const PipelineStatusCB& cb); -void RunPipelineStatusOKCB(const PipelineStatusCB& cb); // Always PIPELINE_OK. void RunFilterCallback3(::testing::Unused, const base::Closure& callback, ::testing::Unused); diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index aa5ac3b..d4c1b8e 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -586,10 +586,10 @@ void PipelineImpl::DisableAudioRenderer() { } // Called from any thread. -void PipelineImpl::OnFilterInitialize(PipelineStatus status) { +void PipelineImpl::OnFilterInitialize() { // Continue the initialize task by proceeding to the next stage. - message_loop_->PostTask( - FROM_HERE, base::Bind(&PipelineImpl::InitializeTask, this, status)); + message_loop_->PostTask(FROM_HERE, + base::Bind(&PipelineImpl::InitializeTask, this)); } // Called from any thread. @@ -661,21 +661,9 @@ void PipelineImpl::StartTask(FilterCollection* filter_collection, // TODO(hclam): InitializeTask() is now starting the pipeline asynchronously. It // works like a big state change table. If we no longer need to start filters // in order, we need to get rid of all the state change. -void PipelineImpl::InitializeTask(PipelineStatus last_stage_status) { +void PipelineImpl::InitializeTask() { DCHECK_EQ(MessageLoop::current(), message_loop_); - if (last_stage_status != PIPELINE_OK) { - // Currently only VideoDecoders have a recoverable error code. - if (state_ == kInitVideoDecoder && - last_stage_status == DECODER_ERROR_NOT_SUPPORTED) { - pipeline_init_state_->composite_->RemoveFilter( - pipeline_init_state_->video_decoder_.get()); - state_ = kInitAudioRenderer; - } else { - SetError(last_stage_status); - } - } - // If we have received the stop or error signal, return immediately. if (IsPipelineStopPending() || IsPipelineStopped() || !IsPipelineOk()) return; @@ -1123,8 +1111,10 @@ void PipelineImpl::FinishDestroyingFiltersTask() { bool PipelineImpl::PrepareFilter(scoped_refptr<Filter> filter) { bool ret = pipeline_init_state_->composite_->AddFilter(filter.get()); - if (!ret) + + if (!ret) { SetError(PIPELINE_ERROR_INITIALIZATION_FAILED); + } return ret; } @@ -1165,7 +1155,7 @@ void PipelineImpl::OnDemuxerBuilt(PipelineStatus status, Demuxer* demuxer) { clock_->SetTime(demuxer_->GetStartTime()); } - OnFilterInitialize(PIPELINE_OK); + OnFilterInitialize(); } bool PipelineImpl::InitializeAudioDecoder( @@ -1193,7 +1183,7 @@ bool PipelineImpl::InitializeAudioDecoder( pipeline_init_state_->audio_decoder_ = audio_decoder; audio_decoder->Initialize( stream, - base::Bind(&PipelineImpl::OnFilterInitialize, this, PIPELINE_OK), + base::Bind(&PipelineImpl::OnFilterInitialize, this), base::Bind(&PipelineImpl::OnUpdateStatistics, this)); return true; } @@ -1250,7 +1240,7 @@ bool PipelineImpl::InitializeAudioRenderer( audio_renderer_->Initialize( decoder, - base::Bind(&PipelineImpl::OnFilterInitialize, this, PIPELINE_OK), + base::Bind(&PipelineImpl::OnFilterInitialize, this), base::Bind(&PipelineImpl::OnAudioUnderflow, this)); return true; } @@ -1274,7 +1264,7 @@ bool PipelineImpl::InitializeVideoRenderer( video_renderer_->Initialize( decoder, - base::Bind(&PipelineImpl::OnFilterInitialize, this, PIPELINE_OK), + base::Bind(&PipelineImpl::OnFilterInitialize, this), base::Bind(&PipelineImpl::OnUpdateStatistics, this)); return true; } diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h index 9426688..5fb8f82 100644 --- a/media/base/pipeline_impl.h +++ b/media/base/pipeline_impl.h @@ -206,8 +206,8 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline, public FilterHost { virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; virtual int64 GetCurrentReadPosition() OVERRIDE; - // Callbacks executed by filters upon completing initialization. - void OnFilterInitialize(PipelineStatus status); + // Callback executed by filters upon completing initialization. + void OnFilterInitialize(); // Callback executed by filters upon completing Play(), Pause(), or Stop(). void OnFilterStateTransition(); @@ -231,9 +231,8 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline, public FilterHost { // InitializeTask() performs initialization in multiple passes. It is executed // as a result of calling Start() or InitializationComplete() that advances // initialization to the next state. It works as a hub of state transition for - // initialization. One stage communicates its status to the next through - // |last_stage_status|. - void InitializeTask(PipelineStatus last_stage_status); + // initialization. + void InitializeTask(); // Stops and destroys all filters, placing the pipeline in the kStopped state. void StopTask(const PipelineStatusCB& stop_callback); diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index 76f7a0c..fc9692e 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc @@ -21,13 +21,11 @@ using ::testing::_; using ::testing::DeleteArg; using ::testing::InSequence; using ::testing::Invoke; -using ::testing::InvokeArgument; using ::testing::Mock; using ::testing::NotNull; using ::testing::Return; using ::testing::ReturnRef; using ::testing::StrictMock; -using ::testing::WithArg; namespace media { @@ -128,7 +126,7 @@ class PipelineImplTest : public ::testing::Test { void InitializeVideoDecoder(MockDemuxerStream* stream) { EXPECT_CALL(*mocks_->video_decoder(), Initialize(stream, _, _)) - .WillOnce(WithArg<1>(Invoke(&RunPipelineStatusOKCB))); + .WillOnce(Invoke(&RunFilterCallback3)); EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(0.0f)); EXPECT_CALL(*mocks_->video_decoder(), Seek(mocks_->demuxer()->GetStartTime(), _)) diff --git a/media/base/video_decoder_config.cc b/media/base/video_decoder_config.cc index 07bf9a5..ee334d3 100644 --- a/media/base/video_decoder_config.cc +++ b/media/base/video_decoder_config.cc @@ -14,7 +14,6 @@ namespace media { VideoDecoderConfig::VideoDecoderConfig() : codec_(kUnknownVideoCodec), - profile_(VIDEO_CODEC_PROFILE_UNKNOWN), format_(VideoFrame::INVALID), frame_rate_numerator_(0), frame_rate_denominator_(0), @@ -24,7 +23,6 @@ VideoDecoderConfig::VideoDecoderConfig() } VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, - VideoCodecProfile profile, VideoFrame::Format format, const gfx::Size& coded_size, const gfx::Rect& visible_rect, @@ -34,7 +32,7 @@ VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, int aspect_ratio_denominator, const uint8* extra_data, size_t extra_data_size) { - Initialize(codec, profile, format, coded_size, visible_rect, + Initialize(codec, format, coded_size, visible_rect, frame_rate_numerator, frame_rate_denominator, aspect_ratio_numerator, aspect_ratio_denominator, extra_data, extra_data_size); @@ -64,9 +62,7 @@ static void UmaHistogramAspectRatio(const char* name, const T& size) { kCommonAspectRatios100, arraysize(kCommonAspectRatios100))); } -void VideoDecoderConfig::Initialize(VideoCodec codec, - VideoCodecProfile profile, - VideoFrame::Format format, +void VideoDecoderConfig::Initialize(VideoCodec codec, VideoFrame::Format format, const gfx::Size& coded_size, const gfx::Rect& visible_rect, int frame_rate_numerator, @@ -78,15 +74,12 @@ void VideoDecoderConfig::Initialize(VideoCodec codec, CHECK((extra_data_size != 0) == (extra_data != NULL)); UMA_HISTOGRAM_ENUMERATION("Media.VideoCodec", codec, kVideoCodecMax + 1); - UMA_HISTOGRAM_ENUMERATION("Media.VideoCodecProfile", profile, - VIDEO_CODEC_PROFILE_MAX + 1); UMA_HISTOGRAM_COUNTS_10000("Media.VideoCodedWidth", coded_size.width()); UmaHistogramAspectRatio("Media.VideoCodedAspectRatio", coded_size); UMA_HISTOGRAM_COUNTS_10000("Media.VideoVisibleWidth", visible_rect.width()); UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect); codec_ = codec; - profile_ = profile; format_ = format; coded_size_ = coded_size; visible_rect_ = visible_rect; @@ -132,33 +125,10 @@ bool VideoDecoderConfig::IsValidConfig() const { natural_size_.GetArea() <= limits::kMaxCanvas; } -std::string VideoDecoderConfig::AsHumanReadableString() const { - std::ostringstream s; - s << "codec: " << codec() - << " format: " << format() - << " coded size: [" << coded_size().width() - << "," << coded_size().height() << "]" - << " visible rect: [" << visible_rect().x() - << "," << visible_rect().y() - << "," << visible_rect().width() - << "," << visible_rect().height() << "]" - << " natural size: [" << natural_size().width() - << "," << natural_size().height() << "]" - << " frame rate: " << frame_rate_numerator() - << "/" << frame_rate_denominator() - << " aspect ratio: " << aspect_ratio_numerator() - << "/" << aspect_ratio_denominator(); - return s.str(); -} - VideoCodec VideoDecoderConfig::codec() const { return codec_; } -VideoCodecProfile VideoDecoderConfig::profile() const { - return profile_; -} - VideoFrame::Format VideoDecoderConfig::format() const { return format_; } diff --git a/media/base/video_decoder_config.h b/media/base/video_decoder_config.h index 28b1106..b02bee8 100644 --- a/media/base/video_decoder_config.h +++ b/media/base/video_decoder_config.h @@ -14,7 +14,7 @@ namespace media { -enum MEDIA_EXPORT VideoCodec { +enum VideoCodec { // These values are histogrammed over time; do not change their ordinal // values. When deleting a codec replace it with a dummy value; when adding a // codec, do so at the bottom (and update kVideoCodecMax). @@ -33,28 +33,6 @@ enum MEDIA_EXPORT VideoCodec { kVideoCodecMax = kCodecVP8 // Must equal the last "real" codec above. }; -// Video stream profile. This *must* match PP_VideoDecoder_Profile. -enum MEDIA_EXPORT VideoCodecProfile { - // Keep the values in this enum unique, as they imply format (h.264 vs. VP8, - // for example), and keep the values for a particular format grouped - // together for clarity. - VIDEO_CODEC_PROFILE_UNKNOWN = -1, - H264PROFILE_MIN = 0, - H264PROFILE_BASELINE = H264PROFILE_MIN, - H264PROFILE_MAIN, - H264PROFILE_EXTENDED, - H264PROFILE_HIGH, - H264PROFILE_HIGH10PROFILE, - H264PROFILE_HIGH422PROFILE, - H264PROFILE_HIGH444PREDICTIVEPROFILE, - H264PROFILE_SCALABLEBASELINE, - H264PROFILE_SCALABLEHIGH, - H264PROFILE_STEREOHIGH, - H264PROFILE_MULTIVIEWHIGH, - H264PROFILE_MAX = H264PROFILE_MULTIVIEWHIGH, - VIDEO_CODEC_PROFILE_MAX = H264PROFILE_MAX, -}; - class MEDIA_EXPORT VideoDecoderConfig { public: // Constructs an uninitialized object. Clients should call Initialize() with @@ -64,7 +42,6 @@ class MEDIA_EXPORT VideoDecoderConfig { // Constructs an initialized object. It is acceptable to pass in NULL for // |extra_data|, otherwise the memory is copied. VideoDecoderConfig(VideoCodec codec, - VideoCodecProfile profile, VideoFrame::Format format, const gfx::Size& coded_size, const gfx::Rect& visible_rect, @@ -76,7 +53,6 @@ class MEDIA_EXPORT VideoDecoderConfig { // Resets the internal state of this object. void Initialize(VideoCodec codec, - VideoCodecProfile profile, VideoFrame::Format format, const gfx::Size& coded_size, const gfx::Rect& visible_rect, @@ -88,12 +64,7 @@ class MEDIA_EXPORT VideoDecoderConfig { // otherwise. bool IsValidConfig() const; - // Returns a human-readable string describing |*this|. For debugging & test - // output only. - std::string AsHumanReadableString() const; - VideoCodec codec() const; - VideoCodecProfile profile() const; // Video format used to determine YUV buffer sizes. VideoFrame::Format format() const; @@ -131,7 +102,6 @@ class MEDIA_EXPORT VideoDecoderConfig { private: VideoCodec codec_; - VideoCodecProfile profile_; VideoFrame::Format format_; diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index 29c4223..a0dc579 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc @@ -17,8 +17,9 @@ scoped_refptr<VideoFrame> VideoFrame::CreateFrame( base::TimeDelta duration) { DCHECK(width > 0 && height > 0); DCHECK(width * height < 100000000); - scoped_refptr<VideoFrame> frame(new VideoFrame( - format, width, height, timestamp, duration)); + scoped_refptr<VideoFrame> frame(new VideoFrame(format, width, height)); + frame->SetTimestamp(timestamp); + frame->SetDuration(duration); switch (format) { case VideoFrame::RGB555: case VideoFrame::RGB565: @@ -46,25 +47,8 @@ scoped_refptr<VideoFrame> VideoFrame::CreateFrame( } // static -scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( - uint32 texture_id, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, - const base::Closure& no_longer_needed) { - scoped_refptr<VideoFrame> frame( - new VideoFrame(NATIVE_TEXTURE, width, height, timestamp, duration)); - frame->planes_ = 0; - frame->texture_id_ = texture_id; - frame->texture_no_longer_needed_ = no_longer_needed; - return frame; -} - -// static scoped_refptr<VideoFrame> VideoFrame::CreateEmptyFrame() { - return new VideoFrame( - VideoFrame::EMPTY, 0, 0, base::TimeDelta(), base::TimeDelta()); + return new VideoFrame(VideoFrame::EMPTY, 0, 0); } // static @@ -154,26 +138,16 @@ void VideoFrame::AllocateYUV() { VideoFrame::VideoFrame(VideoFrame::Format format, size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration) + size_t height) : format_(format), width_(width), height_(height), - planes_(0), - texture_id_(0) { - SetTimestamp(timestamp); - SetDuration(duration); + planes_(0) { memset(&strides_, 0, sizeof(strides_)); memset(&data_, 0, sizeof(data_)); } VideoFrame::~VideoFrame() { - if (format_ == NATIVE_TEXTURE && !texture_no_longer_needed_.is_null()) { - texture_no_longer_needed_.Run(); - texture_no_longer_needed_.Reset(); - } - // In multi-plane allocations, only a single block of memory is allocated // on the heap, and other |data| pointers point inside the same, single block // so just delete index 0. @@ -193,10 +167,6 @@ bool VideoFrame::IsValidPlane(size_t plane) const { case YV16: return plane == kYPlane || plane == kUPlane || plane == kVPlane; - case NATIVE_TEXTURE: - NOTREACHED() << "NATIVE_TEXTUREs don't use plane-related methods!"; - return false; - default: break; } @@ -266,12 +236,6 @@ uint8* VideoFrame::data(size_t plane) const { return data_[plane]; } -uint32 VideoFrame::texture_id() const { - DCHECK_EQ(format_, NATIVE_TEXTURE); - DCHECK_EQ(planes_, 0U); - return texture_id_; -} - bool VideoFrame::IsEndOfStream() const { return format_ == VideoFrame::EMPTY; } diff --git a/media/base/video_frame.h b/media/base/video_frame.h index 1801077..ab96544 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h @@ -5,7 +5,6 @@ #ifndef MEDIA_BASE_VIDEO_FRAME_H_ #define MEDIA_BASE_VIDEO_FRAME_H_ -#include "base/callback.h" #include "media/base/buffers.h" namespace media { @@ -26,7 +25,6 @@ class MEDIA_EXPORT VideoFrame : public StreamSample { // Surface formats roughly based on FOURCC labels, see: // http://www.fourcc.org/rgb.php // http://www.fourcc.org/yuv.php - // Keep in sync with WebKit::WebVideoFrame! enum Format { INVALID, // Invalid format value. Used for error reporting. RGB555, // 16bpp RGB packed 5:5:5 @@ -40,7 +38,6 @@ class MEDIA_EXPORT VideoFrame : public StreamSample { EMPTY, // An empty frame. ASCII, // A frame with ASCII content. For testing only. I420, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. - NATIVE_TEXTURE, // Opaque native texture. Pixel-format agnostic. }; // Creates a new frame in system memory with given parameters. Buffers for @@ -52,16 +49,6 @@ class MEDIA_EXPORT VideoFrame : public StreamSample { base::TimeDelta timestamp, base::TimeDelta duration); - // Wraps a native texture of the given parameters with a VideoFrame. When the - // frame is destroyed |no_longer_needed.Run()| will be called. - static scoped_refptr<VideoFrame> WrapNativeTexture( - uint32 texture_id, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, - const base::Closure& no_longer_needed); - // Creates a frame with format equals to VideoFrame::EMPTY, width, height // timestamp and duration are all 0. static scoped_refptr<VideoFrame> CreateEmptyFrame(); @@ -91,20 +78,14 @@ class MEDIA_EXPORT VideoFrame : public StreamSample { // VideoFrame object and must not be freed by the caller. uint8* data(size_t plane) const; - // Returns the ID of the native texture wrapped by this frame. Only valid to - // call if this is a NATIVE_TEXTURE frame. - uint32 texture_id() const; - // StreamSample interface. virtual bool IsEndOfStream() const OVERRIDE; - private: + protected: // Clients must use the static CreateFrame() method to create a new frame. VideoFrame(Format format, size_t video_width, - size_t video_height, - base::TimeDelta timestamp, - base::TimeDelta duration); + size_t video_height); virtual ~VideoFrame(); @@ -122,8 +103,8 @@ class MEDIA_EXPORT VideoFrame : public StreamSample { size_t width_; size_t height_; - // Number of planes, typically 1 for packed RGB formats, 3 for planar - // YUV formats, and 0 for native textures. + // Number of planes, typically 1 for packed RGB formats and 3 for planar + // YUV formats. size_t planes_; // Array of strides for each plane, typically greater or equal to the width @@ -134,11 +115,7 @@ class MEDIA_EXPORT VideoFrame : public StreamSample { // Array of data pointers to each plane. uint8* data_[kMaxPlanes]; - // Native texture ID, if this is a NATIVE_TEXTURE frame. - uint32 texture_id_; - base::Closure texture_no_longer_needed_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); + DISALLOW_COPY_AND_ASSIGN(VideoFrame); }; } // namespace media |