Commit a3d8ede74d for ffmpeg
commit a3d8ede74d8875d69eaefc90c048c068c53a0185
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Sun Sep 20 12:25:50 2026 +0000
avcodec/libmp3lame: honor strict ISO compliance
Enable LAME strict ISO buffer constraints when strict_std_compliance is at least FF_COMPLIANCE_STRICT, as suggested in #23733. Preserve the library defaults for lower compliance levels.
This lets users opt into the constraints used by lame --strictly-enforce-ISO without changing the requested sample rate or bitrate. Document the mapping.
Assisted-by: Fairy
diff --git a/doc/encoders.texi b/doc/encoders.texi
index a3ce15fcff..3a07b9d3d7 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -895,6 +895,12 @@ while producing the worst quality.
Set lowpass cutoff frequency. If unspecified, the encoder dynamically
adjusts the cutoff.
+@item strict (@emph{--strictly-enforce-ISO})
+Enable LAME's strict ISO buffer constraints when set to @samp{strict} or
+@samp{very}. Other values leave LAME's default buffer constraints unchanged.
+This can improve compatibility with some decoders, at the cost of reduced
+bit reservoir usage.
+
@item reservoir
Enable use of bit reservoir when set to 1. Default value is 1. LAME
has this enabled by default, but can be overridden by use
diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
index 88a5ba34a8..b84cfa8b4d 100644
--- a/libavcodec/libmp3lame.c
+++ b/libavcodec/libmp3lame.c
@@ -146,6 +146,10 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
/* original flag */
lame_set_original(s->gfp, s->original);
+ /* strict ISO compliance */
+ if (avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT)
+ lame_set_strict_ISO(s->gfp, 1);
+
/* set specified parameters */
if (lame_init_params(s->gfp) < 0) {
ret = AVERROR_EXTERNAL;