avcodec/decode: flush the internal bsfs instead of constantly reinitalizing them

Initialize the bsfs once when opening the codec and uninitialize them once when
closing it, instead of at every codec flush/seek.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2018-07-26 20:42:27 -03:00
parent 2954e51393
commit 94fe138de0
3 changed files with 19 additions and 10 deletions

View File

@@ -727,6 +727,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
goto free_and_end;
}
if (av_codec_is_decoder(avctx->codec)) {
ret = ff_decode_bsfs_init(avctx);
if (ret < 0)
goto free_and_end;
}
if (HAVE_THREADS
&& !(avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) {
ret = ff_thread_init(avctx);
@@ -1032,6 +1038,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_packet_free(&avctx->internal->last_pkt_props);
av_packet_free(&avctx->internal->ds.in_pkt);
ff_decode_bsfs_uninit(avctx);
av_freep(&avctx->internal->pool);
}