| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // The bulk of this file is support code; sorry about that. Here's an overview | 5 // The bulk of this file is support code; sorry about that. Here's an overview |
| 6 // to hopefully help readers of this code: | 6 // to hopefully help readers of this code: |
| 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or | 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or |
| 8 // Win/EGL. | 8 // Win/EGL. |
| 9 // - ClientState is an enum for the state of the decode client used by the test. | 9 // - ClientState is an enum for the state of the decode client used by the test. |
| 10 // - ClientStateNotification is a barrier abstraction that allows the test code | 10 // - ClientStateNotification is a barrier abstraction that allows the test code |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // |delete_decoder_state| indicates when the underlying decoder should be | 318 // |delete_decoder_state| indicates when the underlying decoder should be |
| 319 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() | 319 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() |
| 320 // calls have been made, N>=0 means interpret as ClientState. | 320 // calls have been made, N>=0 means interpret as ClientState. |
| 321 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the | 321 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the |
| 322 // last play-through (governed by |num_play_throughs|). | 322 // last play-through (governed by |num_play_throughs|). |
| 323 // |suppress_rendering| indicates GL rendering is supressed or not. | 323 // |suppress_rendering| indicates GL rendering is supressed or not. |
| 324 // After |delay_reuse_after_frame_num| frame has been delivered, the client | 324 // After |delay_reuse_after_frame_num| frame has been delivered, the client |
| 325 // will start delaying the call to ReusePictureBuffer() for kReuseDelay. | 325 // will start delaying the call to ReusePictureBuffer() for kReuseDelay. |
| 326 // |decode_calls_per_second| is the number of VDA::Decode calls per second. | 326 // |decode_calls_per_second| is the number of VDA::Decode calls per second. |
| 327 // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1. | 327 // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1. |
| 328 // When |test_full_flush| is true, request the VDA to return all buffers it |
| 329 // owns on Flush(), and verify that. |
| 328 GLRenderingVDAClient(size_t window_id, | 330 GLRenderingVDAClient(size_t window_id, |
| 329 RenderingHelper* rendering_helper, | 331 RenderingHelper* rendering_helper, |
| 330 ClientStateNotification<ClientState>* note, | 332 ClientStateNotification<ClientState>* note, |
| 331 const std::string& encoded_data, | 333 const std::string& encoded_data, |
| 332 int num_in_flight_decodes, | 334 int num_in_flight_decodes, |
| 333 int num_play_throughs, | 335 int num_play_throughs, |
| 334 int reset_after_frame_num, | 336 int reset_after_frame_num, |
| 335 int delete_decoder_state, | 337 int delete_decoder_state, |
| 336 int frame_width, | 338 int frame_width, |
| 337 int frame_height, | 339 int frame_height, |
| 338 media::VideoCodecProfile profile, | 340 media::VideoCodecProfile profile, |
| 339 int fake_decoder, | 341 int fake_decoder, |
| 340 bool suppress_rendering, | 342 bool suppress_rendering, |
| 341 int delay_reuse_after_frame_num, | 343 int delay_reuse_after_frame_num, |
| 342 int decode_calls_per_second, | 344 int decode_calls_per_second, |
| 343 bool render_as_thumbnails); | 345 bool render_as_thumbnails, |
| 346 bool test_full_flush); |
| 344 ~GLRenderingVDAClient() override; | 347 ~GLRenderingVDAClient() override; |
| 345 void CreateAndStartDecoder(); | 348 void CreateAndStartDecoder(); |
| 346 | 349 |
| 347 // VideoDecodeAccelerator::Client implementation. | 350 // VideoDecodeAccelerator::Client implementation. |
| 348 // The heart of the Client. | 351 // The heart of the Client. |
| 349 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, | 352 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, |
| 350 uint32_t textures_per_buffer, | 353 uint32_t textures_per_buffer, |
| 351 const gfx::Size& dimensions, | 354 const gfx::Size& dimensions, |
| 352 uint32_t texture_target) override; | 355 uint32_t texture_target) override; |
| 353 void DismissPictureBuffer(int32_t picture_buffer_id) override; | 356 void DismissPictureBuffer(int32_t picture_buffer_id) override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 368 double frames_per_second(); | 371 double frames_per_second(); |
| 369 // Return the median of the decode time of all decoded frames. | 372 // Return the median of the decode time of all decoded frames. |
| 370 base::TimeDelta decode_time_median(); | 373 base::TimeDelta decode_time_median(); |
| 371 bool decoder_deleted() { return !decoder_.get(); } | 374 bool decoder_deleted() { return !decoder_.get(); } |
| 372 | 375 |
| 373 private: | 376 private: |
| 374 typedef std::map<int32_t, scoped_refptr<TextureRef>> TextureRefMap; | 377 typedef std::map<int32_t, scoped_refptr<TextureRef>> TextureRefMap; |
| 375 | 378 |
| 376 void SetState(ClientState new_state); | 379 void SetState(ClientState new_state); |
| 377 void FinishInitialization(); | 380 void FinishInitialization(); |
| 381 void ReturnTexture(int32_t picture_buffer_id); |
| 378 void ReturnPicture(int32_t picture_buffer_id); | 382 void ReturnPicture(int32_t picture_buffer_id); |
| 383 void CallReusePicture(int32_t picture_buffer_id); |
| 384 void FinishFlush(); |
| 379 | 385 |
| 380 // Delete the associated decoder helper. | 386 // Delete the associated decoder helper. |
| 381 void DeleteDecoder(); | 387 void DeleteDecoder(); |
| 382 | 388 |
| 383 // Compute & return the first encoded bytes (including a start frame) to send | 389 // Compute & return the first encoded bytes (including a start frame) to send |
| 384 // to the decoder, starting at |start_pos| and returning one fragment. Skips | 390 // to the decoder, starting at |start_pos| and returning one fragment. Skips |
| 385 // to the first decodable position. | 391 // to the first decodable position. |
| 386 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos); | 392 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos); |
| 387 // Compute & return the encoded bytes of next fragment to send to the decoder | 393 // Compute & return the encoded bytes of next fragment to send to the decoder |
| 388 // (based on |start_pos|). | 394 // (based on |start_pos|). |
| (...skipping 21 matching lines...) Expand all Loading... |
| 410 weak_vda_ptr_factory_; | 416 weak_vda_ptr_factory_; |
| 411 std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory_; | 417 std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory_; |
| 412 int remaining_play_throughs_; | 418 int remaining_play_throughs_; |
| 413 int reset_after_frame_num_; | 419 int reset_after_frame_num_; |
| 414 int delete_decoder_state_; | 420 int delete_decoder_state_; |
| 415 ClientState state_; | 421 ClientState state_; |
| 416 int num_skipped_fragments_; | 422 int num_skipped_fragments_; |
| 417 int num_queued_fragments_; | 423 int num_queued_fragments_; |
| 418 int num_decoded_frames_; | 424 int num_decoded_frames_; |
| 419 int num_done_bitstream_buffers_; | 425 int num_done_bitstream_buffers_; |
| 426 int num_pictures_at_decoder_; |
| 420 base::TimeTicks initialize_done_ticks_; | 427 base::TimeTicks initialize_done_ticks_; |
| 421 media::VideoCodecProfile profile_; | 428 media::VideoCodecProfile profile_; |
| 422 int fake_decoder_; | 429 int fake_decoder_; |
| 423 GLenum texture_target_; | 430 GLenum texture_target_; |
| 424 bool suppress_rendering_; | 431 bool suppress_rendering_; |
| 425 std::vector<base::TimeTicks> frame_delivery_times_; | 432 std::vector<base::TimeTicks> frame_delivery_times_; |
| 426 int delay_reuse_after_frame_num_; | 433 int delay_reuse_after_frame_num_; |
| 427 // A map from bitstream buffer id to the decode start time of the buffer. | 434 // A map from bitstream buffer id to the decode start time of the buffer. |
| 428 std::map<int, base::TimeTicks> decode_start_time_; | 435 std::map<int, base::TimeTicks> decode_start_time_; |
| 429 // The decode time of all decoded frames. | 436 // The decode time of all decoded frames. |
| 430 std::vector<base::TimeDelta> decode_time_; | 437 std::vector<base::TimeDelta> decode_time_; |
| 431 // The number of VDA::Decode calls per second. This is to simulate webrtc. | 438 // The number of VDA::Decode calls per second. This is to simulate webrtc. |
| 432 int decode_calls_per_second_; | 439 int decode_calls_per_second_; |
| 433 bool render_as_thumbnails_; | 440 bool render_as_thumbnails_; |
| 441 bool test_full_flush_; |
| 434 | 442 |
| 435 // A map of the textures that are currently active for the decoder, i.e., | 443 // A map of the textures that are currently active for the decoder, i.e., |
| 436 // have been created via AssignPictureBuffers() and not dismissed via | 444 // have been created via AssignPictureBuffers() and not dismissed via |
| 437 // DismissPictureBuffer(). The keys in the map are the IDs of the | 445 // DismissPictureBuffer(). The keys in the map are the IDs of the |
| 438 // corresponding picture buffers, and the values are TextureRefs to the | 446 // corresponding picture buffers, and the values are TextureRefs to the |
| 439 // textures. | 447 // textures. |
| 440 TextureRefMap active_textures_; | 448 TextureRefMap active_textures_; |
| 441 | 449 |
| 442 // A map of the textures that are still pending in the renderer. | 450 // A map of the textures that are still pending in the renderer. |
| 443 // We check this to ensure all frames are rendered before entering the | 451 // We check this to ensure all frames are rendered before entering the |
| (...skipping 28 matching lines...) Expand all Loading... |
| 472 int num_play_throughs, | 480 int num_play_throughs, |
| 473 int reset_after_frame_num, | 481 int reset_after_frame_num, |
| 474 int delete_decoder_state, | 482 int delete_decoder_state, |
| 475 int frame_width, | 483 int frame_width, |
| 476 int frame_height, | 484 int frame_height, |
| 477 media::VideoCodecProfile profile, | 485 media::VideoCodecProfile profile, |
| 478 int fake_decoder, | 486 int fake_decoder, |
| 479 bool suppress_rendering, | 487 bool suppress_rendering, |
| 480 int delay_reuse_after_frame_num, | 488 int delay_reuse_after_frame_num, |
| 481 int decode_calls_per_second, | 489 int decode_calls_per_second, |
| 482 bool render_as_thumbnails) | 490 bool render_as_thumbnails, |
| 491 bool test_full_flush) |
| 483 : window_id_(window_id), | 492 : window_id_(window_id), |
| 484 rendering_helper_(rendering_helper), | 493 rendering_helper_(rendering_helper), |
| 485 frame_size_(frame_width, frame_height), | 494 frame_size_(frame_width, frame_height), |
| 486 encoded_data_(encoded_data), | 495 encoded_data_(encoded_data), |
| 487 num_in_flight_decodes_(num_in_flight_decodes), | 496 num_in_flight_decodes_(num_in_flight_decodes), |
| 488 outstanding_decodes_(0), | 497 outstanding_decodes_(0), |
| 489 encoded_data_next_pos_to_decode_(0), | 498 encoded_data_next_pos_to_decode_(0), |
| 490 next_bitstream_buffer_id_(0), | 499 next_bitstream_buffer_id_(0), |
| 491 note_(note), | 500 note_(note), |
| 492 remaining_play_throughs_(num_play_throughs), | 501 remaining_play_throughs_(num_play_throughs), |
| 493 reset_after_frame_num_(reset_after_frame_num), | 502 reset_after_frame_num_(reset_after_frame_num), |
| 494 delete_decoder_state_(delete_decoder_state), | 503 delete_decoder_state_(delete_decoder_state), |
| 495 state_(CS_CREATED), | 504 state_(CS_CREATED), |
| 496 num_skipped_fragments_(0), | 505 num_skipped_fragments_(0), |
| 497 num_queued_fragments_(0), | 506 num_queued_fragments_(0), |
| 498 num_decoded_frames_(0), | 507 num_decoded_frames_(0), |
| 499 num_done_bitstream_buffers_(0), | 508 num_done_bitstream_buffers_(0), |
| 509 num_pictures_at_decoder_(0), |
| 500 fake_decoder_(fake_decoder), | 510 fake_decoder_(fake_decoder), |
| 501 texture_target_(0), | 511 texture_target_(0), |
| 502 suppress_rendering_(suppress_rendering), | 512 suppress_rendering_(suppress_rendering), |
| 503 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), | 513 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), |
| 504 decode_calls_per_second_(decode_calls_per_second), | 514 decode_calls_per_second_(decode_calls_per_second), |
| 505 render_as_thumbnails_(render_as_thumbnails), | 515 render_as_thumbnails_(render_as_thumbnails), |
| 516 test_full_flush_(test_full_flush), |
| 506 next_picture_buffer_id_(1), | 517 next_picture_buffer_id_(1), |
| 507 weak_this_factory_(this) { | 518 weak_this_factory_(this) { |
| 508 LOG_ASSERT(num_in_flight_decodes > 0); | 519 LOG_ASSERT(num_in_flight_decodes > 0); |
| 509 LOG_ASSERT(num_play_throughs > 0); | 520 LOG_ASSERT(num_play_throughs > 0); |
| 510 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. | 521 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. |
| 511 if (decode_calls_per_second_ > 0) | 522 if (decode_calls_per_second_ > 0) |
| 512 LOG_ASSERT(1 == num_in_flight_decodes_); | 523 LOG_ASSERT(1 == num_in_flight_decodes_); |
| 513 | 524 |
| 514 // Default to H264 baseline if no profile provided. | 525 // Default to H264 baseline if no profile provided. |
| 515 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN | 526 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN |
| 516 ? profile | 527 ? profile |
| 517 : media::H264PROFILE_BASELINE); | 528 : media::H264PROFILE_BASELINE); |
| 518 | 529 |
| 519 weak_this_ = weak_this_factory_.GetWeakPtr(); | 530 weak_this_ = weak_this_factory_.GetWeakPtr(); |
| 520 } | 531 } |
| 521 | 532 |
| 522 GLRenderingVDAClient::~GLRenderingVDAClient() { | 533 GLRenderingVDAClient::~GLRenderingVDAClient() { |
| 523 DeleteDecoder(); // Clean up in case of expected error. | 534 DeleteDecoder(); // Clean up in case of expected error. |
| 524 LOG_ASSERT(decoder_deleted()); | 535 LOG_ASSERT(decoder_deleted()); |
| 525 SetState(CS_DESTROYED); | 536 SetState(CS_DESTROYED); |
| 526 } | 537 } |
| 527 | 538 |
| 528 void GLRenderingVDAClient::CreateAndStartDecoder() { | 539 void GLRenderingVDAClient::CreateAndStartDecoder() { |
| 529 LOG_ASSERT(decoder_deleted()); | 540 LOG_ASSERT(decoder_deleted()); |
| 530 LOG_ASSERT(!decoder_.get()); | 541 LOG_ASSERT(!decoder_.get()); |
| 531 | 542 |
| 543 VideoDecodeAccelerator::Config config(profile_); |
| 544 config.output_mode = |
| 545 (g_test_import |
| 546 ? media::VideoDecodeAccelerator::Config::OutputMode::IMPORT |
| 547 : media::VideoDecodeAccelerator::Config::OutputMode::ALLOCATE); |
| 548 config.flush_mode = |
| 549 (test_full_flush_ ? media::VideoDecodeAccelerator::Config::FlushMode:: |
| 550 RETURN_OUTPUT_BUFFERS |
| 551 : media::VideoDecodeAccelerator::Config::FlushMode:: |
| 552 KEEP_OUTPUT_BUFFERS); |
| 532 if (fake_decoder_) { | 553 if (fake_decoder_) { |
| 533 decoder_.reset(new FakeVideoDecodeAccelerator( | 554 decoder_.reset(new FakeVideoDecodeAccelerator( |
| 534 frame_size_, base::Bind(&DoNothingReturnTrue))); | 555 frame_size_, base::Bind(&DoNothingReturnTrue))); |
| 535 LOG_ASSERT(decoder_->Initialize(profile_, this)); | 556 LOG_ASSERT(decoder_->Initialize(config, this)); |
| 536 } else { | 557 } else { |
| 537 if (!vda_factory_) { | 558 if (!vda_factory_) { |
| 538 vda_factory_ = GpuVideoDecodeAcceleratorFactoryImpl::Create( | 559 vda_factory_ = GpuVideoDecodeAcceleratorFactoryImpl::Create( |
| 539 base::Bind(&RenderingHelper::GetGLContext, | 560 base::Bind(&RenderingHelper::GetGLContext, |
| 540 base::Unretained(rendering_helper_)), | 561 base::Unretained(rendering_helper_)), |
| 541 base::Bind(&DoNothingReturnTrue), base::Bind(&DummyBindImage)); | 562 base::Bind(&DoNothingReturnTrue), base::Bind(&DummyBindImage)); |
| 542 LOG_ASSERT(vda_factory_); | 563 LOG_ASSERT(vda_factory_); |
| 543 } | 564 } |
| 544 | 565 |
| 545 VideoDecodeAccelerator::Config config(profile_); | |
| 546 if (g_test_import) { | |
| 547 config.output_mode = | |
| 548 media::VideoDecodeAccelerator::Config::OutputMode::IMPORT; | |
| 549 } | |
| 550 gpu::GpuPreferences gpu_preferences; | 566 gpu::GpuPreferences gpu_preferences; |
| 551 decoder_ = vda_factory_->CreateVDA(this, config, gpu_preferences); | 567 decoder_ = vda_factory_->CreateVDA(this, config, gpu_preferences); |
| 552 } | 568 } |
| 553 | 569 |
| 554 LOG_ASSERT(decoder_) << "Failed creating a VDA"; | 570 LOG_ASSERT(decoder_) << "Failed creating a VDA"; |
| 571 weak_vda_ptr_factory_.reset( |
| 572 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); |
| 573 weak_vda_ = weak_vda_ptr_factory_->GetWeakPtr(); |
| 555 | 574 |
| 556 decoder_->TryToSetupDecodeOnSeparateThread( | 575 decoder_->TryToSetupDecodeOnSeparateThread( |
| 557 weak_this_, base::ThreadTaskRunnerHandle::Get()); | 576 weak_this_, base::ThreadTaskRunnerHandle::Get()); |
| 558 | 577 |
| 559 SetState(CS_DECODER_SET); | 578 SetState(CS_DECODER_SET); |
| 560 FinishInitialization(); | 579 FinishInitialization(); |
| 561 } | 580 } |
| 562 | 581 |
| 563 namespace { | 582 namespace { |
| 564 gfx::BufferFormat VideoPixelFormatToGfxBufferFormat( | 583 gfx::BufferFormat VideoPixelFormatToGfxBufferFormat( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 int duped_fd = HANDLE_EINTR(dup(pixmap->GetDmaBufFd())); | 657 int duped_fd = HANDLE_EINTR(dup(pixmap->GetDmaBufFd())); |
| 639 ASSERT_NE(duped_fd, -1); | 658 ASSERT_NE(duped_fd, -1); |
| 640 gfx::GpuMemoryBufferHandle handle; | 659 gfx::GpuMemoryBufferHandle handle; |
| 641 handle.type = gfx::OZONE_NATIVE_PIXMAP; | 660 handle.type = gfx::OZONE_NATIVE_PIXMAP; |
| 642 handle.native_pixmap_handle.fd = base::FileDescriptor(duped_fd, true); | 661 handle.native_pixmap_handle.fd = base::FileDescriptor(duped_fd, true); |
| 643 std::vector<gfx::GpuMemoryBufferHandle> handles; | 662 std::vector<gfx::GpuMemoryBufferHandle> handles; |
| 644 handles.push_back(handle); | 663 handles.push_back(handle); |
| 645 decoder_->ImportBufferForPicture(buffer.id(), handles); | 664 decoder_->ImportBufferForPicture(buffer.id(), handles); |
| 646 } | 665 } |
| 647 } | 666 } |
| 667 |
| 668 num_pictures_at_decoder_ = buffers.size(); |
| 648 } | 669 } |
| 649 | 670 |
| 650 void GLRenderingVDAClient::DismissPictureBuffer(int32_t picture_buffer_id) { | 671 void GLRenderingVDAClient::DismissPictureBuffer(int32_t picture_buffer_id) { |
| 651 LOG_ASSERT(1U == active_textures_.erase(picture_buffer_id)); | 672 LOG_ASSERT(1U == active_textures_.erase(picture_buffer_id)); |
| 673 EXPECT_GT(num_pictures_at_decoder_, 0); |
| 674 --num_pictures_at_decoder_; |
| 652 } | 675 } |
| 653 | 676 |
| 654 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { | 677 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { |
| 655 // We shouldn't be getting pictures delivered after Reset has completed. | 678 // We shouldn't be getting pictures delivered after Reset has completed. |
| 656 LOG_ASSERT(state_ < CS_RESET); | 679 LOG_ASSERT(state_ < CS_RESET); |
| 657 | 680 |
| 658 if (decoder_deleted()) | 681 if (decoder_deleted()) |
| 659 return; | 682 return; |
| 660 | 683 |
| 684 EXPECT_GT(num_pictures_at_decoder_, 0); |
| 685 --num_pictures_at_decoder_; |
| 686 |
| 687 if (picture.bitstream_buffer_id() == -1) { |
| 688 // The picture does not contain any decoded data, reuse it immediately. |
| 689 ReturnPicture(picture.picture_buffer_id()); |
| 690 return; |
| 691 } |
| 692 |
| 661 base::TimeTicks now = base::TimeTicks::Now(); | 693 base::TimeTicks now = base::TimeTicks::Now(); |
| 662 | 694 |
| 663 frame_delivery_times_.push_back(now); | 695 frame_delivery_times_.push_back(now); |
| 664 | 696 |
| 665 // Save the decode time of this picture. | 697 // Save the decode time of this picture. |
| 666 std::map<int, base::TimeTicks>::iterator it = | 698 std::map<int, base::TimeTicks>::iterator it = |
| 667 decode_start_time_.find(picture.bitstream_buffer_id()); | 699 decode_start_time_.find(picture.bitstream_buffer_id()); |
| 668 ASSERT_NE(decode_start_time_.end(), it); | 700 ASSERT_NE(decode_start_time_.end(), it); |
| 669 decode_time_.push_back(now - it->second); | 701 decode_time_.push_back(now - it->second); |
| 670 decode_start_time_.erase(it); | 702 decode_start_time_.erase(it); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 682 // know how to find I-frames and so on in this test. | 714 // know how to find I-frames and so on in this test. |
| 683 encoded_data_next_pos_to_decode_ = 0; | 715 encoded_data_next_pos_to_decode_ = 0; |
| 684 } | 716 } |
| 685 | 717 |
| 686 TextureRefMap::iterator texture_it = | 718 TextureRefMap::iterator texture_it = |
| 687 active_textures_.find(picture.picture_buffer_id()); | 719 active_textures_.find(picture.picture_buffer_id()); |
| 688 ASSERT_NE(active_textures_.end(), texture_it); | 720 ASSERT_NE(active_textures_.end(), texture_it); |
| 689 | 721 |
| 690 scoped_refptr<VideoFrameTexture> video_frame = new VideoFrameTexture( | 722 scoped_refptr<VideoFrameTexture> video_frame = new VideoFrameTexture( |
| 691 texture_target_, texture_it->second->texture_id(), | 723 texture_target_, texture_it->second->texture_id(), |
| 692 base::Bind(&GLRenderingVDAClient::ReturnPicture, AsWeakPtr(), | 724 base::Bind(&GLRenderingVDAClient::ReturnTexture, AsWeakPtr(), |
| 693 picture.picture_buffer_id())); | 725 picture.picture_buffer_id())); |
| 694 ASSERT_TRUE(pending_textures_.insert(*texture_it).second); | 726 ASSERT_TRUE(pending_textures_.insert(*texture_it).second); |
| 695 | 727 |
| 696 if (render_as_thumbnails_) { | 728 if (render_as_thumbnails_) { |
| 697 rendering_helper_->RenderThumbnail(video_frame->texture_target(), | 729 rendering_helper_->RenderThumbnail(video_frame->texture_target(), |
| 698 video_frame->texture_id()); | 730 video_frame->texture_id()); |
| 699 } else if (!suppress_rendering_) { | 731 } else if (!suppress_rendering_) { |
| 700 rendering_helper_->QueueVideoFrame(window_id_, video_frame); | 732 rendering_helper_->QueueVideoFrame(window_id_, video_frame); |
| 701 } | 733 } |
| 702 } | 734 } |
| 703 | 735 |
| 704 void GLRenderingVDAClient::ReturnPicture(int32_t picture_buffer_id) { | 736 void GLRenderingVDAClient::ReturnTexture(int32_t picture_buffer_id) { |
| 705 if (decoder_deleted()) | 737 if (decoder_deleted()) |
| 706 return; | 738 return; |
| 739 |
| 707 LOG_ASSERT(1U == pending_textures_.erase(picture_buffer_id)); | 740 LOG_ASSERT(1U == pending_textures_.erase(picture_buffer_id)); |
| 708 | 741 |
| 709 if (pending_textures_.empty() && state_ == CS_RESETTING) { | 742 if (pending_textures_.empty() && state_ == CS_RESETTING) { |
| 710 SetState(CS_RESET); | 743 SetState(CS_RESET); |
| 711 DeleteDecoder(); | 744 DeleteDecoder(); |
| 712 return; | 745 return; |
| 713 } | 746 } |
| 714 | 747 |
| 748 ReturnPicture(picture_buffer_id); |
| 749 } |
| 750 |
| 751 void GLRenderingVDAClient::CallReusePicture(int32_t picture_buffer_id) { |
| 752 if (state_ == CS_FLUSHED && test_full_flush_) { |
| 753 // If we just got a notification from the VDA that it's flushed and are |
| 754 // testing full flush, we want to have a chance to test that VDA really |
| 755 // returned all buffers before NotifyFlushDone(). Delay returning the buffer |
| 756 // so that we have a chance in FinishFlush() to test we got all the buffers. |
| 757 base::MessageLoop::current()->PostTask( |
| 758 FROM_HERE, base::Bind(&GLRenderingVDAClient::CallReusePicture, |
| 759 weak_this_, picture_buffer_id)); |
| 760 return; |
| 761 } |
| 762 |
| 763 if (weak_vda_) |
| 764 weak_vda_->ReusePictureBuffer(picture_buffer_id); |
| 765 ++num_pictures_at_decoder_; |
| 766 } |
| 767 |
| 768 void GLRenderingVDAClient::ReturnPicture(int32_t picture_buffer_id) { |
| 715 if (num_decoded_frames_ > delay_reuse_after_frame_num_) { | 769 if (num_decoded_frames_ > delay_reuse_after_frame_num_) { |
| 716 base::MessageLoop::current()->PostDelayedTask( | 770 base::MessageLoop::current()->PostDelayedTask( |
| 717 FROM_HERE, base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, | 771 FROM_HERE, base::Bind(&GLRenderingVDAClient::CallReusePicture, |
| 718 weak_vda_, picture_buffer_id), | 772 weak_this_, picture_buffer_id), |
| 719 kReuseDelay); | 773 kReuseDelay); |
| 720 } else { | 774 } else { |
| 721 decoder_->ReusePictureBuffer(picture_buffer_id); | 775 base::MessageLoop::current()->PostTask( |
| 776 FROM_HERE, base::Bind(&GLRenderingVDAClient::CallReusePicture, |
| 777 weak_this_, picture_buffer_id)); |
| 722 } | 778 } |
| 723 } | 779 } |
| 724 | 780 |
| 725 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( | 781 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( |
| 726 int32_t bitstream_buffer_id) { | 782 int32_t bitstream_buffer_id) { |
| 727 // TODO(fischman): this test currently relies on this notification to make | 783 // TODO(fischman): this test currently relies on this notification to make |
| 728 // forward progress during a Reset(). But the VDA::Reset() API doesn't | 784 // forward progress during a Reset(). But the VDA::Reset() API doesn't |
| 729 // guarantee this, so stop relying on it (and remove the notifications from | 785 // guarantee this, so stop relying on it (and remove the notifications from |
| 730 // VaapiVideoDecodeAccelerator::FinishReset()). | 786 // VaapiVideoDecodeAccelerator::FinishReset()). |
| 731 ++num_done_bitstream_buffers_; | 787 ++num_done_bitstream_buffers_; |
| 732 --outstanding_decodes_; | 788 --outstanding_decodes_; |
| 733 | 789 |
| 734 // Flush decoder after all BitstreamBuffers are processed. | 790 // Flush decoder after all BitstreamBuffers are processed. |
| 735 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { | 791 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { |
| 736 // TODO(owenlin): We should not have to check the number of | 792 // TODO(owenlin): We should not have to check the number of |
| 737 // |outstanding_decodes_|. |decoder_| should be able to accept Flush() | 793 // |outstanding_decodes_|. |decoder_| should be able to accept Flush() |
| 738 // before it's done with outstanding decodes. (crbug.com/528183) | 794 // before it's done with outstanding decodes. (crbug.com/528183) |
| 739 if (outstanding_decodes_ == 0) { | 795 if (outstanding_decodes_ == 0) { |
| 740 decoder_->Flush(); | 796 decoder_->Flush(); |
| 741 SetState(CS_FLUSHING); | 797 SetState(CS_FLUSHING); |
| 742 } | 798 } |
| 743 } else if (decode_calls_per_second_ == 0) { | 799 } else if (decode_calls_per_second_ == 0) { |
| 744 DecodeNextFragment(); | 800 DecodeNextFragment(); |
| 745 } | 801 } |
| 746 } | 802 } |
| 747 | 803 |
| 748 void GLRenderingVDAClient::NotifyFlushDone() { | 804 void GLRenderingVDAClient::FinishFlush() { |
| 749 if (decoder_deleted()) | 805 ASSERT_EQ(CS_FLUSHED, state_); |
| 750 return; | 806 if (test_full_flush_) |
| 807 EXPECT_EQ(0, num_pictures_at_decoder_); |
| 751 | 808 |
| 752 SetState(CS_FLUSHED); | |
| 753 --remaining_play_throughs_; | 809 --remaining_play_throughs_; |
| 754 DCHECK_GE(remaining_play_throughs_, 0); | 810 DCHECK_GE(remaining_play_throughs_, 0); |
| 755 if (decoder_deleted()) | 811 if (decoder_deleted()) |
| 756 return; | 812 return; |
| 757 decoder_->Reset(); | 813 decoder_->Reset(); |
| 758 SetState(CS_RESETTING); | 814 SetState(CS_RESETTING); |
| 759 } | 815 } |
| 760 | 816 |
| 817 void GLRenderingVDAClient::NotifyFlushDone() { |
| 818 if (decoder_deleted()) |
| 819 return; |
| 820 |
| 821 ASSERT_EQ(CS_FLUSHING, state_); |
| 822 SetState(CS_FLUSHED); |
| 823 |
| 824 // We may have already posted some ReusePictureBuffer() calls before we got |
| 825 // here. If we are testing RETURN_OUTPUT_BUFFERS flush mode, make sure we |
| 826 // don't execute them returning the buffers to VDA until we have a chance |
| 827 // to verify the VDA really returned all the buffers before finishing flush. |
| 828 // Otherwise, we don't care and can continue without holding off any pending |
| 829 // ReusePictureBuffer() calls |
| 830 if (test_full_flush_) { |
| 831 base::MessageLoop::current()->PostTask( |
| 832 FROM_HERE, base::Bind(&GLRenderingVDAClient::FinishFlush, weak_this_)); |
| 833 } else { |
| 834 FinishFlush(); |
| 835 } |
| 836 } |
| 837 |
| 761 void GLRenderingVDAClient::NotifyResetDone() { | 838 void GLRenderingVDAClient::NotifyResetDone() { |
| 762 if (decoder_deleted()) | 839 if (decoder_deleted()) |
| 763 return; | 840 return; |
| 764 | 841 |
| 765 if (reset_after_frame_num_ == MID_STREAM_RESET) { | 842 if (reset_after_frame_num_ == MID_STREAM_RESET) { |
| 766 reset_after_frame_num_ = END_OF_STREAM_RESET; | 843 reset_after_frame_num_ = END_OF_STREAM_RESET; |
| 767 DecodeNextFragment(); | 844 DecodeNextFragment(); |
| 768 return; | 845 return; |
| 769 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) { | 846 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) { |
| 770 reset_after_frame_num_ = END_OF_STREAM_RESET; | 847 reset_after_frame_num_ = END_OF_STREAM_RESET; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 // Test parameters: | 1262 // Test parameters: |
| 1186 // - Number of concurrent decoders. The value takes effect when there is only | 1263 // - Number of concurrent decoders. The value takes effect when there is only |
| 1187 // one input stream; otherwise, one decoder per input stream will be | 1264 // one input stream; otherwise, one decoder per input stream will be |
| 1188 // instantiated. | 1265 // instantiated. |
| 1189 // - Number of concurrent in-flight Decode() calls per decoder. | 1266 // - Number of concurrent in-flight Decode() calls per decoder. |
| 1190 // - Number of play-throughs. | 1267 // - Number of play-throughs. |
| 1191 // - reset_after_frame_num: see GLRenderingVDAClient ctor. | 1268 // - reset_after_frame_num: see GLRenderingVDAClient ctor. |
| 1192 // - delete_decoder_phase: see GLRenderingVDAClient ctor. | 1269 // - delete_decoder_phase: see GLRenderingVDAClient ctor. |
| 1193 // - whether to test slow rendering by delaying ReusePictureBuffer(). | 1270 // - whether to test slow rendering by delaying ReusePictureBuffer(). |
| 1194 // - whether the video frames are rendered as thumbnails. | 1271 // - whether the video frames are rendered as thumbnails. |
| 1272 // - whether to test VDA::Flush(true) |
| 1195 class VideoDecodeAcceleratorParamTest | 1273 class VideoDecodeAcceleratorParamTest |
| 1196 : public VideoDecodeAcceleratorTest, | 1274 : public VideoDecodeAcceleratorTest, |
| 1197 public ::testing::WithParamInterface< | 1275 public ::testing::WithParamInterface< |
| 1198 base::Tuple<int, int, int, ResetPoint, ClientState, bool, bool> > { | 1276 base:: |
| 1277 Tuple<int, int, int, ResetPoint, ClientState, bool, bool, bool>> { |
| 1199 }; | 1278 }; |
| 1200 | 1279 |
| 1201 // Wait for |note| to report a state and if it's not |expected_state| then | 1280 // Wait for |note| to report a state and if it's not |expected_state| then |
| 1202 // assert |client| has deleted its decoder. | 1281 // assert |client| has deleted its decoder. |
| 1203 static void AssertWaitForStateOrDeleted( | 1282 static void AssertWaitForStateOrDeleted( |
| 1204 ClientStateNotification<ClientState>* note, | 1283 ClientStateNotification<ClientState>* note, |
| 1205 GLRenderingVDAClient* client, | 1284 GLRenderingVDAClient* client, |
| 1206 ClientState expected_state) { | 1285 ClientState expected_state) { |
| 1207 ClientState state = note->Wait(); | 1286 ClientState state = note->Wait(); |
| 1208 if (state == expected_state) return; | 1287 if (state == expected_state) return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1219 // Test the most straightforward case possible: data is decoded from a single | 1298 // Test the most straightforward case possible: data is decoded from a single |
| 1220 // chunk and rendered to the screen. | 1299 // chunk and rendered to the screen. |
| 1221 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { | 1300 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { |
| 1222 size_t num_concurrent_decoders = base::get<0>(GetParam()); | 1301 size_t num_concurrent_decoders = base::get<0>(GetParam()); |
| 1223 const size_t num_in_flight_decodes = base::get<1>(GetParam()); | 1302 const size_t num_in_flight_decodes = base::get<1>(GetParam()); |
| 1224 int num_play_throughs = base::get<2>(GetParam()); | 1303 int num_play_throughs = base::get<2>(GetParam()); |
| 1225 const int reset_point = base::get<3>(GetParam()); | 1304 const int reset_point = base::get<3>(GetParam()); |
| 1226 const int delete_decoder_state = base::get<4>(GetParam()); | 1305 const int delete_decoder_state = base::get<4>(GetParam()); |
| 1227 bool test_reuse_delay = base::get<5>(GetParam()); | 1306 bool test_reuse_delay = base::get<5>(GetParam()); |
| 1228 const bool render_as_thumbnails = base::get<6>(GetParam()); | 1307 const bool render_as_thumbnails = base::get<6>(GetParam()); |
| 1308 const bool test_full_flush = base::get<7>(GetParam()); |
| 1229 | 1309 |
| 1230 if (test_video_files_.size() > 1) | 1310 if (test_video_files_.size() > 1) |
| 1231 num_concurrent_decoders = test_video_files_.size(); | 1311 num_concurrent_decoders = test_video_files_.size(); |
| 1232 | 1312 |
| 1233 if (g_num_play_throughs > 0) | 1313 if (g_num_play_throughs > 0) |
| 1234 num_play_throughs = g_num_play_throughs; | 1314 num_play_throughs = g_num_play_throughs; |
| 1235 | 1315 |
| 1236 UpdateTestVideoFileParams( | 1316 UpdateTestVideoFileParams( |
| 1237 num_concurrent_decoders, reset_point, &test_video_files_); | 1317 num_concurrent_decoders, reset_point, &test_video_files_); |
| 1238 | 1318 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 num_play_throughs, | 1357 num_play_throughs, |
| 1278 video_file->reset_after_frame_num, | 1358 video_file->reset_after_frame_num, |
| 1279 delete_decoder_state, | 1359 delete_decoder_state, |
| 1280 video_file->width, | 1360 video_file->width, |
| 1281 video_file->height, | 1361 video_file->height, |
| 1282 video_file->profile, | 1362 video_file->profile, |
| 1283 g_fake_decoder, | 1363 g_fake_decoder, |
| 1284 suppress_rendering, | 1364 suppress_rendering, |
| 1285 delay_after_frame_num, | 1365 delay_after_frame_num, |
| 1286 0, | 1366 0, |
| 1287 render_as_thumbnails); | 1367 render_as_thumbnails, |
| 1368 test_full_flush); |
| 1288 | 1369 |
| 1289 clients[index] = client; | 1370 clients[index] = client; |
| 1290 helper_params.window_sizes.push_back( | 1371 helper_params.window_sizes.push_back( |
| 1291 render_as_thumbnails | 1372 render_as_thumbnails |
| 1292 ? kThumbnailsPageSize | 1373 ? kThumbnailsPageSize |
| 1293 : gfx::Size(video_file->width, video_file->height)); | 1374 : gfx::Size(video_file->width, video_file->height)); |
| 1294 } | 1375 } |
| 1295 | 1376 |
| 1296 InitializeRenderingHelper(helper_params); | 1377 InitializeRenderingHelper(helper_params); |
| 1297 | 1378 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 base::Bind(&STLDeleteElements< | 1513 base::Bind(&STLDeleteElements< |
| 1433 std::vector<ClientStateNotification<ClientState>*>>, | 1514 std::vector<ClientStateNotification<ClientState>*>>, |
| 1434 ¬es)); | 1515 ¬es)); |
| 1435 WaitUntilIdle(); | 1516 WaitUntilIdle(); |
| 1436 }; | 1517 }; |
| 1437 | 1518 |
| 1438 // Test that replay after EOS works fine. | 1519 // Test that replay after EOS works fine. |
| 1439 INSTANTIATE_TEST_CASE_P( | 1520 INSTANTIATE_TEST_CASE_P( |
| 1440 ReplayAfterEOS, VideoDecodeAcceleratorParamTest, | 1521 ReplayAfterEOS, VideoDecodeAcceleratorParamTest, |
| 1441 ::testing::Values( | 1522 ::testing::Values( |
| 1442 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1523 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false, |
| 1524 false))); |
| 1443 | 1525 |
| 1444 // Test that Reset() before the first Decode() works fine. | 1526 // Test that Reset() before the first Decode() works fine. |
| 1445 INSTANTIATE_TEST_CASE_P( | 1527 INSTANTIATE_TEST_CASE_P( |
| 1446 ResetBeforeDecode, VideoDecodeAcceleratorParamTest, | 1528 ResetBeforeDecode, VideoDecodeAcceleratorParamTest, |
| 1447 ::testing::Values( | 1529 ::testing::Values( |
| 1448 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false))); | 1530 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false, |
| 1531 false))); |
| 1449 | 1532 |
| 1450 // Test Reset() immediately after Decode() containing config info. | 1533 // Test Reset() immediately after Decode() containing config info. |
| 1451 INSTANTIATE_TEST_CASE_P( | 1534 INSTANTIATE_TEST_CASE_P( |
| 1452 ResetAfterFirstConfigInfo, VideoDecodeAcceleratorParamTest, | 1535 ResetAfterFirstConfigInfo, VideoDecodeAcceleratorParamTest, |
| 1453 ::testing::Values( | 1536 ::testing::Values( |
| 1454 MakeTuple( | 1537 MakeTuple(1, 1, 1, RESET_AFTER_FIRST_CONFIG_INFO, CS_RESET, false, |
| 1455 1, 1, 1, RESET_AFTER_FIRST_CONFIG_INFO, CS_RESET, false, false))); | 1538 false, false))); |
| 1456 | 1539 |
| 1457 // Test that Reset() mid-stream works fine and doesn't affect decoding even when | 1540 // Test that Reset() mid-stream works fine and doesn't affect decoding even when |
| 1458 // Decode() calls are made during the reset. | 1541 // Decode() calls are made during the reset. |
| 1459 INSTANTIATE_TEST_CASE_P( | 1542 INSTANTIATE_TEST_CASE_P( |
| 1460 MidStreamReset, VideoDecodeAcceleratorParamTest, | 1543 MidStreamReset, VideoDecodeAcceleratorParamTest, |
| 1461 ::testing::Values( | 1544 ::testing::Values( |
| 1462 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false))); | 1545 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false, false))); |
| 1546 |
| 1547 // Test that the VDA returns all buffers to us on Flush(true). |
| 1548 INSTANTIATE_TEST_CASE_P( |
| 1549 FullFlush, VideoDecodeAcceleratorParamTest, |
| 1550 ::testing::Values( |
| 1551 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false, true))); |
| 1552 |
| 1463 | 1553 |
| 1464 INSTANTIATE_TEST_CASE_P( | 1554 INSTANTIATE_TEST_CASE_P( |
| 1465 SlowRendering, VideoDecodeAcceleratorParamTest, | 1555 SlowRendering, VideoDecodeAcceleratorParamTest, |
| 1466 ::testing::Values( | 1556 ::testing::Values( |
| 1467 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false))); | 1557 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false, false))); |
| 1468 | 1558 |
| 1469 // Test that Destroy() mid-stream works fine (primarily this is testing that no | 1559 // Test that Destroy() mid-stream works fine (primarily this is testing that no |
| 1470 // crashes occur). | 1560 // crashes occur). |
| 1471 INSTANTIATE_TEST_CASE_P( | 1561 INSTANTIATE_TEST_CASE_P( |
| 1472 TearDownTiming, VideoDecodeAcceleratorParamTest, | 1562 TearDownTiming, VideoDecodeAcceleratorParamTest, |
| 1473 ::testing::Values( | 1563 ::testing::Values( |
| 1474 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false), | 1564 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false, |
| 1475 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false), | 1565 false), |
| 1476 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false), | 1566 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false, |
| 1477 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false), | 1567 false), |
| 1478 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false), | 1568 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false, |
| 1479 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1569 false), |
| 1570 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false, |
| 1571 false), |
| 1572 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false, |
| 1573 false), |
| 1574 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false, false), |
| 1480 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1575 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, |
| 1481 static_cast<ClientState>(-1), false, false), | 1576 static_cast<ClientState>(-1), false, false, false), |
| 1482 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1577 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, |
| 1483 static_cast<ClientState>(-10), false, false), | 1578 static_cast<ClientState>(-10), false, false, false), |
| 1484 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1579 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, |
| 1485 static_cast<ClientState>(-100), false, false))); | 1580 static_cast<ClientState>(-100), false, false, false))); |
| 1486 | 1581 |
| 1487 // Test that decoding various variation works with multiple in-flight decodes. | 1582 // Test that decoding various variation works with multiple in-flight decodes. |
| 1488 INSTANTIATE_TEST_CASE_P( | 1583 INSTANTIATE_TEST_CASE_P( |
| 1489 DecodeVariations, VideoDecodeAcceleratorParamTest, | 1584 DecodeVariations, VideoDecodeAcceleratorParamTest, |
| 1490 ::testing::Values( | 1585 ::testing::Values( |
| 1491 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1586 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false, false), |
| 1492 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1587 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false, false), |
| 1493 // Tests queuing. | 1588 // Tests queuing. |
| 1494 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1589 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false, |
| 1590 false))); |
| 1495 | 1591 |
| 1496 // Find out how many concurrent decoders can go before we exhaust system | 1592 // Find out how many concurrent decoders can go before we exhaust system |
| 1497 // resources. | 1593 // resources. |
| 1498 INSTANTIATE_TEST_CASE_P( | 1594 INSTANTIATE_TEST_CASE_P( |
| 1499 ResourceExhaustion, VideoDecodeAcceleratorParamTest, | 1595 ResourceExhaustion, VideoDecodeAcceleratorParamTest, |
| 1500 ::testing::Values( | 1596 ::testing::Values( |
| 1501 // +0 hack below to promote enum to int. | 1597 // +0 hack below to promote enum to int. |
| 1502 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, 1, 1, | 1598 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, 1, 1, |
| 1503 END_OF_STREAM_RESET, CS_RESET, false, false), | 1599 END_OF_STREAM_RESET, CS_RESET, false, false, false), |
| 1504 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, 1, 1, | 1600 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, 1, 1, |
| 1505 END_OF_STREAM_RESET, CS_RESET, false, false))); | 1601 END_OF_STREAM_RESET, CS_RESET, false, false, false))); |
| 1506 | 1602 |
| 1507 // Thumbnailing test | 1603 // Thumbnailing test |
| 1508 INSTANTIATE_TEST_CASE_P( | 1604 INSTANTIATE_TEST_CASE_P( |
| 1509 Thumbnail, VideoDecodeAcceleratorParamTest, | 1605 Thumbnail, VideoDecodeAcceleratorParamTest, |
| 1510 ::testing::Values( | 1606 ::testing::Values( |
| 1511 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); | 1607 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true, false))); |
| 1512 | 1608 |
| 1513 // Measure the median of the decode time when VDA::Decode is called 30 times per | 1609 // Measure the median of the decode time when VDA::Decode is called 30 times per |
| 1514 // second. | 1610 // second. |
| 1515 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { | 1611 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
| 1516 RenderingHelperParams helper_params; | 1612 RenderingHelperParams helper_params; |
| 1517 | 1613 |
| 1518 // Disable rendering by setting the rendering_fps = 0. | 1614 // Disable rendering by setting the rendering_fps = 0. |
| 1519 helper_params.rendering_fps = 0; | 1615 helper_params.rendering_fps = 0; |
| 1520 helper_params.warm_up_iterations = 0; | 1616 helper_params.warm_up_iterations = 0; |
| 1521 helper_params.render_as_thumbnails = false; | 1617 helper_params.render_as_thumbnails = false; |
| 1522 | 1618 |
| 1523 ClientStateNotification<ClientState>* note = | 1619 ClientStateNotification<ClientState>* note = |
| 1524 new ClientStateNotification<ClientState>(); | 1620 new ClientStateNotification<ClientState>(); |
| 1525 GLRenderingVDAClient* client = | 1621 GLRenderingVDAClient* client = |
| 1526 new GLRenderingVDAClient(0, | 1622 new GLRenderingVDAClient(0, |
| 1527 &rendering_helper_, | 1623 &rendering_helper_, |
| 1528 note, | 1624 note, |
| 1529 test_video_files_[0]->data_str, | 1625 test_video_files_[0]->data_str, |
| 1530 1, | 1626 1, |
| 1531 1, | 1627 1, |
| 1532 test_video_files_[0]->reset_after_frame_num, | 1628 test_video_files_[0]->reset_after_frame_num, |
| 1533 CS_RESET, | 1629 CS_RESET, |
| 1534 test_video_files_[0]->width, | 1630 test_video_files_[0]->width, |
| 1535 test_video_files_[0]->height, | 1631 test_video_files_[0]->height, |
| 1536 test_video_files_[0]->profile, | 1632 test_video_files_[0]->profile, |
| 1537 g_fake_decoder, | 1633 g_fake_decoder, |
| 1538 true, | 1634 true, |
| 1539 std::numeric_limits<int>::max(), | 1635 std::numeric_limits<int>::max(), |
| 1540 kWebRtcDecodeCallsPerSecond, | 1636 kWebRtcDecodeCallsPerSecond, |
| 1541 false /* render_as_thumbnail */); | 1637 false /* render_as_thumbnail */, |
| 1638 false /* test_full_flush */); |
| 1542 helper_params.window_sizes.push_back( | 1639 helper_params.window_sizes.push_back( |
| 1543 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); | 1640 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); |
| 1544 InitializeRenderingHelper(helper_params); | 1641 InitializeRenderingHelper(helper_params); |
| 1545 CreateAndStartDecoder(client, note); | 1642 CreateAndStartDecoder(client, note); |
| 1546 WaitUntilDecodeFinish(note); | 1643 WaitUntilDecodeFinish(note); |
| 1547 | 1644 |
| 1548 base::TimeDelta decode_time_median = client->decode_time_median(); | 1645 base::TimeDelta decode_time_median = client->decode_time_median(); |
| 1549 std::string output_string = | 1646 std::string output_string = |
| 1550 base::StringPrintf("Decode time median: %" PRId64 " us", | 1647 base::StringPrintf("Decode time median: %" PRId64 " us", |
| 1551 decode_time_median.InMicroseconds()); | 1648 decode_time_median.InMicroseconds()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 content::VaapiWrapper::PreSandboxInitialization(); | 1746 content::VaapiWrapper::PreSandboxInitialization(); |
| 1650 #endif | 1747 #endif |
| 1651 | 1748 |
| 1652 content::g_env = | 1749 content::g_env = |
| 1653 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>( | 1750 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>( |
| 1654 testing::AddGlobalTestEnvironment( | 1751 testing::AddGlobalTestEnvironment( |
| 1655 new content::VideoDecodeAcceleratorTestEnvironment())); | 1752 new content::VideoDecodeAcceleratorTestEnvironment())); |
| 1656 | 1753 |
| 1657 return RUN_ALL_TESTS(); | 1754 return RUN_ALL_TESTS(); |
| 1658 } | 1755 } |
| OLD | NEW |