| 249 | } |
| 250 | |
| 251 | int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt) |
| 252 | { |
| 253 | AVCodecInternal *avci = avctx->internal; |
| 254 | DecodeContext *dc = decode_ctx(avci); |
| 255 | |
| 256 | if (avci->draining) |
| 257 | return AVERROR_EOF; |
| 258 | |
| 259 | /* If we are a worker thread, get the next packet from the threading |
| 260 | * context. Otherwise we are the main (user-facing) context, so we get the |
| 261 | * next packet from the input filterchain. |
| 262 | */ |
| 263 | if (avctx->internal->is_frame_mt) |
| 264 | return ff_thread_get_packet(avctx, pkt); |
| 265 | |
| 266 | while (1) { |
| 267 | int ret = decode_get_packet(avctx, pkt); |
| 268 | if (ret == AVERROR(EAGAIN) && |
| 269 | (!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) { |
| 270 | ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt); |
| 271 | if (ret >= 0) |
| 272 | continue; |
| 273 | |
| 274 | av_packet_unref(avci->buffer_pkt); |
| 275 | } |
| 276 | |
| 277 | if (ret == AVERROR_EOF) |
| 278 | avci->draining = 1; |
| 279 | return ret; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Attempt to guess proper monotonic timestamps for decoded video frames |
no test coverage detected