summaryrefslogtreecommitdiffstats
path: root/libavcodec/qdmc.c
diff options
context:
space:
mode:
authorMuhammad Faiz <mfcc64@gmail.com>2018-02-03 01:18:27 +0700
committerMuhammad Faiz <mfcc64@gmail.com>2018-02-04 06:11:07 +0700
commit3caecf7ce8e9642cd17942e61f12803bbab52ad2 (patch)
tree82ade65db730c02046761e30325490cf4a0ed308 /libavcodec/qdmc.c
parent8e50bd61e4ff97bd7fc6cbd7ec4ca514e17a70c4 (diff)
downloadffmpeg-streaming-3caecf7ce8e9642cd17942e61f12803bbab52ad2.zip
ffmpeg-streaming-3caecf7ce8e9642cd17942e61f12803bbab52ad2.tar.gz
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 <nfxjfg@googlemail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
Diffstat (limited to 'libavcodec/qdmc.c')
-rw-r--r--libavcodec/qdmc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
index 1c8952b..f1f86ac 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,
OpenPOWER on IntegriCloud