[MPlayer-dev-eng] [PATCH] Automatic downmix

Clément Bœsch ubitux at gmail.com
Sun Sep 26 10:27:05 CEST 2010


On Fri, Sep 24, 2010 at 08:33:06PM +0200, Tobias Diedrich wrote:
> Clément Bœsch wrote:
> > On Thu, Sep 23, 2010 at 03:03:31PM +0200, Clément Bœsch wrote:
> > > > For example:
> > > > 
> > > > 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
> > > > 
> > > 
> > > That sure could be used for one case. I'm going to test those values, and
> > > see if I can adapt them to all the other input channels case.
> > > 
> > 
> > Well, I just did try those values, and I'm not really enthusiastic about
> > the actual result (RL and RR are mixed and have a weird sound, I get
> > saturation in some cases, etc.).
> 
> Did you try the adjusted matrix, where everything adds up to 1? That
> one shoulnd't have saturation.
> RL+RR will have weird sound because it's dolby encoded, so you'd
> need to put it into a dolby decoder to get the rear channels back.
> 
> I'm not proposing to have this as default, but optional because it
> makes sense to have this option for people with an old dolby
> surround amplifier.
> 

Well then it may belong to another patch; downmix codecs builtin don't
seem to behave like that.

> For normal non-dolby stereo this would make more sense:
> Lt = 1.0*L + 0.707*C + 0.707*LFE + 1.0*Ls
> Rt = 1.0*R + 0.707*C + 0.707*LFE + 1.0*Rs
> 
> Normalized to add up to 1.0:
> Lt = .2929*L + .207*C + .207*LFE + .2929*Ls
> Rt = .2929*R + .207*C + .207*LFE + .2929*Rs
> 

I agree, those normalized values seem good.

> For best usability I'd imagine having a 'downmix' filter where you
> can just specify the unnormalized 5.1 downmix matrix would be great
> I think.
> i.e. "-af downmix=1.0:1.0:0.707:0.707:1.0:1.0" (downmix=L:R:C:LFE:Ls:Rs)
> and the filter would normalize to a sum of 1.0 internally.
> 

Won't be so hard to do, but once again, another patch I think (it's
already hard to get one accepted so… maybe later :))

> Oh, and this links explains where the .707 for C and LFE is coming from:
> http://ac3filter.net/guides/mixing_matrix
> 
> "We should hear the center channel from between of left and right
> channels. To do this we should route equal amount of the center
> channel to the left and to the right. But if we mix the center to
> both front channels it will be louder than just one original center
> channel! Therefore we should attenuate it. It's why the value of 0.7
> is in the mixing matrix"
> 
> "Why 0.7 and not 0.5 (twice quieter)? No, it's not a bug. Loudness
> is not summed as usual. We must sum the *power* of the signal.
> Simply talking, we must sum squared amplitudes"
> 
> Or in electrical engineering terms:
> The sampled waveform records the voltage.
> If we halve the voltage we also halve the current and thus get only
> one quarter of the power output.
> 
> But we want to distribute the power output of one center speaker
> onto the left and right channels, so each should get half of the
> power output, not just one quarter.
> 
> So we need to multiply by 1/sqrt(2) instead of 1/2.
> 

Ok I think I get it. So do those values seem fine to you? :

3 input channels
1.0000:0.0000  0.0000:1.0000  0.7070:0.7070
0.5858:0.0000  0.0000:0.5858  0.4142:0.4142

4 input channels
1.0000:0.0000  0.0000:1.0000  1.0000:0.0000  0.0000:1.0000
0.5000:0.0000  0.0000:0.5000  0.5000:0.0000  0.0000:0.5000

5 input channels
1.0000:0.0000  0.0000:1.0000  1.0000:0.0000  0.0000:1.0000  0.7070:0.7070
0.3694:0.0000  0.0000:0.3694  0.3694:0.0000  0.0000:0.3694  0.2612:0.2612

6 input channels
1.0000:0.0000  0.0000:1.0000  1.0000:0.0000  0.0000:1.0000  0.7070:0.7070  0.7070:0.7070
0.2929:0.0000  0.0000:0.2929  0.2929:0.0000  0.0000:0.2929  0.2071:0.2071  0.2071:0.2071

7 input channels
1.0000:0.0000  0.0000:1.0000  1.0000:0.0000  0.0000:1.0000  0.7070:0.7070  1.0000:0.0000  0.0000:1.0000
0.2698:0.0000  0.0000:0.2698  0.2698:0.0000  0.0000:0.2698  0.1907:0.1907  0.2698:0.0000  0.0000:0.2698

8 input channels
1.0000:0.0000  0.0000:1.0000  1.0000:0.0000  0.0000:1.0000  0.7070:0.7070  0.7070:0.7070  1.0000:0.0000  0.0000:1.0000
0.2266:0.0000  0.0000:0.2266  0.2266:0.0000  0.0000:0.2266  0.1602:0.1602  0.1602:0.1602  0.2266:0.0000  0.0000:0.2266

I generate them with the script attached. I just did it in a few minutes
so it's a bit naive, but values seem ok. If it's fine with you, I update
the patch.

Thanks for the review,

Regards,

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dmix.py
Type: text/x-python
Size: 1007 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20100926/c176747a/attachment.py>


More information about the MPlayer-dev-eng mailing list