[MPlayer-dev-eng] [PATCH] layer2.c + gcc 3.3.1 + -fstrict-aliasing ->'underwater sound'

Henk Slager henk.slager at home.nl
Sun Dec 28 18:23:54 CET 2003


On Thursday 18 December 2003 23:29, Henk Slager wrote:
> I am using stock SuSE 9.0 32bit and 64bit on an Athlon64 platform and
> found
> out that software based on mpg123 (e.g. MPlayer-1.0pre2) compiles wrong
> if -O2 is used for the whole mpg123 0.59s package. No segfaults or so, but
> there is a strong  'underwater soundeffect', especially when the source
> has
> quite some mid-and hi frequencies.
>
> If -O1 and all extra O2 optimisations except -fstrict-aliasing is used,
> than
> it is just right. The problem originates from the file  layer2.c  and thus
> affects MPEG1/(S)VCD content. It does not occur with stock SuSE 8.2 (gcc
> 3.3
> 20030226 prerelease).

Although I could use MAD for decoding layer2 audio (e.g. as Xine does), mpg123 
is much faster (and still doesn't use all the CPU resources available) so I 
found a fix for the problem decribed earlier.

Patch for the  MPlayer-1.0pre3  package:
--- layer2.c.old        2003-01-29 11:00:40.000000000 +0100
+++ layer2.c    2003-12-28 17:44:54.367903560 +0100
@@ -16,21 +16,21 @@

 static void init_layer2(void)
 {
-  static double mulmul[27] = {
+  const double mulmul[27] = {
     0.0 , -2.0/3.0 , 2.0/3.0 ,
     2.0/7.0 , 2.0/15.0 , 2.0/31.0, 2.0/63.0 , 2.0/127.0 , 2.0/255.0 ,
     2.0/511.0 , 2.0/1023.0 , 2.0/2047.0 , 2.0/4095.0 , 2.0/8191.0 ,
     2.0/16383.0 , 2.0/32767.0 , 2.0/65535.0 ,
     -4.0/5.0 , -2.0/5.0 , 2.0/5.0, 4.0/5.0 ,
     -8.0/9.0 , -4.0/9.0 , -2.0/9.0 , 2.0/9.0 , 4.0/9.0 , 8.0/9.0 };
-  static int base[3][9] = {
+  const int base[3][9] = {
      { 1 , 0, 2 , } ,
      { 17, 18, 0 , 19, 20 , } ,
      { 21, 1, 22, 23, 0, 24, 25, 2, 26 } };
   int i,j,k,l,len;
   real *table;
-  static int tablen[3] = { 3 , 5 , 9 };
-  static int *itable,*tables[3] = { grp_3tab , grp_5tab , grp_9tab };
+  const int tablen[3] = { 3 , 5 , 9 };
+  int *itable,*tables[3] = { grp_3tab , grp_5tab , grp_9tab };

   for(i=0;i<3;i++)
   {

Patch for the  mpg123-pre0.59s  package:
--- layer2.c.old        2001-01-23 16:10:02.000000000 +0100
+++ layer2.c    2003-12-28 17:57:37.565879832 +0100
@@ -19,21 +19,21 @@

 void init_layer2(void)
 {
-  static double mulmul[27] = {
+  const double mulmul[27] = {
     0.0 , -2.0/3.0 , 2.0/3.0 ,
     2.0/7.0 , 2.0/15.0 , 2.0/31.0, 2.0/63.0 , 2.0/127.0 , 2.0/255.0 ,
     2.0/511.0 , 2.0/1023.0 , 2.0/2047.0 , 2.0/4095.0 , 2.0/8191.0 ,
     2.0/16383.0 , 2.0/32767.0 , 2.0/65535.0 ,
     -4.0/5.0 , -2.0/5.0 , 2.0/5.0, 4.0/5.0 ,
     -8.0/9.0 , -4.0/9.0 , -2.0/9.0 , 2.0/9.0 , 4.0/9.0 , 8.0/9.0 };
-  static int base[3][9] = {
+  const int base[3][9] = {
      { 1 , 0, 2 , } ,
      { 17, 18, 0 , 19, 20 , } ,
      { 21, 1, 22, 23, 0, 24, 25, 2, 26 } };
   int i,j,k,l,len;
   real *table;
-  static int tablen[3] = { 3 , 5 , 9 };
-  static int *itable,*tables[3] = { grp_3tab , grp_5tab , grp_9tab };
+  const int tablen[3] = { 3 , 5 , 9 };
+  int *itable,*tables[3] = { grp_3tab , grp_5tab , grp_9tab };
 #ifdef REAL_IS_FIXED
   const double twotothethird = pow((double)2.0, (double)1/3);
 #endif




More information about the MPlayer-dev-eng mailing list