Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 24th June 2002, 23:39   #1  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
The Dolby Surround Pro Logic II Matrix

BeSweet 1.4b7 has a plugin that can downmix DS2 audio tracks. In newer versions this downmix is built-in. But the downmix has heavy bugs, centre channel C sounds 16 dB louder than L, R! I searched the internet for the right downmix matrix but no success.
In this thread I'll explain the technics and derive the right DS2 downmix matrix parameters. Basics of Dolby Pro Logic are published on http://www.dolby.com

Dolby Surround Pro Logic II (DS2)
Quote:
Dolby:
In Pro Logic decoders the control circuit is looking at the relative level and phase between the input signals. This information is sent to the variable output matrix stage to adjust VCAs (voltage controlled amplifiers) controlling the level of antiphase signals. This is called a feed-forward system.
Pro Logic II looks at the same input signals and servos them to match their levels. These matched audio signals are sent directly to the matrix stages to derive the various output channels. Because the same audio signals that feed the output matrix are themselves used to control the servo loop, it is called a feedback-design.
Dolby says that DS2 is compliant to Pro Logic. The encoding matrix is simpler, the decoder has significant improvements.

Downmix matrix
In Pro Logic the rear channels Ls, Rs are stored as ONE mono surround signal S with symmetrical amounts into the stereo wave. In DS2 the rears Ls, Rs are stored with DIFFERENT amount of levels. That's the trick! The new feedback-design allows to steer the gain of Ls, Rs.

Pro Logic
Code:
Lt = 1.0*L + 0.707*C - 0.707*Ls - 0.707*Rs  left-total
Rt = 1.0*R + 0.707*C + 0.707*Ls + 0.707*Rs  right-total
The level amounts are stored symmetrically into the wav (Lt, Rt).

Pro Logic II
We set the amount of acoustic power of Rs in Lt equal to the half of Ls. Or, Rs has a level of -3 dB referred to Ls. Same to Ls in Rt. The total power sum of each channel L, R, C, Ls, Rs equals 1.
For acoustic power we must square!

a*a*Ls*Ls + 2*a*a*Rs*Rs = 1
max levels = 1
a*a + 2*a*a = 1
--> a*a = 1/3 = 0.3333 --> a = 0.5774
--> 2*a*a = 2/3 = 0.6666 = b*b --> b = 0.8165
Code:
Lt = 1.0*L + 0.707*C - 0.8165*Ls - 0.5774*Rs
Rt = 1.0*R + 0.707*C + 0.5774*Ls + 0.8165*Rs
Now it's possible to generate a rear directional steering signal with an operational amplifier, computing Lt+Rt but eliminating L, R, C. The output
(Lt+Rt)' = 0.2391*(Rs - Ls)
is fed to a polarity splitter which will control Ls, Rs outputs.
If amount of Rs < Ls then output will be negative for left directional dominance, and if Rs > Ls the output will be positive for right directional dominance.
So far to the principle of operation, in reality the Pro Logic II decoder is much more complicated.

The actual coefficients used must be scaled downwards to prevent arithmetic overflow.
The sum of unscaled coefficients is
1 + 0.707 + 0.8165 + 0.5774 = 3.101
All coefficients must be multiplied by 1/3.101 = 0.3225
Downwards scaling by -9.8 dB.

That means the DS2 downmix has an attenuation of -9.8 dB.
The probability of overflow is very small. You should start a 1-step decoding with a static gain of +9.8 dB. The resulting dialog level will be unchanged in this case.

Important: For downmix you ever have to use DRC because more acoustic power will be concentrated in less channels!

Pro Logic II with LFE (Not recommended by Dolby)
Code:
Lt = 1.0*L + 0.707*C + 0.707*LFE - 0.8165*Ls - 0.5774*Rs
Rt = 1.0*R + 0.707*C + 0.707*LFE + 0.5774*Ls + 0.8165*Rs
All coefficients must be multiplied by 1/3.808 = 0.2626
Downwards scaling by -11.6 dB.

Because of the small overflow probability and low LFE level it is sufficient to work with -9.8 dB scaling from above.

Last edited by frank; 2nd July 2002 at 16:58.
frank is offline   Reply With Quote
Old 25th June 2002, 00:49   #2  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
Compiling BeSweet Plugin - Help wanted

Here comes the corrected DS2 BeeSweet plugin.
Please help compile, I don't have MS C++.
With Besweet 1.4b7 you can test the plugin. The following BeeSweet versions until b11 include the buggy version.

Debugged source BS_downmix.c from DSPGuru in the next thread.

