diff options
author | Andreas Rheinhardt <[email protected]> | 2025-09-04 12:00:24 +0200 |
---|---|---|
committer | Andreas Rheinhardt <[email protected]> | 2025-09-12 21:38:48 +0200 |
commit | 84f4b9fc1fdb9dd48b258e26cdc0edfa383b857c (patch) | |
tree | 018f52ca09ab9db5fcb8f9c80984c3f8e54954ef | |
parent | 87cb7c871b6b25e537a7b19e47bf2779ad8d31b4 (diff) |
avcodec/mpegaudiodec_template: Don't modify AVCodecContext.priv_data
Reviewed-by: Peter Ross <[email protected]>
Signed-off-by: Andreas Rheinhardt <[email protected]>
-rw-r--r-- | libavcodec/mpegaudiodec_template.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index d7c5210eb8..5c38f4e9d7 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -280,10 +280,9 @@ static av_cold void decode_init_static(void) ff_mpegaudiodec_common_init_static(); } -static av_cold int decode_init(AVCodecContext * avctx) +static av_cold int decode_ctx_init(AVCodecContext *avctx, MPADecodeContext *s) { static AVOnce init_static_once = AV_ONCE_INIT; - MPADecodeContext *s = avctx->priv_data; s->avctx = avctx; @@ -315,6 +314,11 @@ static av_cold int decode_init(AVCodecContext * avctx) return 0; } +static av_cold int decode_init(AVCodecContext *avctx) +{ + return decode_ctx_init(avctx, avctx->priv_data); +} + #define C3 FIXHR(0.86602540378443864676/2) #define C4 FIXHR(0.70710678118654752439/2) //0.5 / cos(pi*(9)/36) #define C5 FIXHR(0.51763809020504152469/2) //0.5 / cos(pi*(5)/36) @@ -1771,19 +1775,13 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) s->syncword = 0xfff00000; /* Init the first mp3 decoder in standard way, so that all tables get built - * We replace avctx->priv_data with the context of the first decoder so that - * decode_init() does not have to be changed. * Other decoders will be initialized here copying data from the first context */ // Allocate zeroed memory for the first decoder context s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext)); if (!s->mp3decctx[0]) return AVERROR(ENOMEM); - // Put decoder context in place to make init_decode() happy - avctx->priv_data = s->mp3decctx[0]; - ret = decode_init(avctx); - // Restore mp3on4 context pointer - avctx->priv_data = s; + ret = decode_ctx_init(avctx, s->mp3decctx[0]); if (ret < 0) return ret; s->mp3decctx[0]->adu_mode = 1; // Set adu mode |