From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 5C2FC4C31C for ; Thu, 4 Sep 2025 11:17:14 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'ZC3kxUXhDeM0/HphJNQqSJol6Sed7f1smc1JqmIwuMg=', expected b'cUoFbPze4ORxBPGd0nOXBL3RAzVuzKVopBXHJGAcyuk=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1756984602; h=mime-version : to : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=ZC3kxUXhDeM0/HphJNQqSJol6Sed7f1smc1JqmIwuMg=; b=zZrWMLeJxZDfM/1AHd80Nvx1W4q85yth/n9/6XVTjqixpqbVhJ6+h6GlFbArDYaN4+rUU +zEGGcU+J9uP6OWwDoUYecUfxxtvVAyG87Z6Q1RixhpfCDjANW1FMkxw7QjFKyOgrQZO6aA +VbgXCtSQ8gkl1yQmAdqg9mqHvgT7deUpCI61IKP8+zeBG2RMOg26+Py+PiyMT2AGmnb1HC coOZYKVQjkvm2Zw5DSg5MIVCPN/XsJTTngvnpk8850JoDHRiLKFwVyNptjAXEIeOmExflHZ DyzzSCaCFyygY+mUM4QBO6ByeKsDbGRRMN9eZtw3cBh5d+gLVxPPev0Akm4Q== Received: from [172.19.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 5EF4C68E7AC; Thu, 4 Sep 2025 14:16:42 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1756984590; b=T1YMhdA7AXH442K9srb2OOVUkY+A3SgWGDc4KVNW1WxxoDTQ4R9F2fN02lXMiumh5JeHz o4ulrudaec3WdqrGJXlNIdh2uFqGZrUvkde1C2/yH5xMfLniP1MUndKVXL21bl7yHPeUZbu 4NRX2qZWAIgOkO3t2eQsRGyRtgG9jl/MPxb0RXLcOWYULIwbeBIns56I1lYiCuFMfHdxjLU P+Uc/RzqxzbYV/MJdGDBI7fkYRegM4/uuckLi0rzIUoPigATja+ZAUImzJapCgYw4CriIdH Qft6Wxv8rlhPcICVfAhiq2nOodY+rFmhdmKHrA+ewDSk2diFKCdgHUF/kgBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1756984590; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=EPezWOO4IS8wZ7AhP3lRdW07t8ldfyfmWlI22z6YqJg=; b=BJQFNCVCKM513kNFX+WNcu3ZYYFH4OYW+IgurKYSIlJpUdCtf3MCMkf6ZY8oTLFXq2oz/ 4UJ6D1JCfizzdFeHEN+cuYt3VFdJ387ZOmeYSrzEqAjaW/eFEfJUs+jLlKUZUCtuH/y0p94 HdIgiNSHWYXfxb0miVJn4joE7TVQ5hKYwZCfVOw/e8qZtFFwCKtMppehE7EvIVrjhtVBe84 Ha2pEHplF3+wPS3sghRhOSK3WrlehVceCDIpVWVIdX46Gnt5IYu2iJPeTlrz1Tm65sLM3Js qLJjxXtHnucrRa+NvwBDrpLc0rEWoJ5Q374XbHfPu5UAjOKD0JHzTMUmGrNQ== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=none Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1756984581; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : from; bh=cUoFbPze4ORxBPGd0nOXBL3RAzVuzKVopBXHJGAcyuk=; b=i46xFRoZ1kUKfQPPDkwhhRWATUDps0BQBwvcZNY3iMy2eLSq5n3XLUfr28FGJ0sPmSkrm jxBuODXZSJf2BaYwS6a+AB1+CUVASHC9+Ai4rKYftQmDhwvR4Pxyy0EqrmHGxsjVw1MvDzy 5TGHN2puTXOKgAV6lu4ERTNKzSXfBxCsshit1F2Wh2UPwTIA1yAaTHhJtyJcqRaN4D411zA SEhU693Im7AjUXvrOKNVMqSDuEYlfE8sAmtmFJRwy2brN2s0Jyu4uvN8mnW91j9y2S97TCI RBm/MCuIvUteOUHI5e+DbjDCF2tg986i4wM1MJoa3iZFtdfGbdFK1SauqgwA== Received: from 5d8f51c41678 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 3C28068D949 for ; Thu, 4 Sep 2025 14:16:21 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Message-ID: <175698458140.25.6983222867919072760@463a07221176> Message-ID-Hash: NW5JLZIUZ77O4P7B4SY42KLYACAL63PJ X-Message-ID-Hash: NW5JLZIUZ77O4P7B4SY42KLYACAL63PJ X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avcodec/mpegaudiodec_template: Don't modify AVCodecContext.priv_data (PR #20431) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: mkver via ffmpeg-devel Cc: mkver Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20431 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20431 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20431.patch >>From fcfe42e86c7c3027b80f60dd0a43a99ebedbdccb Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 4 Sep 2025 12:00:24 +0200 Subject: [PATCH 1/4] avcodec/mpegaudiodec_template: Don't modify AVCodecContext.priv_data Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 16 +++++++--------- 1 file 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 -- 2.49.1 >>From fb818736d4a9ef8eafd85c97c0f2ff2c31ff6703 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 4 Sep 2025 12:07:06 +0200 Subject: [PATCH 2/4] avcodec/mpegaudiodec_template: Allocate sub-contexts jointly Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 5c38f4e9d7..42e995643b 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -1738,10 +1738,8 @@ static const int16_t chan_layout[8] = { static av_cold int decode_close_mp3on4(AVCodecContext * avctx) { MP3On4DecodeContext *s = avctx->priv_data; - int i; - for (i = 0; i < s->frames; i++) - av_freep(&s->mp3decctx[i]); + av_freep(&s->mp3decctx[0]); return 0; } @@ -1777,8 +1775,8 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) /* Init the first mp3 decoder in standard way, so that all tables get built * 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)); + // Allocate zeroed memory for the decoder contexts + s->mp3decctx[0] = av_calloc(s->frames, sizeof(*s->mp3decctx[0])); if (!s->mp3decctx[0]) return AVERROR(ENOMEM); ret = decode_ctx_init(avctx, s->mp3decctx[0]); @@ -1790,9 +1788,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) * Each frame is 1 or 2 channels - up to 5 frames allowed */ for (i = 1; i < s->frames; i++) { - s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext)); - if (!s->mp3decctx[i]) - return AVERROR(ENOMEM); + s->mp3decctx[i] = s->mp3decctx[0] + i; s->mp3decctx[i]->adu_mode = 1; s->mp3decctx[i]->avctx = avctx; s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp; -- 2.49.1 >>From 3e1a4eb308100f30b7b141ec5390f1ff7121ef77 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 4 Sep 2025 12:25:48 +0200 Subject: [PATCH 3/4] avcodec/mpegaudiodec_template: Mark flush functions as av_cold Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 42e995643b..3ca9adb8ab 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -1625,7 +1625,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, return buf_size + skipped; } -static void mp_flush(MPADecodeContext *ctx) +static av_cold void mp_flush(MPADecodeContext *ctx) { memset(ctx->synth_buf, 0, sizeof(ctx->synth_buf)); memset(ctx->mdct_buf, 0, sizeof(ctx->mdct_buf)); @@ -1633,7 +1633,7 @@ static void mp_flush(MPADecodeContext *ctx) ctx->dither_state = 0; } -static void flush(AVCodecContext *avctx) +static av_cold void flush(AVCodecContext *avctx) { mp_flush(avctx->priv_data); } @@ -1799,7 +1799,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) } -static void flush_mp3on4(AVCodecContext *avctx) +static av_cold void flush_mp3on4(AVCodecContext *avctx) { int i; MP3On4DecodeContext *s = avctx->priv_data; -- 2.49.1 >>From 407c8ae0e89573da2aad0845bb1f58ba760b2b3d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 4 Sep 2025 12:29:28 +0200 Subject: [PATCH 4/4] avcodec/mpegaudiodec_template: Avoid write-only stores Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 3ca9adb8ab..0efcf9853d 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -1792,7 +1792,9 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) s->mp3decctx[i]->adu_mode = 1; s->mp3decctx[i]->avctx = avctx; s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp; +#if USE_FLOATS s->mp3decctx[i]->butterflies_float = s->mp3decctx[0]->butterflies_float; +#endif } return 0; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org