Corrected downmix matrix:
Code:
{ // l,c,r,sl,sr,lfe
		buffer[j]   =buffer[i++]* 0.3225;    	// fl.	-> l.   
		buffer[j]  +=buffer[i]  * 0.2280;    	// c.	-3db -> l.
		buffer[j+1] =buffer[i++]* 0.2280;    	// c.	-3dB -> r.
		buffer[j+1]+=buffer[i++]* 0.3225;    	// fr.	-> r.
		buffer[j]  +=buffer[i]  *-0.2633;	// sl	-1.76dB -> l.
		buffer[j+1]+=buffer[i++]* 0.1862;	// sl	-4.77dB -> r.
		buffer[j]  +=buffer[i]  *-0.1862;	// sr	-4.77dB	-> l.
		buffer[j+1]+=buffer[i++]* 0.2633;	// sr	-1.76dB -> r.

Last edited by frank; 25th June 2002 at 01:15.
frank is offline   Reply With Quote
Old 25th June 2002, 01:09   #3  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
BS_Downmix Attachment

Here the debugged source to compile.

Last edited by frank; 25th June 2002 at 01:16.
frank is offline   Reply With Quote
Old 25th June 2002, 04:55   #4  |  Link
DSPguru
BeSweet Author
 
DSPguru's Avatar
 
Join Date: Oct 2001
Location: On top of a supercompact cardinal
Posts: 3,506
frank's matrix had been integrated into beta12.
didn't debug it.

post your comments.
DSPguru is offline   Reply With Quote
Old 25th June 2002, 11:12   #5  |  Link
trg100
Registered User
 
Join Date: Oct 2001
Location: England
Posts: 19
Brilliant work frank It works great now. I had a quick look at the source myself but it would've taken me ages to figure it all out. Thanks.

For completeness' sake here is a shot of my test file downmixed with your new matrix. (It is zoomed not normalised )

I have written to cyberlink asking why DS2 encoded wav/mp3 files don't work in PoerDVD but AC3 files do. Am not holding my breath though!
trg100 is offline   Reply With Quote
Old 25th June 2002, 13:26   #6  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
Thanks for the quick help DSPGuru, trg100. I'm very pleased.

trg100,
your tests show an issue on BeSweet's LFE level.
I'm missing the -3 dB attenuation to each track. The LFE level must be equal to the centre. Did you set Azid's LFE downmix parameters right? (-3db into L,R)
Or, is there another issue in BeSweet? BeSweet does the LFE downmix prior the matrix.
Please verify.

Last edited by frank; 25th June 2002 at 13:36.
frank is offline   Reply With Quote
Old 25th June 2002, 14:10   #7  |  Link
trg100
Registered User
 
Join Date: Oct 2001
Location: England
Posts: 19
Ooops

You're quite right frank. I had specified -L 0db. I had rerun the test with -L -3db and updated the picture. The LFE channel is now equal in voume to the centre channel

To be honest I wasn't exactly sure why the -3db was necessary but I notice HeadAC3he does it automatically.

I've added another picture (8) which shows that the transitions are not perfectly smooth. I wonder if this is due to the Dolby Digital compression.
trg100 is offline   Reply With Quote
Old 25th June 2002, 15:21   #8  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
Yeah! Now I can sleep well.
The constant signal power for all reproduced channels is maintained now.

C and LFE are splitted in two parts with half of the power. Means -3 db level attenuation if you don't want any power change. The decoder sums the two parts back into ONE channel!

LFE is a small bandwith low bass channel. Greater signal raising time and delaying. I think these artifacts come from Dolby compression and aren't audible at this low frequencies.

For downmixing is no need to mix the LFE if the AC-3 tracks are right mastered - Dolby says. 5ch into 2ch mix is a consumer adaption. And which consumer has a separated active subwoofer (30 cm loudspeakers)? Very expensive technics, needed by THX systems only. But this HiFi fans normally use 5.1 audio.

Last edited by frank; 26th June 2002 at 09:37.
frank is offline   Reply With Quote
Old 26th June 2002, 14:24   #9  |  Link
kxy
Registered User
 
Join Date: Oct 2001
Posts: 343
trg100,

Your picture #4 and #7 are identical, at least I dont see a difference. Does it mean HeadAC3he and BeSweet now produces the identical ds2 downmix?
kxy is offline   Reply With Quote
Old 26th June 2002, 17:46   #10  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
In principle YES.


Here a DS2 file to test the surround channels (speaking voice).
frank is offline   Reply With Quote
Old 27th June 2002, 07:05   #11  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
v1.4b12: DS2 has more attenuation

I compared transcoding to WAVs (no floating point).

1) DS2 downmix is fully compliant to DS . Sounds equal on my DS receiver if the rear filter was disabled on DS (less muffled sound in the rears).

