| 379 | } |
| 380 | |
| 381 | void avcodec_flush_buffers(AVCodecContext *avctx) |
| 382 | { |
| 383 | AVCodecInternal *avci = avctx->internal; |
| 384 | |
| 385 | if (av_codec_is_encoder(avctx->codec)) { |
| 386 | int caps = avctx->codec->capabilities; |
| 387 | |
| 388 | if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) { |
| 389 | // Only encoders that explicitly declare support for it can be |
| 390 | // flushed. Otherwise, this is a no-op. |
| 391 | av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder " |
| 392 | "that doesn't support it\n"); |
| 393 | return; |
| 394 | } |
| 395 | ff_encode_flush_buffers(avctx); |
| 396 | } else |
| 397 | ff_decode_flush_buffers(avctx); |
| 398 | |
| 399 | avci->draining = 0; |
| 400 | avci->draining_done = 0; |
| 401 | if (avci->buffer_frame) |
| 402 | av_frame_unref(avci->buffer_frame); |
| 403 | if (avci->buffer_pkt) |
| 404 | av_packet_unref(avci->buffer_pkt); |
| 405 | |
| 406 | if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME && |
| 407 | !avci->is_frame_mt) |
| 408 | ff_thread_flush(avctx); |
| 409 | else if (ffcodec(avctx->codec)->flush) |
| 410 | ffcodec(avctx->codec)->flush(avctx); |
| 411 | } |
| 412 | |
| 413 | void avsubtitle_free(AVSubtitle *sub) |
| 414 | { |