[FFmpeg-devel] [PATCH] dnxhd: set keyframe/pict_type before calling get_buffer().

Ronald S. Bultje rsbultje at gmail.com
Tue Apr 4 16:09:48 EEST 2017


This fixes the following tsan warning:

WARNING: ThreadSanitizer: data race (pid=95987)
  Write of size 4 at 0x7d5000004278 by main thread:
    #0 get_frame_defaults frame.c:117 (ffmpeg:x86_64+0x1016c5b18)
[..]
  Previous write of size 4 at 0x7d5000004278 by thread T2:
    [failed to restore the stack]
---
 libavcodec/dnxhddec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 383e64c..77e62a2 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -626,10 +626,10 @@ decode_coding_unit:
         return ret;
 
     if (first_field) {
-        if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
-            return ret;
         picture->pict_type = AV_PICTURE_TYPE_I;
         picture->key_frame = 1;
+        if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
+            return ret;
     }
 
     ctx->buf_size = buf_size - ctx->data_offset;
-- 
2.8.1



More information about the ffmpeg-devel mailing list