[MPlayer-users] bug in audio resample code - not calling clip()

mplayer at tonyRobinson.com mplayer at tonyRobinson.com
Thu Jan 19 18:54:57 CET 2006


The audio resampling code has a bad bug whereby clipping isn't performed
properly (probably because an intermediate value is stored in an int16_t
and so overflow isn't detected).

More detail:

I'm using the CVS build via http://rpm.greysector.net which identifies
itself as:

MPlayer dev-Fedora-GS-CVS-051128-12:25-4.0.1 (C) 2000-2005 MPlayer Team

I have a saturated wmv file from which I am extracting the audio like so:

unix$ mplayer -vo null -vc null -ao pcm:file=tmp.wav tmp.wmv

All is well and good until I try to resample on output:

unix$ mplayer -vo null -vc null -ao pcm:file=tmp.wav -af format=s16le,channels=1,resample=16000:0:2 tmp16.wmv

Now the saturated sections sound really crappy, some samples just wrap
around, so if the value was just smaller than -32768 to becomes very
large and if just larger than 32767 it becomes very small.  Here's an
example of the output, the 4th sample in the middle line should have
been thresholded to -32768 but instead it has wrapped to 32682.

unix$: od -i tmp16.wav

0124640  12346  16373  20678  22063  21900  23751  25914  29666
0124660  32348  26396  15695  15901  14977  10416  -6392 -20418
0124700 -20371 -25761 -32003  32682 -32764 -32766  32498 -28444
0124720 -14496  -6723  -2997  -2003   8648  18561  24677  26113
0124740  20633  20948  22690  20785  19837  14354  11278   5237

It's an easy bug to let in, I've done it myself lots of times.  I've had
a look at resample[2].c but can't find the right bit of code so I'm
hoping someone else will know it well enough to squash this bug.


Tony Robinson




More information about the MPlayer-users mailing list