[FFmpeg-cvslog] mpegaudio: do not use init_static_data() for initializing tables.
Justin Ruggles
git at videolan.org
Mon Nov 28 01:14:16 CET 2011
ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Sun Nov 27 13:07:19 2011 -0500| [0df5e869cb9fc4eb6f7aacdf40920b0b87ce4db7] | committer: Justin Ruggles
mpegaudio: do not use init_static_data() for initializing tables.
It is called once for each mpegaudio codec that is registered, which adds
significant overhead.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0df5e869cb9fc4eb6f7aacdf40920b0b87ce4db7
---
libavcodec/mpegaudiodec.c | 13 +++++++------
libavcodec/mpegaudiodec_float.c | 5 -----
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index bc01273..ffd3690 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -266,7 +266,7 @@ static inline int l3_unscale(int value, int exponent)
return m;
}
-static void decode_init_static(AVCodec *codec)
+static av_cold void decode_init_static(void)
{
int i, j, k;
int offset;
@@ -457,8 +457,14 @@ static void decode_init_static(AVCodec *codec)
static av_cold int decode_init(AVCodecContext * avctx)
{
+ static int initialized_tables = 0;
MPADecodeContext *s = avctx->priv_data;
+ if (!initialized_tables) {
+ decode_init_static();
+ initialized_tables = 1;
+ }
+
s->avctx = avctx;
ff_mpadsp_init(&s->mpadsp);
@@ -2110,7 +2116,6 @@ AVCodec ff_mp1_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP1,
.priv_data_size = sizeof(MPADecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init,
.decode = decode_frame,
#if FF_API_PARSE_FRAME
@@ -2126,7 +2131,6 @@ AVCodec ff_mp2_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP2,
.priv_data_size = sizeof(MPADecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init,
.decode = decode_frame,
#if FF_API_PARSE_FRAME
@@ -2142,7 +2146,6 @@ AVCodec ff_mp3_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP3,
.priv_data_size = sizeof(MPADecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init,
.decode = decode_frame,
#if FF_API_PARSE_FRAME
@@ -2158,7 +2161,6 @@ AVCodec ff_mp3adu_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP3ADU,
.priv_data_size = sizeof(MPADecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init,
.decode = decode_frame_adu,
#if FF_API_PARSE_FRAME
@@ -2174,7 +2176,6 @@ AVCodec ff_mp3on4_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP3ON4,
.priv_data_size = sizeof(MP3On4DecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init_mp3on4,
.close = decode_close_mp3on4,
.decode = decode_frame_mp3on4,
diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c
index 4a18736..9300de2 100644
--- a/libavcodec/mpegaudiodec_float.c
+++ b/libavcodec/mpegaudiodec_float.c
@@ -28,7 +28,6 @@ AVCodec ff_mp1float_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP1,
.priv_data_size = sizeof(MPADecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init,
.decode = decode_frame,
#if FF_API_PARSE_FRAME
@@ -44,7 +43,6 @@ AVCodec ff_mp2float_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP2,
.priv_data_size = sizeof(MPADecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init,
.decode = decode_frame,
#if FF_API_PARSE_FRAME
@@ -60,7 +58,6 @@ AVCodec ff_mp3float_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP3,
.priv_data_size = sizeof(MPADecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init,
.decode = decode_frame,
#if FF_API_PARSE_FRAME
@@ -76,7 +73,6 @@ AVCodec ff_mp3adufloat_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP3ADU,
.priv_data_size = sizeof(MPADecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init,
.decode = decode_frame_adu,
#if FF_API_PARSE_FRAME
@@ -92,7 +88,6 @@ AVCodec ff_mp3on4float_decoder = {
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_MP3ON4,
.priv_data_size = sizeof(MP3On4DecodeContext),
- .init_static_data = decode_init_static,
.init = decode_init_mp3on4,
.close = decode_close_mp3on4,
.decode = decode_frame_mp3on4,
More information about the ffmpeg-cvslog
mailing list