aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/qsvdec.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-09-02 19:23:26 -0300
committerJames Almer <jamrial@gmail.com>2018-09-02 19:23:26 -0300
commit7167ac33a8f2c7d063384c267f984f23d2b73854 (patch)
treee5d4d881507af94a2b7f816eee7867a794c8731b /libavcodec/qsvdec.c
parent768b07e3bca7e81d2f9c60badb3973d3d88481dc (diff)
parentc1bcd321ea2c2ae1765a1e64f03278712221d726 (diff)
downloadffmpeg-7167ac33a8f2c7d063384c267f984f23d2b73854.tar.gz
Merge commit 'c1bcd321ea2c2ae1765a1e64f03278712221d726'
* commit 'c1bcd321ea2c2ae1765a1e64f03278712221d726': avcodec/qsv: fix async support Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/qsvdec.c')
-rw-r--r--libavcodec/qsvdec.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 32f1fe79d7..22e7a46a85 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;