Chromium Code Reviews| Index: content/common/gpu/media/video_decode_accelerator_unittest.cc |
| diff --git a/content/common/gpu/media/video_decode_accelerator_unittest.cc b/content/common/gpu/media/video_decode_accelerator_unittest.cc |
| index 071dced9f09f49c11f3a2362e5d1037b5c9cc51c..818e54dd82fa9bee8307ecbbfd09662687d4ee5e 100644 |
| --- a/content/common/gpu/media/video_decode_accelerator_unittest.cc |
| +++ b/content/common/gpu/media/video_decode_accelerator_unittest.cc |
| @@ -193,9 +193,10 @@ enum ClientState { |
| // the TESTs below. |
| class GLRenderingVDAClient |
| : public VideoDecodeAccelerator::Client, |
| - public RenderingHelper::Client, |
| public base::SupportsWeakPtr<GLRenderingVDAClient> { |
| public: |
| + // |window_id| the window_id of the client, which is used to identify the |
| + // rendering area in the |rendering_helper|. |
| // Doesn't take ownership of |rendering_helper| or |note|, which must outlive |
| // |*this|. |
| // |num_play_throughs| indicates how many times to play through the video. |
| @@ -212,7 +213,8 @@ class GLRenderingVDAClient |
| // will start delaying the call to ReusePictureBuffer() for kReuseDelay. |
| // |decode_calls_per_second| is the number of VDA::Decode calls per second. |
| // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1. |
| - GLRenderingVDAClient(RenderingHelper* rendering_helper, |
| + GLRenderingVDAClient(size_t window_id, |
| + RenderingHelper* rendering_helper, |
| ClientStateNotification<ClientState>* note, |
| const std::string& encoded_data, |
| int num_in_flight_decodes, |
| @@ -242,14 +244,8 @@ class GLRenderingVDAClient |
| virtual void NotifyResetDone() OVERRIDE; |
| virtual void NotifyError(VideoDecodeAccelerator::Error error) OVERRIDE; |
| - // RenderingHelper::Client implementation. |
| - virtual void RenderContent(RenderingHelper*) OVERRIDE; |
| - virtual const gfx::Size& GetWindowSize() OVERRIDE; |
| - |
| void OutputFrameDeliveryTimes(base::File* output); |
| - void NotifyFrameDropped(int32 picture_buffer_id); |
| - |
| // Simple getters for inspecting the state of the Client. |
| int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; } |
| int num_skipped_fragments() { return num_skipped_fragments_; } |
| @@ -285,6 +281,7 @@ class GLRenderingVDAClient |
| // Request decode of the next fragment in the encoded data. |
| void DecodeNextFragment(); |
| + size_t window_id_; |
| RenderingHelper* rendering_helper_; |
| gfx::Size frame_size_; |
| std::string encoded_data_; |
| @@ -319,13 +316,12 @@ class GLRenderingVDAClient |
| // The number of VDA::Decode calls per second. This is to simulate webrtc. |
| int decode_calls_per_second_; |
| bool render_as_thumbnails_; |
| - bool pending_picture_updated_; |
| - std::deque<int32> pending_picture_buffer_ids_; |
| DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); |
| }; |
| GLRenderingVDAClient::GLRenderingVDAClient( |
| + size_t window_id, |
| RenderingHelper* rendering_helper, |
| ClientStateNotification<ClientState>* note, |
| const std::string& encoded_data, |
| @@ -340,7 +336,8 @@ GLRenderingVDAClient::GLRenderingVDAClient( |
| int delay_reuse_after_frame_num, |
| int decode_calls_per_second, |
| bool render_as_thumbnails) |
| - : rendering_helper_(rendering_helper), |
| + : window_id_(window_id), |
| + rendering_helper_(rendering_helper), |
| frame_size_(frame_width, frame_height), |
| encoded_data_(encoded_data), |
| num_in_flight_decodes_(num_in_flight_decodes), |
| @@ -360,8 +357,7 @@ GLRenderingVDAClient::GLRenderingVDAClient( |
| suppress_rendering_(suppress_rendering), |
| delay_reuse_after_frame_num_(delay_reuse_after_frame_num), |
| decode_calls_per_second_(decode_calls_per_second), |
| - render_as_thumbnails_(render_as_thumbnails), |
| - pending_picture_updated_(true) { |
| + render_as_thumbnails_(render_as_thumbnails) { |
| CHECK_GT(num_in_flight_decodes, 0); |
| CHECK_GT(num_play_throughs, 0); |
| // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. |
| @@ -459,42 +455,6 @@ void GLRenderingVDAClient::DismissPictureBuffer(int32 picture_buffer_id) { |
| picture_buffers_by_id_.erase(it); |
| } |
| -void GLRenderingVDAClient::RenderContent(RenderingHelper*) { |
| - CHECK(!render_as_thumbnails_); |
| - |
| - // No decoded texture for rendering yet, just skip. |
| - if (pending_picture_buffer_ids_.size() == 0) |
| - return; |
| - |
| - int32 buffer_id = pending_picture_buffer_ids_.front(); |
| - media::PictureBuffer* picture_buffer = picture_buffers_by_id_[buffer_id]; |
| - |
| - CHECK(picture_buffer); |
| - if (!pending_picture_updated_) { |
| - // Frame dropped, just redraw the last texture. |
| - rendering_helper_->RenderTexture(texture_target_, |
| - picture_buffer->texture_id()); |
| - return; |
| - } |
| - |
| - base::TimeTicks now = base::TimeTicks::Now(); |
| - frame_delivery_times_.push_back(now); |
| - |
| - rendering_helper_->RenderTexture(texture_target_, |
| - picture_buffer->texture_id()); |
| - |
| - if (pending_picture_buffer_ids_.size() == 1) { |
| - pending_picture_updated_ = false; |
| - } else { |
| - pending_picture_buffer_ids_.pop_front(); |
| - ReturnPicture(buffer_id); |
| - } |
| -} |
| - |
| -const gfx::Size& GLRenderingVDAClient::GetWindowSize() { |
| - return render_as_thumbnails_ ? kThumbnailsPageSize : frame_size_; |
| -} |
| - |
| void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { |
| // We shouldn't be getting pictures delivered after Reset has completed. |
| CHECK_LT(state_, CS_RESET); |
| @@ -503,6 +463,9 @@ void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { |
| return; |
| base::TimeTicks now = base::TimeTicks::Now(); |
| + |
| + frame_delivery_times_.push_back(now); |
|
Pawel Osciak
2014/08/14 04:48:23
Yay!
Owen Lin
2014/08/14 09:20:41
We will need to change the autotest code to reflec
Pawel Osciak
2014/08/15 05:45:16
Still :)
|
| + |
| // Save the decode time of this picture. |
| std::map<int, base::TimeTicks>::iterator it = |
| decode_start_time_.find(picture.bitstream_buffer_id()); |
| @@ -524,25 +487,22 @@ void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { |
| encoded_data_next_pos_to_decode_ = 0; |
| } |
| + media::PictureBuffer* picture_buffer = |
| + picture_buffers_by_id_[picture.picture_buffer_id()]; |
| + CHECK(picture_buffer); |
| + |
| + scoped_ptr<VideoFrame> video_frame( |
| + new VideoFrame(texture_target_, |
| + picture_buffer->texture_id(), |
| + base::Bind(&GLRenderingVDAClient::ReturnPicture, |
| + AsWeakPtr(), |
| + picture.picture_buffer_id()))); |
| + |
| if (render_as_thumbnails_) { |
| - frame_delivery_times_.push_back(now); |
| - media::PictureBuffer* picture_buffer = |
| - picture_buffers_by_id_[picture.picture_buffer_id()]; |
| - CHECK(picture_buffer); |
| - rendering_helper_->RenderThumbnail(texture_target_, |
| - picture_buffer->texture_id()); |
| - ReturnPicture(picture.picture_buffer_id()); |
| + rendering_helper_->RenderThumbnail(video_frame->texture_target(), |
| + video_frame->texture_id()); |
| } else if (!suppress_rendering_) { |
| - // Keep the picture for rendering. |
| - pending_picture_buffer_ids_.push_back(picture.picture_buffer_id()); |
| - if (pending_picture_buffer_ids_.size() > 1 && !pending_picture_updated_) { |
| - ReturnPicture(pending_picture_buffer_ids_.front()); |
| - pending_picture_buffer_ids_.pop_front(); |
| - pending_picture_updated_ = true; |
| - } |
| - } else { |
| - frame_delivery_times_.push_back(now); |
| - ReturnPicture(picture.picture_buffer_id()); |
| + rendering_helper_->QueueVideoFrame(window_id_, video_frame.Pass()); |
| } |
| } |
| @@ -590,12 +550,7 @@ void GLRenderingVDAClient::NotifyResetDone() { |
| if (decoder_deleted()) |
| return; |
| - // Clear pending_pictures and reuse them. |
| - while (!pending_picture_buffer_ids_.empty()) { |
| - decoder_->ReusePictureBuffer(pending_picture_buffer_ids_.front()); |
| - pending_picture_buffer_ids_.pop_front(); |
| - } |
| - pending_picture_updated_ = true; |
| + rendering_helper_->ClearVideoFrames(window_id_); |
| if (reset_after_frame_num_ == MID_STREAM_RESET) { |
| reset_after_frame_num_ = END_OF_STREAM_RESET; |
| @@ -637,10 +592,6 @@ void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) { |
| } |
| } |
| -void GLRenderingVDAClient::NotifyFrameDropped(int32 picture_buffer_id) { |
| - decoder_->ReusePictureBuffer(picture_buffer_id); |
| -} |
| - |
| static bool LookingAtNAL(const std::string& encoded, size_t pos) { |
| return encoded[pos] == 0 && encoded[pos + 1] == 0 && |
| encoded[pos + 2] == 0 && encoded[pos + 3] == 1; |
| @@ -1127,7 +1078,8 @@ TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { |
| } |
| GLRenderingVDAClient* client = |
| - new GLRenderingVDAClient(&rendering_helper_, |
| + new GLRenderingVDAClient(index, |
| + &rendering_helper_, |
| note, |
| video_file->data_str, |
| num_in_flight_decodes, |
| @@ -1143,7 +1095,10 @@ TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { |
| render_as_thumbnails); |
| clients[index] = client; |
| - helper_params.clients.push_back(client->AsWeakPtr()); |
| + helper_params.window_sizes.push_back( |
| + render_as_thumbnails |
| + ? kThumbnailsPageSize |
| + : gfx::Size(video_file->width, video_file->height)); |
| } |
| InitializeRenderingHelper(helper_params); |
| @@ -1376,7 +1331,8 @@ TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
| ClientStateNotification<ClientState>* note = |
| new ClientStateNotification<ClientState>(); |
| GLRenderingVDAClient* client = |
| - new GLRenderingVDAClient(&rendering_helper_, |
| + new GLRenderingVDAClient(0, |
| + &rendering_helper_, |
| note, |
| test_video_files_[0]->data_str, |
| 1, |
| @@ -1390,7 +1346,8 @@ TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
| std::numeric_limits<int>::max(), |
| kWebRtcDecodeCallsPerSecond, |
| false /* render_as_thumbnail */); |
| - helper_params.clients.push_back(client->AsWeakPtr()); |
| + helper_params.window_sizes.push_back( |
| + gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); |
| InitializeRenderingHelper(helper_params); |
| CreateAndStartDecoder(client, note); |
| WaitUntilDecodeFinish(note); |
| @@ -1420,17 +1377,17 @@ TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
| int main(int argc, char **argv) { |
| testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. |
| - base::CommandLine::Init(argc, argv); |
| + CommandLine::Init(argc, argv); |
|
Pawel Osciak
2014/08/14 04:48:24
Please don't remove base::
Owen Lin
2014/08/14 09:20:42
git cl format did it for me.
Pawel Osciak
2014/08/15 05:45:16
We just had crrev.com/288787, so I think we are su
|
| // Needed to enable DVLOG through --vmodule. |
| logging::LoggingSettings settings; |
| settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| CHECK(logging::InitLogging(settings)); |
| - const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| + CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
|
Pawel Osciak
2014/08/14 04:48:24
nit: const
Owen Lin
2014/08/14 09:20:42
Again, git cl format did it.
|
| DCHECK(cmd_line); |
| - base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); |
| + CommandLine::SwitchMap switches = cmd_line->GetSwitches(); |
| for (CommandLine::SwitchMap::const_iterator it = switches.begin(); |
| it != switches.end(); ++it) { |
| if (it->first == "test_video_data") { |