Opened 10 years ago

Closed 9 years ago

#1792 closed defect (wontfix)

libswresample mono to stereo conversion is lowering the amplitude

Reported by: Albert Zeyer Owned by: Michael Niedermayer
Priority: normal Component: swresample
Version: git-master Keywords: regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I am resampling sound data with libswresample. I have one sample case where I resample

44100Hz, sint16, mono

to

44100Hz, sint16, stereo.

I.e. this is just a mono to stereo conversion.

I was expecting that

leftSample = rightSample = monoSample;

However, I was more getting something mostly like:

leftSample = rightSample = monoSample / 1.41;
(maybe 1.41 ~= sqrt(2) ?)

Is this a bug? Or expected? I don't have profesional audio background but I heard that a normal mono to stereo conversion is as what I would expect. I also have seen many different implementations where it is done like this, e.g. the main ReplayGain implementation.

Change History (10)

comment:1 by Elon Musk, 9 years ago

Resolution: invalid
Status: newclosed

This is not place to ask questions.

comment:2 by Albert Zeyer, 9 years ago

Resolution: invalid
Status: closedreopened

It was not simply a question. Either this is expected, then it maybe should be documented somehow. Or it is not expected, then it is a bug.

comment:3 by Elon Musk, 9 years ago

It is expected, if you want different behavior use pan filter.

comment:4 by Carl Eugen Hoyos, 9 years ago

SoX behaves differently: sox mono.wav -c 2 stereo.wav does not change the loudness.

comment:5 by Hendrik, 9 years ago

When you output one channel to two speakers, the perceived loudness increases and swresample compensates for this by reducing the loudness of the channels accordingly, so that the perceived loudness does not change.

This behavior is expected.

comment:6 by Albert Zeyer, 9 years ago

I think when you send a mono-signal to the sound driver, it just uses the same signal for both channels. That is different from what FFmpeg does.

comment:7 by Elon Musk, 9 years ago

If you want custom conversion use audio filters, or send patch for swresample.

This ticket is neither bug report or feature request.

comment:8 by Albert Zeyer, 9 years ago

But when the behavior is supposed to be different, it is a bug.

Or it is a bug that this is the default behavior. (Because the default is normally something else.)

comment:9 by Elon Musk, 9 years ago

Its not a bug. Its expected normal and default behavior.

comment:10 by Carl Eugen Hoyos, 9 years ago

Keywords: regression added
Reproduced by developer: set
Resolution: wontfix
Status: reopenedclosed
Version: unspecifiedgit-master

The new behaviour is reproducible since release 0.9, apart from what Hendrik wrote above I believe there are two additional good reasons why it should not be changed again:
$ ffmpeg -i mono.wav -channel_layout 7.0 out.wav would produce surprising output if we copy sox's behaviour (upmixing to more than two channels did not work before 0.9)
The behaviour you want can easily be achieved using the pan filter.

Note: See TracTickets for help on using tickets.