aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2008-05-31 21:53:31 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2008-05-31 21:53:31 +0000
commitb85a15fe737d162524f3555d8d22cc2bfe086b52 (patch)
tree9fb58e93a7fce5e624016133fb6c5a604ddfe431 /libavcodec
parentaa148649a449fb09149868a70a88d6f651a35be2 (diff)
downloadffmpeg-b85a15fe737d162524f3555d8d22cc2bfe086b52.tar.gz
only calculate number of exponent groups when exponents are not reused.
Originally committed as revision 13587 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3dec.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 45296aa7bf..40727e78b4 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -154,6 +154,7 @@ typedef struct {
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 @@ static int ac3_parse_audio_block(AC3DecodeContext *s, int blk)
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 @@ static int ac3_parse_audio_block(AC3DecodeContext *s, int blk)
}
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 */