| 457 | } |
| 458 | |
| 459 | int FramesDecoderGpu::HandlePictureDisplay(CUVIDPARSERDISPINFO *picture_display_info) { |
| 460 | CUVIDPROCPARAMS videoProcessingParameters = {}; |
| 461 | videoProcessingParameters.progressive_frame = !picture_display_info->progressive_frame; |
| 462 | videoProcessingParameters.second_field = 1; |
| 463 | videoProcessingParameters.top_field_first = picture_display_info->top_field_first; |
| 464 | videoProcessingParameters.unpaired_field = 0; |
| 465 | videoProcessingParameters.output_stream = stream_; |
| 466 | |
| 467 | // If there are no piped pts, use the last pts available (unexpected extra frame) |
| 468 | if (!piped_pts_.empty()) { |
| 469 | current_pts_ = piped_pts_.front(); |
| 470 | piped_pts_.pop(); |
| 471 | } |
| 472 | assert(current_pts_ != AV_NOPTS_VALUE); |
| 473 | |
| 474 | LOG_LINE << "HandlePictureDisplay-" |
| 475 | << (picture_display_info->progressive_frame ? |
| 476 | "I" : |
| 477 | "NI") // I=progressive frame, NI=interlaced |
| 478 | << ": " << (current_copy_to_output_ ? "Read" : "Skip") << " frame, index " |
| 479 | << next_frame_idx_ << ", timestamp " << std::setw(5) << current_pts_ << std::endl; |
| 480 | |
| 481 | // current_pts_ is pts of frame that came from the decoder |
| 482 | // index_[NextFrameIdx()].pts is pts of the frame that we want to return |
| 483 | // in this call to ReadNextFrame |
| 484 | // If they are the same, we just return this frame |
| 485 | // If not, we store it in the buffer for later |
| 486 | |
| 487 | void *frame_output = nullptr; |
| 488 | if (HasIndex() && current_pts_ == index_[NextFrameIdx()].pts) { |
| 489 | // Currently decoded frame is actually the one we want to display |
| 490 | frame_returned_ = true; |
| 491 | LOG_LINE << "Found frame with correct display timestamp " << current_pts_ |
| 492 | << " for index " << next_frame_idx_ << std::endl; |
| 493 | if (current_copy_to_output_ == false) { |
| 494 | return 1; |
| 495 | } |
| 496 | frame_output = current_frame_output_; |
| 497 | } else { |
| 498 | // Put currently decoded frame to the buffer for later |
| 499 | auto &slot = FindEmptySlot(); |
| 500 | slot.pts_ = current_pts_; |
| 501 | frame_output = slot.frame_.data(); |
| 502 | } |
| 503 | |
| 504 | CUdeviceptr frame = {}; |
| 505 | unsigned int pitch = 0; |
| 506 | |
| 507 | CUDA_CALL(cuvidMapVideoFrame( |
| 508 | nvdecode_state_->decoder, |
| 509 | picture_display_info->picture_index, |
| 510 | &frame, |
| 511 | &pitch, |
| 512 | &videoProcessingParameters)); |
| 513 | |
| 514 | LOG_LINE << "VideoColorSpaceConversion with conversion_type_=" |
| 515 | << static_cast<int>(conversion_type_) << " and dimensions " << Height() << "x" << Width() |
| 516 | << std::endl; |
no test coverage detected