static void output_audio_block(AC3EncodeContext *s, int blk)

{

    int ch, i, baie, bnd, got_cpl, ch0;

    AC3Block *block = &s->blocks[blk];



    /* block switching */

    if (!s->eac3) {

        for (ch = 0; ch < s->fbw_channels; ch++)

            put_bits(&s->pb, 1, 0);

    }



    /* dither flags */

    if (!s->eac3) {

        for (ch = 0; ch < s->fbw_channels; ch++)

            put_bits(&s->pb, 1, 1);

    }



    /* dynamic range codes */

    put_bits(&s->pb, 1, 0);



    /* spectral extension */

    if (s->eac3)

        put_bits(&s->pb, 1, 0);



    /* channel coupling */

    if (!s->eac3)

        put_bits(&s->pb, 1, block->new_cpl_strategy);

    if (block->new_cpl_strategy) {

        if (!s->eac3)

            put_bits(&s->pb, 1, block->cpl_in_use);

        if (block->cpl_in_use) {

            int start_sub, end_sub;

            if (s->eac3)

                put_bits(&s->pb, 1, 0); /* enhanced coupling */

            if (!s->eac3 || s->channel_mode != AC3_CHMODE_STEREO) {

                for (ch = 1; ch <= s->fbw_channels; ch++)

                    put_bits(&s->pb, 1, block->channel_in_cpl[ch]);

            }

            if (s->channel_mode == AC3_CHMODE_STEREO)

                put_bits(&s->pb, 1, 0); /* phase flags in use */

            start_sub = (s->start_freq[CPL_CH] - 37) / 12;

            end_sub   = (s->cpl_end_freq       - 37) / 12;

            put_bits(&s->pb, 4, start_sub);

            put_bits(&s->pb, 4, end_sub - 3);

            /* coupling band structure */

            if (s->eac3) {

                put_bits(&s->pb, 1, 0); /* use default */

            } else {

                for (bnd = start_sub+1; bnd < end_sub; bnd++)

                    put_bits(&s->pb, 1, ff_eac3_default_cpl_band_struct[bnd]);

            }

        }

    }



    /* coupling coordinates */

    if (block->cpl_in_use) {

        for (ch = 1; ch <= s->fbw_channels; ch++) {

            if (block->channel_in_cpl[ch]) {

                if (!s->eac3 || block->new_cpl_coords[ch] != 2)

                    put_bits(&s->pb, 1, block->new_cpl_coords[ch]);

                if (block->new_cpl_coords[ch]) {

                    put_bits(&s->pb, 2, block->cpl_master_exp[ch]);

                    for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {

                        put_bits(&s->pb, 4, block->cpl_coord_exp [ch][bnd]);

                        put_bits(&s->pb, 4, block->cpl_coord_mant[ch][bnd]);

                    }

                }

            }

        }

    }



    /* stereo rematrixing */

    if (s->channel_mode == AC3_CHMODE_STEREO) {

        if (!s->eac3 || blk > 0)

            put_bits(&s->pb, 1, block->new_rematrixing_strategy);

        if (block->new_rematrixing_strategy) {

            /* rematrixing flags */

            for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++)

                put_bits(&s->pb, 1, block->rematrixing_flags[bnd]);

        }

    }



    /* exponent strategy */

    if (!s->eac3) {

        for (ch = !block->cpl_in_use; ch <= s->fbw_channels; ch++)

            put_bits(&s->pb, 2, s->exp_strategy[ch][blk]);

        if (s->lfe_on)

            put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]);

    }



    /* bandwidth */

    for (ch = 1; ch <= s->fbw_channels; ch++) {

        if (s->exp_strategy[ch][blk] != EXP_REUSE && !block->channel_in_cpl[ch])

            put_bits(&s->pb, 6, s->bandwidth_code);

    }



    /* exponents */

    for (ch = !block->cpl_in_use; ch <= s->channels; ch++) {

        int nb_groups;

        int cpl = (ch == CPL_CH);



        if (s->exp_strategy[ch][blk] == EXP_REUSE)

            continue;



        /* DC exponent */

        put_bits(&s->pb, 4, block->grouped_exp[ch][0] >> cpl);



        /* exponent groups */

        nb_groups = exponent_group_tab[cpl][s->exp_strategy[ch][blk]-1][block->end_freq[ch]-s->start_freq[ch]];

        for (i = 1; i <= nb_groups; i++)

            put_bits(&s->pb, 7, block->grouped_exp[ch][i]);



        /* gain range info */

        if (ch != s->lfe_channel && !cpl)

            put_bits(&s->pb, 2, 0);

    }



    /* bit allocation info */

    if (!s->eac3) {

        baie = (blk == 0);

        put_bits(&s->pb, 1, baie);

        if (baie) {

            put_bits(&s->pb, 2, s->slow_decay_code);

            put_bits(&s->pb, 2, s->fast_decay_code);

            put_bits(&s->pb, 2, s->slow_gain_code);

            put_bits(&s->pb, 2, s->db_per_bit_code);

            put_bits(&s->pb, 3, s->floor_code);

        }

    }



    /* snr offset */

    if (!s->eac3) {

        put_bits(&s->pb, 1, block->new_snr_offsets);

        if (block->new_snr_offsets) {

            put_bits(&s->pb, 6, s->coarse_snr_offset);

            for (ch = !block->cpl_in_use; ch <= s->channels; ch++) {

                put_bits(&s->pb, 4, s->fine_snr_offset[ch]);

                put_bits(&s->pb, 3, s->fast_gain_code[ch]);

            }

        }

    } else {

        put_bits(&s->pb, 1, 0); /* no converter snr offset */

    }



    /* coupling leak */

    if (block->cpl_in_use) {

        if (!s->eac3 || block->new_cpl_leak != 2)

            put_bits(&s->pb, 1, block->new_cpl_leak);

        if (block->new_cpl_leak) {

            put_bits(&s->pb, 3, s->bit_alloc.cpl_fast_leak);

            put_bits(&s->pb, 3, s->bit_alloc.cpl_slow_leak);

        }

    }



    if (!s->eac3) {

        put_bits(&s->pb, 1, 0); /* no delta bit allocation */

        put_bits(&s->pb, 1, 0); /* no data to skip */

    }



    /* mantissas */

    got_cpl = !block->cpl_in_use;

    for (ch = 1; ch <= s->channels; ch++) {

        int b, q;



        if (!got_cpl && ch > 1 && block->channel_in_cpl[ch-1]) {

            ch0     = ch - 1;

            ch      = CPL_CH;

            got_cpl = 1;

        }

        for (i = s->start_freq[ch]; i < block->end_freq[ch]; i++) {

            q = block->qmant[ch][i];

            b = s->ref_bap[ch][blk][i];

            switch (b) {

            case 0:                                          break;

            case 1: if (q != 128) put_bits (&s->pb,   5, q); break;

            case 2: if (q != 128) put_bits (&s->pb,   7, q); break;

            case 3:               put_sbits(&s->pb,   3, q); break;

            case 4: if (q != 128) put_bits (&s->pb,   7, q); break;

            case 14:              put_sbits(&s->pb,  14, q); break;

            case 15:              put_sbits(&s->pb,  16, q); break;

            default:              put_sbits(&s->pb, b-1, q); break;

            }

        }

        if (ch == CPL_CH)

            ch = ch0;

    }

}

