qsvdec: fix get_format and hwaccel_context handling
authorHendrik Leppkes <h.leppkes@gmail.com>
Thu, 22 Oct 2015 15:00:49 +0000 (17:00 +0200)
committerHendrik Leppkes <h.leppkes@gmail.com>
Thu, 22 Oct 2015 15:01:13 +0000 (17:01 +0200)
This enables the qsv transcoder to actually get activated

libavcodec/qsvdec.c

index 9fefc41..c451fb9 100644 (file)
@@ -58,24 +58,30 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt
                                        AV_PIX_FMT_NV12,
                                        AV_PIX_FMT_NONE };
 
+    ret = ff_get_format(avctx, pix_fmts);
+    if (ret < 0)
+        return ret;
+
+    avctx->pix_fmt      = ret;
+
     q->iopattern  = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
-    if (!q->session) {
-        if (avctx->hwaccel_context) {
-            AVQSVContext *qsv = avctx->hwaccel_context;
+    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) {
+        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) {
+        if (!q->internal_qs.session) {
             ret = ff_qsv_init_internal_session(avctx, &q->internal_qs,
                                                q->load_plugins);
             if (ret < 0)
                 return ret;
-
-            q->session = q->internal_qs.session;
         }
+
+        q->session = q->internal_qs.session;
     }
 
     if (avpkt->size) {
@@ -123,11 +129,6 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt
         return ff_qsv_error(ret);
     }
 
-    ret = ff_get_format(avctx, pix_fmts);
-    if (ret < 0)
-        return ret;
-
-    avctx->pix_fmt      = ret;
     avctx->profile      = param.mfx.CodecProfile;
     avctx->level        = param.mfx.CodecLevel;
     avctx->coded_width  = param.mfx.FrameInfo.Width;