Opened 15 months ago

Closed 8 days ago

Last modified 4 days ago

#11503 closed defect (fixed)

AC-3 downmix levels defaulting to 1.414 with recent decoder changes

Reported by: Wallboy Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: ac3 resampling downmix
Cc: Tim Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Wallboy)

Summary of the bug:

With the recent commits to AC-3 decoder, I've noticed the default mixing levels (when no metadata present) have changed from 0.707 to 1.414 for both clev and slev, respectively.

The ATSC A/52 spec does have these 1.414 values listed in the Alternate Bit Stream Syntax, but only for the center channel.

How to reproduce:

Run a command similar to the following on the latest master branch with a 5.1 channel AC-3 file (here using AAC codec so we get fltp sample format, so the rematrixing code doesn't normalize the mixing levels):

ffmpeg -hide_banner -loglevel debug -i someac3file -vn -c:a aac -frames:a 1 -ac 2 -f null /dev/null

Relevant debug output:

[auto_aresample_0 @ 000001c6d9787100] Mix levels: center 1.414214 - surround 1.414214 - lfe 0.000000.
[auto_aresample_0 @ 000001c6d9787100] [SWR @ 000001c6d9787fc0] Using fltp internally between filters
[auto_aresample_0 @ 000001c6d9787100] [SWR @ 000001c6d9787fc0] Matrix coefficients:
[auto_aresample_0 @ 000001c6d9787100] [SWR @ 000001c6d9787fc0] FL: FL:1.000000 FR:0.000000 FC:1.414214 LFE:0.000000 SL:1.414214 SR:0.000000
[auto_aresample_0 @ 000001c6d9787100] [SWR @ 000001c6d9787fc0] FR: FL:0.000000 FR:1.000000 FC:1.414214 LFE:0.000000 SL:0.000000 SR:1.414214

Run again on a release version of ffmpeg such as 7.1:

[auto_aresample_0 @ 00000228732b7440] [SWR @ 00000228734caf80] Matrix coefficients:
[auto_aresample_0 @ 00000228732b7440] [SWR @ 00000228734caf80] FL: FL:1.000000 FR:0.000000 FC:0.707107 LFE:0.000000 SL:0.707107 SR:0.000000
[auto_aresample_0 @ 00000228732b7440] [SWR @ 00000228734caf80] FR: FL:0.000000 FR:1.000000 FC:0.707107 LFE:0.000000 SL:0.000000 SR:0.707107

which I believe these are the expected defaults if the metadata doesn't explicitly specify otherwise.

If this change was intentional, feel free to close this ticket.


UPDATE: Furthermore, if you manually specify -clev and -slev values, they are ignored in the latest git master:

[auto_aresample_0 @ 0000026f4df79680] [debug] Setting 'slev' to value '0.707'
[auto_aresample_0 @ 0000026f4df79680] [debug] Setting 'clev' to value '0.707'
...
[auto_aresample_0 @ 0000026f4df79680] [verbose] Mix levels: center 1.414214 - surround 1.414214 - lfe 0.000000.
[auto_aresample_0 @ 0000026f4df79680] [SWR @ 0000026f4e03c900] [debug] Using fltp internally between filters
[auto_aresample_0 @ 0000026f4df79680] [SWR @ 0000026f4e03c900] [debug] Matrix coefficients:
[auto_aresample_0 @ 0000026f4df79680] [SWR @ 0000026f4e03c900] [debug] FL: FL:1.000000 FR:0.000000 FC:1.414214 LFE:0.000000 SL:1.414214 SR:0.000000 
[auto_aresample_0 @ 0000026f4df79680] [SWR @ 0000026f4e03c900] [debug] FR: FL:0.000000 FR:1.000000 FC:1.414214 LFE:0.000000 SL:0.000000 SR:1.414214 

Probably related.

Change History (8)

comment:2 by Wallboy, 15 months ago

Description: modified (diff)

comment:3 by Balling, 15 months ago

Have you checked patch above?

"when no metadata present" would not that metadata always be present when encoded with Dolby Media Encoder?

I will just point out that before another value was being ignored "Value 3 is used to signal "Dolby Pro Logic II" by some encoders."

https://github.com/FFmpeg/FFmpeg/commit/9d16c64134b1731f5aa98f9a31afa297b1193018

Was not even set https://github.com/FFmpeg/FFmpeg/commit/15b16d58df7d2372c6b7535633556e955ab97090

Last edited 15 months ago by Balling (previous) (diff)

comment:4 by Wallboy, 15 months ago

"Have you checked patch above?"

yes, it's not relevant code for rematrixing 5.1 -> 2.0.

"when no metadata present" would not that metadata always be present when encoded with Dolby Media Encoder?

The file I've been testing with is an E-AC-3 file. I should have made that clearer, sorry. In E-AC-3 there is a bit (mixmdate) that specifies if mixing levels/downmix mode is present. In my test file, there wasn't.

comment:5 by Balling, 9 days ago

This seems to be fixed now? No, I just checked the file I have has mixmdate. How do you create file without it??

Last edited 8 days ago by Balling (previous) (diff)

comment:6 by Tim, 9 days ago

Cc: Tim added

comment:7 by Balling, 8 days ago

Resolution: fixed
Status: newclosed

Okay, so ffmpeg encoder itself produces eac3 without mixmdate bit set. And it is fixed now:

Mix levels: center 0.594604 - surround 0.500000 - lfe 0.000000

spec does have these 1.414 values listed in the Alternate Bit Stream Syntax

I don't think this is valid for what ffmpeg encodes. But stereo downmix is certainly a guess game without preferred downmix.

Other samples will print e.g.:

Mix levels: center 0.840896 - surround 0.500000 - lfe 0.000000.

Manual slev and clev don't work anymore, yes.

Last edited 4 days ago by Balling (previous) (diff)

comment:8 by Balling, 5 days ago

To recreate the original behaviour in old ffmpeg you can use this:

ffmpeg -i tearsofsteel-surround.flac -c:a eac3 -b:a 748k -dmix_mode ltrt -ltrt_cmixlev 0.707 -ltrt_surmixlev 0.500 -loro_cmixlev 0.707 -loro_surmixlev 0.500 eafa.mp4

which then will decode like you want, but please note that downmix still looks different to what was in old ffmpeg. To get the same downmix (as downmix option does not respect metadata) use this: ffmpeg -drc_scale 0 -downmix stereo -i eafa1.eac3 -vn wawfa2.wav

This only changes the metadata though in eac3 bitstream, no AUDIO data or anything much really changes besides some small values for that ltrt downmix, loro downmix will not give you the same numbers...

I believe these are the expected defaults if the metadata doesn't explicitly specify otherwise.

Any file would downmix with 0.707 center in old ffmpeg, this was arguably a bug, as I can imagine clipping happens if not correctly done or something. And the default is an arguable thing, but imagine new default without mixmdate is now to use this.

Last edited 4 days ago by Balling (previous) (diff)
Note: See TracTickets for help on using tickets.