Merge commit 'f5c4d38c78347b09478e21a661befff4b2d44643'
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 19 Jul 2015 14:13:35 +0000 (16:13 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 19 Jul 2015 14:13:35 +0000 (16:13 +0200)
* commit 'f5c4d38c78347b09478e21a661befff4b2d44643':
  qsvdec: properly handle asynchronous decoding

Conflicts:
libavcodec/qsvdec.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
1  2 
libavcodec/qsv_internal.h
libavcodec/qsvdec.c
libavcodec/qsvdec.h

Simple merge
@@@ -54,23 -73,17 +54,28 @@@ int ff_qsv_decode_init(AVCodecContext *
      mfxVideoParam param = { { 0 } };
      int ret;
  
 -    ret = qsv_init_session(avctx, q, session);
 -    if (ret < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "Error initializing an MFX session\n");
 -        return ret;
+     q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
+                                   (sizeof(mfxSyncPoint) + sizeof(QSVFrame*)));
+     if (!q->async_fifo)
+         return AVERROR(ENOMEM);
 +    q->iopattern  = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
 +
 +    if (avctx->hwaccel_context) {
 +        AVQSVContext *qsv = avctx->hwaccel_context;
 +
 +        q->session        = qsv->session;
 +        q->iopattern      = qsv->iopattern;
 +        q->ext_buffers    = qsv->ext_buffers;
 +        q->nb_ext_buffers = qsv->nb_ext_buffers;
      }
 +    if (!q->session) {
 +        ret = ff_qsv_init_internal_session(avctx, &q->internal_qs, NULL);
 +        if (ret < 0)
 +            return ret;
  
 +        q->session = q->internal_qs.session;
 +    }
  
      ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
      if (ret < 0)
@@@ -274,7 -304,12 +296,11 @@@ int ff_qsv_decode_close(QSVContext *q
          av_freep(&cur);
          cur = q->work_frames;
      }
 -    if (q->internal_session)
 -        MFXClose(q->internal_session);
+     av_fifo_free(q->async_fifo);
+     q->async_fifo = NULL;
 +    ff_qsv_close_internal_session(&q->internal_qs);
  
      return 0;
  }
Simple merge