diff options
author | Ivan Uskov <ivan.uskov@nablet.com> | 2015-08-06 12:10:24 -0400 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-09-07 22:04:02 +0200 |
commit | 3f8e2e9953240365361e939ca2ecd788dd5bef59 (patch) | |
tree | fba9333fe5d584e1383b85ec512f4bb836f7802e /libavcodec/qsvdec.c | |
parent | cc167f7e55dafdeeca7ac9622331db8d8f6cb463 (diff) | |
download | ffmpeg-3f8e2e9953240365361e939ca2ecd788dd5bef59.tar.gz |
libavcodec/qsvdec.c: correct flush() handler has been implemented
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/qsvdec.c')
-rw-r--r-- | libavcodec/qsvdec.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 51ad2f7090..00990badb1 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -517,6 +517,51 @@ int ff_qsv_decode(AVCodecContext *avctx, QSVContext *q, return ret; } +/* + This function resets decoder and corresponded buffers before seek operation +*/ +void ff_qsv_decode_reset(AVCodecContext *avctx, QSVContext *q) +{ + QSVFrame *cur; + AVPacket pkt; + int ret = 0; + mfxVideoParam param = { { 0 } }; + + if (q->reinit_pending) { + close_decoder(q); + } else if (q->engine_ready) { + ret = MFXVideoDECODE_GetVideoParam(q->session, ¶m); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "MFX decode get param error %d\n", ret); + } + + ret = MFXVideoDECODE_Reset(q->session, ¶m); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "MFX decode reset error %d\n", ret); + } + + /* Free all frames*/ + cur = q->work_frames; + while (cur) { + q->work_frames = cur->next; + av_frame_free(&cur->frame); + av_freep(&cur); + cur = q->work_frames; + } + } + + /* Reset output surfaces */ + av_fifo_reset(q->async_fifo); + + /* Reset input packets fifo */ + while (av_fifo_size(q->pkt_fifo)) { + av_fifo_generic_read(q->pkt_fifo, &pkt, sizeof(pkt), NULL); + av_packet_unref(&pkt); + } + + /* Reset input bitstream fifo */ + av_fifo_reset(q->input_fifo); +} int ff_qsv_decode_close(QSVContext *q) { |