[FFmpeg-devel] [PATCH] hevc: fix deadlock for frame threading safe callbacks disabled

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Mar 8 17:20:28 CET 2015

On Sun, Mar 08, 2015 at 05:12:50PM +0100, Rainer Hochecker wrote:
> ---
>  libavcodec/hevc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
> index fdbaa28..7c7f920 100644
> --- a/libavcodec/hevc.c
> +++ b/libavcodec/hevc.c
> @@ -307,7 +307,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
>      *fmt++ = sps->pix_fmt;
>      *fmt = AV_PIX_FMT_NONE;
> -    ret = ff_thread_get_format(s->avctx, pix_fmts);
> +    ret = ff_get_format(s->avctx, pix_fmts);

I don't think this is correct, this code can be called from both
frame threads and from the main thread, so none of these variants
is correct.
I sent an alternative patch "pthread: Fix ff_thread_get_format issues
when called outside frame decode."
However there are additional bugs like update_context calling this and thus
a single SPS change with n threads resulting in n get_format callbacks,
all except the first completely pointless (and potentially causing
issues with implementations that don't ensure that multiple get_format
are side-effect free).
As a result I am somewhat hesitant about my patch that would end up
hiding all these issues.

More information about the ffmpeg-devel mailing list