static void output_audio_block(AC3EncodeContext *s, int blk)

{

    int ch, i, baie, bnd, got_cpl, ch0;

    AC3Block *block = &s->blocks[blk];



    

    if (!s->eac3) {

        for (ch = 0; ch < s->fbw_channels; ch++)

            put_bits(&s->pb, 1, 0);

    }



    

    if (!s->eac3) {

        for (ch = 0; ch < s->fbw_channels; ch++)

            put_bits(&s->pb, 1, 1);

    }



    

    put_bits(&s->pb, 1, 0);



    

    if (s->eac3)

        put_bits(&s->pb, 1, 0);



    

    if (!s->eac3)

        put_bits(&s->pb, 1, block->new_cpl_strategy);

    if (block->new_cpl_strategy) {

        if (!s->eac3)

            put_bits(&s->pb, 1, block->cpl_in_use);

        if (block->cpl_in_use) {

            int start_sub, end_sub;

            if (s->eac3)

                put_bits(&s->pb, 1, 0); 

            if (!s->eac3 || s->channel_mode != AC3_CHMODE_STEREO) {

                for (ch = 1; ch <= s->fbw_channels; ch++)

                    put_bits(&s->pb, 1, block->channel_in_cpl[ch]);

            }

            if (s->channel_mode == AC3_CHMODE_STEREO)

                put_bits(&s->pb, 1, 0); 

            start_sub = (s->start_freq[CPL_CH] - 37) / 12;

            end_sub   = (s->cpl_end_freq       - 37) / 12;

            put_bits(&s->pb, 4, start_sub);

            put_bits(&s->pb, 4, end_sub - 3);

            

            if (s->eac3) {

                put_bits(&s->pb, 1, 0); 

            } else {

                for (bnd = start_sub+1; bnd < end_sub; bnd++)

                    put_bits(&s->pb, 1, ff_eac3_default_cpl_band_struct[bnd]);

            }

        }

    }



    

    if (block->cpl_in_use) {

        for (ch = 1; ch <= s->fbw_channels; ch++) {

            if (block->channel_in_cpl[ch]) {

                if (!s->eac3 || block->new_cpl_coords[ch] != 2)

                    put_bits(&s->pb, 1, block->new_cpl_coords[ch]);

                if (block->new_cpl_coords[ch]) {

                    put_bits(&s->pb, 2, block->cpl_master_exp[ch]);

                    for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {

                        put_bits(&s->pb, 4, block->cpl_coord_exp [ch][bnd]);

                        put_bits(&s->pb, 4, block->cpl_coord_mant[ch][bnd]);

                    }

                }

            }

        }

    }



    

    if (s->channel_mode == AC3_CHMODE_STEREO) {

        if (!s->eac3 || blk > 0)

            put_bits(&s->pb, 1, block->new_rematrixing_strategy);

        if (block->new_rematrixing_strategy) {

            

            for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++)

                put_bits(&s->pb, 1, block->rematrixing_flags[bnd]);

        }

    }



    

    if (!s->eac3) {

        for (ch = !block->cpl_in_use; ch <= s->fbw_channels; ch++)

            put_bits(&s->pb, 2, s->exp_strategy[ch][blk]);

        if (s->lfe_on)

            put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]);

    }



    

    for (ch = 1; ch <= s->fbw_channels; ch++) {

        if (s->exp_strategy[ch][blk] != EXP_REUSE && !block->channel_in_cpl[ch])

            put_bits(&s->pb, 6, s->bandwidth_code);

    }



    

    for (ch = !block->cpl_in_use; ch <= s->channels; ch++) {

        int nb_groups;

        int cpl = (ch == CPL_CH);



        if (s->exp_strategy[ch][blk] == EXP_REUSE)

            continue;



        

        put_bits(&s->pb, 4, block->grouped_exp[ch][0] >> cpl);



        

        nb_groups = exponent_group_tab[cpl][s->exp_strategy[ch][blk]-1][block->end_freq[ch]-s->start_freq[ch]];

        for (i = 1; i <= nb_groups; i++)

            put_bits(&s->pb, 7, block->grouped_exp[ch][i]);



        

        if (ch != s->lfe_channel && !cpl)

            put_bits(&s->pb, 2, 0);

    }



    

    if (!s->eac3) {

        baie = (blk == 0);

        put_bits(&s->pb, 1, baie);

        if (baie) {

            put_bits(&s->pb, 2, s->slow_decay_code);

            put_bits(&s->pb, 2, s->fast_decay_code);

            put_bits(&s->pb, 2, s->slow_gain_code);

            put_bits(&s->pb, 2, s->db_per_bit_code);

            put_bits(&s->pb, 3, s->floor_code);

        }

    }



    

    if (!s->eac3) {

        put_bits(&s->pb, 1, block->new_snr_offsets);

        if (block->new_snr_offsets) {

            put_bits(&s->pb, 6, s->coarse_snr_offset);

            for (ch = !block->cpl_in_use; ch <= s->channels; ch++) {

                put_bits(&s->pb, 4, s->fine_snr_offset[ch]);

                put_bits(&s->pb, 3, s->fast_gain_code[ch]);

            }

        }

    } else {

        put_bits(&s->pb, 1, 0); 

    }



    

    if (block->cpl_in_use) {

        if (!s->eac3 || block->new_cpl_leak != 2)

            put_bits(&s->pb, 1, block->new_cpl_leak);

        if (block->new_cpl_leak) {

            put_bits(&s->pb, 3, s->bit_alloc.cpl_fast_leak);

            put_bits(&s->pb, 3, s->bit_alloc.cpl_slow_leak);

        }

    }



    if (!s->eac3) {

        put_bits(&s->pb, 1, 0); 

        put_bits(&s->pb, 1, 0); 

    }



    

    got_cpl = !block->cpl_in_use;

    for (ch = 1; ch <= s->channels; ch++) {

        int b, q;



        if (!got_cpl && ch > 1 && block->channel_in_cpl[ch-1]) {

            ch0     = ch - 1;

            ch      = CPL_CH;

            got_cpl = 1;

        }

        for (i = s->start_freq[ch]; i < block->end_freq[ch]; i++) {

            q = block->qmant[ch][i];

            b = s->ref_bap[ch][blk][i];

            switch (b) {

            case 0:                                          break;

            case 1: if (q != 128) put_bits (&s->pb,   5, q); break;

            case 2: if (q != 128) put_bits (&s->pb,   7, q); break;

            case 3:               put_sbits(&s->pb,   3, q); break;

            case 4: if (q != 128) put_bits (&s->pb,   7, q); break;

            case 14:              put_sbits(&s->pb,  14, q); break;

            case 15:              put_sbits(&s->pb,  16, q); break;

            default:              put_sbits(&s->pb, b-1, q); break;

            }

        }

        if (ch == CPL_CH)

            ch = ch0;

    }

}

    int ch, i, baie, bnd, got_cpl, ch0;
