History

mpegaudiodec: init static tables in AVCodec.init_static_data()

Justin Ruggles committed 15 years ago

Commit 11587451 parent 3f5d6a62 files · +22 −18Browse files

Unified · Split

2 files
  1. libavcodec/mpegaudiodec.c +17 −18
  2. libavcodec/mpegaudiodec_float.c +5 −0
libavcodec/mpegaudiodec.c+17−18
@@ -266,24 +266,9 @@ static inline int l3_unscale(int value, int exponent) · 265 unmodified lines
266266 return m;
267267 }
268268
269−static av_cold int decode_init(AVCodecContext * avctx)
269+static void decode_init_static(AVCodec *codec)
270270 {
271− MPADecodeContext *s = avctx->priv_data;
272− static int init = 0;
273271 int i, j, k;
274−
275− s->avctx = avctx;
276−
277− ff_mpadsp_init(&s->mpadsp);
278−
279− avctx->sample_fmt= OUT_FMT;
280− s->err_recognition = avctx->err_recognition;
281−
282−#if FF_API_PARSE_FRAME
283− if (!init && !avctx->parse_only) {
284−#else
285− if (!init) {
286−#endif
287272 int offset;
288273
289274 /* scale factors table for layer 1/2 */
@@ -468,9 +453,18 @@ static av_cold int decode_init(AVCodecContext * avctx) · 178 unmodified lines
468453 mdct_win[j + 4][i + 1] = -mdct_win[j][i + 1];
469454 }
470455 }
456+}
471457
472− init = 1;
473− }
458+static av_cold int decode_init(AVCodecContext * avctx)
459+{
460+ MPADecodeContext *s = avctx->priv_data;
461+
462+ s->avctx = avctx;
463+
464+ ff_mpadsp_init(&s->mpadsp);
465+
466+ avctx->sample_fmt= OUT_FMT;
467+ s->err_recognition = avctx->err_recognition;
474468
475469 if (avctx->codec_id == CODEC_ID_MP3ADU)
476470 s->adu_mode = 1;
@@ -2116,6 +2110,7 @@ AVCodec ff_mp1_decoder = { · 1639 unmodified lines
21162110 .type = AVMEDIA_TYPE_AUDIO,
21172111 .id = CODEC_ID_MP1,
21182112 .priv_data_size = sizeof(MPADecodeContext),
2113+ .init_static_data = decode_init_static,
21192114 .init = decode_init,
21202115 .decode = decode_frame,
21212116 #if FF_API_PARSE_FRAME
@@ -2131,6 +2126,7 @@ AVCodec ff_mp2_decoder = { · 9 unmodified lines
21312126 .type = AVMEDIA_TYPE_AUDIO,
21322127 .id = CODEC_ID_MP2,
21332128 .priv_data_size = sizeof(MPADecodeContext),
2129+ .init_static_data = decode_init_static,
21342130 .init = decode_init,
21352131 .decode = decode_frame,
21362132 #if FF_API_PARSE_FRAME
@@ -2146,6 +2142,7 @@ AVCodec ff_mp3_decoder = { · 9 unmodified lines
21462142 .type = AVMEDIA_TYPE_AUDIO,
21472143 .id = CODEC_ID_MP3,
21482144 .priv_data_size = sizeof(MPADecodeContext),
2145+ .init_static_data = decode_init_static,
21492146 .init = decode_init,
21502147 .decode = decode_frame,
21512148 #if FF_API_PARSE_FRAME
@@ -2161,6 +2158,7 @@ AVCodec ff_mp3adu_decoder = { · 9 unmodified lines
21612158 .type = AVMEDIA_TYPE_AUDIO,
21622159 .id = CODEC_ID_MP3ADU,
21632160 .priv_data_size = sizeof(MPADecodeContext),
2161+ .init_static_data = decode_init_static,
21642162 .init = decode_init,
21652163 .decode = decode_frame_adu,
21662164 #if FF_API_PARSE_FRAME
@@ -2176,6 +2174,7 @@ AVCodec ff_mp3on4_decoder = { · 9 unmodified lines
21762174 .type = AVMEDIA_TYPE_AUDIO,
21772175 .id = CODEC_ID_MP3ON4,
21782176 .priv_data_size = sizeof(MP3On4DecodeContext),
2177+ .init_static_data = decode_init_static,
21792178 .init = decode_init_mp3on4,
21802179 .close = decode_close_mp3on4,
21812180 .decode = decode_frame_mp3on4,
libavcodec/mpegaudiodec_float.c+5−0
@@ -28,6 +28,7 @@ AVCodec ff_mp1float_decoder = { · 27 unmodified lines
2828 .type = AVMEDIA_TYPE_AUDIO,
2929 .id = CODEC_ID_MP1,
3030 .priv_data_size = sizeof(MPADecodeContext),
31+ .init_static_data = decode_init_static,
3132 .init = decode_init,
3233 .decode = decode_frame,
3334 #if FF_API_PARSE_FRAME
@@ -43,6 +44,7 @@ AVCodec ff_mp2float_decoder = { · 9 unmodified lines
4344 .type = AVMEDIA_TYPE_AUDIO,
4445 .id = CODEC_ID_MP2,
4546 .priv_data_size = sizeof(MPADecodeContext),
47+ .init_static_data = decode_init_static,
4648 .init = decode_init,
4749 .decode = decode_frame,
4850 #if FF_API_PARSE_FRAME
@@ -58,6 +60,7 @@ AVCodec ff_mp3float_decoder = { · 9 unmodified lines
5860 .type = AVMEDIA_TYPE_AUDIO,
5961 .id = CODEC_ID_MP3,
6062 .priv_data_size = sizeof(MPADecodeContext),
63+ .init_static_data = decode_init_static,
6164 .init = decode_init,
6265 .decode = decode_frame,
6366 #if FF_API_PARSE_FRAME
@@ -73,6 +76,7 @@ AVCodec ff_mp3adufloat_decoder = { · 9 unmodified lines
7376 .type = AVMEDIA_TYPE_AUDIO,
7477 .id = CODEC_ID_MP3ADU,
7578 .priv_data_size = sizeof(MPADecodeContext),
79+ .init_static_data = decode_init_static,
7680 .init = decode_init,
7781 .decode = decode_frame_adu,
7882 #if FF_API_PARSE_FRAME
@@ -88,6 +92,7 @@ AVCodec ff_mp3on4float_decoder = { · 9 unmodified lines
8892 .type = AVMEDIA_TYPE_AUDIO,
8993 .id = CODEC_ID_MP3ON4,
9094 .priv_data_size = sizeof(MP3On4DecodeContext),
95+ .init_static_data = decode_init_static,
9196 .init = decode_init_mp3on4,
9297 .close = decode_close_mp3on4,
9398 .decode = decode_frame_mp3on4,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t