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

Function decoder_thread

fftools/ffmpeg_dec.c:916–1029  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

914}
915
916static int decoder_thread(void *arg)
917{
918 DecoderPriv *dp = arg;
919 DecThreadContext dt;
920 int ret = 0, input_status = 0;
921
922 ret = dec_thread_init(&dt);
923 if (ret < 0)
924 goto finish;
925
926 dec_thread_set_name(dp);
927
928 while (!input_status) {
929 int flush_buffers, have_data;
930
931 input_status = sch_dec_receive(dp->sch, dp->sch_idx, dt.pkt);
932 have_data = input_status >= 0 &&
933 (dt.pkt->buf || dt.pkt->side_data_elems ||
934 (intptr_t)dt.pkt->opaque == PKT_OPAQUE_SUB_HEARTBEAT ||
935 (intptr_t)dt.pkt->opaque == PKT_OPAQUE_FIX_SUB_DURATION);
936 flush_buffers = input_status >= 0 && !have_data;
937 if (!have_data)
938 av_log(dp, AV_LOG_VERBOSE, "Decoder thread received %s packet\n",
939 flush_buffers ? "flush" : "EOF");
940
941 // this is a standalone decoder that has not been initialized yet
942 if (!dp->dec_ctx) {
943 if (flush_buffers)
944 continue;
945 if (input_status < 0) {
946 av_log(dp, AV_LOG_ERROR,
947 "Cannot initialize a standalone decoder\n");
948 ret = input_status;
949 goto finish;
950 }
951
952 ret = dec_standalone_open(dp, dt.pkt);
953 if (ret < 0)
954 goto finish;
955 }
956
957 ret = packet_decode(dp, have_data ? dt.pkt : NULL, dt.frame);
958
959 av_packet_unref(dt.pkt);
960 av_frame_unref(dt.frame);
961
962 // AVERROR_EOF - EOF from the decoder
963 // AVERROR_EXIT - EOF from the scheduler
964 // we treat them differently when flushing
965 if (ret == AVERROR_EXIT) {
966 ret = AVERROR_EOF;
967 flush_buffers = 0;
968 }
969
970 if (ret == AVERROR_EOF) {
971 av_log(dp, AV_LOG_VERBOSE, "Decoder returned EOF, %s\n",
972 flush_buffers ? "resetting" : "finishing");
973

Callers

nothing calls this directly

Calls 12

dec_thread_initFunction · 0.85
dec_thread_set_nameFunction · 0.85
sch_dec_receiveFunction · 0.85
av_logFunction · 0.85
dec_standalone_openFunction · 0.85
packet_decodeFunction · 0.85
av_packet_unrefFunction · 0.85
av_frame_unrefFunction · 0.85
avcodec_flush_buffersFunction · 0.85
sch_dec_sendFunction · 0.85
dec_thread_uninitFunction · 0.85
avcodec_free_contextFunction · 0.85

Tested by

no test coverage detected