(2017-02-13, 12:51)noggin Wrote: Looking at the ffmpeg documentation it IS possible to flag the presence of matrixed surround in a Dolby Digital bitstream produced by ffmpeg - so a) above might be possible?
Quote:-dsur_mode mode
Dolby Surround Mode. Specifies whether the stereo signal uses Dolby Surround (Pro Logic). This field will only be written to the bitstream if the audio stream is stereo. Using this option does NOT mean the encoder will actually apply Dolby Surround processing.
0
notindicated
Not Indicated (default)
1
off
Not Dolby Surround Encoded
2
on
Dolby Surround Encoded
So I guess in an ideal situation - IF you have transcode to Dolby Digital enabled, AND there is Matrix Surround content flagged on the source 2.0 audio (either in AC3 or AAC metadata) then this flag should be enabled on the Dolby Digital encode process used in Kodi?
Actually it needs to do more than this. By default DD and AAC 2.0 audio will be decoded to PCM 2.0 (as in theory that is the best quality solution for a SPDIF connection, as a secondary encode to DD will introduce new artefacts for no obvious reason) HOWEVER - if the 2.0 audio is matrix surround encoded - then transcoding to Dolby Digital (if you can't preserve the bitstream) and preserving the d_surr type metadata DOES have a purpose.
For quite a while broadcasters weren't correctly flagging Dolby Surround content (i.e. movies and TV shows that were either made before Dolby Digital was widespread, or that have had a mix-down from Dolby Digital 5.1 to a stereo 2.0 signal with matrix surround encoding rather than mono compatibility encoding) or were using audio codecs that didn't really preserve the phase information required for a decent ProLogic decode (low bitrate MP2 probably didn't do much for it...)
However if broadcasters ARE now correctly flagging 2.0 Dolby/Matrix Surround content in their AAC or AC3 streams it would be great if Kodi could cope with this use case in both transcode and decode terms.
I guess and ideal world would be :
If AAC or AC3 source audio is flagged as 2.0 Dolby/Matrix Surround encoded, not just plain stereo 2.0, then :
a) If Dolby Transcode is enabled, then don't output as PCM 2,0, instead re-encode to Dolby BUT preserve the D_Surr Metadata (ideally preserve all metadata from Dolby and all that can be remapped from AAC?) and pass that to the Dolby encoder? (This would then output DD 2.0 with the correct metadata for off-board decoding)
b) If Channels > 2.0 then PCM decode the Matrix Surround to a suitable surround format (Stereo + single rear, Stereo + 2 rears, Stereo + centre + 2 rears etc.)
a) requires that there is a way of passing metadata from decoder to encoder (which you'd hope would be there for 5.1 use cases - where DTS, DTS HD, E-AC3, 5.1 AAC etc. are decoded and re-encoded to Dolby 5.1?)
b) requires that there is a decent implementation of a 2.0 Dolby Surround to multichannel PCM decoder, presumably within ffmpeg. I don't know if this is the case. I had a quick look through MythTVs documentation - as in the past there have been reports that it has had better handling of Matrix Surround 2.0 content (as there is a LOT of it around in Live TV - particularly on stations that don't do DD/AAC 5.1 and only send 2.0) but couldn't see anything other than an 'upmix to 5.1' option (which may be it)