[FFmpeg-cvslog] Merge commit '404e51478ecad060249d5b9bee6ab39a8a9d8c1c'

Mark Thompson git at videolan.org
Fri Mar 31 00:02:28 EEST 2017


ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Thu Mar 30 22:00:03 2017 +0100| [2f18e452f88fc6ed7b0e308d4de5c386ee1b3a12] | committer: Mark Thompson

Merge commit '404e51478ecad060249d5b9bee6ab39a8a9d8c1c'

* commit '404e51478ecad060249d5b9bee6ab39a8a9d8c1c':
  qsv{dec,enc}: always use an internal mfxFrameSurface1

Minor fixups for differences in the QSV encoder because of a53cc.

Merged-by: Mark Thompson <sw at jkqxz.net>

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

 libavcodec/qsv_internal.h |  5 ++---
 libavcodec/qsvdec.c       | 32 ++++++++++++++++++--------------
 libavcodec/qsvenc.c       | 32 ++++++++++++++++----------------
 3 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 6ccb72a..b1567fb 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -40,12 +40,11 @@
 
 typedef struct QSVFrame {
     AVFrame *frame;
-    mfxFrameSurface1 *surface;
+    mfxFrameSurface1 surface;
     mfxEncodeCtrl enc_ctrl;
 
-    mfxFrameSurface1 surface_internal;
-
     int queued;
+    int used;
 
     struct QSVFrame *next;
 } QSVFrame;
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 7d496d9..e11aa71 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -194,17 +194,17 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext *q, QSVFrame *frame)
         return ret;
 
     if (frame->frame->format == AV_PIX_FMT_QSV) {
-        frame->surface = (mfxFrameSurface1*)frame->frame->data[3];
+        frame->surface = *(mfxFrameSurface1*)frame->frame->data[3];
     } else {
-        frame->surface_internal.Info = q->frame_info;
+        frame->surface.Info = q->frame_info;
 
-        frame->surface_internal.Data.PitchLow = frame->frame->linesize[0];
-        frame->surface_internal.Data.Y        = frame->frame->data[0];
-        frame->surface_internal.Data.UV       = frame->frame->data[1];
-
-        frame->surface = &frame->surface_internal;
+        frame->surface.Data.PitchLow = frame->frame->linesize[0];
+        frame->surface.Data.Y        = frame->frame->data[0];
+        frame->surface.Data.UV       = frame->frame->data[1];
     }
 
+    frame->used = 1;
+
     return 0;
 }
 
