It's not a decoding exclusive function. Signed-off-by: James Almer <jamr...@gmail.com> --- libavcodec/decode.c | 36 ------------------------------------ libavcodec/utils.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 36 deletions(-)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 03b9da25f9..93b0db7ef8 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -2020,42 +2020,6 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) return ret; } -static void bsfs_flush(AVCodecContext *avctx) -{ - DecodeFilterContext *s = &avctx->internal->filter; - - for (int i = 0; i < s->nb_bsfs; i++) - av_bsf_flush(s->bsfs[i]); -} - -void avcodec_flush_buffers(AVCodecContext *avctx) -{ - AVCodecInternal *avci = avctx->internal; - - avci->draining = 0; - avci->draining_done = 0; - avci->nb_draining_errors = 0; - av_frame_unref(avci->buffer_frame); - av_frame_unref(avci->compat_decode_frame); - av_packet_unref(avci->buffer_pkt); - avci->buffer_pkt_valid = 0; - - av_packet_unref(avci->ds.in_pkt); - - if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) - ff_thread_flush(avctx); - else if (avctx->codec->flush) - avctx->codec->flush(avctx); - - avctx->pts_correction_last_pts = - avctx->pts_correction_last_dts = INT64_MIN; - - bsfs_flush(avctx); - - if (!avctx->refcounted_frames) - av_frame_unref(avci->to_free); -} - void ff_decode_bsfs_uninit(AVCodecContext *avctx) { DecodeFilterContext *s = &avctx->internal->filter; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index c4dc136d3c..5257a1c627 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1084,6 +1084,39 @@ FF_ENABLE_DEPRECATION_WARNINGS goto end; } +void avcodec_flush_buffers(AVCodecContext *avctx) +{ + AVCodecInternal *avci = avctx->internal; + + avci->draining = 0; + avci->draining_done = 0; + avci->nb_draining_errors = 0; + av_frame_unref(avci->buffer_frame); + av_frame_unref(avci->compat_decode_frame); + av_packet_unref(avci->buffer_pkt); + avci->buffer_pkt_valid = 0; + + av_packet_unref(avci->ds.in_pkt); + + if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) + ff_thread_flush(avctx); + else if (avctx->codec->flush) + avctx->codec->flush(avctx); + + avctx->pts_correction_last_pts = + avctx->pts_correction_last_dts = INT64_MIN; + + if (av_codec_is_decoder(avctx->codec)) { + DecodeFilterContext *s = &avctx->internal->filter; + + for (int i = 0; i < s->nb_bsfs; i++) + av_bsf_flush(s->bsfs[i]); + } + + if (!avctx->refcounted_frames) + av_frame_unref(avci->to_free); +} + void avsubtitle_free(AVSubtitle *sub) { int i; -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".