[FFmpeg-devel] [PATCH] avcodec/videotoolboxenc: don't wait when flushing data
Rick Kern
kernrj at gmail.com
Fri Aug 28 16:14:57 EEST 2020
On Wed, Aug 26, 2020 at 10:53 PM Steven Liu <lq at chinaffmpeg.org> wrote:
> From: Tian Qi <tianqi at kuaishou.com>
>
> 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.
>
I'd like to reproduce the issue and test the fix before the patch is
applied, so if you can provide a media file that causes the issue or code
snippet, it would be helpful.
It looks like this could happen after an encoding error. Do you see any
"Error encoding frame ..." logs?
>
> Signed-off-by: Tian Qi <tianqi at kuaishou.com>
> Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
> ---
> 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;
> }
> --
> 2.25.0
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list