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 EAEB24B91E for ; Wed, 24 Sep 2025 15:27:23 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'MB5oYnASvgvEmEHzLyz5Z4dXlhijbWJepbO9xvSFXZI=', expected b'M5mprR1ujyMws7YDmYIBV+JQuGWmA5OAMDUfIsWF/CM=')) 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=1758727629; h=mime-version : to : date : 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=MB5oYnASvgvEmEHzLyz5Z4dXlhijbWJepbO9xvSFXZI=; b=lVTgd4qhKdjXqmULe7oo8cVZLJoWmpl6nLhhEwohl0OO3yBZo5pmSWcUrvHNkM1D/94XQ 1q3Dn4YhdT1QeAxaEjDjWBiLKyNOJNBflgLHk6ehtxq5MuKmFTRSsFDGPZ52/deJUsrX9gx JgnKUE8FqsjDcBOqvr/vstMhZtFQMThJISqbpd4BPW1zpWJzyZjeZEeNc1vG/f0f9o3wdKJ 2ufhAZaT2d99rgiCgZ0g9UCZ/ExtkflbdocfrG2bK+7LOcd1U5nKZ5ex89gh0xRkHc47SUk FjckWor4pcfX7oPgxTQpA74vCBOMH8g6/1cVrVvdV/OfOoou/qaBvpfapQTg== Received: from [172.19.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id AC9E668ED0D; Wed, 24 Sep 2025 18:27:09 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1758727625; b=MTDCvfM78uI98janP6BYp01kpUlh6t6o+kDMfCu7jOYDj/lF5PKAFGCPxsTDOoVOUkOL0 9i9zt9a1deLyHi8IfMibNjD4lwTO9UbAl1ECS2bZy/Uwyw1pxBfZygeUeYFK4AHhPpw4lXb Adlj0dvlMOqVoUrseCIuciUBt/w3ojkSU6rViE/mGX0r06O68N17UPLLHQ1oIlHYKxL0CS4 MzFZLb9DQI1AcGO0eawo5JqnYHT5ImP3o4vnRUHRcM9zSbJ36p8MXaBsMvoY+Bgs2qBnlJi IZdP2a0U/vDGHLe5vuloCtUJSygnDegGN7W/TjDaXNUGhPAO/QxHShSMCkLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1758727625; 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=qzi316ERn1SYVflv5PcK/sEtEBwMN92q1Y8aYwVAUuw=; b=NgJM1y3JdPvcX6KeibNJUb0fkrJocSfynPWbMsa3NIG9oJb24M9DB88PPbioAGQp2/NUT XCvnAaIivtbpaL0HvImmAuet02OQcfRM6R4BrwxEhSmAn/rUqLyHfqRWrOvLrN/tlUMdSxP a8v49c2g/0xQ+AGpYiOcg4V7zLawaR3Cx6OfHrzkAuTpAdpsDGu4tM5jBVsMskwWNoouMxH di+YeDRb+W+4rDYm+mC/MhufuYfcw7Tm79Z6I8iYvCcfbECd6KVe+3MgBOVBVIQ/B0tISJd VVe/gKjNUEVI97sw8hIEM77z98TbrJ0jPK0QeYrSD6/t5scWZRkj021Q0mgg== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1758727617; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=M5mprR1ujyMws7YDmYIBV+JQuGWmA5OAMDUfIsWF/CM=; b=s0Mnpvtu6nylAT3aWo/U+XJB0HplnThKHwZI7mK4UgjbwUBD8uxixGjZ6fCwphyRyRQPt 7SFt1RfSZgxpmrbwY3nV2O75EJdFvZxL0M0MELkt5zHFUkHMssewJVssRrjSu7LwJFqDpfY Z6WLlymKDlSeoZjaYujJSGJfSv2vavrIkTr/9EDmX5+xNCEtzcyKmArdAAABYpjoXkuoUlP VSCuVcau1xFRnwK+GDRCUSmVHuYOw069qNipLDIrsniKro0c0OPNUGOl8t7yWGlmawZVxxR +Z4zw+2+7BFfaadJe6SxPSuKfOKu0rWwKxEW8NoKlLJp4oJZY4ZPqhR+/VbQ== Received: from ed19c606a818 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id A281768EC3E for ; Wed, 24 Sep 2025 18:26:57 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Sep 2025 15:26:57 -0000 Message-ID: <175872761781.25.4480376046819961295@bf249f23a2c8> Message-ID-Hash: FKFZRFY6WNK32GK2MOU2G256KA2CGIIR X-Message-ID-Hash: FKFZRFY6WNK32GK2MOU2G256KA2CGIIR 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] Various libmpeghdec patches (PR #20602) 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 #20602 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20602 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20602.patch There is another issue not fixed in this PR: The decoder treats avctx->sample_rate as time base of avpkt->pts, although it is AVCodecContext.pkt_timebase. That is probably the reason for the sample_rate check. >>From a4b870ecb2c422faa8bb9fb5876b3a83f5ec4918 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Sep 2025 12:07:28 +0200 Subject: [PATCH 1/8] avcodec/libmpeghdec: Remove redundant manual close calls This decoder has the INIT_CLEANUP flag set. Signed-off-by: Andreas Rheinhardt --- libavcodec/libmpeghdec.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c index e293ec3396..ae85924625 100644 --- a/libavcodec/libmpeghdec.c +++ b/libavcodec/libmpeghdec.c @@ -171,16 +171,13 @@ static av_cold int mpegh3dadec_init(AVCodecContext *avctx) s->decoder_buffer_size = MAX_OUTBUF_SIZE; s->decoder_buffer = av_malloc(s->decoder_buffer_size); - if (!s->decoder_buffer) { - mpegh3dadec_close(avctx); + if (!s->decoder_buffer) return AVERROR(ENOMEM); - } // initialize the decoder s->decoder = mpeghdecoder_init(cicp); if (s->decoder == NULL) { av_log(avctx, AV_LOG_ERROR, "MPEG-H decoder library init failed.\n"); - mpegh3dadec_close(avctx); return AVERROR_EXTERNAL; } @@ -188,7 +185,6 @@ static av_cold int mpegh3dadec_init(AVCodecContext *avctx) if (mpeghdecoder_setMhaConfig(s->decoder, avctx->extradata, avctx->extradata_size)) { av_log(avctx, AV_LOG_ERROR, "Unable to set MHA configuration\n"); - mpegh3dadec_close(avctx); return AVERROR_INVALIDDATA; } } -- 2.49.1 >>From b7ef96c52a8534cd2c00ab4d560cf0aca39bc1d7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Sep 2025 12:09:39 +0200 Subject: [PATCH 2/8] avcodec/libmpeghdec: Remove private class This decoder doesn't have any options. Signed-off-by: Andreas Rheinhardt --- libavcodec/libmpeghdec.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c index ae85924625..2d6798e49e 100644 --- a/libavcodec/libmpeghdec.c +++ b/libavcodec/libmpeghdec.c @@ -35,7 +35,6 @@ #include "libavutil/channel_layout.h" #include "libavutil/frame.h" #include "libavutil/mem.h" -#include "libavutil/opt.h" #include "codec_internal.h" #include "decode.h" @@ -45,7 +44,6 @@ #define MAX_OUTBUF_SIZE (sizeof(int32_t) * 24 * 3072 * (MAX_LOST_FRAMES + 1)) typedef struct MPEGH3DADecContext { - AVClass *av_class; // pointer to the decoder HANDLE_MPEGH_DECODER_CONTEXT decoder; @@ -54,13 +52,6 @@ typedef struct MPEGH3DADecContext { int decoder_buffer_size; } MPEGH3DADecContext; -// private class definition for ffmpeg -static const AVClass mpegh3da_class = { - .class_name = "MPEG-H 3D Audio Decoder", - .item_name = av_default_item_name, - .version = LIBAVUTIL_VERSION_INT, -}; - static av_cold int mpegh3dadec_close(AVCodecContext *avctx) { MPEGH3DADecContext *s = avctx->priv_data; @@ -268,7 +259,6 @@ static av_cold void mpegh3dadec_flush(AVCodecContext *avctx) const FFCodec ff_libmpeghdec_decoder = { .p.name = "libmpeghdec", CODEC_LONG_NAME("libmpeghdec (MPEG-H 3D Audio)"), - .p.priv_class = &mpegh3da_class, .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MPEGH_3D_AUDIO, .p.capabilities = -- 2.49.1 >>From 63a1d668db8922a12b8093115512348836e139d5 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Sep 2025 12:10:32 +0200 Subject: [PATCH 3/8] avcodec/libmpeghdec: Don't set AVCodec.sample_fmts It is mostly pointless for decoders (only useful for those codecs for which a floating-point and a fixed-point decoder exists). Signed-off-by: Andreas Rheinhardt --- libavcodec/libmpeghdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c index 2d6798e49e..e3cb219838 100644 --- a/libavcodec/libmpeghdec.c +++ b/libavcodec/libmpeghdec.c @@ -268,7 +268,6 @@ const FFCodec ff_libmpeghdec_decoder = { FF_CODEC_DECODE_CB(mpegh3dadec_decode_frame), .close = mpegh3dadec_close, .flush = mpegh3dadec_flush, - CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_S32), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.wrapper_name = "libmpeghdec", }; -- 2.49.1 >>From 2a6618920c40420b0604fe41546ff88fab4e2473 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Sep 2025 12:13:16 +0200 Subject: [PATCH 4/8] avcodec/libmpeghdec: Inline constant Signed-off-by: Andreas Rheinhardt --- libavcodec/libmpeghdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c index e3cb219838..5233b36bc3 100644 --- a/libavcodec/libmpeghdec.c +++ b/libavcodec/libmpeghdec.c @@ -236,7 +236,7 @@ static int mpegh3dadec_decode_frame(AVCodecContext *avctx, AVFrame *frame, memcpy(frame->extended_data[0], s->decoder_buffer, avctx->ch_layout.nb_channels * avctx->frame_size * - av_get_bytes_per_sample(avctx->sample_fmt)); + sizeof(*s->decoder_buffer) /* only AV_SAMPLE_FMT_S32 is supported */); *got_frame_ptr = 1; return ret = avpkt->size; -- 2.49.1 >>From 76892e05752acab6a9e769478cd07058dd6692c8 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Sep 2025 12:18:57 +0200 Subject: [PATCH 5/8] avcodec/libmpeghdec: Don't use too big buffer The channel count is fixed, so we don't need to allocate space to hold samples for nonexisting channels. Also switch to decoder_buffer_size to be samples-based. Signed-off-by: Andreas Rheinhardt --- libavcodec/libmpeghdec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c index 5233b36bc3..ebb5e54d7b 100644 --- a/libavcodec/libmpeghdec.c +++ b/libavcodec/libmpeghdec.c @@ -40,8 +40,8 @@ #include "decode.h" #define MAX_LOST_FRAMES 2 -// 32-bit int * 22.2 * max framesize * (max delay frames + 1) -#define MAX_OUTBUF_SIZE (sizeof(int32_t) * 24 * 3072 * (MAX_LOST_FRAMES + 1)) +// max framesize * (max delay frames + 1) +#define PER_CHANNEL_OUTBUF_SIZE (3072 * (MAX_LOST_FRAMES + 1)) typedef struct MPEGH3DADecContext { // pointer to the decoder @@ -49,7 +49,7 @@ typedef struct MPEGH3DADecContext { // Internal values int32_t *decoder_buffer; - int decoder_buffer_size; + int decoder_buffer_size; ///< in samples } MPEGH3DADecContext; static av_cold int mpegh3dadec_close(AVCodecContext *avctx) @@ -160,8 +160,8 @@ static av_cold int mpegh3dadec_init(AVCodecContext *avctx) avctx->sample_fmt = AV_SAMPLE_FMT_S32; avctx->sample_rate = 48000; - s->decoder_buffer_size = MAX_OUTBUF_SIZE; - s->decoder_buffer = av_malloc(s->decoder_buffer_size); + s->decoder_buffer_size = PER_CHANNEL_OUTBUF_SIZE * avctx->ch_layout.nb_channels; + s->decoder_buffer = av_malloc_array(s->decoder_buffer_size, sizeof(*s->decoder_buffer)); if (!s->decoder_buffer) return AVERROR(ENOMEM); @@ -214,7 +214,7 @@ static int mpegh3dadec_decode_frame(AVCodecContext *avctx, AVFrame *frame, } err = mpeghdecoder_getSamples(s->decoder, s->decoder_buffer, - s->decoder_buffer_size / sizeof(int32_t), + s->decoder_buffer_size, &out_info); if (err == MPEGH_DEC_FEED_DATA) { // no frames to produce at the moment -- 2.49.1 >>From cad21108aa91439c01bc85073808424fbea6e4dd Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Sep 2025 12:22:33 +0200 Subject: [PATCH 6/8] avcodec/libmpeghdec: Remove always-false check The pointer to the decoder is always set after init has been called successfully. Signed-off-by: Andreas Rheinhardt --- libavcodec/libmpeghdec.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c index ebb5e54d7b..174fd5da34 100644 --- a/libavcodec/libmpeghdec.c +++ b/libavcodec/libmpeghdec.c @@ -247,9 +247,6 @@ static av_cold void mpegh3dadec_flush(AVCodecContext *avctx) MPEGH_DECODER_ERROR err; MPEGH3DADecContext *s = avctx->priv_data; - if (!s->decoder) - return; - err = mpeghdecoder_flush(s->decoder); if (err != MPEGH_DEC_OK && err != MPEGH_DEC_FEED_DATA) -- 2.49.1 >>From 523517c4426820164dfaf55ce6c2a57d65bc8915 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Sep 2025 15:00:25 +0200 Subject: [PATCH 7/8] avcodec/libmpeghdec: Align FFCodec initializers Signed-off-by: Andreas Rheinhardt --- libavcodec/libmpeghdec.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c index 174fd5da34..bd63db8ed6 100644 --- a/libavcodec/libmpeghdec.c +++ b/libavcodec/libmpeghdec.c @@ -254,17 +254,17 @@ static av_cold void mpegh3dadec_flush(AVCodecContext *avctx) } const FFCodec ff_libmpeghdec_decoder = { - .p.name = "libmpeghdec", + .p.name = "libmpeghdec", CODEC_LONG_NAME("libmpeghdec (MPEG-H 3D Audio)"), - .p.type = AVMEDIA_TYPE_AUDIO, - .p.id = AV_CODEC_ID_MPEGH_3D_AUDIO, - .p.capabilities = - AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_CHANNEL_CONF, + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_MPEGH_3D_AUDIO, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_CHANNEL_CONF, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .priv_data_size = sizeof(MPEGH3DADecContext), - .init = mpegh3dadec_init, + .init = mpegh3dadec_init, FF_CODEC_DECODE_CB(mpegh3dadec_decode_frame), - .close = mpegh3dadec_close, - .flush = mpegh3dadec_flush, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .flush = mpegh3dadec_flush, + .close = mpegh3dadec_close, .p.wrapper_name = "libmpeghdec", }; -- 2.49.1 >>From c72e8408c26eda5dd8795d713d9850a1fdd2893b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Sep 2025 17:05:27 +0200 Subject: [PATCH 8/8] avcodec/libmpeghdec: Don't set AVCodecContext.frame_size It indicates a constant frame size (in samples); yet the documentation of the MPEGH_DECODER_OUTPUT_INFO structure says that it "gives information about the currently decoded audio data" and makes no guarantees about it being constant. Signed-off-by: Andreas Rheinhardt --- libavcodec/libmpeghdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c index bd63db8ed6..527627ba16 100644 --- a/libavcodec/libmpeghdec.c +++ b/libavcodec/libmpeghdec.c @@ -225,7 +225,7 @@ static int mpegh3dadec_decode_frame(AVCodecContext *avctx, AVFrame *frame, return AVERROR_UNKNOWN; } - frame->nb_samples = avctx->frame_size = out_info.numSamplesPerChannel; + frame->nb_samples = out_info.numSamplesPerChannel; frame->sample_rate = avctx->sample_rate = out_info.sampleRate; frame->pts = out_info.ticks; frame->time_base.num = 1; @@ -235,7 +235,7 @@ static int mpegh3dadec_decode_frame(AVCodecContext *avctx, AVFrame *frame, return ret; memcpy(frame->extended_data[0], s->decoder_buffer, - avctx->ch_layout.nb_channels * avctx->frame_size * + avctx->ch_layout.nb_channels * frame->nb_samples * sizeof(*s->decoder_buffer) /* only AV_SAMPLE_FMT_S32 is supported */); *got_frame_ptr = 1; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org