static void FUNC_0(AC3EncodeContext *VAR_0, int VAR_1)

{

    int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;

    AC3Block *block = &VAR_0->blocks[VAR_1];



    

    if (!VAR_0->eac3) {

        for (VAR_2 = 0; VAR_2 < VAR_0->fbw_channels; VAR_2++)

            put_bits(&VAR_0->pb, 1, 0);

    }



    

    if (!VAR_0->eac3) {

        for (VAR_2 = 0; VAR_2 < VAR_0->fbw_channels; VAR_2++)

            put_bits(&VAR_0->pb, 1, 1);

    }



    

    put_bits(&VAR_0->pb, 1, 0);



    

    if (VAR_0->eac3)

        put_bits(&VAR_0->pb, 1, 0);



    

    if (!VAR_0->eac3)

        put_bits(&VAR_0->pb, 1, block->new_cpl_strategy);

    if (block->new_cpl_strategy) {

        if (!VAR_0->eac3)

            put_bits(&VAR_0->pb, 1, block->cpl_in_use);

        if (block->cpl_in_use) {

            int VAR_8, VAR_9;

            if (VAR_0->eac3)

                put_bits(&VAR_0->pb, 1, 0); 

            if (!VAR_0->eac3 || VAR_0->channel_mode != AC3_CHMODE_STEREO) {

                for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++)

                    put_bits(&VAR_0->pb, 1, block->channel_in_cpl[VAR_2]);

            }

            if (VAR_0->channel_mode == AC3_CHMODE_STEREO)

                put_bits(&VAR_0->pb, 1, 0); 

            VAR_8 = (VAR_0->start_freq[CPL_CH] - 37) / 12;

            VAR_9   = (VAR_0->cpl_end_freq       - 37) / 12;

            put_bits(&VAR_0->pb, 4, VAR_8);

            put_bits(&VAR_0->pb, 4, VAR_9 - 3);

            

            if (VAR_0->eac3) {

                put_bits(&VAR_0->pb, 1, 0); 

            } else {

                for (VAR_5 = VAR_8+1; VAR_5 < VAR_9; VAR_5++)

                    put_bits(&VAR_0->pb, 1, ff_eac3_default_cpl_band_struct[VAR_5]);

            }

        }

    }



    

    if (block->cpl_in_use) {

        for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {

            if (block->channel_in_cpl[VAR_2]) {

                if (!VAR_0->eac3 || block->new_cpl_coords[VAR_2] != 2)

                    put_bits(&VAR_0->pb, 1, block->new_cpl_coords[VAR_2]);

                if (block->new_cpl_coords[VAR_2]) {

                    put_bits(&VAR_0->pb, 2, block->cpl_master_exp[VAR_2]);

                    for (VAR_5 = 0; VAR_5 < VAR_0->num_cpl_bands; VAR_5++) {

                        put_bits(&VAR_0->pb, 4, block->cpl_coord_exp [VAR_2][VAR_5]);

                        put_bits(&VAR_0->pb, 4, block->cpl_coord_mant[VAR_2][VAR_5]);

                    }

                }

            }

        }

    }



    

    if (VAR_0->channel_mode == AC3_CHMODE_STEREO) {

        if (!VAR_0->eac3 || VAR_1 > 0)

            put_bits(&VAR_0->pb, 1, block->new_rematrixing_strategy);

        if (block->new_rematrixing_strategy) {

            

            for (VAR_5 = 0; VAR_5 < block->num_rematrixing_bands; VAR_5++)

                put_bits(&VAR_0->pb, 1, block->rematrixing_flags[VAR_5]);

        }

    }



    

    if (!VAR_0->eac3) {

        for (VAR_2 = !block->cpl_in_use; VAR_2 <= VAR_0->fbw_channels; VAR_2++)

            put_bits(&VAR_0->pb, 2, VAR_0->exp_strategy[VAR_2][VAR_1]);

        if (VAR_0->lfe_on)

            put_bits(&VAR_0->pb, 1, VAR_0->exp_strategy[VAR_0->lfe_channel][VAR_1]);

    }



    

    for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {

        if (VAR_0->exp_strategy[VAR_2][VAR_1] != EXP_REUSE && !block->channel_in_cpl[VAR_2])

            put_bits(&VAR_0->pb, 6, VAR_0->bandwidth_code);

    }



    

    for (VAR_2 = !block->cpl_in_use; VAR_2 <= VAR_0->channels; VAR_2++) {

        int nb_groups;

        int cpl = (VAR_2 == CPL_CH);



        if (VAR_0->exp_strategy[VAR_2][VAR_1] == EXP_REUSE)

            continue;



        

        put_bits(&VAR_0->pb, 4, block->grouped_exp[VAR_2][0] >> cpl);



        

        nb_groups = exponent_group_tab[cpl][VAR_0->exp_strategy[VAR_2][VAR_1]-1][block->end_freq[VAR_2]-VAR_0->start_freq[VAR_2]];

        for (VAR_3 = 1; VAR_3 <= nb_groups; VAR_3++)

            put_bits(&VAR_0->pb, 7, block->grouped_exp[VAR_2][VAR_3]);



        

        if (VAR_2 != VAR_0->lfe_channel && !cpl)

            put_bits(&VAR_0->pb, 2, 0);

    }



    

    if (!VAR_0->eac3) {

        VAR_4 = (VAR_1 == 0);

        put_bits(&VAR_0->pb, 1, VAR_4);

        if (VAR_4) {

            put_bits(&VAR_0->pb, 2, VAR_0->slow_decay_code);

            put_bits(&VAR_0->pb, 2, VAR_0->fast_decay_code);

            put_bits(&VAR_0->pb, 2, VAR_0->slow_gain_code);

            put_bits(&VAR_0->pb, 2, VAR_0->db_per_bit_code);

            put_bits(&VAR_0->pb, 3, VAR_0->floor_code);

        }

    }



    

    if (!VAR_0->eac3) {

        put_bits(&VAR_0->pb, 1, block->new_snr_offsets);

        if (block->new_snr_offsets) {

            put_bits(&VAR_0->pb, 6, VAR_0->coarse_snr_offset);

            for (VAR_2 = !block->cpl_in_use; VAR_2 <= VAR_0->channels; VAR_2++) {

                put_bits(&VAR_0->pb, 4, VAR_0->fine_snr_offset[VAR_2]);

                put_bits(&VAR_0->pb, 3, VAR_0->fast_gain_code[VAR_2]);

            }

        }

    } else {

        put_bits(&VAR_0->pb, 1, 0); 

    }



    

    if (block->cpl_in_use) {

        if (!VAR_0->eac3 || block->new_cpl_leak != 2)

            put_bits(&VAR_0->pb, 1, block->new_cpl_leak);

        if (block->new_cpl_leak) {

            put_bits(&VAR_0->pb, 3, VAR_0->bit_alloc.cpl_fast_leak);

            put_bits(&VAR_0->pb, 3, VAR_0->bit_alloc.cpl_slow_leak);

        }

    }



    if (!VAR_0->eac3) {

        put_bits(&VAR_0->pb, 1, 0); 

        put_bits(&VAR_0->pb, 1, 0); 

    }



    

    VAR_6 = !block->cpl_in_use;

    for (VAR_2 = 1; VAR_2 <= VAR_0->channels; VAR_2++) {

        int b, q;



        if (!VAR_6 && VAR_2 > 1 && block->channel_in_cpl[VAR_2-1]) {

            VAR_7     = VAR_2 - 1;

            VAR_2      = CPL_CH;

            VAR_6 = 1;

        }

        for (VAR_3 = VAR_0->start_freq[VAR_2]; VAR_3 < block->end_freq[VAR_2]; VAR_3++) {

            q = block->qmant[VAR_2][VAR_3];

            b = VAR_0->ref_bap[VAR_2][VAR_1][VAR_3];

            switch (b) {

            case 0:                                          break;

            case 1: if (q != 128) put_bits (&VAR_0->pb,   5, q); break;

            case 2: if (q != 128) put_bits (&VAR_0->pb,   7, q); break;

            case 3:               put_sbits(&VAR_0->pb,   3, q); break;

            case 4: if (q != 128) put_bits (&VAR_0->pb,   7, q); break;

            case 14:              put_sbits(&VAR_0->pb,  14, q); break;

            case 15:              put_sbits(&VAR_0->pb,  16, q); break;

            default:              put_sbits(&VAR_0->pb, b-1, q); break;

            }

        }

        if (VAR_2 == CPL_CH)

            VAR_2 = VAR_7;

    }

}

