AC3/EAC3 Decoder Spectral Banding Fix
"donald.graft--- via ffmpeg-devel" <[email protected]>
| Newsgroups | gmane.comp.video.ffmpeg.devel |
|---|---|
| Message-ID | <[email protected]> |
Please refer to:
https://www.rationalqm.us/board/viewtopic.php?p=24199#p24199
This fixes the issue in the latest ffmpeg stable.
$ diff -u libavcodec/ac3dec.c.bak libavcodec/ac3dec.c
--- libavcodec/ac3dec.c.bak 2026-06-19 16:11:14.198323700 -0500
+++ libavcodec/ac3dec.c 2026-06-19 18:47:26.631695100 -0500
@@ -362,8 +362,20 @@
if (s->channel_in_cpl[ch]) {
int cpl_coord = s->cpl_coords[ch][band] << 5;
for (bin = band_start; bin < band_end; bin++) {
- s->fixed_coeffs[ch][bin] =
- MULH(s->fixed_coeffs[CPL_CH][bin] * (1 << 4), cpl_coord);
+ if (!s->bap[CPL_CH][bin]) {
+ /* A/52 s7.3.4: dither is applied after channel extraction
+ so each coupled channel gets independent dither */
+ if (s->dither_flag[ch]) {
+ int mantissa = (((av_lfg_get(&s->dith_state)>>8)*181)>>8) - 5931008;
+ mantissa >>= s->dexps[CPL_CH][bin];
+ s->fixed_coeffs[ch][bin] = MULH(mantissa * (1 << 4), cpl_coord);
+ } else {
+ s->fixed_coeffs[ch][bin] = 0;
+ }
+ } else {
+ s->fixed_coeffs[ch][bin] =
+ MULH(s->fixed_coeffs[CPL_CH][bin] * (1 << 4), cpl_coord);
+ }
}
if (ch == 2 && s->phase_flags[band]) {
for (bin = band_start; bin < band_end; bin++)
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]