From patchwork Thu Aug 27 02:53:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 21938 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 319F744AA76 for ; Thu, 27 Aug 2020 05:53:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F9BD6881C4; Thu, 27 Aug 2020 05:53:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CFAA668807B for ; Thu, 27 Aug 2020 05:53:48 +0300 (EEST) X-QQ-mid: bizesmtp11t1598496810t8ppebxp Received: from localhost (unknown [103.107.216.230]) by esmtp6.qq.com (ESMTP) with id ; Thu, 27 Aug 2020 10:53:29 +0800 (CST) X-QQ-SSF: 01100000002000Z0Z000B00A0000000 X-QQ-FEAT: eMj3uo9amlzIPUoja3bozV/0htXxYTQPmqz6+kshNK1Fm5nSFfjVsKSX8KPZp hJCvmXRAUNctOYNH8fIqAWnMMuyCrwzLD6zQLvZyHM4v+hy7lkkhxOrK2r2eKZ1CvHh5lqr e9R0gNcYndWpe//wI2zsGRdtLGLkz1aRi4aErd6QiS2A9E2Kur92L8lCGFi4IcPcRrwmHgv UB6Dg+fAm8wsSSxw/qAwhp+CZjYTTvjEi+qwQ6S0og1gnNMSuNHL/5NRPppOcFLF25ZgNGw wHBRd5MDtDogq52X5sPFZWz+v2kH9ZEpAU0XQCEocd0p9m X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Aug 2020 10:53:27 +0800 Message-Id: <20200827025327.28334-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign7 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avcodec/videotoolboxenc: don't wait when flushing data X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu , Tian Qi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Tian Qi 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 Signed-off-by: Steven Liu --- libavcodec/videotoolboxenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index e89cfaeed8..f9626be18f 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -292,7 +292,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); } @@ -308,6 +308,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; @@ -319,7 +320,6 @@ static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef *buf, E } av_free(info); - vtctx->frame_ct_out++; return 0; }