diff mbox series

[FFmpeg-devel,05/17] avcodec/rv40: Make decoder init-threadsafe

Message ID AM7PR03MB6660EF1A9A3916DB9BFDB6658F319@AM7PR03MB6660.eurprd03.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,01/17] avcodec/svq3: Mark decoder as init-threadsafe | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 12, 2022, 6:41 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/rv40.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
index 31a7a04e51..8f7589242d 100644
--- a/libavcodec/rv40.c
+++ b/libavcodec/rv40.c
@@ -27,6 +27,7 @@ 
 #include "config.h"
 
 #include "libavutil/imgutils.h"
+#include "libavutil/thread.h"
 
 #include "avcodec.h"
 #include "mpegutils.h"
@@ -553,14 +554,13 @@  static void rv40_loop_filter(RV34DecContext *r, int row)
  */
 static av_cold int rv40_decode_init(AVCodecContext *avctx)
 {
+    static AVOnce init_static_once = AV_ONCE_INIT;
     RV34DecContext *r = avctx->priv_data;
     int ret;
 
     r->rv30 = 0;
     if ((ret = ff_rv34_decode_init(avctx)) < 0)
         return ret;
-    if(!aic_top_vlc.bits)
-        rv40_init_tables();
     r->parse_slice_header = rv40_parse_slice_header;
     r->decode_intra_types = rv40_decode_intra_types;
     r->decode_mb_info     = rv40_decode_mb_info;
@@ -568,6 +568,7 @@  static av_cold int rv40_decode_init(AVCodecContext *avctx)
     r->luma_dc_quant_i = rv40_luma_dc_quant[0];
     r->luma_dc_quant_p = rv40_luma_dc_quant[1];
     ff_rv40dsp_init(&r->rdsp);
+    ff_thread_once(&init_static_once, rv40_init_tables);
     return 0;
 }
 
@@ -588,5 +589,6 @@  const AVCodec ff_rv40_decoder = {
         AV_PIX_FMT_NONE
     },
     .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context),
-    .caps_internal         = FF_CODEC_CAP_ALLOCATE_PROGRESS,
+    .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE |
+                             FF_CODEC_CAP_ALLOCATE_PROGRESS,
 };