NAME: III_sideinfo() DESCRIPTION: decode frame side information from a bitstream */
| 537 | DESCRIPTION: decode frame side information from a bitstream |
| 538 | */ |
| 539 | static |
| 540 | enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, |
| 541 | int lsf, struct sideinfo *si, |
| 542 | unsigned int *data_bitlen, |
| 543 | unsigned int *priv_bitlen) |
| 544 | { |
| 545 | unsigned int ngr, gr, ch, i; |
| 546 | enum mad_error result = MAD_ERROR_NONE; |
| 547 | stack(__FUNCTION__, __FILE__, __LINE__); |
| 548 | |
| 549 | *data_bitlen = 0; |
| 550 | *priv_bitlen = lsf ? ((nch == 1) ? 1 : 2) : ((nch == 1) ? 5 : 3); |
| 551 | |
| 552 | si->main_data_begin = mad_bit_read(ptr, lsf ? 8 : 9); |
| 553 | si->private_bits = mad_bit_read(ptr, *priv_bitlen); |
| 554 | |
| 555 | ngr = 1; |
| 556 | if (!lsf) { |
| 557 | ngr = 2; |
| 558 | |
| 559 | for (ch = 0; ch < nch; ++ch) |
| 560 | si->scfsi[ch] = mad_bit_read(ptr, 4); |
| 561 | } |
| 562 | |
| 563 | for (gr = 0; gr < ngr; ++gr) { |
| 564 | struct granule *granule = &si->gr[gr]; |
| 565 | |
| 566 | for (ch = 0; ch < nch; ++ch) { |
| 567 | struct channel *channel = &granule->ch[ch]; |
| 568 | |
| 569 | channel->part2_3_length = mad_bit_read(ptr, 12); |
| 570 | channel->big_values = mad_bit_read(ptr, 9); |
| 571 | channel->global_gain = mad_bit_read(ptr, 8); |
| 572 | channel->scalefac_compress = mad_bit_read(ptr, lsf ? 9 : 4); |
| 573 | |
| 574 | *data_bitlen += channel->part2_3_length; |
| 575 | |
| 576 | if (channel->big_values > 288 && result == 0) |
| 577 | result = MAD_ERROR_BADBIGVALUES; |
| 578 | |
| 579 | channel->flags = 0; |
| 580 | |
| 581 | /* window_switching_flag */ |
| 582 | if (mad_bit_read(ptr, 1)) { |
| 583 | channel->block_type = mad_bit_read(ptr, 2); |
| 584 | |
| 585 | if (channel->block_type == 0 && result == 0) |
| 586 | result = MAD_ERROR_BADBLOCKTYPE; |
| 587 | |
| 588 | if (!lsf && channel->block_type == 2 && si->scfsi[ch] && result == 0) |
| 589 | result = MAD_ERROR_BADSCFSI; |
| 590 | |
| 591 | channel->region0_count = 7; |
| 592 | channel->region1_count = 36; |
| 593 | |
| 594 | if (mad_bit_read(ptr, 1)) |
| 595 | channel->flags |= mixed_block_flag; |
| 596 | else if (channel->block_type == 2) |
no test coverage detected