diff options
author | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-19 20:18:33 +0000 |
---|---|---|
committer | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-19 20:18:33 +0000 |
commit | 2975fa5391dfd5c57def10929408d814c4acaf6d (patch) | |
tree | 32e17ca77ac82b2adf3e36b23f3f7b7918b6b509 /content/renderer | |
parent | ef03e1ded45fe5dff2b3a783b1be554b5064dfea (diff) | |
download | chromium_src-2975fa5391dfd5c57def10929408d814c4acaf6d.zip chromium_src-2975fa5391dfd5c57def10929408d814c4acaf6d.tar.gz chromium_src-2975fa5391dfd5c57def10929408d814c4acaf6d.tar.bz2 |
Reland r101418: Fix aspect ratio and clarify video frame dimensions
Fixes shared build errors for windows and linux.
BUG=18941,94861
TEST=shared builds compile
TBR=acolwell
Review URL: http://codereview.chromium.org/7932005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/media/capture_video_decoder.cc | 14 | ||||
-rw-r--r-- | content/renderer/media/capture_video_decoder.h | 3 | ||||
-rw-r--r-- | content/renderer/media/rtc_video_decoder.cc | 43 | ||||
-rw-r--r-- | content/renderer/media/rtc_video_decoder.h | 6 | ||||
-rw-r--r-- | content/renderer/media/rtc_video_decoder_unittest.cc | 11 |
5 files changed, 40 insertions, 37 deletions
diff --git a/content/renderer/media/capture_video_decoder.cc b/content/renderer/media/capture_video_decoder.cc index 0ceb1ac..74652f3 100644 --- a/content/renderer/media/capture_video_decoder.cc +++ b/content/renderer/media/capture_video_decoder.cc @@ -50,12 +50,8 @@ void CaptureVideoDecoder::ProduceVideoFrame( &CaptureVideoDecoder::ProduceVideoFrameOnDecoderThread, video_frame)); } -int CaptureVideoDecoder::width() { - return capability_.width; -} - -int CaptureVideoDecoder::height() { - return capability_.height; +gfx::Size CaptureVideoDecoder::natural_size() { + return gfx::Size(capability_.width, capability_.height); } void CaptureVideoDecoder::Play(media::FilterCallback* callback) { @@ -223,7 +219,8 @@ void CaptureVideoDecoder::OnBufferReadyOnDecoderThread( if (buf->width != capability_.width || buf->height != capability_.height) { capability_.width = buf->width; capability_.height = buf->height; - host()->SetVideoSize(capability_.width, capability_.height); + host()->SetNaturalVideoSize( + gfx::Size(capability_.width, capability_.height)); } // Check if there's a size change. @@ -242,6 +239,9 @@ void CaptureVideoDecoder::OnBufferReadyOnDecoderThread( uint8* buffer = buf->memory_pointer; + // Assume YV12 format. + // TODO(vrk): This DCHECK fails in content_unittests ... it should not! + // DCHECK(capability_.raw_type == media::VideoFrame::YV12); int y_width = capability_.width; int y_height = capability_.height; int uv_width = capability_.width / 2; diff --git a/content/renderer/media/capture_video_decoder.h b/content/renderer/media/capture_video_decoder.h index 0f8b585..ef2ffad 100644 --- a/content/renderer/media/capture_video_decoder.h +++ b/content/renderer/media/capture_video_decoder.h @@ -44,8 +44,7 @@ class CaptureVideoDecoder media::StatisticsCallback* stat_callback) OVERRIDE; virtual void ProduceVideoFrame( scoped_refptr<media::VideoFrame> video_frame) OVERRIDE; - virtual int width() OVERRIDE; - virtual int height() OVERRIDE; + virtual gfx::Size natural_size() OVERRIDE; // VideoCapture::EventHandler implementation. virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc index 56ec6d1..4722f96 100644 --- a/content/renderer/media/rtc_video_decoder.cc +++ b/content/renderer/media/rtc_video_decoder.cc @@ -33,8 +33,7 @@ using media::VideoFrame; RTCVideoDecoder::RTCVideoDecoder(MessageLoop* message_loop, const std::string& url) : message_loop_(message_loop), - width_(176), - height_(144), + visible_size_(176, 144), url_(url), state_(kUnInitialized) { } @@ -127,9 +126,10 @@ void RTCVideoDecoder::Seek(base::TimeDelta time, const FilterStatusCB& cb) { state_ = kSeeking; // Create output buffer pool and pass the frames to renderer - // so that the renderer can complete the seeking + // so that the renderer can complete the seeking. for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) { - VideoFrameReady(VideoFrame::CreateBlackFrame(width_, height_)); + VideoFrameReady(VideoFrame::CreateBlackFrame( + visible_size_.width(), visible_size_.height())); } state_ = kNormal; @@ -151,19 +151,16 @@ void RTCVideoDecoder::ProduceVideoFrame( frame_queue_available_.push_back(video_frame); } -int RTCVideoDecoder::width() { - return width_; -} - -int RTCVideoDecoder::height() { - return height_; +gfx::Size RTCVideoDecoder::natural_size() { + // TODO(vrk): Return natural size when aspect ratio support is implemented. + return visible_size_; } bool RTCVideoDecoder::SetSize(int width, int height, int reserved) { - width_ = width; - height_ = height; + visible_size_.SetSize(width, height); - host()->SetVideoSize(width_, height_); + // TODO(vrk): Provide natural size when aspect ratio support is implemented. + host()->SetNaturalVideoSize(visible_size_); return true; } @@ -173,7 +170,7 @@ bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) { if (state_ != kNormal) return true; - // This is called from another thread + // This is called from another thread. scoped_refptr<VideoFrame> video_frame; { base::AutoLock auto_lock(lock_); @@ -184,16 +181,24 @@ bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) { frame_queue_available_.pop_front(); } - // Check if there's a size change - if (video_frame->width() != width_ || video_frame->height() != height_) { - // Allocate new buffer based on the new size + // Check if there's a size change. + // TODO(vrk): Remove casts when media::VideoFrame is updated with gfx::Sizes + // for width/height. + if (video_frame->width() != static_cast<size_t>(visible_size_.width()) || + video_frame->height() != static_cast<size_t>(visible_size_.height())) { + // Allocate new buffer based on the new size. video_frame = VideoFrame::CreateFrame(VideoFrame::YV12, - width_, - height_, + visible_size_.width(), + visible_size_.height(), kNoTimestamp, kNoTimestamp); } + // Only YV12 frames are supported. + DCHECK(video_frame->format() == VideoFrame::YV12); + // Aspect ratio unsupported; DCHECK when there are non-square pixels. + DCHECK(frame->GetPixelWidth() == 1); + DCHECK(frame->GetPixelHeight() == 1); video_frame->SetTimestamp(host()->GetTime()); video_frame->SetDuration(base::TimeDelta::FromMilliseconds(30)); diff --git a/content/renderer/media/rtc_video_decoder.h b/content/renderer/media/rtc_video_decoder.h index 82b78fc..d3b4196 100644 --- a/content/renderer/media/rtc_video_decoder.h +++ b/content/renderer/media/rtc_video_decoder.h @@ -42,8 +42,7 @@ class RTCVideoDecoder media::StatisticsCallback* stat_callback) OVERRIDE; virtual void ProduceVideoFrame( scoped_refptr<media::VideoFrame> video_frame) OVERRIDE; - virtual int width() OVERRIDE; - virtual int height() OVERRIDE; + virtual gfx::Size natural_size() OVERRIDE; // cricket::VideoRenderer implementation virtual bool SetSize(int width, int height, int reserved) OVERRIDE; @@ -65,8 +64,7 @@ class RTCVideoDecoder }; MessageLoop* message_loop_; - size_t width_; - size_t height_; + gfx::Size visible_size_; std::string url_; DecoderState state_; std::deque<scoped_refptr<media::VideoFrame> > frame_queue_available_; diff --git a/content/renderer/media/rtc_video_decoder_unittest.cc b/content/renderer/media/rtc_video_decoder_unittest.cc index 14a3b22..ce434fd 100644 --- a/content/renderer/media/rtc_video_decoder_unittest.cc +++ b/content/renderer/media/rtc_video_decoder_unittest.cc @@ -161,8 +161,8 @@ TEST_F(RTCVideoDecoderTest, Initialize_Successful) { // Test that the output media format is an uncompressed video surface that // matches the dimensions specified by RTC. - EXPECT_EQ(kWidth, decoder_->width()); - EXPECT_EQ(kHeight, decoder_->height()); + EXPECT_EQ(kWidth, decoder_->natural_size().width()); + EXPECT_EQ(kHeight, decoder_->natural_size().height()); } TEST_F(RTCVideoDecoderTest, DoSeek) { @@ -216,15 +216,16 @@ TEST_F(RTCVideoDecoderTest, DoSetSize) { int new_width = kWidth * 2; int new_height = kHeight * 2; + gfx::Size new_natural_size(new_width, new_height); int new_reserved = 0; EXPECT_CALL(host_, - SetVideoSize(new_width, new_height)).WillRepeatedly(Return()); + SetNaturalVideoSize(new_natural_size)).WillRepeatedly(Return()); decoder_->SetSize(new_width, new_height, new_reserved); - EXPECT_EQ(new_width, decoder_->width()); - EXPECT_EQ(new_height, decoder_->height()); + EXPECT_EQ(new_width, decoder_->natural_size().width()); + EXPECT_EQ(new_height, decoder_->natural_size().height()); message_loop_.RunAllPending(); } |