Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: content/common/gpu/media/video_decode_accelerator_unittest.cc

Issue 465293002: rendering_helper - Wait for rendering before resetting the decoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased to TOT Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/gpu/media/rendering_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 bool suppress_rendering_; 309 bool suppress_rendering_;
310 std::vector<base::TimeTicks> frame_delivery_times_; 310 std::vector<base::TimeTicks> frame_delivery_times_;
311 int delay_reuse_after_frame_num_; 311 int delay_reuse_after_frame_num_;
312 // A map from bitstream buffer id to the decode start time of the buffer. 312 // A map from bitstream buffer id to the decode start time of the buffer.
313 std::map<int, base::TimeTicks> decode_start_time_; 313 std::map<int, base::TimeTicks> decode_start_time_;
314 // The decode time of all decoded frames. 314 // The decode time of all decoded frames.
315 std::vector<base::TimeDelta> decode_time_; 315 std::vector<base::TimeDelta> decode_time_;
316 // The number of VDA::Decode calls per second. This is to simulate webrtc. 316 // The number of VDA::Decode calls per second. This is to simulate webrtc.
317 int decode_calls_per_second_; 317 int decode_calls_per_second_;
318 bool render_as_thumbnails_; 318 bool render_as_thumbnails_;
319 int frames_at_render_;
Pawel Osciak 2014/08/22 08:49:43 Please document.
319 320
320 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); 321 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient);
321 }; 322 };
322 323
323 GLRenderingVDAClient::GLRenderingVDAClient( 324 GLRenderingVDAClient::GLRenderingVDAClient(
324 size_t window_id, 325 size_t window_id,
325 RenderingHelper* rendering_helper, 326 RenderingHelper* rendering_helper,
326 ClientStateNotification<ClientState>* note, 327 ClientStateNotification<ClientState>* note,
327 const std::string& encoded_data, 328 const std::string& encoded_data,
328 int num_in_flight_decodes, 329 int num_in_flight_decodes,
(...skipping 21 matching lines...) Expand all
350 delete_decoder_state_(delete_decoder_state), 351 delete_decoder_state_(delete_decoder_state),
351 state_(CS_CREATED), 352 state_(CS_CREATED),
352 num_skipped_fragments_(0), 353 num_skipped_fragments_(0),
353 num_queued_fragments_(0), 354 num_queued_fragments_(0),
354 num_decoded_frames_(0), 355 num_decoded_frames_(0),
355 num_done_bitstream_buffers_(0), 356 num_done_bitstream_buffers_(0),
356 texture_target_(0), 357 texture_target_(0),
357 suppress_rendering_(suppress_rendering), 358 suppress_rendering_(suppress_rendering),
358 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), 359 delay_reuse_after_frame_num_(delay_reuse_after_frame_num),
359 decode_calls_per_second_(decode_calls_per_second), 360 decode_calls_per_second_(decode_calls_per_second),
360 render_as_thumbnails_(render_as_thumbnails) { 361 render_as_thumbnails_(render_as_thumbnails),
362 frames_at_render_(0) {
361 CHECK_GT(num_in_flight_decodes, 0); 363 CHECK_GT(num_in_flight_decodes, 0);
362 CHECK_GT(num_play_throughs, 0); 364 CHECK_GT(num_play_throughs, 0);
363 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. 365 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0.
364 if (decode_calls_per_second_ > 0) 366 if (decode_calls_per_second_ > 0)
365 CHECK_EQ(1, num_in_flight_decodes_); 367 CHECK_EQ(1, num_in_flight_decodes_);
366 368
367 // Default to H264 baseline if no profile provided. 369 // Default to H264 baseline if no profile provided.
368 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN 370 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN
369 ? profile 371 ? profile
370 : media::H264PROFILE_BASELINE); 372 : media::H264PROFILE_BASELINE);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 media::PictureBuffer* picture_buffer = 492 media::PictureBuffer* picture_buffer =
491 picture_buffers_by_id_[picture.picture_buffer_id()]; 493 picture_buffers_by_id_[picture.picture_buffer_id()];
492 CHECK(picture_buffer); 494 CHECK(picture_buffer);
493 495
494 scoped_refptr<VideoFrameTexture> video_frame = 496 scoped_refptr<VideoFrameTexture> video_frame =
495 new VideoFrameTexture(texture_target_, 497 new VideoFrameTexture(texture_target_,
496 picture_buffer->texture_id(), 498 picture_buffer->texture_id(),
497 base::Bind(&GLRenderingVDAClient::ReturnPicture, 499 base::Bind(&GLRenderingVDAClient::ReturnPicture,
498 AsWeakPtr(), 500 AsWeakPtr(),
499 picture.picture_buffer_id())); 501 picture.picture_buffer_id()));
502 ++frames_at_render_;
500 503
501 if (render_as_thumbnails_) { 504 if (render_as_thumbnails_) {
502 rendering_helper_->RenderThumbnail(video_frame->texture_target(), 505 rendering_helper_->RenderThumbnail(video_frame->texture_target(),
503 video_frame->texture_id()); 506 video_frame->texture_id());
504 } else if (!suppress_rendering_) { 507 } else if (!suppress_rendering_) {
505 rendering_helper_->QueueVideoFrame(window_id_, video_frame); 508 rendering_helper_->QueueVideoFrame(window_id_, video_frame);
506 } 509 }
507 } 510 }
508 511
509 void GLRenderingVDAClient::ReturnPicture(int32 picture_buffer_id) { 512 void GLRenderingVDAClient::ReturnPicture(int32 picture_buffer_id) {
510 if (decoder_deleted()) 513 if (decoder_deleted())
511 return; 514 return;
515
516 --frames_at_render_;
517 if (frames_at_render_ == 0 && state_ == CS_RESETTING) {
518 SetState(CS_RESET);
519 DeleteDecoder();
520 return;
521 }
522
512 if (num_decoded_frames_ > delay_reuse_after_frame_num_) { 523 if (num_decoded_frames_ > delay_reuse_after_frame_num_) {
513 base::MessageLoop::current()->PostDelayedTask( 524 base::MessageLoop::current()->PostDelayedTask(
514 FROM_HERE, 525 FROM_HERE,
515 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, 526 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer,
516 weak_decoder_factory_->GetWeakPtr(), 527 weak_decoder_factory_->GetWeakPtr(),
517 picture_buffer_id), 528 picture_buffer_id),
518 kReuseDelay); 529 kReuseDelay);
519 } else { 530 } else {
520 decoder_->ReusePictureBuffer(picture_buffer_id); 531 decoder_->ReusePictureBuffer(picture_buffer_id);
521 } 532 }
(...skipping 21 matching lines...) Expand all
543 if (decoder_deleted()) 554 if (decoder_deleted())
544 return; 555 return;
545 decoder_->Reset(); 556 decoder_->Reset();
546 SetState(CS_RESETTING); 557 SetState(CS_RESETTING);
547 } 558 }
548 559
549 void GLRenderingVDAClient::NotifyResetDone() { 560 void GLRenderingVDAClient::NotifyResetDone() {
550 if (decoder_deleted()) 561 if (decoder_deleted())
551 return; 562 return;
552 563
553 rendering_helper_->DropPendingFrames(window_id_);
554
555 if (reset_after_frame_num_ == MID_STREAM_RESET) { 564 if (reset_after_frame_num_ == MID_STREAM_RESET) {
556 reset_after_frame_num_ = END_OF_STREAM_RESET; 565 reset_after_frame_num_ = END_OF_STREAM_RESET;
557 DecodeNextFragment(); 566 DecodeNextFragment();
558 return; 567 return;
559 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) { 568 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) {
560 reset_after_frame_num_ = END_OF_STREAM_RESET; 569 reset_after_frame_num_ = END_OF_STREAM_RESET;
561 for (int i = 0; i < num_in_flight_decodes_; ++i) 570 for (int i = 0; i < num_in_flight_decodes_; ++i)
562 DecodeNextFragment(); 571 DecodeNextFragment();
563 return; 572 return;
564 } 573 }
565 574
566 if (remaining_play_throughs_) { 575 if (remaining_play_throughs_) {
567 encoded_data_next_pos_to_decode_ = 0; 576 encoded_data_next_pos_to_decode_ = 0;
568 FinishInitialization(); 577 FinishInitialization();
569 return; 578 return;
570 } 579 }
571 580
572 SetState(CS_RESET); 581 rendering_helper_->Flush(window_id_);
573 if (!decoder_deleted()) 582
583 if (frames_at_render_ == 0) {
584 SetState(CS_RESET);
574 DeleteDecoder(); 585 DeleteDecoder();
586 }
575 } 587 }
576 588
577 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) { 589 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) {
578 SetState(CS_ERROR); 590 SetState(CS_ERROR);
579 } 591 }
580 592
581 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) { 593 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) {
582 std::string s = base::StringPrintf("frame count: %" PRIuS "\n", 594 std::string s = base::StringPrintf("frame count: %" PRIuS "\n",
583 frame_delivery_times_.size()); 595 frame_delivery_times_.size());
584 output->WriteAtCurrentPos(s.data(), s.length()); 596 output->WriteAtCurrentPos(s.data(), s.length());
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 if (it->first == "v" || it->first == "vmodule") 1426 if (it->first == "v" || it->first == "vmodule")
1415 continue; 1427 continue;
1416 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1428 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1417 } 1429 }
1418 1430
1419 base::ShadowingAtExitManager at_exit_manager; 1431 base::ShadowingAtExitManager at_exit_manager;
1420 content::RenderingHelper::InitializeOneOff(); 1432 content::RenderingHelper::InitializeOneOff();
1421 1433
1422 return RUN_ALL_TESTS(); 1434 return RUN_ALL_TESTS();
1423 } 1435 }
OLDNEW
« no previous file with comments | « content/common/gpu/media/rendering_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698