| @@ -266,24 +266,9 @@ static inline int l3_unscale(int value, int exponent) · 265 unmodified lines |
| 266 | 266 | return m; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | | −static av_cold int decode_init(AVCodecContext * avctx) |
| 269 | +static void decode_init_static(AVCodec *codec) |
| 270 | 270 | { |
| 271 | | − MPADecodeContext *s = avctx->priv_data; |
| 272 | | − static int init = 0; |
| 273 | 271 | 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 |
| 287 | 272 | int offset; |
| 288 | 273 | |
| 289 | 274 | /* scale factors table for layer 1/2 */ |
| @@ -468,9 +453,18 @@ static av_cold int decode_init(AVCodecContext * avctx) · 178 unmodified lines |
| 468 | 453 | mdct_win[j + 4][i + 1] = -mdct_win[j][i + 1]; |
| 469 | 454 | } |
| 470 | 455 | } |
| 456 | +} |
| 471 | 457 | |
| 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; |
| 474 | 468 | |
| 475 | 469 | if (avctx->codec_id == CODEC_ID_MP3ADU) |
| 476 | 470 | s->adu_mode = 1; |
| @@ -2116,6 +2110,7 @@ AVCodec ff_mp1_decoder = { · 1639 unmodified lines |
| 2116 | 2110 | .type = AVMEDIA_TYPE_AUDIO, |
| 2117 | 2111 | .id = CODEC_ID_MP1, |
| 2118 | 2112 | .priv_data_size = sizeof(MPADecodeContext), |
| 2113 | + .init_static_data = decode_init_static, |
| 2119 | 2114 | .init = decode_init, |
| 2120 | 2115 | .decode = decode_frame, |
| 2121 | 2116 | #if FF_API_PARSE_FRAME |
| @@ -2131,6 +2126,7 @@ AVCodec ff_mp2_decoder = { · 9 unmodified lines |
| 2131 | 2126 | .type = AVMEDIA_TYPE_AUDIO, |
| 2132 | 2127 | .id = CODEC_ID_MP2, |
| 2133 | 2128 | .priv_data_size = sizeof(MPADecodeContext), |
| 2129 | + .init_static_data = decode_init_static, |
| 2134 | 2130 | .init = decode_init, |
| 2135 | 2131 | .decode = decode_frame, |
| 2136 | 2132 | #if FF_API_PARSE_FRAME |
| @@ -2146,6 +2142,7 @@ AVCodec ff_mp3_decoder = { · 9 unmodified lines |
| 2146 | 2142 | .type = AVMEDIA_TYPE_AUDIO, |
| 2147 | 2143 | .id = CODEC_ID_MP3, |
| 2148 | 2144 | .priv_data_size = sizeof(MPADecodeContext), |
| 2145 | + .init_static_data = decode_init_static, |
| 2149 | 2146 | .init = decode_init, |
| 2150 | 2147 | .decode = decode_frame, |
| 2151 | 2148 | #if FF_API_PARSE_FRAME |
| @@ -2161,6 +2158,7 @@ AVCodec ff_mp3adu_decoder = { · 9 unmodified lines |
| 2161 | 2158 | .type = AVMEDIA_TYPE_AUDIO, |
| 2162 | 2159 | .id = CODEC_ID_MP3ADU, |
| 2163 | 2160 | .priv_data_size = sizeof(MPADecodeContext), |
| 2161 | + .init_static_data = decode_init_static, |
| 2164 | 2162 | .init = decode_init, |
| 2165 | 2163 | .decode = decode_frame_adu, |
| 2166 | 2164 | #if FF_API_PARSE_FRAME |
| @@ -2176,6 +2174,7 @@ AVCodec ff_mp3on4_decoder = { · 9 unmodified lines |
| 2176 | 2174 | .type = AVMEDIA_TYPE_AUDIO, |
| 2177 | 2175 | .id = CODEC_ID_MP3ON4, |
| 2178 | 2176 | .priv_data_size = sizeof(MP3On4DecodeContext), |
| 2177 | + .init_static_data = decode_init_static, |
| 2179 | 2178 | .init = decode_init_mp3on4, |
| 2180 | 2179 | .close = decode_close_mp3on4, |
| 2181 | 2180 | .decode = decode_frame_mp3on4, |