static void FUNC_0(AC3EncodeContext *VAR_0, int VAR_1)
{ int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; AC3Block *block = &VAR_0->blocks[VAR_1]; if (!VAR_0->eac3) { for (VAR_2 = 0; VAR_2 < VAR_0->fbw_channels; VAR_2++) put_bits(&VAR_0->pb, 1, 0); } if (!VAR_0->eac3) { for (VAR_2 = 0; VAR_2 < VAR_0->fbw_channels; VAR_2++) put_bits(&VAR_0->pb, 1, 1); } put_bits(&VAR_0->pb, 1, 0); if (VAR_0->eac3)
put_bits(&VAR_0->pb, 1, 0); if (!VAR_0->eac3)
put_bits(&VAR_0->pb, 1, block->new_cpl_strategy); if (block->new_cpl_strategy) { if (!VAR_0->eac3)
put_bits(&VAR_0->pb, 1, block->cpl_in_use); if (block->cpl_in_use) { int VAR_8, VAR_9; if (VAR_0->eac3)
put_bits(&VAR_0->pb, 1, 0); if (!VAR_0->eac3 || VAR_0->channel_mode != AC3_CHMODE_STEREO) { for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) put_bits(&VAR_0->pb, 1, block->channel_in_cpl[VAR_2]); } if (VAR_0->channel_mode == AC3_CHMODE_STEREO)
put_bits(&VAR_0->pb, 1, 0); VAR_8 = (VAR_0->start_freq[CPL_CH] - 37) / 12; VAR_9   = (VAR_0->cpl_end_freq       - 37) / 12; put_bits(&VAR_0->pb, 4, VAR_8); put_bits(&VAR_0->pb, 4, VAR_9 - 3); if (VAR_0->eac3) { put_bits(&VAR_0->pb, 1, 0); } else { for (VAR_5 = VAR_8+1; VAR_5 < VAR_9; VAR_5++) put_bits(&VAR_0->pb, 1, ff_eac3_default_cpl_band_struct[VAR_5]); } } } if (block->cpl_in_use) { for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) { if (block->channel_in_cpl[VAR_2]) { if (!VAR_0->eac3 || block->new_cpl_coords[VAR_2] != 2)
put_bits(&VAR_0->pb, 1, block->new_cpl_coords[VAR_2]); if (block->new_cpl_coords[VAR_2]) { put_bits(&VAR_0->pb, 2, block->cpl_master_exp[VAR_2]); for (VAR_5 = 0; VAR_5 < VAR_0->num_cpl_bands; VAR_5++) { put_bits(&VAR_0->pb, 4, block->cpl_coord_exp [VAR_2][VAR_5]); put_bits(&VAR_0->pb, 4, block->cpl_coord_mant[VAR_2][VAR_5]); } } } } } if (VAR_0->channel_mode == AC3_CHMODE_STEREO) { if (!VAR_0->eac3 || VAR_1 > 0)
put_bits(&VAR_0->pb, 1, block->new_rematrixing_strategy); if (block->new_rematrixing_strategy) { for (VAR_5 = 0; VAR_5 < block->num_rematrixing_bands; VAR_5++) put_bits(&VAR_0->pb, 1, block->rematrixing_flags[VAR_5]); } } if (!VAR_0->eac3) { for (VAR_2 = !block->cpl_in_use; VAR_2 <= VAR_0->fbw_channels; VAR_2++) put_bits(&VAR_0->pb, 2, VAR_0->exp_strategy[VAR_2][VAR_1]); if (VAR_0->lfe_on)
put_bits(&VAR_0->pb, 1, VAR_0->exp_strategy[VAR_0->lfe_channel][VAR_1]); } for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) { if (VAR_0->exp_strategy[VAR_2][VAR_1] != EXP_REUSE && !block->channel_in_cpl[VAR_2])
put_bits(&VAR_0->pb, 6, VAR_0->bandwidth_code); } for (VAR_2 = !block->cpl_in_use; VAR_2 <= VAR_0->channels; VAR_2++) { int nb_groups; int cpl = (VAR_2 == CPL_CH); if (VAR_0->exp_strategy[VAR_2][VAR_1] == EXP_REUSE)
continue; put_bits(&VAR_0->pb, 4, block->grouped_exp[VAR_2][0] >> cpl); nb_groups = exponent_group_tab[cpl][VAR_0->exp_strategy[VAR_2][VAR_1]-1][block->end_freq[VAR_2]-VAR_0->start_freq[VAR_2]]; for (VAR_3 = 1; VAR_3 <= nb_groups; VAR_3++) put_bits(&VAR_0->pb, 7, block->grouped_exp[VAR_2][VAR_3]); if (VAR_2 != VAR_0->lfe_channel && !cpl)
put_bits(&VAR_0->pb, 2, 0); } if (!VAR_0->eac3) { VAR_4 = (VAR_1 == 0); put_bits(&VAR_0->pb, 1, VAR_4); if (VAR_4) { put_bits(&VAR_0->pb, 2, VAR_0->slow_decay_code); put_bits(&VAR_0->pb, 2, VAR_0->fast_decay_code); put_bits(&VAR_0->pb, 2, VAR_0->slow_gain_code); put_bits(&VAR_0->pb, 2, VAR_0->db_per_bit_code); put_bits(&VAR_0->pb, 3, VAR_0->floor_code); } } if (!VAR_0->eac3) { put_bits(&VAR_0->pb, 1, block->new_snr_offsets); if (block->new_snr_offsets) { put_bits(&VAR_0->pb, 6, VAR_0->coarse_snr_offset); for (VAR_2 = !block->cpl_in_use; VAR_2 <= VAR_0->channels; VAR_2++) { put_bits(&VAR_0->pb, 4, VAR_0->fine_snr_offset[VAR_2]); put_bits(&VAR_0->pb, 3, VAR_0->fast_gain_code[VAR_2]); } } } else { put_bits(&VAR_0->pb, 1, 0); } if (block->cpl_in_use) { if (!VAR_0->eac3 || block->new_cpl_leak != 2)
put_bits(&VAR_0->pb, 1, block->new_cpl_leak); if (block->new_cpl_leak) { put_bits(&VAR_0->pb, 3, VAR_0->bit_alloc.cpl_fast_leak); put_bits(&VAR_0->pb, 3, VAR_0->bit_alloc.cpl_slow_leak); } } if (!VAR_0->eac3) { put_bits(&VAR_0->pb, 1, 0); put_bits(&VAR_0->pb, 1, 0); } VAR_6 = !block->cpl_in_use; for (VAR_2 = 1; VAR_2 <= VAR_0->channels; VAR_2++) { int b, q; if (!VAR_6 && VAR_2 > 1 && block->channel_in_cpl[VAR_2-1]) { VAR_7     = VAR_2 - 1; VAR_2      = CPL_CH; VAR_6 = 1; } for (VAR_3 = VAR_0->start_freq[VAR_2]; VAR_3 < block->end_freq[VAR_2]; VAR_3++) { q = block->qmant[VAR_2][VAR_3]; b = VAR_0->ref_bap[VAR_2][VAR_1][VAR_3]; switch (b) { case 0:                                          break; case 1: if (q != 128) put_bits (&VAR_0->pb,   5, q); break; case 2: if (q != 128) put_bits (&VAR_0->pb,   7, q); break; case 3:               put_sbits(&VAR_0->pb,   3, q); break; case 4: if (q != 128) put_bits (&VAR_0->pb,   7, q); break; case 14:              put_sbits(&VAR_0->pb,  14, q); break; case 15:              put_sbits(&VAR_0->pb,  16, q); break; default:              put_sbits(&VAR_0->pb, b-1, q); break; } } if (VAR_2 == CPL_CH)
VAR_2 = VAR_7; } }