static void count_frame_bits_fixed(AC3EncodeContext *s)

{

    static const int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 };

    int blk;

    int frame_bits;



    /* assumptions:

     *   no dynamic range codes

     *   bit allocation parameters do not change between blocks

     *   no delta bit allocation

     *   no skipped data

     *   no auxilliary data

     *   no E-AC-3 metadata

     */



    /* header */

    frame_bits = 16; /* sync info */

    if (s->eac3) {

        /* bitstream info header */

        frame_bits += 35;

        frame_bits += 1 + 1 + 1;

        /* audio frame header */

        frame_bits += 2;

        frame_bits += 10;

        /* exponent strategy */

        for (blk = 0; blk < AC3_MAX_BLOCKS; blk++)

            frame_bits += 2 * s->fbw_channels + s->lfe_on;

        /* converter exponent strategy */

        frame_bits += s->fbw_channels * 5;

        /* snr offsets */

        frame_bits += 10;

        /* block start info */

        frame_bits++;

    } else {

        frame_bits += 49;

        frame_bits += frame_bits_inc[s->channel_mode];

    }



    /* audio blocks */

    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {

        if (!s->eac3) {

            /* block switch flags */

            frame_bits += s->fbw_channels;



            /* dither flags */

            frame_bits += s->fbw_channels;

        }



        /* dynamic range */

        frame_bits++;



        /* spectral extension */

        if (s->eac3)

            frame_bits++;



        if (!s->eac3) {

            /* exponent strategy */

            frame_bits += 2 * s->fbw_channels;

            if (s->lfe_on)

                frame_bits++;



            /* bit allocation params */

            frame_bits++;

            if (!blk)

                frame_bits += 2 + 2 + 2 + 2 + 3;

        }



        /* converter snr offset */

        if (s->eac3)

            frame_bits++;



        if (!s->eac3) {

            /* delta bit allocation */

            frame_bits++;



            /* skipped data */

            frame_bits++;

        }

    }



    /* auxiliary data */

    frame_bits++;



    /* CRC */

    frame_bits += 1 + 16;



    s->frame_bits_fixed = frame_bits;

}

static void count_frame_bits_fixed(AC3EncodeContext *s)

{

    static const int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 };

    int blk;

    int frame_bits;



    

















    

    frame_bits = 16; 

    if (s->eac3) {

        

        frame_bits += 35;

        frame_bits += 1 + 1 + 1;

        

        frame_bits += 2;

        frame_bits += 10;

        

        for (blk = 0; blk < AC3_MAX_BLOCKS; blk++)

            frame_bits += 2 * s->fbw_channels + s->lfe_on;

        

        frame_bits += s->fbw_channels * 5;

        

        frame_bits += 10;

        

        frame_bits++;

    } else {

        frame_bits += 49;

        frame_bits += frame_bits_inc[s->channel_mode];

    }



    

    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {

        if (!s->eac3) {

            

            frame_bits += s->fbw_channels;



            

            frame_bits += s->fbw_channels;

        }



        

        frame_bits++;



        

        if (s->eac3)

            frame_bits++;



        if (!s->eac3) {

            

            frame_bits += 2 * s->fbw_channels;

            if (s->lfe_on)

                frame_bits++;



            

            frame_bits++;

            if (!blk)

                frame_bits += 2 + 2 + 2 + 2 + 3;

        }



        

        if (s->eac3)

            frame_bits++;



        if (!s->eac3) {

            

            frame_bits++;



            

            frame_bits++;

        }

    }



    

    frame_bits++;



    

    frame_bits += 1 + 16;



    s->frame_bits_fixed = frame_bits;

}

static void FUNC_0(AC3EncodeContext *VAR_0)

{

    static const int VAR_1[8] = { 0, 0, 2, 2, 2, 4, 2, 4 };

    int VAR_2;

    int VAR_3;



    

















    

    VAR_3 = 16; 

    if (VAR_0->eac3) {

        

        VAR_3 += 35;

        VAR_3 += 1 + 1 + 1;

        

        VAR_3 += 2;

        VAR_3 += 10;

        

        for (VAR_2 = 0; VAR_2 < AC3_MAX_BLOCKS; VAR_2++)

            VAR_3 += 2 * VAR_0->fbw_channels + VAR_0->lfe_on;

        

        VAR_3 += VAR_0->fbw_channels * 5;

        

        VAR_3 += 10;

        

        VAR_3++;

    } else {

        VAR_3 += 49;

        VAR_3 += VAR_1[VAR_0->channel_mode];

    }



    

    for (VAR_2 = 0; VAR_2 < AC3_MAX_BLOCKS; VAR_2++) {

        if (!VAR_0->eac3) {

            

            VAR_3 += VAR_0->fbw_channels;



            

            VAR_3 += VAR_0->fbw_channels;

        }



        

        VAR_3++;



        

        if (VAR_0->eac3)

            VAR_3++;



        if (!VAR_0->eac3) {

            

            VAR_3 += 2 * VAR_0->fbw_channels;

            if (VAR_0->lfe_on)

                VAR_3++;



            

            VAR_3++;

            if (!VAR_2)

                VAR_3 += 2 + 2 + 2 + 2 + 3;

        }



        

        if (VAR_0->eac3)

            VAR_3++;



        if (!VAR_0->eac3) {

            

            VAR_3++;



            

            VAR_3++;

        }

    }



    

    VAR_3++;



    

    VAR_3 += 1 + 16;



    VAR_0->frame_bits_fixed = VAR_3;

}

static void FUNC_0(AC3EncodeContext *VAR_0)
{ static const int VAR_1[8] = { 0, 0, 2, 2, 2, 4, 2, 4 }; int VAR_2; int VAR_3; VAR_3 = 16; if (VAR_0->eac3) { VAR_3 += 35; VAR_3 += 1 + 1 + 1; VAR_3 += 2; VAR_3 += 10; for (VAR_2 = 0; VAR_2 < AC3_MAX_BLOCKS; VAR_2++) VAR_3 += 2 * VAR_0->fbw_channels + VAR_0->lfe_on; VAR_3 += VAR_0->fbw_channels * 5; VAR_3 += 10; VAR_3++; } else { VAR_3 += 49; VAR_3 += VAR_1[VAR_0->channel_mode]; } for (VAR_2 = 0; VAR_2 < AC3_MAX_BLOCKS; VAR_2++) { if (!VAR_0->eac3) { VAR_3 += VAR_0->fbw_channels; VAR_3 += VAR_0->fbw_channels; } VAR_3++; if (VAR_0->eac3)
VAR_3++; if (!VAR_0->eac3) { VAR_3 += 2 * VAR_0->fbw_channels; if (VAR_0->lfe_on)
VAR_3++; VAR_3++; if (!VAR_2)
VAR_3 += 2 + 2 + 2 + 2 + 3; } if (VAR_0->eac3)
VAR_3++; if (!VAR_0->eac3) { VAR_3++; VAR_3++; } } VAR_3++; VAR_3 += 1 + 16; VAR_0->frame_bits_fixed = VAR_3; }