CODE
int16_t scale_factor = ics->global_gain;
.
.
.
for (g = 0; g < ics->num_window_groups; g++)
{
for (sfb = 0; sfb < ics->max_sfb; sfb++)
{
switch (ics->sfb_cb[g][sfb])
{
.
.
.
default: /* spectral books */
/* ics->scale_factors[g][sfb] must be between 0 and 255 */
ics->scale_factors[g][sfb] = 0;
/* decode scale factor */
t = huffman_scale_factor(ld);
scale_factor += (t - 60);
if (scale_factor < 0 || scale_factor > 255)
return 4;
.
.
.
for (g = 0; g < ics->num_window_groups; g++)
{
for (sfb = 0; sfb < ics->max_sfb; sfb++)
{
switch (ics->sfb_cb[g][sfb])
{
.
.
.
default: /* spectral books */
/* ics->scale_factors[g][sfb] must be between 0 and 255 */
ics->scale_factors[g][sfb] = 0;
/* decode scale factor */
t = huffman_scale_factor(ld);
scale_factor += (t - 60);
if (scale_factor < 0 || scale_factor > 255)
return 4;
When the error occurs, ics->global_gain is zero, t is 59, so scale_factor is set to -1 which is invalid.
I am using faad2.0 from Sept. 2004, but this part of the code seems unchanged in latest CVS.
Is this a bug in decoding, or is the file invalid? Would it be appropriate to change the faad2 code to round up to zero?
Thanks for the help!
Dave