I am trying to use madplay (ver 0.14.2b) to decode a layer II bitstream (generated by toolame - http://sourceforge.net/projects/toolame). I get an occasional error message: bad scalefactor index
After a little poking around, I see that libmad/layer12.c generates this message around line 172, when it reads a scalefactor index of 63.
This appears to be an ambiguity in the spec: as far as I can see, 11172-3 just says to use the 6-bit scalefactor as an index into table B.1, but B.1 is only defined for 0-62.
Toolame appears to add an extra entry to B.1 that maps 63 to 0.0, and mpg123 seems to do the same thing. Is there any reason not to follow the same convention in mad?
Joe R. http://www.rothweiler.us
On Thursday, April 17, 2003, at 11:55 AM, Joe R wrote:
This appears to be an ambiguity in the spec: as far as I can see, 11172-3 just says to use the 6-bit scalefactor as an index into table B.1, but B.1 is only defined for 0-62.
Toolame appears to add an extra entry to B.1 that maps 63 to 0.0, and mpg123 seems to do the same thing. Is there any reason not to follow the same convention in mad?
There is a good reason not to encode an index of 63 (besides not existing in the standard): it helps avoid creating false sync words.
It's unfortunate some encoders have taken liberty with the standard, but it would be nice for MAD to be able to cope with it. The attached patch enables MAD to accept a scalefactor index of 63 in Layer I and Layer II when OPT_STRICT is not defined.
Thanks to Timothy King who first discovered this problem.
FWIW, I'm hoping to make a new release soon that will include this improvement among many others.