From 3caecf7ce8e9642cd17942e61f12803bbab52ad2 Mon Sep 17 00:00:00 2001 From: Muhammad Faiz Date: Sat, 3 Feb 2018 01:18:27 +0700 Subject: avcodec: do not use init_static_data on some codecs They don't modify AVCodec, no needs to call it at register. They will be wasteful if these codecs are unused. Instead, call static data initialization at codecs' init. Benchmark: old: 51281340 decicycles in avcodec_register_all, 1 runs, 0 skips new: 6738960 decicycles in avcodec_register_all, 1 runs, 0 skips Reviewed-by: wm4 Reviewed-by: Michael Niedermayer Signed-off-by: Muhammad Faiz --- libavcodec/qdmc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libavcodec/qdmc.c') diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c index 1c8952b97b..f1f86accd8 100644 --- a/libavcodec/qdmc.c +++ b/libavcodec/qdmc.c @@ -26,6 +26,7 @@ #define BITSTREAM_READER_LE #include "libavutil/channel_layout.h" +#include "libavutil/thread.h" #include "avcodec.h" #include "bytestream.h" @@ -204,7 +205,7 @@ static const uint8_t phase_diff_codes[] = { INIT_VLC_LE | INIT_VLC_USE_NEW_STATIC); \ } while (0) -static av_cold void qdmc_init_static_data(AVCodec *codec) +static av_cold void qdmc_init_static_data(void) { int i; @@ -250,10 +251,13 @@ static void make_noises(QDMCContext *s) static av_cold int qdmc_decode_init(AVCodecContext *avctx) { + static AVOnce init_static_once = AV_ONCE_INIT; QDMCContext *s = avctx->priv_data; int fft_size, fft_order, size, g, j, x; GetByteContext b; + ff_thread_once(&init_static_once, qdmc_init_static_data); + if (!avctx->extradata || (avctx->extradata_size < 48)) { av_log(avctx, AV_LOG_ERROR, "extradata missing or truncated\n"); return AVERROR_INVALIDDATA; @@ -775,7 +779,6 @@ AVCodec ff_qdmc_decoder = { .id = AV_CODEC_ID_QDMC, .priv_data_size = sizeof(QDMCContext), .init = qdmc_decode_init, - .init_static_data = qdmc_init_static_data, .close = qdmc_decode_close, .decode = qdmc_decode_frame, .flush = qdmc_flush, -- cgit v1.2.3