[FFmpeg-devel] [PATCH 05/17] avcodec/rv40: Make decoder init-threadsafe
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Sat Feb 12 08:41:19 EET 2022
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/rv40.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
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,
};
--
2.32.0
More information about the ffmpeg-devel
mailing list