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 /content/renderer | |
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 '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, 37 insertions, 40 deletions
diff --git a/content/renderer/media/capture_video_decoder.cc b/content/renderer/media/capture_video_decoder.cc index 74652f3..0ceb1ac 100644 --- a/content/renderer/media/capture_video_decoder.cc +++ b/content/renderer/media/capture_video_decoder.cc @@ -50,8 +50,12 @@ void CaptureVideoDecoder::ProduceVideoFrame( &CaptureVideoDecoder::ProduceVideoFrameOnDecoderThread, video_frame)); } -gfx::Size CaptureVideoDecoder::natural_size() { - return gfx::Size(capability_.width, capability_.height); +int CaptureVideoDecoder::width() { + return capability_.width; +} + +int CaptureVideoDecoder::height() { + return capability_.height; } void CaptureVideoDecoder::Play(media::FilterCallback* callback) { @@ -219,8 +223,7 @@ void CaptureVideoDecoder::OnBufferReadyOnDecoderThread( if (buf->width != capability_.width || buf->height != capability_.height) { capability_.width = buf->width; capability_.height = buf->height; - host()->SetNaturalVideoSize( - gfx::Size(capability_.width, capability_.height)); + host()->SetVideoSize(capability_.width, capability_.height); } // Check if there's a size change. @@ -239,9 +242,6 @@ 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 ef2ffad..0f8b585 100644 --- a/content/renderer/media/capture_video_decoder.h +++ b/content/renderer/media/capture_video_decoder.h @@ -44,7 +44,8 @@ class CaptureVideoDecoder media::StatisticsCallback* stat_callback) OVERRIDE; virtual void ProduceVideoFrame( scoped_refptr<media::VideoFrame> video_frame) OVERRIDE; - virtual gfx::Size natural_size() OVERRIDE; + virtual int width() OVERRIDE; + virtual int height() 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 53f1fce..dfc43a1 100644 --- a/content/renderer/media/rtc_video_decoder.cc +++ b/content/renderer/media/rtc_video_decoder.cc @@ -31,7 +31,8 @@ using media::VideoFrame; RTCVideoDecoder::RTCVideoDecoder(MessageLoop* message_loop, const std::string& url) : message_loop_(message_loop), - visible_size_(176, 144), + width_(176), + height_(144), url_(url), state_(kUnInitialized) { } @@ -124,10 +125,9 @@ 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( - visible_size_.width(), visible_size_.height())); + VideoFrameReady(VideoFrame::CreateBlackFrame(width_, height_)); } state_ = kNormal; @@ -149,16 +149,19 @@ void RTCVideoDecoder::ProduceVideoFrame( frame_queue_available_.push_back(video_frame); } -gfx::Size RTCVideoDecoder::natural_size() { - // TODO(vrk): Return natural size when aspect ratio support is implemented. - return visible_size_; +int RTCVideoDecoder::width() { + return width_; +} + +int RTCVideoDecoder::height() { + return height_; } bool RTCVideoDecoder::SetSize(int width, int height, int reserved) { - visible_size_.SetSize(width, height); + width_ = width; + height_ = height; - // TODO(vrk): Provide natural size when aspect ratio support is implemented. - host()->SetNaturalVideoSize(visible_size_); + host()->SetVideoSize(width_, height_); return true; } @@ -168,7 +171,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_); @@ -179,24 +182,16 @@ bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) { frame_queue_available_.pop_front(); } - // 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. + // Check if there's a size change + if (video_frame->width() != width_ || video_frame->height() != height_) { + // Allocate new buffer based on the new size video_frame = VideoFrame::CreateFrame(VideoFrame::YV12, - visible_size_.width(), - visible_size_.height(), + width_, + 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 99993be..32f9c18 100644 --- a/content/renderer/media/rtc_video_decoder.h +++ b/content/renderer/media/rtc_video_decoder.h @@ -40,7 +40,8 @@ class RTCVideoDecoder media::StatisticsCallback* stat_callback) OVERRIDE; virtual void ProduceVideoFrame( scoped_refptr<media::VideoFrame> video_frame) OVERRIDE; - virtual gfx::Size natural_size() OVERRIDE; + virtual int width() OVERRIDE; + virtual int height() OVERRIDE; // cricket::VideoRenderer implementation virtual bool SetSize(int width, int height, int reserved) OVERRIDE; @@ -62,7 +63,8 @@ class RTCVideoDecoder }; MessageLoop* message_loop_; - gfx::Size visible_size_; + size_t width_; + size_t height_; 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 42954d2..a247777 100644 --- a/content/renderer/media/rtc_video_decoder_unittest.cc +++ b/content/renderer/media/rtc_video_decoder_unittest.cc @@ -160,8 +160,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_->natural_size().width()); - EXPECT_EQ(kHeight, decoder_->natural_size().height()); + EXPECT_EQ(kWidth, decoder_->width()); + EXPECT_EQ(kHeight, decoder_->height()); } TEST_F(RTCVideoDecoderTest, DoSeek) { @@ -215,16 +215,15 @@ 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_, - SetNaturalVideoSize(new_natural_size)).WillRepeatedly(Return()); + SetVideoSize(new_width, new_height)).WillRepeatedly(Return()); decoder_->SetSize(new_width, new_height, new_reserved); - EXPECT_EQ(new_width, decoder_->natural_size().width()); - EXPECT_EQ(new_height, decoder_->natural_size().height()); + EXPECT_EQ(new_width, decoder_->width()); + EXPECT_EQ(new_height, decoder_->height()); message_loop_.RunAllPending(); } |