[FFmpeg-cvslog] Merge commit 'a1335149fd610b16459d9281b611282cac51c950'

Derek Buitenhuis git at videolan.org
Mon Apr 11 15:46:42 CEST 2016


ffmpeg | branch: master | Derek Buitenhuis <derek.buitenhuis at gmail.com> | Mon Apr 11 14:45:57 2016 +0100| [acc155ac55baa95d1c16c0364b02244bc04d83a8] | committer: Derek Buitenhuis

Merge commit 'a1335149fd610b16459d9281b611282cac51c950'

* commit 'a1335149fd610b16459d9281b611282cac51c950':
  qsvenc: store the sync point in heap memory

Merged-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>

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

 libavcodec/qsvenc.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index be54bf9..132cf47 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -682,7 +682,7 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
     q->param.AsyncDepth = q->async_depth;
 
     q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
-                                  (sizeof(AVPacket) + sizeof(mfxSyncPoint) + sizeof(mfxBitstream*)));
+                                  (sizeof(AVPacket) + sizeof(mfxSyncPoint*) + sizeof(mfxBitstream*)));
     if (!q->async_fifo)
         return AVERROR(ENOMEM);
 
@@ -926,7 +926,7 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q,
     mfxBitstream *bs;
 
     mfxFrameSurface1 *surf = NULL;
-    mfxSyncPoint sync      = NULL;
+    mfxSyncPoint *sync      = NULL;
     QSVFrame *qsv_frame = NULL;
     mfxEncodeCtrl* enc_ctrl = NULL;
     int ret;
@@ -961,8 +961,15 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q,
         q->set_encode_ctrl_cb(avctx, frame, &qsv_frame->enc_ctrl);
     }
 
+    sync = av_mallocz(sizeof(*sync));
+    if (!sync) {
+        av_freep(&bs);
+        av_packet_unref(&new_pkt);
+        return AVERROR(ENOMEM);
+    }
+
     do {
-        ret = MFXVideoENCODE_EncodeFrameAsync(q->session, enc_ctrl, surf, bs, &sync);
+        ret = MFXVideoENCODE_EncodeFrameAsync(q->session, enc_ctrl, surf, bs, sync);
         if (ret == MFX_WRN_DEVICE_BUSY) {
             av_usleep(500);
             continue;
@@ -991,6 +998,7 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q,
         av_fifo_generic_write(q->async_fifo, &sync,    sizeof(sync),    NULL);
         av_fifo_generic_write(q->async_fifo, &bs,      sizeof(bs),    NULL);
     } else {
+        av_freep(&sync);
         av_packet_unref(&new_pkt);
         av_freep(&bs);
     }
@@ -1011,14 +1019,14 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
         (!frame && av_fifo_size(q->async_fifo))) {
         AVPacket new_pkt;
         mfxBitstream *bs;
-        mfxSyncPoint sync;
+        mfxSyncPoint *sync;
 
         av_fifo_generic_read(q->async_fifo, &new_pkt, sizeof(new_pkt), NULL);
         av_fifo_generic_read(q->async_fifo, &sync,    sizeof(sync),    NULL);
         av_fifo_generic_read(q->async_fifo, &bs,      sizeof(bs),      NULL);
 
         do {
-            ret = MFXVideoCORE_SyncOperation(q->session, sync, 1000);
+            ret = MFXVideoCORE_SyncOperation(q->session, *sync, 1000);
         } while (ret == MFX_WRN_IN_EXECUTION);
 
         new_pkt.dts  = av_rescale_q(bs->DecodeTimeStamp, (AVRational){1, 90000}, avctx->time_base);
@@ -1041,6 +1049,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
         av_freep(&bs);
+        av_freep(&sync);
 
         if (pkt->data) {
             if (pkt->size < new_pkt.size) {
@@ -1087,13 +1096,14 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
 
     while (q->async_fifo && av_fifo_size(q->async_fifo)) {
         AVPacket pkt;
-        mfxSyncPoint sync;
+        mfxSyncPoint *sync;
         mfxBitstream *bs;
 
         av_fifo_generic_read(q->async_fifo, &pkt,  sizeof(pkt),  NULL);
         av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL);
         av_fifo_generic_read(q->async_fifo, &bs,   sizeof(bs),   NULL);
 
+        av_freep(&sync);
         av_freep(&bs);
         av_packet_unref(&pkt);
     }


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

diff --cc libavcodec/qsvenc.c
index be54bf9,473a180..132cf47
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@@ -926,9 -876,7 +926,9 @@@ static int encode_frame(AVCodecContext 
      mfxBitstream *bs;
  
      mfxFrameSurface1 *surf = NULL;
-     mfxSyncPoint sync      = NULL;
 -    mfxSyncPoint *sync     = NULL;
++    mfxSyncPoint *sync      = NULL;
 +    QSVFrame *qsv_frame = NULL;
 +    mfxEncodeCtrl* enc_ctrl = NULL;
      int ret;
  
      if (frame) {
@@@ -957,18 -901,18 +957,25 @@@
      bs->Data      = new_pkt.data;
      bs->MaxLength = new_pkt.size;
  
 +    if (q->set_encode_ctrl_cb) {
 +        q->set_encode_ctrl_cb(avctx, frame, &qsv_frame->enc_ctrl);
 +    }
 +
+     sync = av_mallocz(sizeof(*sync));
+     if (!sync) {
+         av_freep(&bs);
+         av_packet_unref(&new_pkt);
+         return AVERROR(ENOMEM);
+     }
+ 
      do {
-         ret = MFXVideoENCODE_EncodeFrameAsync(q->session, enc_ctrl, surf, bs, &sync);
 -        ret = MFXVideoENCODE_EncodeFrameAsync(q->session, NULL, surf, bs, sync);
 -        if (ret == MFX_WRN_DEVICE_BUSY)
 -            av_usleep(1);
 -    } while (ret > 0);
++        ret = MFXVideoENCODE_EncodeFrameAsync(q->session, enc_ctrl, surf, bs, sync);
 +        if (ret == MFX_WRN_DEVICE_BUSY) {
 +            av_usleep(500);
 +            continue;
 +        }
 +        break;
 +    } while ( 1 );
  
      if (ret < 0) {
          av_packet_unref(&new_pkt);



More information about the ffmpeg-cvslog mailing list