| 914 | } |
| 915 | |
| 916 | static 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 |
nothing calls this directly
no test coverage detected