diff mbox

[FFmpeg-devel] png: set AVFrame flags/fields before calling setup_finished().

Message ID 1491245030-59030-1-git-send-email-rsbultje@gmail.com
State Accepted
Commit eff2861a757b8a46398e6fcb844b960b4775daad
Headers show

Commit Message

Ronald S. Bultje April 3, 2017, 6:43 p.m. UTC
Fixes tsan warnings in fate-apng:

WARNING: ThreadSanitizer: data race (pid=51230)
  Read of size 4 at 0x7d50000042fc by main thread (mutexes: write M1000):
    #0 frame_copy_props frame.c:302 (ffmpeg:x86_64+0x1019a35d6)
[..]
  Previous write of size 4 at 0x7d50000042fc by thread T1 (mutexes: write M997):
    #0 decode_idat_chunk pngdec.c:708 (ffmpeg:x86_64+0x100f5562a)
---
 libavcodec/pngdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paul B Mahol April 3, 2017, 6:45 p.m. UTC | #1
On 4/3/17, Ronald S. Bultje <rsbultje@gmail.com> wrote:
> Fixes tsan warnings in fate-apng:
>
> WARNING: ThreadSanitizer: data race (pid=51230)
>   Read of size 4 at 0x7d50000042fc by main thread (mutexes: write M1000):
>     #0 frame_copy_props frame.c:302 (ffmpeg:x86_64+0x1019a35d6)
> [..]
>   Previous write of size 4 at 0x7d50000042fc by thread T1 (mutexes: write
> M997):
>     #0 decode_idat_chunk pngdec.c:708 (ffmpeg:x86_64+0x100f5562a)
> ---
>  libavcodec/pngdec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> index d184c34..1025519 100644
> --- a/libavcodec/pngdec.c
> +++ b/libavcodec/pngdec.c
> @@ -701,12 +701,12 @@ static int decode_idat_chunk(AVCodecContext *avctx,
> PNGDecContext *s,
>              if ((ret = ff_thread_get_buffer(avctx, &s->previous_picture,
> AV_GET_BUFFER_FLAG_REF)) < 0)
>                  return ret;
>          }
> -        ff_thread_finish_setup(avctx);
> -
>          p->pict_type        = AV_PICTURE_TYPE_I;
>          p->key_frame        = 1;
>          p->interlaced_frame = !!s->interlace_type;
>
> +        ff_thread_finish_setup(avctx);
> +
>          /* compute the compressed row size */
>          if (!s->interlace_type) {
>              s->crow_size = s->row_size + 1;
> --
> 2.8.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

lgtm
diff mbox

Patch

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index d184c34..1025519 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -701,12 +701,12 @@  static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
             if ((ret = ff_thread_get_buffer(avctx, &s->previous_picture, AV_GET_BUFFER_FLAG_REF)) < 0)
                 return ret;
         }
-        ff_thread_finish_setup(avctx);
-
         p->pict_type        = AV_PICTURE_TYPE_I;
         p->key_frame        = 1;
         p->interlaced_frame = !!s->interlace_type;
 
+        ff_thread_finish_setup(avctx);
+
         /* compute the compressed row size */
         if (!s->interlace_type) {
             s->crow_size = s->row_size + 1;