diff mbox

[FFmpeg-devel,2/2] dnxhd: initialize DNXHDContext::avctx to each thread's respective one.

Message ID 1490744275-59294-2-git-send-email-rsbultje@gmail.com
State Accepted
Commit f800d6508d7e8fbd8d9777b775d333a4f02112ef
Headers show

Commit Message

Ronald S. Bultje March 28, 2017, 11:37 p.m. UTC
Otherwise all thread's private contexts have the avctx pointer set to
the AVCodecContext of the first thread, which means all writes to
ctx->avctx->* (in e.g. read_header) are effectively race conditions.

Fixes fate-dnxhd under tsan.
---
 libavcodec/dnxhddec.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Paul B Mahol March 29, 2017, 9:16 p.m. UTC | #1
On 3/29/17, Ronald S. Bultje <rsbultje@gmail.com> wrote:
> Otherwise all thread's private contexts have the avctx pointer set to
> the AVCodecContext of the first thread, which means all writes to
> ctx->avctx->* (in e.g. read_header) are effectively race conditions.
>
> Fixes fate-dnxhd under tsan.
> ---
>  libavcodec/dnxhddec.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
> index 305fd52..766467e 100644
> --- a/libavcodec/dnxhddec.c
> +++ b/libavcodec/dnxhddec.c
> @@ -145,6 +145,7 @@ static av_cold int
> dnxhd_decode_init_thread_copy(AVCodecContext *avctx)
>  {
>      DNXHDContext *ctx = avctx->priv_data;
>
> +    ctx->avctx = avctx;
>      // make sure VLC tables will be loaded when cid is parsed
>      ctx->cid = -1;
>
> --
> 2.8.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

ok
diff mbox

Patch

diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 305fd52..766467e 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -145,6 +145,7 @@  static av_cold int dnxhd_decode_init_thread_copy(AVCodecContext *avctx)
 {
     DNXHDContext *ctx = avctx->priv_data;
 
+    ctx->avctx = avctx;
     // make sure VLC tables will be loaded when cid is parsed
     ctx->cid = -1;