Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Is L/R to M/S a bijection (phase issue)? (Read 4662 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Is L/R to M/S a bijection (phase issue)?

There is a small point that I do not get.

To my mind, if we have L and R in phase opposition, then the S signal will be 0. In this case, we can not reconstruct the initial L/R once we passed through the M/S space.

This would means the M/S transformation can destroy phase information, and so surround (in the DPL way) information.

So, is M/S space able to preserve phase (and so surround) or no?

Comments are welcome.

Is L/R to M/S a bijection (phase issue)?

Reply #1
mp3 encoder:
  M = (L + R) / sqrt(2)
  S = (L - R) / sqrt(2)

mp3 decoder:
  L = (M + S) / sqrt(2)
  R = (M - S) / sqrt(2)

These calculations are bijective, because the equations of the decoder (L, R) are derived directly from the equations of the encoder (M, S). That means, that the Mid/Side-Stereo transformation itself is lossless.

Two examples:

input: L=1, R=1 (mono sound)
encoded: M=sqrt(2), S=0
decoded: L=1, R=1

input: L=1, R=-1 (phase inverse sound)
encoded: M=0, S=sqrt(2)
decoded: L=1, R=-1

Is L/R to M/S a bijection (phase issue)?

Reply #2
Yes, I made a mistake.
So in case of phase opposition, everything is in S (if R was negative). In compression, that might means that in this case we should not be biased toward M channel by allowing more bits to it than S.

Or perhaps detect the frequency point at which phase shift occurs and favorise M below and S upper?

Is L/R to M/S a bijection (phase issue)?

Reply #3
When there are too many things in S, I guess the encoder switches to SS mode.

Is L/R to M/S a bijection (phase issue)?

Reply #4
OK, maybe a silly question for someone who is inside this encoding/decoding thing, but why /SQRT(2)?
Why not:

mp3 encoder:
M = (L + R) / 2
S = (L - R) / 2

mp3 decoder:
L = (M + S)
R = (M - S)

Seems to me much easyer to calculate? And the information is the same.

Is L/R to M/S a bijection (phase issue)?

Reply #5
At least Lame switches to SS when L/R differ more than a given account.
So next question is: would it be possible that L and R would be considered similar enough (ie phase would not be taken into account when computing similarities) in case of phase opposition.

I think that in such case, perhaps it would be interesting to switch to MS, but favorising S channel.

Is L/R to M/S a bijection (phase issue)?

Reply #6
Quote
OK, maybe a silly question for someone who is inside this encoding/decoding thing, but why /SQRT(2)?


Well.. ask people who designed MPEG Layer III standard  AAC uses  2  instead of sqrt(2)

Regarding this side channel issue - similar problems were examined in AAC encoder implementation.  On some mono-like signals (where L and R channels have very similar energy) there was a possibility to code S scalefactor band  improperly  (AAC has advantage - it can switch from L/R to M/S per scalefactor band) - energy in side channel is very low, and quantizer just zeroes it out.  After reconstruction in decoder,  these signals have "thrill" - small "vibrato" between channels.

Is L/R to M/S a bijection (phase issue)?

Reply #7
Ivan, what would you do in a subband with phase opposition? Code in L/R, or code in M/S with emphasis on S instead of M?

In such cases, I think AAC should be easier, with ability to use LR or MS for each subband.

Is L/R to M/S a bijection (phase issue)?

Reply #8
Hmm - since M/S decision is done in energy (power spectrum) domain, all coefficients are positive - so decision module does not take phase into account.

Emphasis (bit allocation) is done by taking perceptual entropy and bit reservoir status in the account - regardless of subband type (L, R, M, S)