[FFmpeg-devel] [PATCH] lavc/webp: Remove frame threading

Thilo Borgmann thilo.borgmann at mail.de
Sun Oct 22 15:45:25 EEST 2023


Revealed by the patch to support animated webp, the current
frame threading implementation contains a data race.
vp8_lossy_decode_frame() calls ff_vp8_decode_frame() wich
calls ff_thread_finish_setup() to sync its internal slice threading.
The race is happens because vp8_lossy_decode_frame() has to touch
the AVCodecContext after it was passed to ff_vp8_decode_frame() and
ff_thread_finish_setup() had been called.

Therefore remove frame threading in webp and rely on slice threading
in VP8 only.
---
 libavcodec/webp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 54b3fde6dc..cde91aa7bb 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -49,7 +49,6 @@
 #include "decode.h"
 #include "exif.h"
 #include "get_bits.h"
-#include "thread.h"
 #include "tiff_common.h"
 #include "vp8.h"
 
@@ -570,7 +569,7 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
     img->frame->height = h;
 
     if (role == IMAGE_ROLE_ARGB && !img->is_alpha_primary) {
-        ret = ff_thread_get_buffer(s->avctx, img->frame, 0);
+        ret = ff_get_buffer(s->avctx, img->frame, 0);
     } else
         ret = av_frame_get_buffer(img->frame, 1);
     if (ret < 0)
@@ -1564,6 +1563,6 @@ const FFCodec ff_webp_decoder = {
     .init           = webp_decode_init,
     FF_CODEC_DECODE_CB(webp_decode_frame),
     .close          = webp_decode_close,
-    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
+    .p.capabilities = AV_CODEC_CAP_DR1,
     .caps_internal  = FF_CODEC_CAP_ICC_PROFILES,
 };
-- 
2.37.1 (Apple Git-137.1)



More information about the ffmpeg-devel mailing list