I think there is a bug in scale_bitcount_lsf :

    for ( over = 0, partition = 0; partition < 4; partition++ )
    {
         if ( max_sfac[partition] > max_sfac_tab[table_number][partition] )
             over++;
    }

max_sfac_tab gives the length in bits of the maximum scale factor
value(according to ISO13818-3, 2.4.3.2, p.17-18) :
static unsigned max_sfac_tab[6][4] =
{
    {4, 4, 3, 3},
    {4, 4, 3, 0},
    {3, 2, 0, 0},
    {4, 5, 5, 0},
    {3, 3, 3, 0},
    {2, 2, 0, 0}
};

In fact max_sfac should be compared with the range of values for the scale
factor band :
    for ( over = 0, partition = 0; partition < 4; partition++ )
    {
      if (max_sfac[partition] > max_range_sfac_tab[table_number][partition])
         over++;
    }

with

static unsigned max_range_sfac_tab[6][4] =
{
 { 15, 15, 7,  7},
 { 15, 15, 7,  0},
 { 7,  3,  0,  0},
 { 15, 31, 31, 0},
 { 7,  7,  7,  0},
 { 3,  3,  0,  0}
};

and then you have the slen with

 for ( partition = 0; partition < 4; partition++ )
     cod_info->slen[partition] = max_sfac_tab[table_number][partition];

It gives more choice for selecting the scale factor in MPEG2.


Lionel
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

Reply via email to