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

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: add document to frames_at_render_. 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 // The number of frames that are not returned from rendering_helper_. We
320 // checks this count to ensure all frames are rendered before entering the
321 // CS_RESET state.
322 int frames_at_render_;
319 323
320 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); 324 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient);
321 }; 325 };
322 326
323 GLRenderingVDAClient::GLRenderingVDAClient( 327 GLRenderingVDAClient::GLRenderingVDAClient(
324 size_t window_id, 328 size_t window_id,
325 RenderingHelper* rendering_helper, 329 RenderingHelper* rendering_helper,
326 ClientStateNotification<ClientState>* note, 330 ClientStateNotification<ClientState>* note,
327 const std::string& encoded_data, 331 const std::string& encoded_data,
328 int num_in_flight_decodes, 332 int num_in_flight_decodes,
(...skipping 21 matching lines...) Expand all
350 delete_decoder_state_(delete_decoder_state), 354 delete_decoder_state_(delete_decoder_state),
351 state_(CS_CREATED), 355 state_(CS_CREATED),
352 num_skipped_fragments_(0), 356 num_skipped_fragments_(0),
353 num_queued_fragments_(0), 357 num_queued_fragments_(0),
354 num_decoded_frames_(0), 358 num_decoded_frames_(0),
355 num_done_bitstream_buffers_(0), 359 num_done_bitstream_buffers_(0),
356 texture_target_(0), 360 texture_target_(0),
357 suppress_rendering_(suppress_rendering), 361 suppress_rendering_(suppress_rendering),
358 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), 362 delay_reuse_after_frame_num_(delay_reuse_after_frame_num),
359 decode_calls_per_second_(decode_calls_per_second), 363 decode_calls_per_second_(decode_calls_per_second),
360 render_as_thumbnails_(render_as_thumbnails) { 364 render_as_thumbnails_(render_as_thumbnails),
365 frames_at_render_(0) {
361 CHECK_GT(num_in_flight_decodes, 0); 366 CHECK_GT(num_in_flight_decodes, 0);
362 CHECK_GT(num_play_throughs, 0); 367 CHECK_GT(num_play_throughs, 0);
363 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. 368 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0.
364 if (decode_calls_per_second_ > 0) 369 if (decode_calls_per_second_ > 0)
365 CHECK_EQ(1, num_in_flight_decodes_); 370 CHECK_EQ(1, num_in_flight_decodes_);
366 371
367 // Default to H264 baseline if no profile provided. 372 // Default to H264 baseline if no profile provided.
368 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN 373 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN
369 ? profile 374 ? profile
370 : media::H264PROFILE_BASELINE); 375 : media::H264PROFILE_BASELINE);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 media::PictureBuffer* picture_buffer = 495 media::PictureBuffer* picture_buffer =
491 picture_buffers_by_id_[picture.picture_buffer_id()]; 496 picture_buffers_by_id_[picture.picture_buffer_id()];
492 CHECK(picture_buffer); 497 CHECK(picture_buffer);
493 498
494 scoped_refptr<VideoFrameTexture> video_frame = 499 scoped_refptr<VideoFrameTexture> video_frame =
495 new VideoFrameTexture(texture_target_, 500 new VideoFrameTexture(texture_target_,
496 picture_buffer->texture_id(), 501 picture_buffer->texture_id(),
497 base::Bind(&GLRenderingVDAClient::ReturnPicture, 502 base::Bind(&GLRenderingVDAClient::ReturnPicture,
498 AsWeakPtr(), 503 AsWeakPtr(),
499 picture.picture_buffer_id())); 504 picture.picture_buffer_id()));
505 ++frames_at_render_;
500 506
501 if (render_as_thumbnails_) { 507 if (render_as_thumbnails_) {
502 rendering_helper_->RenderThumbnail(video_frame->texture_target(), 508 rendering_helper_->RenderThumbnail(video_frame->texture_target(),
503 video_frame->texture_id()); 509 video_frame->texture_id());
504 } else if (!suppress_rendering_) { 510 } else if (!suppress_rendering_) {
505 rendering_helper_->QueueVideoFrame(window_id_, video_frame); 511 rendering_helper_->QueueVideoFrame(window_id_, video_frame);
506 } 512 }
507 } 513 }
508 514
509 void GLRenderingVDAClient::ReturnPicture(int32 picture_buffer_id) { 515 void GLRenderingVDAClient::ReturnPicture(int32 picture_buffer_id) {
510 if (decoder_deleted()) 516 if (decoder_deleted())
511 return; 517 return;
518
519 --frames_at_render_;
520 if (frames_at_render_ == 0 && state_ == CS_RESETTING) {
521 SetState(CS_RESET);
522 DeleteDecoder();
523 return;
524 }
525
512 if (num_decoded_frames_ > delay_reuse_after_frame_num_) { 526 if (num_decoded_frames_ > delay_reuse_after_frame_num_) {
513 base::MessageLoop::current()->PostDelayedTask( 527 base::MessageLoop::current()->PostDelayedTask(
514 FROM_HERE, 528 FROM_HERE,
515 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, 529 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer,
516 weak_decoder_factory_->GetWeakPtr(), 530 weak_decoder_factory_->GetWeakPtr(),
517 picture_buffer_id), 531 picture_buffer_id),
518 kReuseDelay); 532 kReuseDelay);
519 } else { 533 } else {
520 decoder_->ReusePictureBuffer(picture_buffer_id); 534 decoder_->ReusePictureBuffer(picture_buffer_id);
521 } 535 }
(...skipping 21 matching lines...) Expand all
543 if (decoder_deleted()) 557 if (decoder_deleted())
544 return; 558 return;
545 decoder_->Reset(); 559 decoder_->Reset();
546 SetState(CS_RESETTING); 560 SetState(CS_RESETTING);
547 } 561 }
548 562
549 void GLRenderingVDAClient::NotifyResetDone() { 563 void GLRenderingVDAClient::NotifyResetDone() {
550 if (decoder_deleted()) 564 if (decoder_deleted())
551 return; 565 return;
552 566
553 rendering_helper_->DropPendingFrames(window_id_);
554
555 if (reset_after_frame_num_ == MID_STREAM_RESET) { 567 if (reset_after_frame_num_ == MID_STREAM_RESET) {
556 reset_after_frame_num_ = END_OF_STREAM_RESET; 568 reset_after_frame_num_ = END_OF_STREAM_RESET;
557 DecodeNextFragment(); 569 DecodeNextFragment();
558 return; 570 return;
559 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) { 571 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) {
560 reset_after_frame_num_ = END_OF_STREAM_RESET; 572 reset_after_frame_num_ = END_OF_STREAM_RESET;
561 for (int i = 0; i < num_in_flight_decodes_; ++i) 573 for (int i = 0; i < num_in_flight_decodes_; ++i)
562 DecodeNextFragment(); 574 DecodeNextFragment();
563 return; 575 return;
564 } 576 }
565 577
566 if (remaining_play_throughs_) { 578 if (remaining_play_throughs_) {
567 encoded_data_next_pos_to_decode_ = 0; 579 encoded_data_next_pos_to_decode_ = 0;
568 FinishInitialization(); 580 FinishInitialization();
569 return; 581 return;
570 } 582 }
571 583
572 SetState(CS_RESET); 584 rendering_helper_->Flush(window_id_);
573 if (!decoder_deleted()) 585
586 if (frames_at_render_ == 0) {
587 SetState(CS_RESET);
574 DeleteDecoder(); 588 DeleteDecoder();
589 }
575 } 590 }
576 591
577 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) { 592 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) {
578 SetState(CS_ERROR); 593 SetState(CS_ERROR);
579 } 594 }
580 595
581 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) { 596 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) {
582 std::string s = base::StringPrintf("frame count: %" PRIuS "\n", 597 std::string s = base::StringPrintf("frame count: %" PRIuS "\n",
583 frame_delivery_times_.size()); 598 frame_delivery_times_.size());
584 output->WriteAtCurrentPos(s.data(), s.length()); 599 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") 1429 if (it->first == "v" || it->first == "vmodule")
1415 continue; 1430 continue;
1416 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1431 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1417 } 1432 }
1418 1433
1419 base::ShadowingAtExitManager at_exit_manager; 1434 base::ShadowingAtExitManager at_exit_manager;
1420 content::RenderingHelper::InitializeOneOff(); 1435 content::RenderingHelper::InitializeOneOff();
1421 1436
1422 return RUN_ALL_TESTS(); 1437 return RUN_ALL_TESTS();
1423 } 1438 }
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