[FFmpeg-cvslog] Merge commit '6f19bbcf8532d018d8d6d82e000738d0ac2385c9'

James Almer git at videolan.org
Wed Sep 28 19:27:17 EEST 2016


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Sep 28 13:26:12 2016 -0300| [e9a5fc967867f9bd361f472306ca130bb64b0b04] | committer: James Almer

Merge commit '6f19bbcf8532d018d8d6d82e000738d0ac2385c9'

* commit '6f19bbcf8532d018d8d6d82e000738d0ac2385c9':
  qsvdec: move reading the user-provided session to qsv_decode_init()

Conflicts:
    libavcodec/qsvdec.c

Merged-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e9a5fc967867f9bd361f472306ca130bb64b0b04
---

 libavcodec/qsvdec.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 98585e3..b685e0e 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -49,8 +49,27 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format)
     }
 }
 
+static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession session)
+{
+    if (!session) {
+        if (!q->internal_qs.session) {
+           int ret = ff_qsv_init_internal_session(avctx, &q->internal_qs,
+                                                  q->load_plugins);
+            if (ret < 0)
+                return ret;
+        }
+
+        q->session = q->internal_qs.session;
+    } else {
+        q->session = session;
+    }
+
+   return 0;
+}
+
 static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt)
 {
+    mfxSession session = NULL;
     mfxVideoParam param = { { 0 } };
     mfxBitstream bs   = { { { 0 } } };
     int ret;
@@ -68,20 +87,16 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt
     if (avctx->hwaccel_context) {
         AVQSVContext *qsv = avctx->hwaccel_context;
 
-        q->session        = qsv->session;
+        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;
+    ret = qsv_init_session(avctx, q, session);
+    if (ret < 0) {
+        av_log(avctx, AV_LOG_ERROR, "Error initializing an MFX session\n");
+        return ret;
     }
 
     if (avpkt->size) {


======================================================================

diff --cc libavcodec/qsvdec.c
index 98585e3,e3e5bba..b685e0e
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@@ -49,67 -49,70 +49,82 @@@ int ff_qsv_map_pixfmt(enum AVPixelForma
      }
  }
  
+ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession session)
+ {
+     if (!session) {
 -        if (!q->internal_session) {
 -            int ret = ff_qsv_init_internal_session(avctx, &q->internal_session,
 -                                                   q->load_plugins);
++        if (!q->internal_qs.session) {
++           int ret = ff_qsv_init_internal_session(avctx, &q->internal_qs,
++                                                  q->load_plugins);
+             if (ret < 0)
+                 return ret;
+         }
+ 
 -        q->session = q->internal_session;
++        q->session = q->internal_qs.session;
+     } else {
+         q->session = session;
+     }
+ 
 -    /* make sure the decoder is uninitialized */
 -    MFXVideoDECODE_Close(q->session);
 -
 -    return 0;
++   return 0;
+ }
+ 
 -static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
 +static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt)
  {
+     mfxSession session = NULL;
      mfxVideoParam param = { { 0 } };
 +    mfxBitstream bs   = { { { 0 } } };
      int ret;
 +    enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_QSV,
 +                                       AV_PIX_FMT_NV12,
 +                                       AV_PIX_FMT_NONE };
  
 -    if (!q->async_fifo) {
 -        q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
 -                                      (sizeof(mfxSyncPoint*) + sizeof(QSVFrame*)));
 -        if (!q->async_fifo)
 -            return AVERROR(ENOMEM);
 -    }
 +    ret = ff_get_format(avctx, pix_fmts);
 +    if (ret < 0)
 +        return ret;
 +
 +    avctx->pix_fmt      = ret;
  
 +    q->iopattern  = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
      if (avctx->hwaccel_context) {
 -        AVQSVContext *user_ctx = avctx->hwaccel_context;
 -        session           = user_ctx->session;
 -        q->iopattern      = user_ctx->iopattern;
 -        q->ext_buffers    = user_ctx->ext_buffers;
 -        q->nb_ext_buffers = user_ctx->nb_ext_buffers;
 +        AVQSVContext *qsv = avctx->hwaccel_context;
 +
-         q->session        = qsv->session;
++        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;
+     ret = qsv_init_session(avctx, q, session);
+     if (ret < 0) {
+         av_log(avctx, AV_LOG_ERROR, "Error initializing an MFX session\n");
+         return ret;
      }
  
 +    if (avpkt->size) {
 +        bs.Data       = avpkt->data;
 +        bs.DataLength = avpkt->size;
 +        bs.MaxLength  = bs.DataLength;
 +        bs.TimeStamp  = avpkt->pts;
 +    } else
 +        return AVERROR_INVALIDDATA;
 +
      ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
 -    if (ret < 0)
 +    if (ret < 0) {
 +        av_log(avctx, AV_LOG_ERROR, "Unsupported codec_id %08x\n", avctx->codec_id);
          return ret;
 +    }
  
 -    param.mfx.CodecId      = ret;
 -    param.mfx.CodecProfile = avctx->profile;
 -    param.mfx.CodecLevel   = avctx->level;
 -
 -    param.mfx.FrameInfo.BitDepthLuma   = 8;
 -    param.mfx.FrameInfo.BitDepthChroma = 8;
 -    param.mfx.FrameInfo.Shift          = 0;
 -    param.mfx.FrameInfo.FourCC         = MFX_FOURCC_NV12;
 -    param.mfx.FrameInfo.Width          = avctx->coded_width;
 -    param.mfx.FrameInfo.Height         = avctx->coded_height;
 -    param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
 +    param.mfx.CodecId = ret;
  
 +    ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, &param);
 +    if (MFX_ERR_MORE_DATA==ret) {
 +        /* this code means that header not found so we return packet size to skip
 +           a current packet
 +         */
 +        return avpkt->size;
 +    } else if (ret < 0) {
 +        av_log(avctx, AV_LOG_ERROR, "Decode header error %d\n", ret);
 +        return ff_qsv_error(ret);
 +    }
      param.IOPattern   = q->iopattern;
      param.AsyncDepth  = q->async_depth;
      param.ExtParam    = q->ext_buffers;



More information about the ffmpeg-cvslog mailing list