Logo Search packages:      
Sourcecode: aften version File versions  Download package

static void count_frame_bits ( A52ThreadContext *  tctx  )  [static]

Counts all frame bits except for mantissas and exponents

Definition at line 164 of file bitalloc.c.

Referenced by start_bit_allocation().

{
    static int frame_bits_inc[8] = { 8, 0, 2, 2, 2, 4, 2, 4 };
    A52Context *ctx = tctx->ctx;
    A52Frame *frame = &tctx->frame;
    A52Block *block;
    int blk, ch;
    int frame_bits;

    frame_bits = 0;

    // header size
    frame_bits += 65;
    frame_bits += frame_bits_inc[ctx->acmod];
    if (ctx->meta.xbsi1e)
        frame_bits += 14;
    if (ctx->meta.xbsi2e)
        frame_bits += 14;

    // audio blocks
    for (blk = 0; blk < A52_NUM_BLOCKS; blk++) {
        block = &frame->blocks[blk];
        frame_bits += ctx->n_channels; // blksw
        frame_bits += ctx->n_channels; // dithflg
        frame_bits += 1 + (ctx->acmod == A52_ACMOD_DUAL_MONO); // dynrnge, dynrng2e
        if (ctx->params.dynrng_profile != DYNRNG_PROFILE_NONE) {
            frame_bits += 8; // dynrng
            if (ctx->acmod == A52_ACMOD_DUAL_MONO)
                frame_bits += 8; // dynrng2
        }
        frame_bits++; // cplstre
        if (!blk) {
            frame_bits++; // cplinu
        }
        if (ctx->acmod == 2) {
            frame_bits++; // rematstr
            if (!blk)
                frame_bits += 4; // rematflg
        }
        frame_bits += 2 * ctx->n_channels; // chexpstr
        if (ctx->lfe)
            frame_bits++; // lfeexpstr
        for (ch = 0; ch < ctx->n_channels; ch++) {
            if (block->exp_strategy[ch] != EXP_REUSE) {
                frame_bits += 6; // chbwcod
                frame_bits += 2; // gainrng
            }
        }
        frame_bits++; // baie
        if (!blk) {
            // sdcycod[2], fdcycod[2], sgaincod[2], dbpbcod[2], floorcod[3]
            frame_bits += 2 + 2 + 2 + 2 + 3;
        }
        frame_bits++; // snr
        if (block->write_snr) {
            frame_bits += 6; // csnroffset
            frame_bits += ctx->n_all_channels * 4; // fsnroffset
            frame_bits += ctx->n_all_channels * 3; // fgaincod
        }
        frame_bits++; // delta
        frame_bits++; // skip
    }

    // auxdatae, crcrsv
    frame_bits += 2;

    // CRC
    frame_bits += 16;

    frame->frame_bits = frame_bits;
}


Generated by  Doxygen 1.6.0   Back to index