Mercurial > libavcodec.hg
changeset 6957:6eb895971766 libavcodec
only calculate number of exponent groups when exponents are not reused.
author | jbr |
---|---|
date | Sat, 31 May 2008 21:53:31 +0000 |
parents | 9984c30bf233 |
children | 1c523b5212cd |
files | ac3dec.c |
diffstat | 1 files changed, 11 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/ac3dec.c Sat May 31 21:37:28 2008 +0000 +++ b/ac3dec.c Sat May 31 21:53:31 2008 +0000 @@ -154,6 +154,7 @@ int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters + int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups int8_t dexps[AC3_MAX_CHANNELS][256]; ///< decoded exponents uint8_t bap[AC3_MAX_CHANNELS][256]; ///< bit allocation pointers int16_t psd[AC3_MAX_CHANNELS][256]; ///< scaled exponents @@ -907,6 +908,7 @@ for (ch = 1; ch <= fbw_channels; ch++) { s->start_freq[ch] = 0; if (s->exp_strategy[ch] != EXP_REUSE) { + int group_size; int prev = s->end_freq[ch]; if (s->channel_in_cpl[ch]) s->end_freq[ch] = s->start_freq[CPL_CH]; @@ -918,26 +920,26 @@ } s->end_freq[ch] = bandwidth_code * 3 + 73; } + group_size = 3 << (s->exp_strategy[ch] - 1); + s->num_exp_groups[ch] = (s->end_freq[ch]+group_size-4) / group_size; if(blk > 0 && s->end_freq[ch] != prev) memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); } } s->start_freq[s->lfe_ch] = 0; s->end_freq[s->lfe_ch] = 7; + s->num_exp_groups[s->lfe_ch] = 2; + if (s->cpl_in_use && s->exp_strategy[CPL_CH] != EXP_REUSE) { + s->num_exp_groups[CPL_CH] = (s->end_freq[CPL_CH] - s->start_freq[CPL_CH]) / + (3 << (s->exp_strategy[CPL_CH] - 1)); + } /* decode exponents for each channel */ for (ch = !s->cpl_in_use; ch <= s->channels; ch++) { if (s->exp_strategy[ch] != EXP_REUSE) { - int group_size, num_groups; - group_size = 3 << (s->exp_strategy[ch] - 1); - if(ch == CPL_CH) - num_groups = (s->end_freq[ch] - s->start_freq[ch]) / group_size; - else if(ch == s->lfe_ch) - num_groups = 2; - else - num_groups = (s->end_freq[ch] + group_size - 4) / group_size; s->dexps[ch][0] = get_bits(gbc, 4) << !ch; - decode_exponents(gbc, s->exp_strategy[ch], num_groups, s->dexps[ch][0], + decode_exponents(gbc, s->exp_strategy[ch], + s->num_exp_groups[ch], s->dexps[ch][0], &s->dexps[ch][s->start_freq[ch]+!!ch]); if(ch != CPL_CH && ch != s->lfe_ch) skip_bits(gbc, 2); /* skip gainrng */