| 606 | } |
| 607 | |
| 608 | bool FramesDecoderGpu::SendFrameToParser() { |
| 609 | if (packet_->stream_index != stream_id_) { |
| 610 | return false; |
| 611 | } |
| 612 | |
| 613 | // Store pts from current packet to indicate, |
| 614 | // that this frame is in the decoder |
| 615 | if (packet_->pts != AV_NOPTS_VALUE) { |
| 616 | piped_pts_.push(packet_->pts); |
| 617 | } else { |
| 618 | piped_pts_.push(frame_index_if_no_pts_); |
| 619 | frame_index_if_no_pts_++; |
| 620 | } |
| 621 | |
| 622 | // Add header needed for NVDECODE to the packet |
| 623 | if (filtered_packet_->data) { |
| 624 | av_packet_unref(filtered_packet_); |
| 625 | } |
| 626 | |
| 627 | LOG_LINE << "Sending packet to bitstream filter " << packet_->pts << std::endl; |
| 628 | DALI_ENFORCE(av_bsf_send_packet(bsfc_, packet_) >= 0); |
| 629 | DALI_ENFORCE(av_bsf_receive_packet(bsfc_, filtered_packet_) >= 0); |
| 630 | |
| 631 | // Prepare nv packet |
| 632 | CUVIDSOURCEDATAPACKET *packet = &nvdecode_state_->packet; |
| 633 | memset(packet, 0, sizeof(CUVIDSOURCEDATAPACKET)); |
| 634 | packet->payload = filtered_packet_->data; |
| 635 | packet->payload_size = filtered_packet_->size; |
| 636 | packet->flags = CUVID_PKT_TIMESTAMP; |
| 637 | packet->timestamp = filtered_packet_->pts; |
| 638 | |
| 639 | // Send packet to the nv decoder |
| 640 | frame_returned_ = false; |
| 641 | LOG_LINE << "Sending packet to the nv decoder, next pts=" << piped_pts_.front() << std::endl; |
| 642 | CUDA_CALL(cuvidParseVideoData(nvdecode_state_->parser, packet)); |
| 643 | LOG_LINE << "Packet sent to the nv decoder" << std::endl; |
| 644 | current_pts_ = AV_NOPTS_VALUE; // we are done with this packet. Next frame will come from a new packet |
| 645 | return true; |
| 646 | } |
| 647 | |
| 648 | bool FramesDecoderGpu::ReadNextFrameWithoutIndex(uint8_t *data) { |
| 649 | current_copy_to_output_ = data != nullptr; |