diff options
author | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-16 00:20:20 +0000 |
---|---|---|
committer | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-16 00:20:20 +0000 |
commit | e4d9491934ef4bb70aeac5c92cbe76e0399e7367 (patch) | |
tree | 743748d7cc4708e501fb09cfe1e7805b1f1e3dce /media/base | |
parent | a1d41ed5a126c9426f986930fb420e0c9c3f7faa (diff) | |
download | chromium_src-e4d9491934ef4bb70aeac5c92cbe76e0399e7367.zip chromium_src-e4d9491934ef4bb70aeac5c92cbe76e0399e7367.tar.gz chromium_src-e4d9491934ef4bb70aeac5c92cbe76e0399e7367.tar.bz2 |
Revert 101418 - Fix aspect ratio and clarify video frame dimensions
BUG=18941,94861
TEST=video-aspect-ratio.html
Review URL: http://codereview.chromium.org/7864009
TBR=vrk@google.com
Review URL: http://codereview.chromium.org/7919006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/composite_filter.cc | 38 | ||||
-rw-r--r-- | media/base/composite_filter.h | 19 | ||||
-rw-r--r-- | media/base/filter_host.h | 4 | ||||
-rw-r--r-- | media/base/filters.h | 6 | ||||
-rw-r--r-- | media/base/mock_filter_host.h | 2 | ||||
-rw-r--r-- | media/base/mock_filters.h | 3 | ||||
-rw-r--r-- | media/base/pipeline.h | 7 | ||||
-rw-r--r-- | media/base/pipeline_impl.cc | 19 | ||||
-rw-r--r-- | media/base/pipeline_impl.h | 84 | ||||
-rw-r--r-- | media/base/pipeline_impl_unittest.cc | 9 | ||||
-rw-r--r-- | media/base/video_decoder_config.cc | 30 | ||||
-rw-r--r-- | media/base/video_decoder_config.h | 29 |
12 files changed, 127 insertions, 123 deletions
diff --git a/media/base/composite_filter.cc b/media/base/composite_filter.cc index d58bfec..a84bf21 100644 --- a/media/base/composite_filter.cc +++ b/media/base/composite_filter.cc @@ -18,22 +18,22 @@ class CompositeFilter::FilterHostImpl : public FilterHost { FilterHost* host(); // media::FilterHost methods. - virtual void SetError(PipelineStatus error) OVERRIDE; - virtual base::TimeDelta GetTime() const OVERRIDE; - virtual base::TimeDelta GetDuration() const OVERRIDE; - virtual void SetTime(base::TimeDelta time) OVERRIDE; - virtual void SetDuration(base::TimeDelta duration) OVERRIDE; - virtual void SetBufferedTime(base::TimeDelta buffered_time) OVERRIDE; - virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; - virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; - virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE; - virtual void SetStreaming(bool streaming) OVERRIDE; - virtual void NotifyEnded() OVERRIDE; - virtual void SetLoaded(bool loaded) OVERRIDE; - virtual void SetNetworkActivity(bool network_activity) OVERRIDE; - virtual void DisableAudioRenderer() OVERRIDE; - virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; - virtual int64 GetCurrentReadPosition() OVERRIDE; + virtual void SetError(PipelineStatus error); + virtual base::TimeDelta GetTime() const; + virtual base::TimeDelta GetDuration() const; + virtual void SetTime(base::TimeDelta time); + virtual void SetDuration(base::TimeDelta duration); + virtual void SetBufferedTime(base::TimeDelta buffered_time); + virtual void SetTotalBytes(int64 total_bytes); + virtual void SetBufferedBytes(int64 buffered_bytes); + virtual void SetVideoSize(size_t width, size_t height); + virtual void SetStreaming(bool streaming); + virtual void NotifyEnded(); + virtual void SetLoaded(bool loaded); + virtual void SetNetworkActivity(bool network_activity); + virtual void DisableAudioRenderer(); + virtual void SetCurrentReadPosition(int64 offset); + virtual int64 GetCurrentReadPosition(); private: CompositeFilter* parent_; @@ -526,9 +526,9 @@ void CompositeFilter::FilterHostImpl::SetBufferedBytes(int64 buffered_bytes) { host_->SetBufferedBytes(buffered_bytes); } -void CompositeFilter::FilterHostImpl::SetNaturalVideoSize( - const gfx::Size& size) { - host_->SetNaturalVideoSize(size); +void CompositeFilter::FilterHostImpl::SetVideoSize(size_t width, + size_t height) { + host_->SetVideoSize(width, height); } void CompositeFilter::FilterHostImpl::SetStreaming(bool streaming) { diff --git a/media/base/composite_filter.h b/media/base/composite_filter.h index ad070bc..8e1ec4a 100644 --- a/media/base/composite_filter.h +++ b/media/base/composite_filter.h @@ -27,16 +27,15 @@ class MEDIA_EXPORT CompositeFilter : public Filter { bool AddFilter(scoped_refptr<Filter> filter); // media::Filter methods. - virtual void set_host(FilterHost* host) OVERRIDE; - virtual FilterHost* host() OVERRIDE; - virtual void Play(FilterCallback* play_callback) OVERRIDE; - virtual void Pause(FilterCallback* pause_callback) OVERRIDE; - virtual void Flush(FilterCallback* flush_callback) OVERRIDE; - virtual void Stop(FilterCallback* stop_callback) OVERRIDE; - virtual void SetPlaybackRate(float playback_rate) OVERRIDE; - virtual void Seek( - base::TimeDelta time, const FilterStatusCB& seek_cb) OVERRIDE; - virtual void OnAudioRendererDisabled() OVERRIDE; + virtual void set_host(FilterHost* host); + virtual FilterHost* host(); + virtual void Play(FilterCallback* play_callback); + virtual void Pause(FilterCallback* pause_callback); + virtual void Flush(FilterCallback* flush_callback); + virtual void Stop(FilterCallback* stop_callback); + virtual void SetPlaybackRate(float playback_rate); + virtual void Seek(base::TimeDelta time, const FilterStatusCB& seek_cb); + virtual void OnAudioRendererDisabled(); protected: virtual ~CompositeFilter(); diff --git a/media/base/filter_host.h b/media/base/filter_host.h index d6977b6..510e333 100644 --- a/media/base/filter_host.h +++ b/media/base/filter_host.h @@ -53,8 +53,8 @@ class MEDIA_EXPORT FilterHost { // be played. virtual void SetBufferedBytes(int64 buffered_bytes) = 0; - // Sets the natural size of the video output in pixel units. - virtual void SetNaturalVideoSize(const gfx::Size& size) = 0; + // Sets the size of the video output in pixel units. + virtual void SetVideoSize(size_t width, size_t height) = 0; // Sets the flag to indicate that we are doing streaming. virtual void SetStreaming(bool streaming) = 0; diff --git a/media/base/filters.h b/media/base/filters.h index dba2efa..180739d 100644 --- a/media/base/filters.h +++ b/media/base/filters.h @@ -35,7 +35,6 @@ #include "media/base/media_export.h" #include "media/base/pipeline_status.h" #include "media/base/video_frame.h" -#include "ui/gfx/size.h" namespace media { @@ -181,14 +180,15 @@ class MEDIA_EXPORT VideoDecoder : public Filter { consume_video_frame_callback_ = callback; } - // Returns the natural width and height of decoded video in pixels. + // Returns the width and height of decoded video in pixels. // // Clients should NOT rely on these values to remain constant. Instead, use // the width/height from decoded video frames themselves. // // TODO(scherkus): why not rely on prerolling and decoding a single frame to // get dimensions? - virtual gfx::Size natural_size() = 0; + virtual int width() = 0; + virtual int height() = 0; protected: // Executes the permanent callback to pass off decoded video. diff --git a/media/base/mock_filter_host.h b/media/base/mock_filter_host.h index 9b9cd7c..2464de8 100644 --- a/media/base/mock_filter_host.h +++ b/media/base/mock_filter_host.h @@ -32,7 +32,7 @@ class MockFilterHost : public FilterHost { MOCK_METHOD1(SetBufferedTime, void(base::TimeDelta buffered_time)); MOCK_METHOD1(SetTotalBytes, void(int64 total_bytes)); MOCK_METHOD1(SetBufferedBytes, void(int64 buffered_bytes)); - MOCK_METHOD1(SetNaturalVideoSize, void(const gfx::Size& size)); + MOCK_METHOD2(SetVideoSize, void(size_t width, size_t height)); MOCK_METHOD1(SetStreaming, void(bool streamed)); MOCK_METHOD1(SetLoaded, void(bool loaded)); MOCK_METHOD1(SetNetworkActivity, void(bool network_activity)); diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index 901361c..e215186 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -184,7 +184,8 @@ class MockVideoDecoder : public VideoDecoder { FilterCallback* callback, StatisticsCallback* stats_callback)); MOCK_METHOD1(ProduceVideoFrame, void(scoped_refptr<VideoFrame>)); - MOCK_METHOD0(natural_size, gfx::Size()); + MOCK_METHOD0(width, int()); + MOCK_METHOD0(height, int()); void VideoFrameReadyForTest(scoped_refptr<VideoFrame> frame) { VideoDecoder::VideoFrameReady(frame); diff --git a/media/base/pipeline.h b/media/base/pipeline.h index 1945010..3e1f919 100644 --- a/media/base/pipeline.h +++ b/media/base/pipeline.h @@ -147,10 +147,9 @@ class MEDIA_EXPORT Pipeline : public base::RefCountedThreadSafe<Pipeline> { // determined or can not be determined, this value is 0. virtual int64 GetTotalBytes() const = 0; - // Gets the natural size of the video output in pixel units. If there is no - // video or the video has not been rendered yet, the width and height will - // be 0. - virtual void GetNaturalVideoSize(gfx::Size* out_size) const = 0; + // Gets the size of the video output in pixel units. If there is no video + // or the video has not been rendered yet, the width and height will be 0. + virtual void GetVideoSize(size_t* width_out, size_t* height_out) const = 0; // If this method returns true, that means the data source is a streaming // data source. Seeking may not be possible. diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index 263441c..0d3c1dd 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -310,10 +310,12 @@ int64 PipelineImpl::GetTotalBytes() const { return total_bytes_; } -void PipelineImpl::GetNaturalVideoSize(gfx::Size* out_size) const { - CHECK(out_size); +void PipelineImpl::GetVideoSize(size_t* width_out, size_t* height_out) const { + CHECK(width_out); + CHECK(height_out); base::AutoLock auto_lock(lock_); - *out_size = natural_size_; + *width_out = video_width_; + *height_out = video_height_; } bool PipelineImpl::IsStreaming() const { @@ -369,7 +371,8 @@ void PipelineImpl::ResetState() { streaming_ = false; loaded_ = false; total_bytes_ = 0; - natural_size_.SetSize(0, 0); + video_width_ = 0; + video_height_ = 0; volume_ = 1.0f; preload_ = AUTO; playback_rate_ = 0.0f; @@ -533,13 +536,13 @@ void PipelineImpl::SetBufferedBytes(int64 buffered_bytes) { buffered_bytes_ = buffered_bytes; } -void PipelineImpl::SetNaturalVideoSize(const gfx::Size& size) { +void PipelineImpl::SetVideoSize(size_t width, size_t height) { DCHECK(IsRunning()); - media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( - size.width(), size.height())); + media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent(width, height)); base::AutoLock auto_lock(lock_); - natural_size_ = size; + video_width_ = width; + video_height_ = height; } void PipelineImpl::SetStreaming(bool streaming) { diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h index d792347..bb88272 100644 --- a/media/base/pipeline_impl.h +++ b/media/base/pipeline_impl.h @@ -25,7 +25,6 @@ #include "media/base/demuxer.h" #include "media/base/filter_host.h" #include "media/base/pipeline.h" -#include "ui/gfx/size.h" namespace media { @@ -102,32 +101,32 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline, public FilterHost { // Pipeline implementation. virtual void Init(const PipelineStatusCB& ended_callback, const PipelineStatusCB& error_callback, - const PipelineStatusCB& network_callback) OVERRIDE; + const PipelineStatusCB& network_callback); virtual bool Start(FilterCollection* filter_collection, const std::string& uri, - const PipelineStatusCB& start_callback) OVERRIDE; - virtual void Stop(const PipelineStatusCB& stop_callback) OVERRIDE; + const PipelineStatusCB& start_callback); + virtual void Stop(const PipelineStatusCB& stop_callback); virtual void Seek(base::TimeDelta time, - const PipelineStatusCB& seek_callback) OVERRIDE; - virtual bool IsRunning() const OVERRIDE; - virtual bool IsInitialized() const OVERRIDE; - virtual bool IsNetworkActive() const OVERRIDE; - virtual bool HasAudio() const OVERRIDE; - virtual bool HasVideo() const OVERRIDE; - virtual float GetPlaybackRate() const OVERRIDE; - virtual void SetPlaybackRate(float playback_rate) OVERRIDE; - virtual float GetVolume() const OVERRIDE; - virtual void SetVolume(float volume) OVERRIDE; - virtual void SetPreload(Preload preload) OVERRIDE; - virtual base::TimeDelta GetCurrentTime() const OVERRIDE; - virtual base::TimeDelta GetBufferedTime() OVERRIDE; - virtual base::TimeDelta GetMediaDuration() const OVERRIDE; - virtual int64 GetBufferedBytes() const OVERRIDE; - virtual int64 GetTotalBytes() const OVERRIDE; - virtual void GetNaturalVideoSize(gfx::Size* out_size) const OVERRIDE; - virtual bool IsStreaming() const OVERRIDE; - virtual bool IsLoaded() const OVERRIDE; - virtual PipelineStatistics GetStatistics() const OVERRIDE; + const PipelineStatusCB& seek_callback); + virtual bool IsRunning() const; + virtual bool IsInitialized() const; + virtual bool IsNetworkActive() const; + virtual bool HasAudio() const; + virtual bool HasVideo() const; + virtual float GetPlaybackRate() const; + virtual void SetPlaybackRate(float playback_rate); + virtual float GetVolume() const; + virtual void SetVolume(float volume); + virtual void SetPreload(Preload preload); + virtual base::TimeDelta GetCurrentTime() const; + virtual base::TimeDelta GetBufferedTime(); + virtual base::TimeDelta GetMediaDuration() const; + virtual int64 GetBufferedBytes() const; + virtual int64 GetTotalBytes() const; + virtual void GetVideoSize(size_t* width_out, size_t* height_out) const; + virtual bool IsStreaming() const; + virtual bool IsLoaded() const; + virtual PipelineStatistics GetStatistics() const; void SetClockForTesting(Clock* clock); @@ -191,22 +190,22 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline, public FilterHost { State FindNextState(State current); // FilterHost implementation. - virtual void SetError(PipelineStatus error) OVERRIDE; - virtual base::TimeDelta GetTime() const OVERRIDE; - virtual base::TimeDelta GetDuration() const OVERRIDE; - virtual void SetTime(base::TimeDelta time) OVERRIDE; - virtual void SetDuration(base::TimeDelta duration) OVERRIDE; - virtual void SetBufferedTime(base::TimeDelta buffered_time) OVERRIDE; - virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; - virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; - virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE; - virtual void SetStreaming(bool streamed) OVERRIDE; - virtual void SetLoaded(bool loaded) OVERRIDE; - virtual void SetNetworkActivity(bool network_activity) OVERRIDE; - virtual void NotifyEnded() OVERRIDE; - virtual void DisableAudioRenderer() OVERRIDE; - virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; - virtual int64 GetCurrentReadPosition() OVERRIDE; + virtual void SetError(PipelineStatus error); + virtual base::TimeDelta GetTime() const; + virtual base::TimeDelta GetDuration() const; + virtual void SetTime(base::TimeDelta time); + virtual void SetDuration(base::TimeDelta duration); + virtual void SetBufferedTime(base::TimeDelta buffered_time); + virtual void SetTotalBytes(int64 total_bytes); + virtual void SetBufferedBytes(int64 buffered_bytes); + virtual void SetVideoSize(size_t width, size_t height); + virtual void SetStreaming(bool streamed); + virtual void SetLoaded(bool loaded); + virtual void SetNetworkActivity(bool network_activity); + virtual void NotifyEnded(); + virtual void DisableAudioRenderer(); + virtual void SetCurrentReadPosition(int64 offset); + virtual int64 GetCurrentReadPosition(); // Callback executed by filters upon completing initialization. void OnFilterInitialize(); @@ -372,8 +371,9 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline, public FilterHost { // Total size of the media. Set by filters. int64 total_bytes_; - // Video's natural width and height. Set by filters. - gfx::Size natural_size_; + // Video width and height. Set by filters. + size_t video_width_; + size_t video_height_; // Sets by the filters to indicate whether the data source is a streaming // source. diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index ccb43d0..66b430a 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc @@ -308,10 +308,11 @@ TEST_F(PipelineImplTest, NotStarted) { EXPECT_EQ(0, pipeline_->GetTotalBytes()); // Should always get set to zero. - gfx::Size size(1, 1); - pipeline_->GetNaturalVideoSize(&size); - EXPECT_EQ(0, size.width()); - EXPECT_EQ(0, size.height()); + size_t width = 1u; + size_t height = 1u; + pipeline_->GetVideoSize(&width, &height); + EXPECT_EQ(0u, width); + EXPECT_EQ(0u, height); } TEST_F(PipelineImplTest, NeverInitializes) { diff --git a/media/base/video_decoder_config.cc b/media/base/video_decoder_config.cc index 52104cb..0d3ae76 100644 --- a/media/base/video_decoder_config.cc +++ b/media/base/video_decoder_config.cc @@ -9,17 +9,19 @@ namespace media { VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, - const gfx::Size& coded_size, - const gfx::Rect& visible_rect, - const gfx::Size& natural_size, + int width, + int height, + int surface_width, + int surface_height, int frame_rate_numerator, int frame_rate_denominator, const uint8* extra_data, size_t extra_data_size) : codec_(codec), - coded_size_(coded_size), - visible_rect_(visible_rect), - natural_size_(natural_size), + width_(width), + height_(height), + surface_width_(surface_width), + surface_height_(surface_height), frame_rate_numerator_(frame_rate_numerator), frame_rate_denominator_(frame_rate_denominator), extra_data_size_(extra_data_size) { @@ -36,16 +38,20 @@ VideoCodec VideoDecoderConfig::codec() const { return codec_; } -gfx::Size VideoDecoderConfig::coded_size() const { - return coded_size_; +int VideoDecoderConfig::width() const { + return width_; } -gfx::Rect VideoDecoderConfig::visible_rect() const { - return visible_rect_; +int VideoDecoderConfig::height() const { + return height_; } -gfx::Size VideoDecoderConfig::natural_size() const { - return natural_size_; +int VideoDecoderConfig::surface_width() const { + return surface_width_; +} + +int VideoDecoderConfig::surface_height() const { + return surface_height_; } int VideoDecoderConfig::frame_rate_numerator() const { diff --git a/media/base/video_decoder_config.h b/media/base/video_decoder_config.h index fcfd3e7..360451a 100644 --- a/media/base/video_decoder_config.h +++ b/media/base/video_decoder_config.h @@ -8,8 +8,6 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "media/base/media_export.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/size.h" namespace media { @@ -30,17 +28,17 @@ enum VideoCodec { class MEDIA_EXPORT VideoDecoderConfig { public: - VideoDecoderConfig(VideoCodec codec, const gfx::Size& coded_size, - const gfx::Rect& visible_rect, - const gfx::Size& natural_size, + VideoDecoderConfig(VideoCodec codec, int width, int height, + int surface_width, int surface_height, int frame_rate_numerator, int frame_rate_denominator, const uint8* extra_data, size_t extra_data_size); ~VideoDecoderConfig(); VideoCodec codec() const; - gfx::Size coded_size() const; - gfx::Rect visible_rect() const; - gfx::Size natural_size() const; + int width() const; + int height() const; + int surface_width() const; + int surface_height() const; int frame_rate_numerator() const; int frame_rate_denominator() const; uint8* extra_data() const; @@ -49,16 +47,13 @@ class MEDIA_EXPORT VideoDecoderConfig { private: VideoCodec codec_; - // Width and height of video frame immediately post-decode. Not all pixels - // in this region are valid. - gfx::Size coded_size_; + // Container's concept of width and height of this video. + int width_; + int height_; - // Region of |coded_size_| that is visible. - gfx::Rect visible_rect_; - - // Natural width and height of the video, i.e. the visible dimensions - // after aspect ratio is applied. - gfx::Size natural_size_; + // Width and height of the display surface for this video. + int surface_width_; + int surface_height_; // Frame rate in seconds expressed as a fraction. // TODO(scherkus): fairly certain decoders don't require frame rates. |