2) Now DS2 downmix has additional -4...-5 dB attenuation compared with DS and old versions!
I've tested with +11.7 dB static gain to DS and 9.8 dB to DS2. There should be same results.
I think that comes from Azid's different operating modes (2/0 vs. 3/2) and the implementation in BeSweet.
More tests are running to this issue.

Regards
frank
frank is offline   Reply With Quote
Old 27th June 2002, 23:11   #12  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
Test results

Latest test results of transcoding AC-3 5.1 49 min
-27 dB dialog level, DRC normal

Gain to maintain dialog level
(compensation of downmix attenuation)

BeSweet 1.4B12
DS +11.7 dB
DS2 +14.5 dB (6+8.5, LFE included )

headAC3he
+10 dB

Last edited by frank; 5th July 2002 at 12:10.
frank is offline   Reply With Quote
Old 28th June 2002, 08:56   #13  |  Link
DSPguru
BeSweet Author
 
DSPguru's Avatar
 
Join Date: Oct 2001
Location: On top of a supercompact cardinal
Posts: 3,506
Re: Test results

Quote:
Originally posted by frank
BeSweet 1.4B12
DS +11.7 dB
DS2 +14.5 dB (6+8.5)
good work frank! please post logfiles.
DSPguru is offline   Reply With Quote
Old 28th June 2002, 09:08   #14  |  Link
fiorettoe
Registered User
 
Join Date: Feb 2002
Posts: 35
Frank, I had tried to play your mp3 file with PowerDVD4 (with Dolby Pro Logic2 enabled).

It works, I hear the sound in the rear speakers.
But how can I play the same file in DS2 in OGG format? PowerDVD4 doesn't accept OGG file format.
fiorettoe is offline   Reply With Quote
Old 28th June 2002, 09:53   #15  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
Convert mp3 with WinAmp's Diskwriter into WAVs, and encode what ever you want.
frank is offline   Reply With Quote
Old 28th June 2002, 10:03   #16  |  Link
fiorettoe
Registered User
 
Join Date: Feb 2002
Posts: 35
If I open a OGG file with PowerDVD4 doesn't work....why???
fiorettoe is offline   Reply With Quote
Old 28th June 2002, 10:12   #17  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
Hey, since when is OGG a DVD/VCD/SVCD/AUDIO standard??
PowerDVD knows: PCM, AC3, mp2, DTS...
frank is offline   Reply With Quote
Old 28th June 2002, 10:19   #18  |  Link
fiorettoe
Registered User
 
Join Date: Feb 2002
Posts: 35
So which player must I use for OGG?

If I use Windows Media Player, it doesn't support the multi-speaker.
fiorettoe is offline   Reply With Quote
Old 29th June 2002, 09:05   #19  |  Link
frank
Registered User
 
Join Date: Oct 2001
Location: Germany
Posts: 743
Final DS2 test results

Quote:
Compensation of downmix attenuation
BeSweet 1.4B12

DS +11.7 dB
DS2 +14.5 dB (6+8.5)
Sorry, no log file
But the commandline I used at DS2 was

"d:\DVD\AudioTools\BeSweet\BeSweet.exe"
-core( -input "i:\test\kiss1 AC3 T01 3_2ch 448Kbps DELAY 0ms.ac3"
-output "i:\test\test-ds2.wav" -2ch )
-azid( -s surround2 -c normal -g 6db -L -3db )
-ota( -g 8.5db )
-ssrc( --rate 44100 )

The tests included LFE.

Following tests without splitted gain and without LFE brought the expected results.
LFE ( -L -3 dB ) reduced the sound level about -4.4 dB!! That's wrong, in Azid's 2/0 downmix matrix that reduction is only -1.78 dB.

DS2 +10 dB setting as ota gain compensates the matrix attenuation (equal to the theory). Same results as headAC3he.
...
-output "i:\test\test-ds2.wav" -2ch )
-azid( -s surround2 -c normal ) <<<<< or -L 0 (not 0db!)
-ota( -g 10db )
...

BeSweet has ~6dB lower bit noise at lowest sound levels than headAC3he. Measured with CEpro2.

Last edited by frank; 29th June 2002 at 19:12.
frank is offline   Reply With Quote
Old 30th June 2002, 16:21   #20  |  Link
trg100
Registered User
 
Join Date: Oct 2001
Location: England
Posts: 19
fiorettoe: What sounds card/speaker setup are you using to play back frank's file? Does the DS2 channel mapping works correctly with powerDVD? On my 4 channel SBlive it is messed up unless I reencode to a 2.0 AC3. PowerDVD and WinDVD 4 are the only payers with DPL2 I know of so there's nothing that can playback DS2 oggs as far as I know.
trg100 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:43.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.