summaryrefslogtreecommitdiffstats
path: root/libavcodec/decode.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-07-26 20:42:27 -0300
committerJames Almer <jamrial@gmail.com>2018-08-16 23:43:12 -0300
commit94fe138de0ba5892a7051f5b47c191a41b78805a (patch)
tree93760c3bab76f3630feebf71085277479eaa0b6a /libavcodec/decode.c
parent2954e513930f9b1bc2cfba49eed3fc1911e76892 (diff)
downloadffmpeg-streaming-94fe138de0ba5892a7051f5b47c191a41b78805a.zip
ffmpeg-streaming-94fe138de0ba5892a7051f5b47c191a41b78805a.tar.gz
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>
Diffstat (limited to 'libavcodec/decode.c')
-rw-r--r--libavcodec/decode.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index db364ca..2e82f6b 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -182,7 +182,7 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
return 0;
}
-static int bsfs_init(AVCodecContext *avctx)
+int ff_decode_bsfs_init(AVCodecContext *avctx)
{
AVCodecInternal *avci = avctx->internal;
DecodeFilterContext *s = &avci->filter;
@@ -688,10 +688,6 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke
if (avpkt && !avpkt->size && avpkt->data)
return AVERROR(EINVAL);
- ret = bsfs_init(avctx);
- if (ret < 0)
- return ret;
-
av_packet_unref(avci->buffer_pkt);
if (avpkt && (avpkt->data || avpkt->side_data_elems)) {
ret = av_packet_ref(avci->buffer_pkt, avpkt);
@@ -751,10 +747,6 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
return AVERROR(EINVAL);
- ret = bsfs_init(avctx);
- if (ret < 0)
- return ret;
-
if (avci->buffer_frame->buf[0]) {
av_frame_move_ref(frame, avci->buffer_frame);
} else {
@@ -1978,6 +1970,14 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
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)
{
avctx->internal->draining = 0;
@@ -1998,7 +1998,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
avctx->pts_correction_last_pts =
avctx->pts_correction_last_dts = INT64_MIN;
- ff_decode_bsfs_uninit(avctx);
+ bsfs_flush(avctx);
if (!avctx->refcounted_frames)
av_frame_unref(avctx->internal->to_free);
OpenPOWER on IntegriCloud