Bug 115135

Summary: libvorbis is miscompiled
Product: [openSUSE] SUSE LINUX 10.0 Reporter: Andreas Jaeger <aj>
Component: BasesystemAssignee: Richard Biener <rguenther>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: andreas.w.simon, foren
Version: Beta 4   
Target Milestone: ---   
Hardware: Other   
OS: All   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: updated type-punning patch
Patch committed to libvorbis SVN to fix this issue

Description Andreas Jaeger 2005-09-03 14:00:17 UTC
On betta4 with the beta4_libvorbis:
oggen -q4 ***.wav
-rw-r--r--  1 michael users  5940599 2005-09-02 19:59 ***.ogg
The sound quality is NOT ok.(it is really terrible)

On betta4 with the suse9.3_libvorbis:
(rpm -Uvh --force libvorbis... )
oggen -q4 ....wav
-rw-r--r--  1 michael users  4182508 2005-09-02 20:10 ***.ogg
The sound quality is ok!

On betta4 with the suse9.3_libvorbis (rebuild whit gcc 4)
oggen -q4 ....wav
-rw-r--r--  1 michael users  5986931 2005-09-02 20:25 ***.ogg
The sound quality ist NOT ok

The same libvorbis version (suse9.3_libvorbis) makes different files ?!

this is also shown in the following two reports:
http://bugzilla.ubuntu.com/show_bug.cgi?id=12722
http://trac.xiph.org/cgi-bin/trac.cgi/ticket/583

The reports suggest to use -fno-strict-aliasing.  I'll test this now.

Michael, any ideas?

I've put packages for testing at: ftp://ftp.suse.com/pub/people/aj/libogg/ and
would like to get feedback whether this fixes the problem.
Comment 1 Andreas Jaeger 2005-09-03 14:02:26 UTC
Btw. the description came in via the opensuse mailing list.
Comment 2 Michael Lange 2005-09-04 02:39:57 UTC
>I've put packages for testing at: ftp://ftp.suse.com/pub/people/aj/libogg/ and
would like to get feedback whether this fixes the problem.
-----
I think libogg is not the problem.
i have rebuild libvorbis with -fno-strict-aliasing and i think it is ok.

-rw-r--r--  1 michael users  4061 2005-09-04 04:08
libvorbis_beta4_-fno-strict-aliasing.ogg
-rw-r--r--  1 michael users  4085 2005-09-04 04:18 libvorbis_suse93.ogg

The sound quality is now (with -fno-strict-aliasing) ok and i think the file
size different is no problem.(imho different source ?)

mfg




But the file size is still different. 
Comment 3 Michael Lange 2005-09-04 03:14:39 UTC
^^^ Forget the last line. ;)
Comment 4 Andreas Jaeger 2005-09-04 04:46:34 UTC
I didn't know that we have both libogg and libvorbis.  Argh.

Ok, will build libvorbis now.
Comment 5 Andreas Jaeger 2005-09-04 04:58:40 UTC
ftp://ftp.suse.com/pub/people/aj/libvorbis contains new packages.  Could you
test them as well, please?

Thanks!
Comment 6 Andreas Simon 2005-09-04 09:30:31 UTC
I made some tests. The recompiled libogg from above didn't changed anything .

With the recompiled libvorbis from comment #5:

I get much smaller ogg files than with the libvorbis from beta4. They are still
bigger than with SUSE 9.3's libvorbis, but only by less than 1%. Thus I would
say the size problem is fixed.

Sound quality seems fine with me too, but I have neither golden Ears nor super
high quality sound equipment.
Comment 7 Andreas Jaeger 2005-09-04 12:50:07 UTC
Ok, libvorbis has been submitted for RC1 now, so we've workarounded the issue.

Michael, I would appreciate if somebody in the GCC time could look into this.
Comment 8 Richard Biener 2005-09-05 07:56:10 UTC
This will be PITA to reduce, but I'll try.  Someone can hand me some
earphones/speakers or a .wav + good + bad ogg file?

Thx.
Comment 9 Michael Lange 2005-09-05 08:58:41 UTC
>Someone can hand me some earphones/speakers or a .wav + good + bad ogg file?
---
Good joke, look:

libvorbis-1.1.0-7 (-fno-strict-aliasing)

-rw-r--r--  1 michael users 17757644 2005-09-04 17:44 she_is_a_diamond.wav
oggenc -q4 

gcc331.ogg--Total data length: 1553565 bytes--Average bitrate: 123,462119 kbps
gcc335.ogg--Total data length: 1553559 bytes--Average bitrate: 123,461642 kbps
gcc402.ogg--Total data length: 1553586 bytes--Average bitrate: 123,463788 kbps

What is good and what is bad? ;)

I think, the libvorbis with -fno-strict-aliasing is ok -for now.

mfg
Comment 10 Andreas Jaeger 2005-09-05 09:26:06 UTC
Michael, the issue is workarounded for RC1.  But we'd like to fix the real bug.
Comment 11 Andreas Simon 2005-09-05 09:45:52 UTC
If there is no crackling or loud noice etc., judging the sound quality is a  
highly subjective thing.  
       