@@ -212,8 +212,8 @@ static void qsv_clear_unused_frames(QSVContext *q)
 {
     QSVFrame *cur = q->work_frames;
     while (cur) {
-        if (cur->surface && !cur->surface->Data.Locked && !cur->queued) {
-            cur->surface = NULL;
+        if (cur->used && !cur->surface.Data.Locked && !cur->queued) {
+            cur->used = 0;
             av_frame_unref(cur->frame);
         }
         cur = cur->next;
@@ -230,11 +230,11 @@ static int get_surface(AVCodecContext *avctx, QSVContext *q, mfxFrameSurface1 **
     frame = q->work_frames;
     last  = &q->work_frames;
     while (frame) {
-        if (!frame->surface) {
+        if (!frame->used) {
             ret = alloc_frame(avctx, q, frame);
             if (ret < 0)
                 return ret;
-            *surf = frame->surface;
+            *surf = &frame->surface;
             return 0;
         }
 
@@ -256,7 +256,7 @@ static int get_surface(AVCodecContext *avctx, QSVContext *q, mfxFrameSurface1 **
     if (ret < 0)
         return ret;
 
-    *surf = frame->surface;
+    *surf = &frame->surface;
 
     return 0;
 }
@@ -265,7 +265,7 @@ static QSVFrame *find_frame(QSVContext *q, mfxFrameSurface1 *surf)
 {
     QSVFrame *cur = q->work_frames;
     while (cur) {
-        if (surf == cur->surface)
+        if (surf == &cur->surface)
             return cur;
         cur = cur->next;
     }
@@ -363,7 +363,7 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
         if (ret < 0)
             return ret;
 
-        outsurf = out_frame->surface;
+        outsurf = &out_frame->surface;
 
 #if FF_API_PKT_PTS
 FF_DISABLE_DEPRECATION_WARNINGS
@@ -381,6 +381,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
         frame->interlaced_frame =
             !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
 
+        /* update the surface properties */
+        if (avctx->pix_fmt == AV_PIX_FMT_QSV)
+            ((mfxFrameSurface1*)frame->data[3])->Info = outsurf->Info;
+
         *got_frame = 1;
     }
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 2e59150..496a032 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -814,10 +814,10 @@ static void clear_unused_frames(QSVEncContext *q)
 {
     QSVFrame *cur = q->work_frames;
     while (cur) {
-        if (cur->surface && !cur->surface->Data.Locked) {
-            cur->surface = NULL;
+        if (cur->used && !cur->surface.Data.Locked) {
             free_encoder_ctrl_payloads(&cur->enc_ctrl);
             av_frame_unref(cur->frame);
+            cur->used = 0;
         }
         cur = cur->next;
     }
@@ -832,8 +832,9 @@ static int get_free_frame(QSVEncContext *q, QSVFrame **f)
     frame = q->work_frames;
     last  = &q->work_frames;
     while (frame) {
-        if (!frame->surface) {
+        if (!frame->used) {
             *f = frame;
+            frame->used = 1;
             return 0;
         }
 
@@ -857,6 +858,7 @@ static int get_free_frame(QSVEncContext *q, QSVFrame **f)
     *last = frame;
 
     *f = frame;
+    frame->used = 1;
 
     return 0;
 }
@@ -876,7 +878,7 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
         if (ret < 0)
             return ret;
 
-        qf->surface = (mfxFrameSurface1*)qf->frame->data[3];
+        qf->surface = *(mfxFrameSurface1*)qf->frame->data[3];
     } else {
         /* make a copy if the input is not padded as libmfx requires */
         if (frame->height & 31 || frame->linesize[0] & (q->width_align - 1)) {
@@ -900,27 +902,25 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
                 return ret;
         }
 
-        qf->surface_internal.Info = q->param.mfx.FrameInfo;
+        qf->surface.Info = q->param.mfx.FrameInfo;
 
-        qf->surface_internal.Info.PicStruct =
+        qf->surface.Info.PicStruct =
             !frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
             frame->top_field_first   ? MFX_PICSTRUCT_FIELD_TFF :
                                        MFX_PICSTRUCT_FIELD_BFF;
         if (frame->repeat_pict == 1)
-            qf->surface_internal.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
+            qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
         else if (frame->repeat_pict == 2)
-            qf->surface_internal.Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
+            qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
         else if (frame->repeat_pict == 4)
-            qf->surface_internal.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
+            qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
 
-        qf->surface_internal.Data.PitchLow  = qf->frame->linesize[0];
-        qf->surface_internal.Data.Y         = qf->frame->data[0];
-        qf->surface_internal.Data.UV        = qf->frame->data[1];
-
-        qf->surface = &qf->surface_internal;
+        qf->surface.Data.PitchLow  = qf->frame->linesize[0];
+        qf->surface.Data.Y         = qf->frame->data[0];
+        qf->surface.Data.UV        = qf->frame->data[1];
     }
 
-    qf->surface->Data.TimeStamp = av_rescale_q(frame->pts, q->avctx->time_base, (AVRational){1, 90000});
+    qf->surface.Data.TimeStamp = av_rescale_q(frame->pts, q->avctx->time_base, (AVRational){1, 90000});
 
     *new_frame = qf;
 
@@ -959,7 +959,7 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q,
         }
     }
     if (qsv_frame) {
-        surf = qsv_frame->surface;
+        surf = &qsv_frame->surface;
         enc_ctrl = &qsv_frame->enc_ctrl;
     }
 


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

diff --cc libavcodec/qsv_internal.h
index 6ccb72a,5b015a6..b1567fb
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@@ -40,12 -38,10 +40,11 @@@
  
  typedef struct QSVFrame {
      AVFrame *frame;
-     mfxFrameSurface1 *surface;
+     mfxFrameSurface1 surface;
 +    mfxEncodeCtrl enc_ctrl;
  
-     mfxFrameSurface1 surface_internal;
- 
      int queued;
+     int used;
  
      struct QSVFrame *next;
  } QSVFrame;
diff --cc libavcodec/qsvenc.c
index 2e59150,3d99e84..496a032
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@@ -814,10 -813,9 +814,10 @@@ static void clear_unused_frames(QSVEncC
  {
      QSVFrame *cur = q->work_frames;
      while (cur) {
-         if (cur->surface && !cur->surface->Data.Locked) {
-             cur->surface = NULL;
+         if (cur->used && !cur->surface.Data.Locked) {
 +            free_encoder_ctrl_payloads(&cur->enc_ctrl);
              av_frame_unref(cur->frame);
+             cur->used = 0;
          }
          cur = cur->next;
      }
@@@ -907,22 -902,20 +909,20 @@@ static int submit_frame(QSVEncContext *
              frame->top_field_first   ? MFX_PICSTRUCT_FIELD_TFF :
                                         MFX_PICSTRUCT_FIELD_BFF;
          if (frame->repeat_pict == 1)
-             qf->surface_internal.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
+             qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
          else if (frame->repeat_pict == 2)
-             qf->surface_internal.Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
+             qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
          else if (frame->repeat_pict == 4)
-             qf->surface_internal.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
+             qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
  
-         qf->surface_internal.Data.PitchLow  = qf->frame->linesize[0];
-         qf->surface_internal.Data.Y         = qf->frame->data[0];
-         qf->surface_internal.Data.UV        = qf->frame->data[1];
- 
-         qf->surface = &qf->surface_internal;
+         qf->surface.Data.PitchLow  = qf->frame->linesize[0];
+         qf->surface.Data.Y         = qf->frame->data[0];
+         qf->surface.Data.UV        = qf->frame->data[1];
      }
  
-     qf->surface->Data.TimeStamp = av_rescale_q(frame->pts, q->avctx->time_base, (AVRational){1, 90000});
+     qf->surface.Data.TimeStamp = av_rescale_q(frame->pts, q->avctx->time_base, (AVRational){1, 90000});
  
 -    *surface = &qf->surface;
 +    *new_frame = qf;
  
      return 0;
  }
@@@ -958,10 -949,6 +958,10 @@@ static int encode_frame(AVCodecContext 
              return ret;
          }
      }
 +    if (qsv_frame) {
-         surf = qsv_frame->surface;
++        surf = &qsv_frame->surface;
 +        enc_ctrl = &qsv_frame->enc_ctrl;
 +    }
  
      ret = av_new_packet(&new_pkt, q->packet_size);
      if (ret < 0) {



More information about the ffmpeg-cvslog mailing list