(final LameGlobalFlags gfp)
| 588 | } |
| 589 | |
| 590 | private int writeMainData(final LameGlobalFlags gfp) { |
| 591 | int gr, ch, sfb, data_bits, tot_bits = 0; |
| 592 | final LameInternalFlags gfc = gfp.internal_flags; |
| 593 | final IIISideInfo l3_side = gfc.l3_side; |
| 594 | |
| 595 | if (gfp.version == 1) { |
| 596 | /* MPEG 1 */ |
| 597 | for (gr = 0; gr < 2; gr++) { |
| 598 | for (ch = 0; ch < gfc.channels_out; ch++) { |
| 599 | final GrInfo gi = l3_side.tt[gr][ch]; |
| 600 | final int slen1 = Takehiro.slen1_tab[gi.scalefac_compress]; |
| 601 | final int slen2 = Takehiro.slen2_tab[gi.scalefac_compress]; |
| 602 | data_bits = 0; |
| 603 | for (sfb = 0; sfb < gi.sfbdivide; sfb++) { |
| 604 | if (gi.scalefac[sfb] == -1) |
| 605 | continue; /* scfsi is used */ |
| 606 | putbits2(gfc, gi.scalefac[sfb], slen1); |
| 607 | data_bits += slen1; |
| 608 | } |
| 609 | for (; sfb < gi.sfbmax; sfb++) { |
| 610 | if (gi.scalefac[sfb] == -1) |
| 611 | continue; /* scfsi is used */ |
| 612 | putbits2(gfc, gi.scalefac[sfb], slen2); |
| 613 | data_bits += slen2; |
| 614 | } |
| 615 | assert (data_bits == gi.part2_length); |
| 616 | |
| 617 | if (gi.block_type == Encoder.SHORT_TYPE) { |
| 618 | data_bits += ShortHuffmancodebits(gfc, gi); |
| 619 | } else { |
| 620 | data_bits += LongHuffmancodebits(gfc, gi); |
| 621 | } |
| 622 | data_bits += huffman_coder_count1(gfc, gi); |
| 623 | /* does bitcount in quantize.c agree with actual bit count? */ |
| 624 | assert (data_bits == gi.part2_3_length + gi.part2_length); |
| 625 | tot_bits += data_bits; |
| 626 | } /* for ch */ |
| 627 | } /* for gr */ |
| 628 | } else { |
| 629 | /* MPEG 2 */ |
| 630 | gr = 0; |
| 631 | for (ch = 0; ch < gfc.channels_out; ch++) { |
| 632 | final GrInfo gi = l3_side.tt[gr][ch]; |
| 633 | int i, sfb_partition, scale_bits = 0; |
| 634 | assert (gi.sfb_partition_table != null); |
| 635 | data_bits = 0; |
| 636 | sfb = 0; |
| 637 | sfb_partition = 0; |
| 638 | |
| 639 | if (gi.block_type == Encoder.SHORT_TYPE) { |
| 640 | for (; sfb_partition < 4; sfb_partition++) { |
| 641 | final int sfbs = gi.sfb_partition_table[sfb_partition] / 3; |
| 642 | final int slen = gi.slen[sfb_partition]; |
| 643 | for (i = 0; i < sfbs; i++, sfb++) { |
| 644 | putbits2(gfc, |
| 645 | Math.max(gi.scalefac[sfb * 3 + 0], 0), slen); |
| 646 | putbits2(gfc, |
| 647 | Math.max(gi.scalefac[sfb * 3 + 1], 0), slen); |
no test coverage detected