]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/videotoolboxenc: don't wait when flushing data
authorTian Qi <tianqi@kuaishou.com>
Thu, 27 Aug 2020 02:53:27 +0000 (10:53 +0800)
committerRick Kern <kernrj@gmail.com>
Tue, 29 Sep 2020 01:46:30 +0000 (21:46 -0400)
because there is run in thread mode, few times will block
the workflow at the wait, so check the status is flushing data,
don't wait when flushing data.

Signed-off-by: Tian Qi <tianqi@kuaishou.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Rick Kern <kernrj@gmail.com>
libavcodec/videotoolboxenc.c

index ea1384523212f86ca94644406abd6011defd42aa..a99a224bfc2ad60cf2a798ffac2eaf09be5269a0 100644 (file)
@@ -294,7 +294,7 @@ static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef *buf, E
         return 0;
     }
 
-    while (!vtctx->q_head && !vtctx->async_error && wait) {
+    while (!vtctx->q_head && !vtctx->async_error && wait && !vtctx->flushing) {
         pthread_cond_wait(&vtctx->cv_sample_sent, &vtctx->lock);
     }
 
@@ -310,6 +310,7 @@ static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef *buf, E
         vtctx->q_tail = NULL;
     }
 
+    vtctx->frame_ct_out++;
     pthread_mutex_unlock(&vtctx->lock);
 
     *buf = info->cm_buffer;
@@ -321,7 +322,6 @@ static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef *buf, E
     }
     av_free(info);
 
-    vtctx->frame_ct_out++;
 
     return 0;
 }