summaryrefslogtreecommitdiff
path: root/libavcodec/wmavoice.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/wmavoice.c
parent8e50bd61e4ff97bd7fc6cbd7ec4ca514e17a70c4 (diff)
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/wmavoice.c')
-rw-r--r--libavcodec/wmavoice.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 3f86d0da35..444e303b0d 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -30,6 +30,7 @@
#include "libavutil/channel_layout.h"
#include "libavutil/float_dsp.h"
#include "libavutil/mem.h"
+#include "libavutil/thread.h"
#include "avcodec.h"
#include "internal.h"
#include "get_bits.h"
@@ -310,7 +311,7 @@ static av_cold int decode_vbmtree(GetBitContext *gb, int8_t vbm_tree[25])
return 0;
}
-static av_cold void wmavoice_init_static_data(AVCodec *codec)
+static av_cold void wmavoice_init_static_data(void)
{
static const uint8_t bits[] = {
2, 2, 2, 4, 4, 4,
@@ -365,9 +366,12 @@ static av_cold void wmavoice_flush(AVCodecContext *ctx)
*/
static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
{
+ static AVOnce init_static_once = AV_ONCE_INIT;
int n, flags, pitch_range, lsp16_flag;
WMAVoiceContext *s = ctx->priv_data;
+ ff_thread_once(&init_static_once, wmavoice_init_static_data);
+
/**
* Extradata layout:
* - byte 0-18: WMAPro-in-WMAVoice extradata (see wmaprodec.c),
@@ -1991,7 +1995,6 @@ AVCodec ff_wmavoice_decoder = {
.id = AV_CODEC_ID_WMAVOICE,
.priv_data_size = sizeof(WMAVoiceContext),
.init = wmavoice_decode_init,
- .init_static_data = wmavoice_init_static_data,
.close = wmavoice_decode_end,
.decode = wmavoice_decode_packet,
.capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,