5, 6, 7, 8, 9, 10, 11, 12, 14, 16
};
+/** dynamic range table. converts codes to scale factors. */
+static float dynrng_tbl[256];
+
/* Adjustmens in dB gain */
#define LEVEL_MINUS_3DB 0.7071067811865476
#define LEVEL_MINUS_4POINT5DB 0.5946035575013605
b5_mantissas[i] = symmetric_dequant(i, 15);
}
+ /* generate dynamic range table
+ reference: Section 7.7.1 Dynamic Range Control */
+ for(i=0; i<256; i++) {
+ int v = (i >> 5) - ((i >> 7) << 3) - 5;
+ dynrng_tbl[i] = powf(2.0f, v) * ((i & 0x1F) | 0x20);
+ }
+
//generate scale factors
for (i = 0; i < 25; i++)
scale_factors[i] = pow(2.0, -i);
int bit_alloc_flags = 0;
int8_t *dexps;
int mstrcplco, cplcoexp, cplcomant;
- int dynrng, chbwcod, ngrps, cplabsexp, skipl;
+ int chbwcod, ngrps, cplabsexp, skipl;
for (i = 0; i < nfchans; i++) /*block switch flag */
ctx->blksw[i] = get_bits1(gb);
}
if (get_bits1(gb)) { /* dynamic range */
- dynrng = get_sbits(gb, 8);
- ctx->dynrng = (((dynrng & 0x1f) | 0x20) << 13) * pow(2.0, -(18 - (dynrng >> 5)));
+ ctx->dynrng = dynrng_tbl[get_bits(gb, 8)];
} else if(blk == 0) {
ctx->dynrng = 1.0;
}
if(acmod == AC3_ACMOD_DUALMONO) { /* dynamic range 1+1 mode */
if(get_bits1(gb)) {
- dynrng = get_sbits(gb, 8);
- ctx->dynrng2 = (((dynrng & 0x1f) | 0x20) << 13) * pow(2.0, -(18 - (dynrng >> 5)));
+ ctx->dynrng2 = dynrng_tbl[get_bits(gb, 8)];
} else if(blk == 0) {
ctx->dynrng2 = 1.0;
}