| 1633 | } |
| 1634 | |
| 1635 | int CFFDecoder::decode_send_packet(Task &task, AVPacket *pkt, int *got_frame) { |
| 1636 | int ret = 0; |
| 1637 | int decoded = 0; |
| 1638 | *got_frame = 0; |
| 1639 | int index = pkt->stream_index == video_stream_index_ ? 0 : 1; |
| 1640 | InputStream *ist = &ist_[index]; |
| 1641 | AVStream *stream = (index == 0) ? video_stream_ : audio_stream_; |
| 1642 | AVCodecContext *dec_ctx = |
| 1643 | (index == 0) ? video_decode_ctx_ : audio_decode_ctx_; |
| 1644 | |
| 1645 | if (!push_raw_stream_) |
| 1646 | pkt_ts(pkt, index); |
| 1647 | |
| 1648 | if (!ist->saw_first_ts) { |
| 1649 | ist->first_dts = ist->dts = (stream && stream->avg_frame_rate.num) |
| 1650 | ? -dec_ctx->has_b_frames * |
| 1651 | AV_TIME_BASE / |
| 1652 | av_q2d(stream->avg_frame_rate) |
| 1653 | : 0; |
| 1654 | ist->pts = 0; |
| 1655 | if (stream && pkt && pkt->pts != AV_NOPTS_VALUE && |
| 1656 | !ist->decoding_needed) { |
| 1657 | ist->first_dts = ist->dts += |
| 1658 | av_rescale_q(pkt->pts, stream->time_base, AV_TIME_BASE_Q); |
| 1659 | ist->pts = ist->dts; // unused but better to set it to a value thats |
| 1660 | // not totally wrong |
| 1661 | } |
| 1662 | ist->saw_first_ts = 1; |
| 1663 | } |
| 1664 | |
| 1665 | if (ist->next_dts == AV_NOPTS_VALUE) |
| 1666 | ist->next_dts = ist->dts; |
| 1667 | if (ist->next_pts == AV_NOPTS_VALUE) |
| 1668 | ist->next_pts = ist->pts; |
| 1669 | |
| 1670 | if (stream && pkt && pkt->size != 0 && pkt->dts != AV_NOPTS_VALUE) { |
| 1671 | ist->next_dts = ist->dts = |
| 1672 | av_rescale_q(pkt->dts, stream->time_base, AV_TIME_BASE_Q); |
| 1673 | if (dec_ctx->codec_type != AVMEDIA_TYPE_VIDEO || !ist->decoding_needed) |
| 1674 | ist->next_pts = ist->pts = ist->dts; |
| 1675 | } |
| 1676 | |
| 1677 | if (pkt && !ist->decoding_needed) { |
| 1678 | if (pkt->size == 0) { |
| 1679 | Packet packet = Packet::generate_eof_packet(); |
| 1680 | assert(packet.timestamp() == BMF_EOF); |
| 1681 | if (task.get_outputs().find(index) != task.get_outputs().end() && |
| 1682 | file_list_.size() == 0) { |
| 1683 | task.get_outputs()[index]->push(packet); |
| 1684 | if (index == 0) |
| 1685 | video_end_ = true; |
| 1686 | else |
| 1687 | audio_end_ = true; |
| 1688 | } |
| 1689 | return AVERROR_EOF; |
| 1690 | } |
| 1691 | |
| 1692 | AVRational frame_rate = |
nothing calls this directly
no test coverage detected