summaryrefslogtreecommitdiff
path: root/libavcodec/qsvdec.c
diff options
context:
space:
mode:
authorLinjie Fu <linjie.fu@intel.com>2018-10-16 09:36:13 +0800
committerZhong Li <zhong.li@intel.com>2018-11-06 17:42:29 +0800
commit87368884a52b09eef96190ff1654d56591ec7038 (patch)
tree557e1e78f2e4cc678f18173970d04fc1fd9548f8 /libavcodec/qsvdec.c
parentbeaa350e24167f4ff31275a6114693f5ce7cd409 (diff)
lavc/qsvdec: flush buffered data before reinit
Flush the buffered data in libmfx before video param reinit in case the frames drop. Cache the first frame causing the reinit and decode zero-size pkt to flush the buffered pkt before reinit. After all the buffered pkts being flushed, resume to reinit and decode. Fix the issue in ticket #7399. [V2]: Move the definition of zero_pkt to where it is exactly used. Signed-off-by: Linjie Fu <linjie.fu@intel.com> Signed-off-by: Zhong Li <zhong.li@intel.com>
Diffstat (limited to 'libavcodec/qsvdec.c')
-rw-r--r--libavcodec/qsvdec.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 22e7a46a85..6753e596a1 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -372,6 +372,8 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
++q->zero_consume_run;
if (q->zero_consume_run > 1)
ff_qsv_print_warning(avctx, ret, "A decode call did not consume any data");
+ } else if (!*sync && bs.DataOffset) {
+ ++q->buffered_count;
} else {
q->zero_consume_run = 0;
}
@@ -526,6 +528,16 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
AV_PIX_FMT_NONE,
AV_PIX_FMT_NONE };
enum AVPixelFormat qsv_format;
+ AVPacket zero_pkt = {0};
+
+ if (q->buffered_count) {
+ q->reinit_flag = 1;
+ /* decode zero-size pkt to flush the buffered pkt before reinit */
+ q->buffered_count--;
+ return qsv_decode(avctx, q, frame, got_frame, &zero_pkt);
+ }
+
+ q->reinit_flag = 0;
qsv_format = ff_qsv_map_pixfmt(q->parser->format, &q->fourcc);
if (qsv_format < 0) {