diff options
author | Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com> | 2018-07-24 10:36:19 -0700 |
---|---|---|
committer | Maxym Dmytrychenko <maxim.d33@gmail.com> | 2018-07-26 09:57:54 +0200 |
commit | c1bcd321ea2c2ae1765a1e64f03278712221d726 (patch) | |
tree | 7960ea2e628eb7ac132983c5c917a452efd3290a /libavcodec/qsvdec.c | |
parent | f25117a4286505b38c12466ef04459471de3c1b0 (diff) |
avcodec/qsv: fix async support
Current implementations of qsv components incorrectly work with async level, they
actually try to work in async+1 level stepping into MFX_WRN_DEVICE_BUSY and polling
loop. This change address this misbehaviour.
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Cc: Maxym Dmytrychenko <maxim.d33@gmail.com>
Cc: Zhong Li <zhong.li@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
Diffstat (limited to 'libavcodec/qsvdec.c')
-rw-r--r-- | libavcodec/qsvdec.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 31cce2d838..48ac6eb18c 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -110,6 +110,16 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses return 0; } +static inline unsigned int qsv_fifo_item_size(void) +{ + return sizeof(mfxSyncPoint*) + sizeof(QSVFrame*); +} + +static inline unsigned int qsv_fifo_size(const AVFifoBuffer* fifo) +{ + return av_fifo_size(fifo) / qsv_fifo_item_size(); +} + static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q) { const AVPixFmtDescriptor *desc; @@ -125,8 +135,7 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q) return AVERROR_BUG; if (!q->async_fifo) { - q->async_fifo = av_fifo_alloc((1 + q->async_depth) * - (sizeof(mfxSyncPoint*) + sizeof(QSVFrame*))); + q->async_fifo = av_fifo_alloc(q->async_depth * qsv_fifo_item_size()); if (!q->async_fifo) return AVERROR(ENOMEM); } @@ -384,7 +393,7 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q, av_freep(&sync); } - if (!av_fifo_space(q->async_fifo) || + if ((qsv_fifo_size(q->async_fifo) >= q->async_depth) || (!avpkt->size && av_fifo_size(q->async_fifo))) { AVFrame *src_frame; |