| 697 | } |
| 698 | |
| 699 | static int packet_decode(DecoderPriv *dp, AVPacket *pkt, AVFrame *frame) |
| 700 | { |
| 701 | AVCodecContext *dec = dp->dec_ctx; |
| 702 | const char *type_desc = av_get_media_type_string(dec->codec_type); |
| 703 | int ret; |
| 704 | |
| 705 | if (dec->codec_type == AVMEDIA_TYPE_SUBTITLE) |
| 706 | return transcode_subtitles(dp, pkt, frame); |
| 707 | |
| 708 | // With fate-indeo3-2, we're getting 0-sized packets before EOF for some |
| 709 | // reason. This seems like a semi-critical bug. Don't trigger EOF, and |
| 710 | // skip the packet. |
| 711 | if (pkt && pkt->size == 0) |
| 712 | return 0; |
| 713 | |
| 714 | if (pkt && (dp->flags & DECODER_FLAG_TS_UNRELIABLE)) { |
| 715 | pkt->pts = AV_NOPTS_VALUE; |
| 716 | pkt->dts = AV_NOPTS_VALUE; |
| 717 | } |
| 718 | |
| 719 | if (pkt) { |
| 720 | FrameData *fd = packet_data(pkt); |
| 721 | if (!fd) |
| 722 | return AVERROR(ENOMEM); |
| 723 | fd->wallclock[LATENCY_PROBE_DEC_PRE] = av_gettime_relative(); |
| 724 | } |
| 725 | |
| 726 | ret = avcodec_send_packet(dec, pkt); |
| 727 | if (ret < 0 && !(ret == AVERROR_EOF && !pkt)) { |
| 728 | // In particular, we don't expect AVERROR(EAGAIN), because we read all |
| 729 | // decoded frames with avcodec_receive_frame() until done. |
| 730 | if (ret == AVERROR(EAGAIN)) { |
| 731 | av_log(dp, AV_LOG_FATAL, "A decoder returned an unexpected error code. " |
| 732 | "This is a bug, please report it.\n"); |
| 733 | return AVERROR_BUG; |
| 734 | } |
| 735 | av_log(dp, AV_LOG_ERROR, "Error submitting %s to decoder: %s\n", |
| 736 | pkt ? "packet" : "EOF", av_err2str(ret)); |
| 737 | |
| 738 | if (ret == AVERROR_EOF) |
| 739 | return ret; |
| 740 | |
| 741 | dp->dec.decode_errors++; |
| 742 | if (exit_on_error) |
| 743 | return ret; |
| 744 | } |
| 745 | |
| 746 | while (1) { |
| 747 | FrameData *fd; |
| 748 | unsigned outputs_mask = 1; |
| 749 | unsigned flags = 0; |
| 750 | if (!dp->dec.frames_decoded) |
| 751 | flags |= AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS; |
| 752 | |
| 753 | av_frame_unref(frame); |
| 754 | |
| 755 | update_benchmark(NULL); |
| 756 | ret = avcodec_receive_frame_flags(dec, frame, flags); |
no test coverage detected