I for example was not able to hear any difference in my few tests (I used some 
classic music, maybe it is triggered only with electric guitar sounds or 
something like that, who knows).  
  
Thus I think the main issue here is to watch the size of the resulting files.  
Like in the bug description 5940599 bytes instead of 4182508 is a big 
difference. I doesn't matter if it's 4.0 or 4.1 MB but if it's nearly 6MB, 
than there's something wrong. And this is fairly easy to reproduce. Just get 
some wave of 20MB or more and oggenc' it. 
Comment 12 Michael Lange 2005-09-05 09:49:33 UTC
(In reply to comment #6)
> I get much smaller ogg files than with the libvorbis from beta4. They are still
> bigger than with SUSE 9.3's libvorbis, but only by less than 1%. Thus I would
> say the size problem is fixed.

The libvorbis of betta4 and suse 9,3 are not comparable.
libvorbis SuSE9.3 = aoTuV b3 [20041120]
libvorbis betta4 = aoTuV b4 [20050617]

mfg
Comment 13 Richard Biener 2005-09-05 09:54:40 UTC
Created attachment 48763 [details]
updated type-punning patch

I was not able to reproduce the file-size difference, and encoded files differ
even with different runs of the
same executable as follows:

/tmp/mozart.bad.ogg /tmp/mozart.fixed.ogg differ: byte 15, line 1

(oggenc --serial=0 -q4)

Nevertheless, two potential bugs fixed in scales.c
with the updated type-punning patch (untested, no audio, but produces same size
files).  The difference
with -O3 the Xiph report saw can be explained by some
of the functions being only static but not static inline.
Comment 14 Michael Lange 2005-09-05 10:47:48 UTC
(In reply to comment #13)
/tmp/mozart.bad.ogg /tmp/mozart.fixed.ogg differ: byte 15, line 1
---
Yes, but this is no problem if the sound is the same. And the sound is the same!

oggenc -q4 she_is_a_diamond.wav -o she_is_a_diamond-run1.ogg
oggenc -q4 she_is_a_diamond.wav -o she_is_a_diamond-run2.ogg
oggenc -q4 she_is_a_diamond.wav -o she_is_a_diamond-run3.ogg
^^ all the same libvorbis and gcc

ogginfo *.ogg | grep "Total data length"
        Total data length: 1553586 bytes
        Total data length: 1553586 bytes
        Total data length: 1553586 bytes
ogginfo *.ogg | grep "Average bitrate:"
        Average bitrate: 123,463788 kbps
        Average bitrate: 123,463788 kbps
        Average bitrate: 123,463788 kbps

mfg

Comment 15 Michael Smith 2005-09-05 11:09:39 UTC
Created attachment 48777 [details]
Patch committed to libvorbis SVN to fix this issue
Comment 16 Michael Smith 2005-09-05 11:13:07 UTC
Thanks to Richard Guenther, we have a fix for the problem (which is indeed in
libvorbis).

I've attached a patch I just committed to libvorbis SVN (I'd expect it to apply
cleanly to the most recent release, if you prefer that).

Richard: the reason you were getting different files is that oggenc chooses a
random serial number for each encode. A bug (fixed in svn about a month ago) in
oggenc meant that choosing a fixed serial number of zero didn't work (any other
number did). Sorry about that.

Comment 17 Michael Lange 2005-09-06 00:09:53 UTC
Hmm.
Is the problem really fixed? If yes, which file is then the correct?

libvorbis_gcc335_Richard.ogg--Total data length: 1553559 bytes--Average bitrate:
123,461642 kbps
libvorbis_gcc402_Richard.ogg--Total data length: 1553613 bytes--Average bitrate:
123,465934 kbps

mfg
Comment 18 Richard Biener 2005-09-06 08:20:54 UTC
You cannot easily compare gcc-3.3.5 and gcc-4.0.2 output because
 1. you are using FP math on a x86 machine
 2. you are using -ffast-math for compilation

If you really want to compare them (and still then it's not a correct
comparison) at least avoid excess precision by using -mfpmath=sse and
don't use -ffast-math.

If both files are a reasonable encoding of the file wrt quality and filesize
then the bug is fixed (and may have been never there, as I really could not
reproduce the bug with my two sample input .wav files).  Still the "fix" is
correct and needed, but maybe for a totally different reason.

Richard.
Comment 19 Michael Lange 2005-09-06 15:17:47 UTC
It was not my intention to discredit your patch.
The patch works fine and does what it is to do.

A simple make should come to a same result. 
Everything else is badly and a mistake.

Ok, this is no topic for the openSUSE bugzilla.  

eot for me
mfg
Comment 20 Richard Biener 2005-09-29 15:07:47 UTC
"The patch works fine and does what it is to do." and no more input suggests
that this is fixed (upstream at least).  Packager/reporter, can you confirm
this was fixed for 10.0?
Comment 21 Andreas Jaeger 2005-09-29 15:32:59 UTC
Let's assume it's fixed.