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

static int bit_alloc ( A52ThreadContext *  tctx,
int  snroffst 
) [static]

Run the bit allocation routine using the given snroffset values. Returns number of mantissa bits used.

Definition at line 122 of file bitalloc.c.

References a52_bit_alloc_calc_bap(), compute_mantissa_size(), and compute_mantissa_size_final().

Referenced by cbr_bit_allocation(), vbr_bit_allocation(), and vbw_bit_allocation().

{
    A52Context *ctx = tctx->ctx;
    A52Frame *frame = &tctx->frame;
    A52Block *block;
    int mant_cnt[5];
    int blk, ch;
    int bits;

    bits = 0;
    snroffst = (snroffst << 2) - 960;

    for (blk = 0; blk < A52_NUM_BLOCKS; blk++) {
        block = &frame->blocks[blk];
        // initialize grouped mantissa counts. these are set so that they are
        // padded to the next whole group size when bits are counted in
        // compute_mantissa_size_final
        mant_cnt[0] = mant_cnt[3] = 0;
        mant_cnt[1] = mant_cnt[2] = 2;
        mant_cnt[4] = 1;
        for (ch = 0; ch < ctx->n_all_channels; ch++) {
            // Currently the encoder is setup so that the only bit allocation
            // parameter which varies across blocks within a frame is the
            // exponent values.  We can take advantage of that by reusing the
            // bit allocation pointers whenever we reuse exponents.
            if (block->exp_strategy[ch] == EXP_REUSE) {
                memcpy(block->bap[ch], frame->blocks[blk-1].bap[ch], 256);
            } else {
                a52_bit_alloc_calc_bap(block->mask[ch], block->psd[ch], 0, frame->ncoefs[ch],
                                       snroffst, frame->bit_alloc.floor, block->bap[ch]);
            }
            bits += compute_mantissa_size(mant_cnt, block->bap[ch], frame->ncoefs[ch]);

        }
        bits += compute_mantissa_size_final(mant_cnt);
    }

    return bits;
}


Generated by  Doxygen 1.6.0   Back to index