MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / packet_decode

Function packet_decode

fftools/ffmpeg_dec.c:699–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

697}
698
699static 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);

Callers 1

decoder_threadFunction · 0.85

Calls 14

av_get_media_type_stringFunction · 0.85
transcode_subtitlesFunction · 0.85
packet_dataFunction · 0.85
av_gettime_relativeFunction · 0.85
avcodec_send_packetFunction · 0.85
av_logFunction · 0.85
av_frame_unrefFunction · 0.85
update_benchmarkFunction · 0.85
frame_dataFunction · 0.85
audio_ts_processFunction · 0.85
video_frame_processFunction · 0.85

Tested by

no test coverage detected